SND@LHC Software
Loading...
Searching...
No Matches
hcalAnalysisSimple.cxx
Go to the documentation of this file.
2
3#include "FairRootManager.h"
4
5#include "hcalStructure.h"
6#include "hcalModule.h"
7#include "hcalPoint.h"
8
9#include "TTree.h"
10#include "TClonesArray.h"
11#include "TRandom.h"
12
13#include <iostream>
14#include <fstream>
15#include <list>
16
17using namespace std;
18
20void hcalAnalysisSimple::Exec(Option_t* option)
21{
22 Int_t n=fTracks->GetEntries();
23 Int_t i;
24 hcalPoint* t;
25 hcalModule* module;
26 hcalModule* mmodule;
27 TVector3 m;
28 list<hcalModule*> modules;
29 list<hcalModule*>::const_iterator p;
30// TVector3 m1;
31
32 fEv++;
33 InitTree();
34
35 for(i=0;i<n;i++)
36 {
37 t=(hcalPoint*)fTracks->At(i);
38 fX=t->GetX();
39 fY=t->GetY();
40 t->Momentum(m);
41 fP=m.Mag();
42 fPX=m.Px();
43 fPY=m.Py();
44 fPZ=m.Pz();
45
46// m1=m.Unit();
47 module=fStr->GetModule(fX, fY);
48 if (!module) continue;
49 mmodule=module;
50 module->GetNeighborsList(modules);
51 for(p=modules.begin();p!=modules.end();++p)
52 if ((*p)->GetEnergy()>mmodule->GetEnergy())
53 mmodule=(*p);
54
55 mmodule->GetNeighborsList(modules);
56 for(p=modules.begin();p!=modules.end();++p)
57 if ((*p)->GetEnergy()>mmodule->GetEnergy())
58 break;
59
60 if (p!=modules.end()) continue;
61
62 fCX=mmodule->GetCenterX();
63 fCY=mmodule->GetCenterY();
64 fCE=mmodule->GetEnergy();
65 fCE2=mmodule->GetEnergy2();
66 fModuleNum=mmodule->GetNumber();
67 fADC=mmodule->ADC();
68 fOE=fCE;
69 for(p=modules.begin();p!=modules.end();++p)
70 fOE+=(*p)->GetEnergy();
71
72 fTree->Fill();
73 }
74
75}
76
78{
79 if (fTree) return;
80 fTree=new TTree("calib", "calib");
81 fTree->Branch("px", &fPX, "px/D");
82 fTree->Branch("py", &fPY, "py/D");
83 fTree->Branch("pz", &fPZ, "pz/D");
84 fTree->Branch("p" , &fP , "p/D");
85 fTree->Branch("x" , &fX , "x/D");
86 fTree->Branch("y" , &fY , "y/D");
87 fTree->Branch("cx", &fCX, "cx/D");
88 fTree->Branch("cy", &fCY, "cy/D");
89 fTree->Branch("ce", &fCE, "ce/D");
90 fTree->Branch("ce2",&fCE2,"ce2/D");
91 fTree->Branch("oe", &fOE, "oe/D");
92 fTree->Branch("ev", &fEv, "ev/I");
93 fTree->Branch("mn", &fModuleNum, "mn/I");
94 fTree->Branch("adc", &fADC, "adc/I");
95}
96
97hcalAnalysisSimple::hcalAnalysisSimple(const char* name, const Int_t iVerbose)
98 : FairTask(name, iVerbose),
99 fTree(NULL),
100 fX(0.),
101 fY(0.),
102 fCX(0.),
103 fCY(0.),
104 fP(0.),
105 fCE(0.),
106 fCE2(0.),
107 fOE(0.),
108 fPX(0.),
109 fPY(0.),
110 fPZ(0.),
111 fEv(0),
112 fModuleNum(0),
113 fADC(0),
114 fStr(NULL),
115 fTracks(NULL)
116{
117}
118
120 : FairTask(),
121 fTree(NULL),
122 fX(0.),
123 fY(0.),
124 fCX(0.),
125 fCY(0.),
126 fP(0.),
127 fCE(0.),
128 fCE2(0.),
129 fOE(0.),
130 fPX(0.),
131 fPY(0.),
132 fPZ(0.),
133 fEv(0),
134 fModuleNum(0),
135 fADC(0),
136 fStr(NULL),
137 fTracks(NULL)
138{
139}
140
143{
144 FairRootManager* fManager=FairRootManager::Instance();
145 fStr=(hcalStructure*)fManager->GetObject("HcalStructure");
146 if (!fStr)
147 {
148 Fatal("Init()", "Can't find calorimeter structure. ");
149 return kFATAL;
150 }
151 fTracks=(TClonesArray*)fManager->GetObject("HcalPoint");
152 if (!fTracks)
153 {
154 Fatal("Init()", "Can't find array of reconstructed tracks. ");
155 return kFATAL;
156 }
157
158 return kSUCCESS;
159}
160
163{
164 if (fTree)
165 fTree->Write();
166}
167
Double_t m
virtual void Exec(Option_t *option)
virtual InitStatus Init()
ClassImp(ecalContFact) ecalContFact