SND@LHC Software
Loading...
Searching...
No Matches
ecalStructureFiller.cxx
Go to the documentation of this file.
2#include "ecalPoint.h"
3#include "ecalCellMC.h"
4#include "ecalInf.h"
5#include "ecalStructure.h"
6
7#include "FairRootManager.h"
8
9#include "TRandom.h"
10#include "TVector3.h"
11#include "TClonesArray.h"
12
13#include <vector>
14#include <iostream>
15
16using namespace std;
17
18// ----- Default constructor -------------------------------------------
20 : FairTask(),
21 fStr(NULL),
22 fInf(NULL),
23 fListECALpts(NULL),
24 fEvent(0),
25 fInited(kFALSE),
26 fUseMCPoints(kFALSE),
27 fStoreTrackInfo(kTRUE),
28 fFileGeo("")
29{
30}
31// -------------------------------------------------------------------------
32
33// ----- Standard constructor -------------------------------------------
34ecalStructureFiller::ecalStructureFiller(const char *name, const Int_t iVerbose, const char* fileGeo)
35 : FairTask(name,iVerbose),
36 fStr(NULL),
37 fInf(ecalInf::GetInstance(fileGeo)),
38 fListECALpts(NULL),
39 fEvent(0),
40 fInited(kFALSE),
41 fUseMCPoints(kFALSE),
42 fStoreTrackInfo(kTRUE),
43 fFileGeo(fileGeo)
44{
45}
46// -------------------------------------------------------------------------
47
48
49// ----- Destructor ----------------------------------------------------
54// -------------------------------------------------------------------------
55
60
61// ----- Initialization ------------------------------------------------
63{
64 fInited=kTRUE;
65 FairRootManager* fManager = FairRootManager::Instance();
66
67 if (fUseMCPoints==kFALSE)
68 {
69 Warning("Init()", "No data source for structure filler! Calorimeter structure will be empty.");
70// return kFATAL;
71 }
72 //ECAL MC points
73 if (fUseMCPoints)
74 fListECALpts = (TClonesArray*)fManager->GetObject("EcalPointLite");
75
76 //fInf->CheckVariables();
79 fStr->Construct();
80
81 fManager->Register("EcalStructure", "ECAL", fStr, kFALSE);
82 return kSUCCESS;
83}
84// -------------------------------------------------------------------------
85
86
88{
89 fListECALpts=litePoints;
90
91 //fInf->CheckVariables();
94 fStr->Construct();
95
96 return fStr;
97}
98
99
102{
103 ecalPoint* pt;
104 ecalCell* cell;
105 Int_t ten;
106 UInt_t n;
107 Bool_t isPS;
108
109 n=fListECALpts->GetEntriesFast();
110 if (fVerbose>0)
111 {
112 cout << ". Number of input MC points: ";
113 cout << n << flush;
114 }
115
116 for(UInt_t j=0; j<n; j++)
117 {
118 pt=(ecalPoint*)fListECALpts->At(j);
119 cell=fStr->GetCell(pt->GetDetectorID(), ten, isPS);
120 if (ten==0) {
121 if (isPS)
122 ; // cell->AddPSEnergy(pt->GetEnergyLoss()); preshower removed
123 else
124 cell->AddEnergy(pt->GetEnergyLoss());
125 }
126 }
127 if (fStoreTrackInfo)
128 for(UInt_t j=0; j<n; j++)
129 {
130 pt=(ecalPoint*)fListECALpts->At(j);
131 ecalCellMC* cellmc=(ecalCellMC*)fStr->GetCell(pt->GetDetectorID(), ten, isPS);
132 if (ten==0) {
133 if (isPS)
134 ; // cell->AddTrackPSEnergy(pt->GetTrackID(),pt->GetEnergyLoss()); //preshower removed
135 else
136 cellmc->AddTrackEnergy(pt->GetTrackID(),pt->GetEnergyLoss(), pt->GetTime());
137 }
138 }
139}
140
141// ----- Execution of Task ---------------------------------------------
142void ecalStructureFiller::Exec(Option_t* option,TClonesArray* litePoints)
143{
144 fEvent++;
145 fListECALpts=litePoints;
146 if (fVerbose>0)
147 cout << "--> Event no. " << fEvent;
148
151
152 if (fVerbose>0)
153 cout << endl << flush;
154}
155// -------------------------------------------------------------------------
156
157
158// ----- Finish Task ---------------------------------------------------
160{
161 ;
162}
163// -------------------------------------------------------------------------
164
165
void AddTrackEnergy(Int_t num, Float_t energy, Float_t time=-1111)
Definition ecalCellMC.h:31
void AddEnergy(Float_t energy)
Definition ecalCell.h:68
virtual InitStatus Init()
Bool_t fInited
Internal event counter.
ecalStructure * InitPython(TClonesArray *litePoints)
TClonesArray * fListECALpts
virtual void Exec(Option_t *option, TClonesArray *litePoints)
void SetUseMC(Int_t mc=0)
ecalCell * GetCell(Float_t x, Float_t y) const
ClassImp(ecalContFact) ecalContFact