er  dev
ERNeuRadViewer.cxx
1 #include "ERNeuRadViewer.h"
2 
3 #include <iostream>
4 
5 #include "TGraph.h"
6 #include "TArrayF.h"
7 #include "TCanvas.h"
8 #include "TDirectory.h"
9 #include "TString.h"
10 
11 #include "FairRootManager.h"
12 #include "FairRunAna.h"
13 #include "FairRuntimeDb.h"
14 #include "FairEventHeader.h"
15 
16 #include "ERNeuRadPixelSignal.h"
17 
18 // ----------------------------------------------------------------------------
20  : fNeuRadPixelSignals(NULL),
21  FairTask("ER NeuRad Viewer")
22 {
23 }
24 // ----------------------------------------------------------------------------
25 
26 // ----------------------------------------------------------------------------
27 ERNeuRadViewer::ERNeuRadViewer(Int_t verbose)
28  : fNeuRadPixelSignals(NULL),
29  FairTask("ER NeuRad Viewer", verbose)
30 {
31 }
32 // ----------------------------------------------------------------------------
33 
34 // ----------------------------------------------------------------------------
36 {
37 }
38 //----------------------------------------------------------------------------
39 
40 //----------------------------------------------------------------------------
41 void ERNeuRadViewer::SetParContainers()
42 {
43  // Get run and runtime database
44  FairRunAna* run = FairRunAna::Instance();
45  if ( ! run ) Fatal("SetParContainers", "No analysis run");
46 
47  FairRuntimeDb* rtdb = run->GetRuntimeDb();
48  if ( ! rtdb ) Fatal("SetParContainers", "No runtime database");
49 }
50 //----------------------------------------------------------------------------
51 
52 //----------------------------------------------------------------------------
54 {
55  // Get input array
56  FairRootManager* ioman = FairRootManager::Instance();
57  if ( ! ioman ) Fatal("Init", "No FairRootManager");
58 
59  fNeuRadPixelSignals = (TClonesArray*) ioman->GetObject("NeuRadPixelSignal");
60  if ( ! fNeuRadPixelSignals) Fatal("ERNeuRadViewer::Init","No NeuRadPixelSignal Collection in input file");
61 
62  fFile = FairRunAna::Instance()->GetOutputFile();
63  return kSUCCESS;
64 }
65 // -------------------------------------------------------------------------
66 
67 // ----- Public method Exec --------------------------------------------
68 void ERNeuRadViewer::Exec(Option_t* opt)
69 {
70  TString dirTitle;
71  dirTitle.Form("Event%d",FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber());
72  TDirectory* dir = fFile->mkdir(dirTitle.Data());
73 
74  dir->cd();
75  TDirectory* front = dir->mkdir("front");
76  TDirectory* back = dir->mkdir("back");
77  for (Int_t iSignal = 0; iSignal < fNeuRadPixelSignals->GetEntriesFast(); iSignal++){
79 
80  TArrayF* result = signal->ResultSignal();
81  Int_t count = (Int_t)(signal->FinishTime()-signal->StartTime())/signal->dT();
82  Float_t* times = new Float_t[count];
83  for (Int_t i = 0; i < count; i++){
84  times[i] = signal->StartTime() + signal->dT()*i;
85  }
86  TGraph* gr = new TGraph(count,times,result->GetArray());
87  TString title;
88  title.Form("PMT Signal, side %d,%d fiber, %d module, %d pe, %d", signal->Side(),
89  signal->PixelNb(), signal->ModuleNb(), signal->PECount(),
90  FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber());
91  gr->SetTitle(title);
92  if (signal->Side() == 0)
93  front->cd();
94  else
95  back->cd();
96  gr->Write();
97  delete gr;
98  delete [] times;
99 
100  }
101  fFile->cd();
102 }
103 //----------------------------------------------------------------------------
104 
105 //----------------------------------------------------------------------------
107 {
108 }
109 // ----------------------------------------------------------------------------
110 
111 // ----------------------------------------------------------------------------
113 {
114 }
115 // ----------------------------------------------------------------------------
116 
117 //-----------------------------------------------------------------------------
118 ClassImp(ERNeuRadViewer)
TClonesArray * fNeuRadPixelSignals
virtual void Finish()
virtual InitStatus Init()
virtual void Exec(Option_t *opt)
virtual void Reset()