SND@LHC Software
Loading...
Searching...
No Matches
hcalStructureFiller.cxx
Go to the documentation of this file.
2#include "hcalPoint.h"
3#include "hcalModuleMC.h"
4#include "hcalInf.h"
5#include "hcalStructure.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 fListHCALpts(NULL),
24 fEvent(0),
25 fInited(kFALSE),
26 fUseMCPoints(kFALSE),
27 fStoreTrackInfo(kTRUE),
28 fFileGeo("")
29{
30}
31// -------------------------------------------------------------------------
32
33// ----- Standard constructor -------------------------------------------
34hcalStructureFiller::hcalStructureFiller(const char *name, const Int_t iVerbose, const char* fileGeo)
35 : FairTask(name,iVerbose),
36 fStr(NULL),
37 fInf(hcalInf::GetInstance(fileGeo)),
38 fListHCALpts(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 //HCAL MC points
73 if (fUseMCPoints)
74 fListHCALpts = (TClonesArray*)fManager->GetObject("HcalPointLite");
75
76 //fInf->CheckVariables();
79 fStr->Construct();
80
81 fManager->Register("HcalStructure", "HCAL", fStr, kFALSE);
82 return kSUCCESS;
83}
84// -------------------------------------------------------------------------
85
88{
89 hcalPoint* pt=NULL;
90 hcalModule* module;
91 UInt_t n;
92 Int_t section;
93
94 n=fListHCALpts->GetEntriesFast();
95 if (fVerbose>0)
96 {
97 cout << ". Number of input MC points: ";
98 cout << n << flush;
99 }
100
101 for(UInt_t j=0; j<n; j++)
102 {
103 pt=(hcalPoint*)fListHCALpts->At(j);
104 module=fStr->GetModule(pt->GetDetectorID(), section);
105 cout << section << " " << pt->GetEnergyLoss() << endl;
106 if (section==0)
107 module->AddEnergy(pt->GetEnergyLoss());
108 else
109 module->AddEnergy2(pt->GetEnergyLoss());
110 }
111 if (fStoreTrackInfo)
112 for(UInt_t j=0; j<n; j++)
113 {
114 pt=(hcalPoint*)fListHCALpts->At(j);
115 hcalModuleMC* modulemc=(hcalModuleMC*)fStr->GetModule(pt->GetDetectorID(), section);
116 if (section==0)
117 modulemc->AddTrackEnergy(pt->GetTrackID(),pt->GetEnergyLoss());
118 else
119 modulemc->AddTrackEnergy2(pt->GetTrackID(),pt->GetEnergyLoss());
120 }
121}
122
123// ----- Execution of Task ---------------------------------------------
124void hcalStructureFiller::Exec(Option_t* option)
125{
126 fEvent++;
127 if (fVerbose>0)
128 cout << "--> Event no. " << fEvent;
129
132
133 if (fVerbose>0)
134 cout << endl << flush;
135}
136// -------------------------------------------------------------------------
137
138
139// ----- Finish Task ---------------------------------------------------
141{
142 ;
143}
144// -------------------------------------------------------------------------
145
146
void AddTrackEnergy(Int_t num, Float_t energy)
void AddTrackEnergy2(Int_t num, Float_t energy)
TClonesArray * fListHCALpts
Bool_t fInited
Internal event counter.
virtual void Exec(Option_t *option)
virtual InitStatus Init()
hcalModule * GetModule(Float_t x, Float_t y) const
void SetUseMC(Int_t mc=0)
ClassImp(ecalContFact) ecalContFact