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