Obsolete Integrated Beam Test base class. The new one is AliITSBeamTestITS04
[u/mrichter/AliRoot.git] / ITS / AliITSBeamTestDigitizer.cxx
CommitLineData
38300302 1////////////////////////////////////////////////////
2// Class to manage the //
3// ITS beam test conversion from rawdata //
4// to digits. It executes the digitization for //
5// SPD, SDD and SSD. //
6// Origin: E. Crescio crescio@to.infn.it //
7// J. Conrad Jan.Conrad@cern.ch //
8////////////////////////////////////////////////////
9#include "AliHeader.h"
10#include "AliRun.h"
11#include "AliRunLoader.h"
12#include "AliITSEventHeader.h"
13#include "AliITSLoader.h"
14#include "AliITSBeamTest.h"
15#include "AliITSBeamTestDigSDD.h"
16#include "AliITSBeamTestDigSPD.h"
17#include "AliITSBeamTestDigSSD.h"
18#include "AliITSBeamTestDigitizer.h"
19#include "AliRawReaderDate.h"
20
21
22const TString AliITSBeamTestDigitizer::fgkDefaultDigitsFileName="ITSbt.Digits.root";
23
24ClassImp(AliITSBeamTestDigitizer)
25
26
27//_____________________________________________________________
28AliITSBeamTestDigitizer::AliITSBeamTestDigitizer():TTask()
29{
30 //
31 // Default constructor
32 //
33 fRunLoader = 0;
34 fLoader =0;
35 fEvIn=0;
36 fEvFin=0;
37 fFlagHeader=kTRUE;
38 fDATEEvType=7;
39 fRunNumber=-1;
40 SetFlagInit();
41 fBt=0;
42 SetBeamTestPeriod();
43}
44
45//_____________________________________________________________
46 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const Text_t* name, const Text_t* title):TTask(name,title)
47{
48 //
49 // Standard constructor
50 //
51 Init();
52 fEvIn=0;
53 fEvFin=0;
54 fDATEEvType=7;
55 fFlagHeader=kTRUE;
56 fRunNumber=-1;
57 SetBeamTestPeriod();
58 }
59
60//_____________________________________________________________
61 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const Text_t* name, const Text_t* title, Int_t run):TTask(name,title)
62
63{
64 //
65 // Constructor
66 //
67 Init();
68 fEvIn=0;
69 fEvFin=0;
70 fDATEEvType=7;
71 fFlagHeader=kTRUE;
72 fRunNumber=run;
73 SetBeamTestPeriod();
74 }
75
76//___________________________________________________________
77void AliITSBeamTestDigitizer::Init(){
78
79 //
80 //Initialization of run loader and its loader
81 //creation of galice.root
82 //
83 fRunLoader = AliRunLoader::Open("galice.root",
84 AliConfig::GetDefaultEventFolderName(),"recreate");
85
86 gAlice->SetRunLoader(fRunLoader);
87 fRunLoader->SetEventFolderName();
88 fBt = new AliITSBeamTest("ITS","ITS beam test");
89 fBt->SetDefaults();
90 gAlice->AddModule(fBt);
91 fRunLoader->AddLoader(fBt);
92 fLoader = (AliITSLoader*)fRunLoader->GetLoader("ITSLoader");
93 fRunLoader->MakeTree("E");
94
95 fRunLoader->WriteRunLoader("OVERWRITE");
96 fRunLoader->WriteAliRun("OVERWRITE");
97 fDigitsFileName=fgkDefaultDigitsFileName;
98 this->Add(new AliITSBeamTestDigSPD("DigSPD","SPD Digitization"));
99 this->Add(new AliITSBeamTestDigSDD("DigSDD","SDD Digitization"));
100 this->Add(new AliITSBeamTestDigSSD("DigSSD","SSD Digitization"));
101
102 SetFlagInit(kTRUE);
103}
104
105//_____________________________________________________________
106 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const char* filename)
107{
108 //
109 // Constructor for reading (reads galice.root)
110 //
111
112 fRunLoader = AliRunLoader::Open(filename);
113 if (fRunLoader == 0x0)
114 {
115 Error("AliITSBeamTestDigitizer","Can not load the session",filename);
116 return;
117 }
118 fRunLoader->LoadgAlice();
119 gAlice = fRunLoader->GetAliRun();
120
121 if(!gAlice) {
122 Error("AliITSBeamTestDigitizer","gAlice not found on file. Aborting.");
123 return;
124 }
125
126 fLoader = (AliITSLoader*)fRunLoader->GetLoader("ITSLoader");
127
128 fBt = (AliITSBeamTest*)gAlice->GetDetector("ITS");
129 fBt->SetDefaults();
130
131 fDigitsFileName=fgkDefaultDigitsFileName;
132
133 fEvIn=0;
134 fEvFin=0;
135
136}
137
138//______________________________________________________________________
139AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const AliITSBeamTestDigitizer &bt):TTask(bt){
140 // Copy constructor.
141 //not allowed
142 if(this==&bt) return;
143 Error("Copy constructor",
144 "You are not allowed to make a copy of the AliITSBeamTestDigitizer");
145 exit(1);
146
147}
148//______________________________________________________________________
149AliITSBeamTestDigitizer& AliITSBeamTestDigitizer::operator=(AliITSBeamTestDigitizer &bt){
150 // Assignment operator. This is a function which is not allowed to be
151 // done to the ITS beam test digitizer. It exits with an error.
152 // Inputs:
153 if(this==&bt) return *this;
154 Error("operator=","You are not allowed to make a copy of the AliITSBeamTestDigitizer");
155 exit(1);
156 return *this; //fake return
157}
158
159
160//______________________________________________________________
161AliITSBeamTestDigitizer::~AliITSBeamTestDigitizer(){
162
163 //Destructor
164 if(fBt) delete fBt;
165 if(fLoader) delete fLoader;
166 if(fRunLoader) delete fRunLoader;
167}
168
169
170//_____________________________________________________________
171void AliITSBeamTestDigitizer::SetNumberOfEventsPerFile(Int_t nev)
172{
173 //Sets number of events per file
174
175 if(fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nev);
176 else Warning("SetNumberOfEventsPerFile","fRunLoader is 0");
177}
178
179
180//____________________________________________________
181void AliITSBeamTestDigitizer::ExecDigitization(){
182
183 // Execution of digitisation for SPD,SDD and SSD
184
185 if(!GetFlagInit()){
186 Warning("ExecDigitization()","Run Init() please..");
187 return;
188 }
189 fLoader->SetDigitsFileName(fDigitsFileName);
190 fLoader->LoadDigits("recreate");
191
192 AliRawReaderDate rd(fRawdataFileName,fEvIn);
193 AliHeader* header = fRunLoader->GetHeader();
194
195 Int_t iev=fEvIn-1;
196
197
198 AliITSBeamTestDigSDD* digSDD = (AliITSBeamTestDigSDD*)fTasks->FindObject("DigSDD");
199 AliITSBeamTestDigSPD* digSPD = (AliITSBeamTestDigSPD*)fTasks->FindObject("DigSPD");
200 AliITSBeamTestDigSSD* digSSD = (AliITSBeamTestDigSSD*)fTasks->FindObject("DigSSD");
201
202
203 do{
204 iev++;
205 if(fEvFin!=0){
206 if(iev>fEvFin) break;
207 }
208 AliITSEventHeader* itsh = new AliITSEventHeader("ITSHeader");
209 fRunLoader->SetEventNumber(iev);
210
211 rd.RequireHeader(fFlagHeader);
212 rd.SelectEvents(fDATEEvType);
213
214 digSDD->SetRawReaderDate(&rd);
215 digSPD->SetRawReaderDate(&rd);
216 digSSD->SetRawReaderDate(&rd);
217
218 if(fLoader->TreeD() == 0x0) fLoader->MakeTree("D");
219
220 TTree* treeD = (TTree*)fLoader->TreeD();
221
222 // Make branches outside the dig-classes
223
224 TClonesArray* digitsSPD = new TClonesArray("AliITSdigitSPD",1000);
225 treeD->Branch("ITSDigitSPD",&digitsSPD);
226
227 TClonesArray* digitsSDD = new TClonesArray("AliITSdigitSDD",1000);
228 treeD->Branch("ITSDigitSDD",&digitsSDD);
229
230 TClonesArray* digitsSSD = new TClonesArray("AliITSdigitSSD",1000);
231 treeD->Branch("ITSDigitSSD",&digitsSSD);
232
233
234 digSSD->SetTree(treeD);
235 digSDD->SetTree(treeD);
236 digSPD->SetTree(treeD);
237
238 digSSD->SetBeamTest(fBt);
239 digSDD->SetBeamTest(fBt);
240 digSPD->SetBeamTest(fBt);
241
242 digSSD->SetITSEventHeader(itsh);
243 digSDD->SetITSEventHeader(itsh);
244 digSPD->SetITSEventHeader(itsh);
245
246 digSDD->SetBtPeriod(GetBeamTestPeriod());
247 digSDD->SetThreshold(16);
248
249 ExecuteTask(0);
250
251 header->SetEventNrInRun(iev);
252 header->SetEvent(iev);
253 header->SetRun(fRunNumber);
254 fRunLoader->GetHeader()->AddDetectorEventHeader(itsh);
255 fRunLoader->TreeE()->Fill();
256 header->Reset(fRunNumber,iev);
257
258 delete digitsSPD;
259 delete digitsSDD;
260 delete digitsSSD;
261
262 }while(rd.NextEvent());
263
264 fRunLoader->WriteHeader("OVERWRITE");
265 fRunLoader->WriteRunLoader("OVERWRITE");
266 fLoader->UnloadDigits();
267 fLoader->UnloadRawClusters();
268 fRunLoader->UnloadHeader();
269
270}
271
272
273
274//_______________________________________________
275void AliITSBeamTestDigitizer:: SetActive(const TString& subdet,Bool_t value){
276
277 //Sets active sub-tasks (detectors)
278
279 Bool_t sdd = subdet.Contains("SDD");
280 Bool_t spd = subdet.Contains("SPD");
281 Bool_t ssd = subdet.Contains("SSD");
282
283 if(sdd){
284 AliITSBeamTestDigSDD* digSDD = (AliITSBeamTestDigSDD*)fTasks->FindObject("DigSDD");
285 digSDD->SetActive(value);
286 }
287
288 if(spd){
289 AliITSBeamTestDigSPD* digSPD = (AliITSBeamTestDigSPD*)fTasks->FindObject("DigSPD");
290 digSPD->SetActive(value);
291
292 }
293
294 if(ssd){
295 AliITSBeamTestDigSSD* digSSD = (AliITSBeamTestDigSSD*)fTasks->FindObject("DigSSD");
296 digSSD->SetActive(value);
297
298 }
299
300
301
302}
303