FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMBSTask.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #include "FairMBSTask.h"
10 
11 #include "FairMBSRawItem.h"
12 #include "FairRootManager.h"
13 #include "FairRunOnline.h"
14 
15 #include <TCanvas.h>
16 #include <TClonesArray.h>
17 #include <TFolder.h>
18 #include <TH1F.h>
19 
20 FairMBSTask::FairMBSTask(const char* name, Int_t iVerbose)
21  : FairTask(name, iVerbose)
22  , fRawData(nullptr)
23  , fhQdc(nullptr)
24  , fhTac(nullptr)
25  , fhClock(nullptr)
26  , fhTacCh(nullptr)
27 {}
28 
30 {
32  if (nullptr == mgr) {
33  return kFATAL;
34  }
35 
36  fRawData = static_cast<TClonesArray*>(mgr->GetObject("MBSRawItem"));
37  if (nullptr == fRawData) {
38  return kERROR;
39  }
40 
41  fhQdc = new TH1F("hQdc", "Raw QDC distribution", 400, 0., 4000.);
42  fhTac = new TH1F("hTac", "Raw TAC distribution", 400, 0., 4000.);
43  fhClock = new TH1F("hClock", "Raw Clock distribution", 64, 0., 64.);
44  fhTacCh = new TH1F("hTacCh", "Raw TAC Channel distribution", 20, 0., 20.);
45 
47  if (nullptr == run) {
48  return kERROR;
49  }
50 
51  run->AddObject(fhQdc);
52  run->RegisterHttpCommand("/Reset_hQdc", "/hQdc/->Reset()");
53 
54  TCanvas* c1 = new TCanvas("c1", "", 10, 10, 500, 500);
55  c1->Divide(2, 2);
56  c1->cd(1);
57  fhQdc->Draw();
58  c1->cd(2);
59  fhTac->Draw();
60  c1->cd(3);
61  fhClock->Draw();
62  c1->cd(4);
63  fhTacCh->Draw();
64  c1->cd(0);
65  run->AddObject(c1);
66 
67  TFolder* folder = new TFolder("MbsDetFolder", "Example Folder");
68  folder->Add(fhQdc);
69  folder->Add(fhTac);
70  folder->Add(fhClock);
71  folder->Add(fhTacCh);
72  run->AddObject(folder);
73 
74  return kSUCCESS;
75 }
76 
77 void FairMBSTask::Exec(Option_t*)
78 {
79  if (nullptr == fRawData) {
80  return;
81  }
82  Int_t nItems = fRawData->GetEntriesFast();
83  FairMBSRawItem* item;
84  for (Int_t i = 0; i < nItems; i++) {
85  item = static_cast<FairMBSRawItem*>(fRawData->At(i));
86  if (nullptr == item) {
87  continue;
88  }
89  fhQdc->Fill(item->GetQdcData());
90  fhTac->Fill(item->GetTacData());
91  fhClock->Fill(item->GetClock());
92  fhTacCh->Fill(item->GetTacCh());
93  }
94 }
95 
InitStatus
Definition: FairTask.h:33
const UShort_t & GetTacData() const
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
const UShort_t & GetClock() const
FairMBSTask(const char *name, Int_t iVerbose)
Definition: FairMBSTask.cxx:20
void AddObject(TObject *object)
const UShort_t & GetTacCh() const
virtual void Exec(Option_t *)
Definition: FairMBSTask.cxx:77
void RegisterHttpCommand(TString name, TString command)
virtual InitStatus Init()
Definition: FairMBSTask.cxx:29
static FairRunOnline * Instance()
const UShort_t & GetQdcData() const