]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
88cb7938 | 16 | /* $Id$ */ |
2ab0c725 | 17 | |
4c039060 | 18 | |
fe4da5cc | 19 | /////////////////////////////////////////////////////////////////////////////// |
04366a57 | 20 | // // |
21 | // An overview of the basic philosophy of the ITS code development // | |
22 | // and analysis is show in the figure below. // | |
23 | //Begin_Html // | |
24 | /* | |
a92b2b7d | 25 | <img src="picts/ITS/ITS_Analysis_schema.gif"> |
fe4da5cc | 26 | </pre> |
27 | <br clear=left> | |
28 | <font size=+2 color=red> | |
58005f18 | 29 | <p>Roberto Barbera is in charge of the ITS Offline code (1999). |
fe4da5cc | 30 | <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>. |
31 | </font> | |
32 | <pre> | |
33 | */ | |
34 | //End_Html | |
58005f18 | 35 | // |
36 | // AliITS. Inner Traking System base class. | |
37 | // This class contains the base procedures for the Inner Tracking System | |
38 | // | |
39 | //Begin_Html | |
40 | /* | |
a92b2b7d | 41 | <img src="picts/ITS/AliITS_Class_Diagram.gif"> |
58005f18 | 42 | </pre> |
43 | <br clear=left> | |
44 | <font size=+2 color=red> | |
45 | <p>This show the class diagram of the different elements that are part of | |
46 | the AliITS class. | |
47 | </font> | |
48 | <pre> | |
49 | */ | |
50 | //End_Html | |
51 | // | |
52 | // Version: 0 | |
53 | // Written by Rene Brun, Federico Carminati, and Roberto Barbera | |
54 | // | |
55 | // Version: 1 | |
56 | // Modified and documented by Bjorn S. Nilsen | |
57 | // July 11 1999 | |
58 | // | |
3bd79107 | 59 | // Version: 2 |
60 | // Modified and documented by A. Bologna | |
61 | // October 18 1999 | |
62 | // | |
58005f18 | 63 | // AliITS is the general base class for the ITS. Also see AliDetector for |
64 | // futher information. | |
65 | // | |
fe4da5cc | 66 | /////////////////////////////////////////////////////////////////////////////// |
88cb7938 | 67 | |
4ae5bbc4 | 68 | #include <Riostream.h> |
143d1056 | 69 | #include <stdlib.h> |
88cb7938 | 70 | |
9c74c52b | 71 | #include <TBranch.h> |
caf37aec | 72 | #include <TClonesArray.h> |
9c74c52b | 73 | #include <TFile.h> |
88cb7938 | 74 | #include <TMath.h> |
75 | #include <TObjectTable.h> | |
76 | #include <TROOT.h> | |
77 | #include <TRandom.h> | |
d5da1ecf | 78 | #include <TString.h> |
88cb7938 | 79 | #include <TTree.h> |
80 | #include <TVector.h> | |
81 | #include <TVirtualMC.h> | |
3bd79107 | 82 | |
88cb7938 | 83 | #include "AliConfig.h" |
828e06c7 | 84 | #include "AliHeader.h" |
3bd79107 | 85 | #include "AliITS.h" |
88cb7938 | 86 | #include "AliITSClusterFinderSDD.h" |
87 | #include "AliITSClusterFinderSPD.h" | |
88 | #include "AliITSClusterFinderSSD.h" | |
04366a57 | 89 | #include "AliITSClusterFinderV2SDD.h" |
90 | #include "AliITSClusterFinderV2SPD.h" | |
91 | #include "AliITSClusterFinderV2SSD.h" | |
e8189707 | 92 | #include "AliITSDetType.h" |
88cb7938 | 93 | #include "AliITSLoader.h" |
41b19549 | 94 | #include "AliITSRawClusterSPD.h" |
95 | #include "AliITSRawClusterSDD.h" | |
96 | #include "AliITSRawClusterSSD.h" | |
88cb7938 | 97 | #include "AliITSRecPoint.h" |
04366a57 | 98 | #include "AliITSclusterV2.h" |
e869281d | 99 | #include "AliITSdigitSPD.h" |
100 | #include "AliITSdigitSDD.h" | |
101 | #include "AliITSdigitSSD.h" | |
88cb7938 | 102 | #include "AliITSgeom.h" |
103 | #include "AliITShit.h" | |
104 | #include "AliITSmodule.h" | |
105 | #include "AliITSpList.h" | |
3bd79107 | 106 | #include "AliITSresponseSDD.h" |
88cb7938 | 107 | #include "AliITSresponseSPD.h" |
3bd79107 | 108 | #include "AliITSresponseSSD.h" |
828e06c7 | 109 | #include "AliITSsegmentationSDD.h" |
88cb7938 | 110 | #include "AliITSsegmentationSPD.h" |
828e06c7 | 111 | #include "AliITSsegmentationSSD.h" |
828e06c7 | 112 | #include "AliITSsimulationSDD.h" |
88cb7938 | 113 | #include "AliITSsimulationSPD.h" |
828e06c7 | 114 | #include "AliITSsimulationSSD.h" |
5d12ce38 | 115 | #include "AliMC.h" |
85a5290f | 116 | #include "AliITSDigitizer.h" |
0421c3d1 | 117 | #include "AliITSDDLRawData.h" |
8f726cb3 | 118 | #include "AliRun.h" |
04366a57 | 119 | #include "AliRawReader.h" |
828e06c7 | 120 | |
3bd79107 | 121 | ClassImp(AliITS) |
3bd79107 | 122 | |
2aea926d | 123 | //______________________________________________________________________ |
e80bf2b3 | 124 | AliITS::AliITS() : AliDetector(), |
125 | fITSgeom(0), | |
126 | fEuclidOut(0), | |
127 | fITSmodules(0), | |
128 | fOpt("All"), | |
129 | fIdN(0), | |
130 | fIdSens(0), | |
131 | fIdName(0), | |
132 | fNDetTypes(kNTYPES), | |
133 | fDetTypes(0), | |
134 | fSDigits(0), | |
135 | fNSDigits(0), | |
136 | fDtype(0), | |
137 | fNdtype(0), | |
138 | fCtype(0), | |
139 | fNctype(0), | |
140 | fRecPoints(0), | |
141 | fNRecPoints(0), | |
04366a57 | 142 | fClustersV2(0), |
143 | fNClustersV2(0), | |
e80bf2b3 | 144 | fSelectedVertexer(0){ |
4a5bebc2 | 145 | // Default initializer for ITS |
2aea926d | 146 | // The default constructor of the AliITS class. In addition to |
147 | // creating the AliITS class it zeros the variables fIshunt (a member | |
148 | // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers | |
149 | // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor | |
150 | // is also called. | |
4a5bebc2 | 151 | // Inputs: |
152 | // none. | |
153 | // Outputs: | |
154 | // none. | |
155 | // Return: | |
156 | // Blank ITS class. | |
3bd79107 | 157 | |
2aea926d | 158 | fIshunt = 0; // not zeroed in AliDetector. |
3bd79107 | 159 | |
2aea926d | 160 | // AliITS variables. |
aa044888 | 161 | // SetDetectors(); // default to fOpt="All". This variable not written out. |
2aea926d | 162 | SetMarkerColor(kRed); |
2257f27e | 163 | SelectVertexer(" "); |
fe4da5cc | 164 | } |
2aea926d | 165 | //______________________________________________________________________ |
e80bf2b3 | 166 | AliITS::AliITS(const char *name, const char *title):AliDetector(name,title), |
167 | fITSgeom(0), | |
168 | fEuclidOut(0), | |
169 | fITSmodules(0), | |
170 | fOpt("All"), | |
171 | fIdN(0), | |
172 | fIdSens(0), | |
173 | fIdName(0), | |
174 | fNDetTypes(kNTYPES), | |
175 | fDetTypes(0), | |
176 | fSDigits(0), | |
177 | fNSDigits(0), | |
178 | fDtype(0), | |
179 | fNdtype(0), | |
180 | fCtype(0), | |
181 | fNctype(0), | |
182 | fRecPoints(0), | |
183 | fNRecPoints(0), | |
04366a57 | 184 | fClustersV2(0), |
185 | fNClustersV2(0), | |
e80bf2b3 | 186 | fSelectedVertexer(0){ |
4a5bebc2 | 187 | // The standard Constructor for the ITS class. In addition to |
188 | // creating the AliITS class, it allocates memory for the TClonesArrays | |
189 | // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype | |
190 | // (clusters). It also zeros the variables | |
2aea926d | 191 | // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros |
192 | // the pointers fIdSens and fIdName. To help in displaying hits via the | |
193 | // ROOT macro display.C AliITS also sets the marker color to red. The | |
194 | // variables passes with this constructor, const char *name and *title, | |
195 | // are used by the constructor of AliDetector class. See AliDetector | |
196 | // class for a description of these parameters and its constructor | |
197 | // functions. | |
4a5bebc2 | 198 | // Inputs: |
199 | // const char *name Detector name. Should always be "ITS" | |
200 | // const char *title Detector title. | |
201 | // Outputs: | |
202 | // none. | |
203 | // Return: | |
204 | // An ITS class. | |
2aea926d | 205 | |
206 | fIshunt = 0; // not zeroed in AliDetector | |
207 | fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector | |
aacedc3e | 208 | // Not done in AliDetector. |
209 | if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits); | |
2aea926d | 210 | |
211 | fEuclidOut = 0; | |
212 | fITSgeom = 0; | |
213 | fITSmodules = 0; | |
cd77595e | 214 | SetDetectors(); // default to fOpt="All". This variable not written out. |
2aea926d | 215 | |
216 | fIdN = 0; | |
217 | fIdName = 0; | |
218 | fIdSens = 0; | |
219 | ||
220 | fNDetTypes = kNTYPES; | |
221 | fDetTypes = new TObjArray(fNDetTypes); | |
222 | ||
2aea926d | 223 | fSDigits = new TClonesArray("AliITSpListItem",1000); |
224 | fNSDigits = 0; | |
225 | ||
226 | fNdtype = new Int_t[fNDetTypes]; | |
227 | fDtype = new TObjArray(fNDetTypes); | |
228 | ||
229 | fCtype = new TObjArray(fNDetTypes); | |
230 | fNctype = new Int_t[fNDetTypes]; | |
2aea926d | 231 | |
232 | fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
233 | fNRecPoints = 0; | |
04366a57 | 234 | fClustersV2 = new TClonesArray("AliITSclusterV2",3000); |
235 | fNClustersV2=0; | |
3bd79107 | 236 | |
2aea926d | 237 | Int_t i; |
238 | for(i=0;i<fNDetTypes;i++) { | |
88cb7938 | 239 | fDetTypes->AddAt(new AliITSDetType(),i); |
240 | fNdtype[i] = 0; | |
241 | fNctype[i] = 0; | |
2aea926d | 242 | } // end for i |
fe4da5cc | 243 | |
2aea926d | 244 | SetMarkerColor(kRed); |
2257f27e | 245 | SelectVertexer(" "); |
3bd79107 | 246 | } |
2aea926d | 247 | //______________________________________________________________________ |
58005f18 | 248 | AliITS::~AliITS(){ |
4a5bebc2 | 249 | // Default destructor for ITS. |
2aea926d | 250 | // The default destructor of the AliITS class. In addition to deleting |
251 | // the AliITS class it deletes the memory pointed to by the fHits, fDigits, | |
4a5bebc2 | 252 | // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName, |
253 | // fITSpoints, fDetType and it's contents. | |
254 | // Inputs: | |
255 | // none. | |
256 | // Outputs: | |
257 | // none. | |
258 | // Return: | |
259 | // none. | |
2aea926d | 260 | |
88cb7938 | 261 | if (fHits) { |
262 | fHits->Delete(); | |
263 | delete fHits; | |
264 | fHits=0; | |
265 | } | |
266 | if (fSDigits) { | |
267 | fSDigits->Delete(); | |
268 | delete fSDigits; | |
269 | fSDigits=0; | |
270 | } | |
271 | if (fDigits) { | |
272 | fDigits->Delete(); | |
273 | delete fDigits; | |
274 | fDigits=0; | |
275 | } | |
276 | if (fRecPoints) { | |
277 | fRecPoints->Delete(); | |
278 | delete fRecPoints; | |
279 | fRecPoints=0; | |
280 | } | |
04366a57 | 281 | if(fClustersV2){ |
282 | fClustersV2->Delete(); | |
283 | delete fClustersV2; | |
284 | fClustersV2=0; | |
285 | } | |
88cb7938 | 286 | delete[] fIdName; // Array of TStrings |
287 | delete[] fIdSens; | |
288 | if(fITSmodules) { | |
289 | this->ClearModules(); | |
290 | delete fITSmodules; | |
279a35d7 | 291 | fITSmodules = 0; |
88cb7938 | 292 | }// end if fITSmodules!=0 |
293 | ||
294 | if(fDtype) { | |
295 | fDtype->Delete(); | |
296 | delete fDtype; | |
297 | } // end if fDtype | |
298 | delete [] fNdtype; | |
299 | if (fCtype) { | |
300 | fCtype->Delete(); | |
301 | delete fCtype; | |
302 | fCtype = 0; | |
303 | } // end if fCtype | |
304 | delete [] fNctype; | |
305 | ||
306 | if (fDetTypes) { | |
307 | fDetTypes->Delete(); | |
308 | delete fDetTypes; | |
309 | fDetTypes = 0; | |
310 | } // end if fDetTypes | |
311 | ||
312 | ||
313 | if (fITSgeom) delete fITSgeom; | |
3bd79107 | 314 | } |
2aea926d | 315 | //______________________________________________________________________ |
ac74f489 | 316 | AliITS::AliITS(const AliITS &source) : AliDetector(source){ |
4a5bebc2 | 317 | // Copy constructor. This is a function which is not allowed to be |
318 | // done to the ITS. It exits with an error. | |
319 | // Inputs: | |
320 | // AliITS &source An AliITS class. | |
321 | // Outputs: | |
322 | // none. | |
323 | // Return: | |
324 | // none. | |
3bd79107 | 325 | |
2aea926d | 326 | if(this==&source) return; |
4a5bebc2 | 327 | Error("Copy constructor", |
88cb7938 | 328 | "You are not allowed to make a copy of the AliITS"); |
2aea926d | 329 | exit(1); |
3bd79107 | 330 | } |
2aea926d | 331 | //______________________________________________________________________ |
332 | AliITS& AliITS::operator=(AliITS &source){ | |
4a5bebc2 | 333 | // Assignment operator. This is a function which is not allowed to be |
334 | // done to the ITS. It exits with an error. | |
335 | // Inputs: | |
336 | // AliITS &source An AliITS class. | |
337 | // Outputs: | |
338 | // none. | |
339 | // Return: | |
340 | // none. | |
3bd79107 | 341 | |
2aea926d | 342 | if(this==&source) return *this; |
4a5bebc2 | 343 | Error("operator=","You are not allowed to make a copy of the AliITS"); |
2aea926d | 344 | exit(1); |
345 | return *this; //fake return | |
3bd79107 | 346 | } |
2aea926d | 347 | //______________________________________________________________________ |
aacedc3e | 348 | AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{ |
349 | // Creates the AliITSDigitizer in a standard way for use via AliModule. | |
350 | // This function can not be included in the .h file because of problems | |
351 | // with the order of inclusion (recursive). | |
4a5bebc2 | 352 | // Inputs: |
aacedc3e | 353 | // AliRunDigitizer *manager The Manger class for Digitization |
354 | // Output: | |
355 | // none. | |
4a5bebc2 | 356 | // Return: |
aacedc3e | 357 | // A new AliITSRunDigitizer (cast as a AliDigitizer). |
3bd79107 | 358 | |
aacedc3e | 359 | return new AliITSDigitizer(manager); |
3bd79107 | 360 | } |
2aea926d | 361 | //______________________________________________________________________ |
362 | void AliITS::Init(){ | |
4a5bebc2 | 363 | // Initializer ITS after it has been built |
2aea926d | 364 | // This routine initializes the AliITS class. It is intended to be |
365 | // called from the Init function in AliITSv?. Besides displaying a banner | |
366 | // indicating that it has been called it initializes the array fIdSens | |
367 | // and sets the default segmentation, response, digit and raw cluster | |
368 | // classes therefore it should be called after a call to CreateGeometry. | |
4a5bebc2 | 369 | // Inputs: |
370 | // none. | |
371 | // Outputs: | |
372 | // none. | |
373 | // Return: | |
374 | // none. | |
3bd79107 | 375 | Int_t i; |
3bd79107 | 376 | |
2aea926d | 377 | SetDefaults(); |
378 | // Array of TStrings | |
0e73d04c | 379 | if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]); |
3bd79107 | 380 | } |
2aea926d | 381 | //______________________________________________________________________ |
382 | void AliITS::SetDefaults(){ | |
4a5bebc2 | 383 | // sets the default segmentation, response, digit and raw cluster classes. |
384 | // Inputs: | |
385 | // none. | |
386 | // Outputs: | |
387 | // none. | |
388 | // Return: | |
389 | // none. | |
aacedc3e | 390 | AliITSsegmentation *seg; |
391 | AliITSresponse *resp; | |
2aea926d | 392 | AliITSDetType *iDetType; |
393 | ||
aacedc3e | 394 | if(fDebug) Info("SetDefauls","%s: SetDefaults",ClassName()); |
395 | ||
2aea926d | 396 | //SPD |
aacedc3e | 397 | iDetType = DetType(kSPD); |
398 | if(iDetType){ | |
399 | if (!iDetType->GetSegmentationModel()) { | |
400 | seg = new AliITSsegmentationSPD(fITSgeom); | |
401 | SetSegmentationModel(kSPD,seg); | |
402 | } // end if | |
403 | if (!iDetType->GetResponseModel()) { | |
404 | SetResponseModel(kSPD,new AliITSresponseSPD()); | |
405 | } // end if | |
406 | // set digit and raw cluster classes to be used | |
2aea926d | 407 | |
aacedc3e | 408 | const char *kData0=(iDetType->GetResponseModel())->DataType(); |
409 | if (strstr(kData0,"real")) { | |
410 | iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD"); | |
411 | } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD"); | |
412 | } // end if iDetType | |
2aea926d | 413 | |
414 | // SDD | |
aacedc3e | 415 | iDetType = DetType(kSDD); |
416 | if(iDetType){ | |
417 | if (!iDetType->GetResponseModel()) { | |
418 | SetResponseModel(kSDD,new AliITSresponseSDD("simulated")); | |
419 | } // end if | |
420 | resp = iDetType->GetResponseModel(); | |
421 | if (!iDetType->GetSegmentationModel()) { | |
422 | seg = new AliITSsegmentationSDD(fITSgeom,resp); | |
423 | SetSegmentationModel(kSDD,seg); | |
424 | } // end if | |
425 | const char *kData1 = (iDetType->GetResponseModel())->DataType(); | |
426 | const char *kopt = iDetType->GetResponseModel()->ZeroSuppOption(); | |
427 | if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || | |
428 | strstr(kData1,"real") ){ | |
429 | iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD"); | |
430 | } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD"); | |
431 | } // end if iDetType | |
2aea926d | 432 | |
433 | // SSD | |
aacedc3e | 434 | iDetType = DetType(kSSD); |
435 | if(iDetType){ | |
436 | if (!iDetType->GetSegmentationModel()) { | |
437 | seg = new AliITSsegmentationSSD(fITSgeom); | |
438 | SetSegmentationModel(kSSD,seg); | |
439 | } // end if | |
440 | if (!iDetType->GetResponseModel()) { | |
441 | SetResponseModel(kSSD,new AliITSresponseSSD("simulated")); | |
442 | } // end if | |
443 | const char *kData2 = (iDetType->GetResponseModel())->DataType(); | |
444 | if (strstr(kData2,"real")) { | |
445 | iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD"); | |
446 | } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD"); | |
447 | } // end if iDetType | |
2aea926d | 448 | |
449 | if (kNTYPES>3) { | |
88cb7938 | 450 | Warning("SetDefaults", |
451 | "Only the three basic detector types are initialized!"); | |
2aea926d | 452 | } // end if |
3bd79107 | 453 | } |
2aea926d | 454 | //______________________________________________________________________ |
455 | void AliITS::SetDefaultSimulation(){ | |
4a5bebc2 | 456 | // sets the default simulation. |
457 | // Inputs: | |
458 | // none. | |
459 | // Outputs: | |
460 | // none. | |
461 | // Return: | |
462 | // none. | |
2aea926d | 463 | AliITSDetType *iDetType; |
54b8cf3b | 464 | AliITSsimulation *sim; |
aacedc3e | 465 | AliITSsegmentation *seg; |
466 | AliITSresponse *res; | |
467 | ||
468 | iDetType = DetType(kSPD); | |
469 | if(iDetType){ | |
470 | sim = iDetType->GetSimulationModel(); | |
471 | if (!sim) { | |
472 | seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
473 | res = (AliITSresponse*)iDetType->GetResponseModel(); | |
474 | sim = new AliITSsimulationSPD(seg,res); | |
475 | SetSimulationModel(kSPD,sim); | |
476 | }else{ // simulation exists, make sure it is set up properly. | |
477 | if(sim->GetResponseModel()==0) sim->SetResponseModel( | |
478 | (AliITSresponse*)iDetType->GetResponseModel()); | |
479 | if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( | |
480 | (AliITSsegmentation*)iDetType->GetSegmentationModel()); | |
481 | sim->Init(); | |
482 | } // end if | |
483 | }// end if iDetType | |
484 | iDetType = DetType(kSDD); | |
485 | if(iDetType){ | |
486 | sim = iDetType->GetSimulationModel(); | |
487 | if (!sim) { | |
488 | seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
489 | res = (AliITSresponse*)iDetType->GetResponseModel(); | |
490 | sim = new AliITSsimulationSDD(seg,res); | |
491 | SetSimulationModel(kSDD,sim); | |
492 | }else{ // simulation exists, make sure it is set up properly. | |
493 | if(sim->GetResponseModel()==0) sim->SetResponseModel( | |
494 | (AliITSresponse*)iDetType->GetResponseModel()); | |
495 | if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( | |
496 | (AliITSsegmentation*)iDetType->GetSegmentationModel()); | |
497 | sim->Init(); | |
498 | } //end if | |
499 | }// end if iDetType | |
500 | iDetType = DetType(kSSD); | |
501 | if(iDetType){ | |
502 | sim = iDetType->GetSimulationModel(); | |
503 | if (!sim) { | |
504 | seg =(AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
505 | res = (AliITSresponse*)iDetType->GetResponseModel(); | |
506 | sim = new AliITSsimulationSSD(seg,res); | |
507 | SetSimulationModel(kSSD,sim); | |
508 | }else{ // simulation exists, make sure it is set up properly. | |
509 | if(sim->GetResponseModel()==0) sim->SetResponseModel( | |
510 | (AliITSresponse*)iDetType->GetResponseModel()); | |
511 | if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( | |
512 | (AliITSsegmentation*)iDetType->GetSegmentationModel()); | |
513 | sim->Init(); | |
514 | } // end if | |
515 | } // end if iDetType | |
3bd79107 | 516 | } |
2aea926d | 517 | //______________________________________________________________________ |
518 | void AliITS::SetDefaultClusterFinders(){ | |
4a5bebc2 | 519 | // Sets the default cluster finders. Used in finding RecPoints. |
520 | // Inputs: | |
521 | // none. | |
522 | // Outputs: | |
523 | // none. | |
524 | // Return: | |
525 | // none. | |
aacedc3e | 526 | AliITSDetType *iDetType; |
527 | AliITSsegmentation *seg; | |
528 | AliITSClusterFinder *clf; | |
529 | AliITSresponse *res; | |
2aea926d | 530 | |
531 | MakeTreeC(); | |
2aea926d | 532 | |
533 | // SPD | |
aacedc3e | 534 | iDetType=DetType(kSPD); |
535 | if(iDetType){ | |
536 | if (!iDetType->GetReconstructionModel()) { | |
537 | seg =(AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
538 | TClonesArray *dig0 = DigitsAddress(0); | |
539 | TClonesArray *recp0 = ClustersAddress(0); | |
540 | clf = new AliITSClusterFinderSPD(seg,dig0,recp0); | |
541 | SetReconstructionModel(kSPD,clf); | |
542 | } // end if | |
543 | } // end if iDetType | |
2aea926d | 544 | |
545 | // SDD | |
aacedc3e | 546 | iDetType=DetType(kSDD); |
547 | if(iDetType){ | |
548 | if (!iDetType->GetReconstructionModel()) { | |
549 | seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
550 | res = (AliITSresponse*)iDetType->GetResponseModel(); | |
551 | TClonesArray *dig1 = DigitsAddress(1); | |
552 | TClonesArray *recp1 = ClustersAddress(1); | |
553 | clf = new AliITSClusterFinderSDD(seg,res,dig1,recp1); | |
554 | SetReconstructionModel(kSDD,clf); | |
555 | } // end if | |
556 | } // end if iDetType | |
2aea926d | 557 | |
558 | // SSD | |
aacedc3e | 559 | iDetType=DetType(kSSD); |
560 | if(iDetType){ | |
561 | if (!iDetType->GetReconstructionModel()) { | |
562 | seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
563 | TClonesArray *dig2 = DigitsAddress(2); | |
564 | clf = new AliITSClusterFinderSSD(seg,dig2); | |
565 | SetReconstructionModel(kSSD,clf); | |
566 | } // end if | |
567 | } // end if iDetType | |
3bd79107 | 568 | } |
04366a57 | 569 | |
570 | ||
571 | //______________________________________________________________________ | |
572 | void AliITS::SetDefaultClusterFindersV2(){ | |
573 | // Sets the default cluster finders. Used in finding RecPoints. | |
574 | // Inputs: | |
575 | // none. | |
576 | // Outputs: | |
577 | // none. | |
578 | // Return: | |
579 | // none. | |
580 | AliITSDetType *iDetType; | |
581 | AliITSsegmentation *seg; | |
582 | AliITSClusterFinder *clf; | |
583 | ||
584 | MakeTreeC(); | |
585 | ||
586 | // SPD | |
587 | iDetType=DetType(kSPD); | |
588 | if(iDetType){ | |
589 | if (!iDetType->GetReconstructionModel()) { | |
590 | seg =(AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
591 | clf = new AliITSClusterFinderV2SPD(); | |
592 | clf->SetSegmentation(seg); | |
593 | clf->SetDigits(DigitsAddress(0)); | |
594 | SetReconstructionModel(kSPD,clf); | |
595 | } // end if | |
596 | } // end if iDetType | |
597 | ||
598 | // SDD | |
599 | iDetType=DetType(kSDD); | |
600 | if(iDetType){ | |
601 | if (!iDetType->GetReconstructionModel()) { | |
602 | seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
603 | clf = new AliITSClusterFinderV2SDD(); | |
604 | clf->SetSegmentation(seg); | |
605 | clf->SetDigits(DigitsAddress(1)); | |
606 | SetReconstructionModel(kSDD,clf); | |
607 | } // end if | |
608 | } // end if iDetType | |
609 | ||
610 | // SSD | |
611 | iDetType=DetType(kSSD); | |
612 | if(iDetType){ | |
613 | if (!iDetType->GetReconstructionModel()) { | |
614 | seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); | |
615 | clf = new AliITSClusterFinderV2SSD(); | |
616 | clf->SetSegmentation(seg); | |
617 | clf->SetDigits(DigitsAddress(2)); | |
618 | SetReconstructionModel(kSSD,clf); | |
619 | } // end if | |
620 | } // end if iDetType | |
621 | } | |
622 | ||
623 | ||
2aea926d | 624 | //______________________________________________________________________ |
88cb7938 | 625 | void AliITS::MakeBranch(Option_t* option){ |
2aea926d | 626 | // Creates Tree branches for the ITS. |
4a5bebc2 | 627 | // Inputs: |
628 | // Option_t *option String of Tree types S,D, and/or R. | |
629 | // const char *file String of the file name where these branches | |
630 | // are to be stored. If blank then these branches | |
631 | // are written to the same tree as the Hits were | |
632 | // read from. | |
633 | // Outputs: | |
634 | // none. | |
635 | // Return: | |
636 | // none. | |
88cb7938 | 637 | Bool_t cH = (strstr(option,"H")!=0); |
ff0e455e | 638 | Bool_t cS = (strstr(option,"S")!=0); |
639 | Bool_t cD = (strstr(option,"D")!=0); | |
640 | Bool_t cR = (strstr(option,"R")!=0); | |
641 | Bool_t cRF = (strstr(option,"RF")!=0); | |
04366a57 | 642 | Bool_t v2 = (strstr(option,"v2")!=0); |
88cb7938 | 643 | |
04366a57 | 644 | |
ff0e455e | 645 | if(cRF)cR = kFALSE; |
88cb7938 | 646 | if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560); |
647 | ||
648 | AliDetector::MakeBranch(option); | |
2aea926d | 649 | |
88cb7938 | 650 | if(cS) MakeBranchS(0); |
651 | if(cD) MakeBranchD(0); | |
652 | if(cR) MakeBranchR(0); | |
653 | if(cRF) MakeBranchRF(0); | |
04366a57 | 654 | if(v2) MakeBranchR(0,"v2"); |
fe4da5cc | 655 | } |
2aea926d | 656 | //______________________________________________________________________ |
657 | void AliITS::SetTreeAddress(){ | |
658 | // Set branch address for the Trees. | |
4a5bebc2 | 659 | // Inputs: |
660 | // none. | |
661 | // Outputs: | |
662 | // none. | |
663 | // Return: | |
664 | // none. | |
88cb7938 | 665 | TTree *treeS = fLoader->TreeS(); |
666 | TTree *treeD = fLoader->TreeD(); | |
667 | TTree *treeR = fLoader->TreeR(); | |
aacedc3e | 668 | if (fLoader->TreeH() && (fHits == 0x0)) |
669 | fHits = new TClonesArray("AliITShit", 1560); | |
670 | ||
2aea926d | 671 | AliDetector::SetTreeAddress(); |
672 | ||
673 | SetTreeAddressS(treeS); | |
674 | SetTreeAddressD(treeD); | |
675 | SetTreeAddressR(treeR); | |
fe4da5cc | 676 | } |
2aea926d | 677 | //______________________________________________________________________ |
2aea926d | 678 | void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){ |
679 | // Add an ITS hit | |
680 | // The function to add information to the AliITShit class. See the | |
681 | // AliITShit class for a full description. This function allocates the | |
682 | // necessary new space for the hit information and passes the variable | |
683 | // track, and the pointers *vol and *hits to the AliITShit constructor | |
684 | // function. | |
4a5bebc2 | 685 | // Inputs: |
686 | // Int_t track Track number which produced this hit. | |
687 | // Int_t *vol Array of Integer Hit information. See AliITShit.h | |
688 | // Float_t *hits Array of Floating Hit information. see AliITShit.h | |
689 | // Outputs: | |
690 | // none. | |
691 | // Return: | |
692 | // none. | |
2aea926d | 693 | |
694 | TClonesArray &lhits = *fHits; | |
695 | new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits); | |
3bd79107 | 696 | } |
2aea926d | 697 | //______________________________________________________________________ |
3bd79107 | 698 | void AliITS::InitModules(Int_t size,Int_t &nmodules){ |
4a5bebc2 | 699 | // Initialize the modules array. |
700 | // Inputs: | |
701 | // Int_t size Size of array of the number of modules to be | |
702 | // created. If size <=0 then the number of modules | |
703 | // is gotten from AliITSgeom class kept in fITSgeom. | |
704 | // Outputs: | |
705 | // Int_t &nmodules The number of modules existing. | |
706 | // Return: | |
707 | // none. | |
3bd79107 | 708 | |
2aea926d | 709 | if(fITSmodules){ |
88cb7938 | 710 | fITSmodules->Delete(); |
711 | delete fITSmodules; | |
2aea926d | 712 | } // end fir fITSmoudles |
e8189707 | 713 | |
3bd79107 | 714 | Int_t nl,indexMAX,index; |
3bd79107 | 715 | |
716 | if(size<=0){ // default to using data stored in AliITSgeom | |
88cb7938 | 717 | if(fITSgeom==0) { |
718 | Error("InitModules","fITSgeom not defined"); | |
719 | return; | |
720 | } // end if fITSgeom==0 | |
721 | nl = fITSgeom->GetNlayers(); | |
7e932df0 | 722 | indexMAX = fITSgeom->GetIndexMax(); |
88cb7938 | 723 | nmodules = indexMAX; |
724 | fITSmodules = new TObjArray(indexMAX); | |
725 | for(index=0;index<indexMAX;index++){ | |
726 | fITSmodules->AddAt( new AliITSmodule(index),index); | |
727 | } // end for index | |
3bd79107 | 728 | }else{ |
88cb7938 | 729 | fITSmodules = new TObjArray(size); |
730 | for(index=0;index<size;index++) { | |
731 | fITSmodules->AddAt( new AliITSmodule(index),index); | |
732 | } // end for index | |
9c74c52b | 733 | |
3bd79107 | 734 | nmodules = size; |
735 | } // end i size<=0 | |
736 | } | |
2aea926d | 737 | //______________________________________________________________________ |
738 | void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules, | |
8e8eae84 | 739 | Option_t *option, const char *filename){ |
2aea926d | 740 | // fill the modules with the sorted by module hits; add hits from |
4a5bebc2 | 741 | // background if option=Add. |
742 | // Inputs: | |
743 | // Int_t evnt Event to be processed. | |
744 | // Int_t bgrev Background Hit tree number. | |
745 | // Int_t nmodules Not used. | |
746 | // Option_t *option String indicating if merging hits or not. To | |
747 | // merge hits set equal to "Add". Otherwise no | |
748 | // background hits are considered. | |
749 | // Test_t *filename File name containing the background hits.. | |
750 | // Outputs: | |
751 | // none. | |
752 | // Return: | |
753 | // none. | |
3bd79107 | 754 | static TTree *trH1; //Tree with background hits |
3bd79107 | 755 | static Bool_t first=kTRUE; |
756 | static TFile *file; | |
5cf7bbad | 757 | const char *addBgr = strstr(option,"Add"); |
3bd79107 | 758 | |
ac74f489 | 759 | evnt = nmodules; // Dummy use of variables to remove warnings |
e8189707 | 760 | if (addBgr ) { |
88cb7938 | 761 | if(first) { |
762 | file=new TFile(filename); | |
763 | } // end if first | |
764 | first=kFALSE; | |
765 | file->cd(); | |
766 | file->ls(); | |
767 | // Get Hits Tree header from file | |
768 | if(trH1) delete trH1; | |
769 | trH1=0; | |
770 | ||
771 | char treeName[20]; | |
772 | sprintf(treeName,"TreeH%d",bgrev); | |
773 | trH1 = (TTree*)gDirectory->Get(treeName); | |
774 | if (!trH1) { | |
775 | Error("FillModules","cannot find Hits Tree for event:%d",bgrev); | |
776 | } // end if !trH1 | |
777 | // Set branch addresses | |
2aea926d | 778 | } // end if addBgr |
3bd79107 | 779 | |
88cb7938 | 780 | FillModules(fLoader->TreeH(),0); // fill from this file's tree. |
3bd79107 | 781 | |
e8189707 | 782 | if (addBgr ) { |
88cb7938 | 783 | FillModules(trH1,10000000); // Default mask 10M. |
784 | TTree *fAli=fLoader->GetRunLoader()->TreeK(); | |
785 | TFile *fileAli=0; | |
786 | if (fAli) fileAli =fAli->GetCurrentFile(); | |
787 | fileAli->cd(); | |
3bd79107 | 788 | } // end if add |
3bd79107 | 789 | } |
2aea926d | 790 | //______________________________________________________________________ |
b4012daf | 791 | void AliITS::FillModules(TTree *treeH, Int_t mask) { |
792 | // fill the modules with the sorted by module hits; | |
793 | // can be called many times to do a merging | |
794 | // Inputs: | |
795 | // TTree *treeH The tree containing the hits to be copied into | |
796 | // the modules. | |
797 | // Int_t mask The track number mask to indecate which file | |
798 | // this hits came from. | |
799 | // Outputs: | |
800 | // none. | |
801 | // Return: | |
802 | // none. | |
803 | ||
88cb7938 | 804 | if (treeH == 0x0) |
805 | { | |
806 | Error("FillModules","Tree is NULL"); | |
807 | } | |
b4012daf | 808 | Int_t lay,lad,det,index; |
809 | AliITShit *itsHit=0; | |
810 | AliITSmodule *mod=0; | |
811 | char branchname[20]; | |
812 | sprintf(branchname,"%s",GetName()); | |
813 | TBranch *branch = treeH->GetBranch(branchname); | |
814 | if (!branch) { | |
88cb7938 | 815 | Error("FillModules","%s branch in TreeH not found",branchname); |
816 | return; | |
b4012daf | 817 | } // end if !branch |
818 | branch->SetAddress(&fHits); | |
819 | Int_t nTracks =(Int_t) treeH->GetEntries(); | |
820 | Int_t iPrimTrack,h; | |
821 | for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){ | |
88cb7938 | 822 | ResetHits(); |
823 | Int_t nBytes = treeH->GetEvent(iPrimTrack); | |
824 | if (nBytes <= 0) continue; | |
825 | Int_t nHits = fHits->GetEntriesFast(); | |
826 | for(h=0; h<nHits; h++){ | |
827 | itsHit = (AliITShit *)fHits->UncheckedAt(h); | |
828 | itsHit->GetDetectorID(lay,lad,det); | |
829 | if (fITSgeom) { | |
830 | index = fITSgeom->GetModuleIndex(lay,lad,det); | |
831 | } else { | |
832 | index=det-1; // This should not be used. | |
833 | } // end if [You must have fITSgeom for this to work!] | |
834 | mod = GetModule(index); | |
835 | itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask. | |
836 | mod->AddHit(itsHit,iPrimTrack,h); | |
837 | } // end loop over hits | |
b4012daf | 838 | } // end loop over tracks |
839 | } | |
840 | //______________________________________________________________________ | |
4a5bebc2 | 841 | void AliITS::MakeBranchS(const char *fl){ |
842 | // Creates Tree Branch for the ITS summable digits. | |
843 | // Inputs: | |
844 | // cont char *fl File name where SDigits branch is to be written | |
845 | // to. If blank it write the SDigits to the same | |
846 | // file in which the Hits were found. | |
847 | // Outputs: | |
848 | // none. | |
849 | // Return: | |
850 | // none. | |
2aea926d | 851 | Int_t buffersize = 4000; |
852 | char branchname[30]; | |
2ab0c725 | 853 | |
2aea926d | 854 | // only one branch for SDigits. |
855 | sprintf(branchname,"%s",GetName()); | |
88cb7938 | 856 | |
857 | ||
7941072e | 858 | if(fLoader->TreeS()){ |
aacedc3e | 859 | if(fSDigits==0x0) fSDigits = new TClonesArray("AliITSpListItem",1000); |
88cb7938 | 860 | MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl); |
2aea926d | 861 | } // end if |
862 | } | |
863 | //______________________________________________________________________ | |
864 | void AliITS::SetTreeAddressS(TTree *treeS){ | |
865 | // Set branch address for the ITS summable digits Trees. | |
4a5bebc2 | 866 | // Inputs: |
867 | // TTree *treeS Tree containing the SDigits. | |
868 | // Outputs: | |
869 | // none. | |
870 | // Return: | |
871 | // none. | |
2aea926d | 872 | char branchname[30]; |
828e06c7 | 873 | |
2aea926d | 874 | if(!treeS) return; |
88cb7938 | 875 | if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000); |
2aea926d | 876 | TBranch *branch; |
877 | sprintf(branchname,"%s",GetName()); | |
878 | branch = treeS->GetBranch(branchname); | |
879 | if (branch) branch->SetAddress(&fSDigits); | |
880 | } | |
881 | //______________________________________________________________________ | |
9ad8b5dd | 882 | void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){ |
2aea926d | 883 | // Creates Tree branches for the ITS. |
4a5bebc2 | 884 | // Inputs: |
e0fc0305 | 885 | // TTree *treeD Pointer to the Digits Tree. |
4a5bebc2 | 886 | // cont char *file File name where Digits branch is to be written |
887 | // to. If blank it write the SDigits to the same | |
888 | // file in which the Hits were found. | |
889 | // Outputs: | |
890 | // none. | |
891 | // Return: | |
892 | // none. | |
2aea926d | 893 | // one branch for digits per type of detector |
aacedc3e | 894 | const Char_t *det[3] = {"SPD","SDD","SSD"}; |
895 | TString digclass; | |
2aea926d | 896 | Int_t i; |
aacedc3e | 897 | Int_t buffersize = 4000; |
898 | Char_t branchname[30]; | |
899 | ||
900 | if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes); | |
2aea926d | 901 | for (i=0; i<kNTYPES ;i++) { |
aacedc3e | 902 | digclass = DetType(i)->GetDigitClassName(); |
88cb7938 | 903 | // digits |
aacedc3e | 904 | if(!(fDtype->At(i))){ |
905 | fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i); | |
906 | }else{ | |
907 | ResetDigits(i); | |
908 | } // end if | |
909 | if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]); | |
910 | else sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
911 | if (fDtype && treeD) { | |
912 | MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file); | |
913 | } // end if | |
2aea926d | 914 | } // end for i |
aacedc3e | 915 | /* |
2aea926d | 916 | for (i=0; i<kNTYPES ;i++) { |
88cb7938 | 917 | if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]); |
918 | else sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
919 | if (fDtype && treeD) { | |
aacedc3e | 920 | MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file); |
88cb7938 | 921 | } // end if |
2aea926d | 922 | } // end for i |
aacedc3e | 923 | */ |
2ab0c725 | 924 | } |
2aea926d | 925 | //______________________________________________________________________ |
926 | void AliITS::SetTreeAddressD(TTree *treeD){ | |
927 | // Set branch address for the Trees. | |
4a5bebc2 | 928 | // Inputs: |
929 | // TTree *treeD Tree containing the Digits. | |
930 | // Outputs: | |
931 | // none. | |
932 | // Return: | |
933 | // none. | |
2aea926d | 934 | const char *det[3] = {"SPD","SDD","SSD"}; |
935 | TBranch *branch; | |
aacedc3e | 936 | TString digclass; |
2aea926d | 937 | Int_t i; |
aacedc3e | 938 | char branchname[30]; |
2ab0c725 | 939 | |
2aea926d | 940 | if(!treeD) return; |
aacedc3e | 941 | if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes); |
2aea926d | 942 | for (i=0; i<kNTYPES; i++) { |
aacedc3e | 943 | digclass = DetType(i)->GetDigitClassName(); |
88cb7938 | 944 | // digits |
aacedc3e | 945 | if(!(fDtype->At(i))) { |
946 | fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i); | |
947 | }else{ | |
948 | ResetDigits(i); | |
949 | } // end if | |
88cb7938 | 950 | if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]); |
951 | else sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
952 | if (fDtype) { | |
953 | branch = treeD->GetBranch(branchname); | |
954 | if (branch) branch->SetAddress(&((*fDtype)[i])); | |
955 | } // end if fDtype | |
2aea926d | 956 | } // end for i |
957 | } | |
958 | //______________________________________________________________________ | |
959 | void AliITS::Hits2SDigits(){ | |
960 | // Standard Hits to summable Digits function. | |
4a5bebc2 | 961 | // Inputs: |
962 | // none. | |
963 | // Outputs: | |
964 | // none. | |
2aea926d | 965 | |
85a5290f | 966 | fLoader->LoadHits("read"); |
967 | fLoader->LoadSDigits("recreate"); | |
88cb7938 | 968 | AliRunLoader* rl = fLoader->GetRunLoader(); |
85a5290f | 969 | |
970 | for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { | |
aacedc3e | 971 | // Do the Hits to Digits operation. Use Standard input values. |
972 | // Event number from file, no background hit merging , use size from | |
973 | // AliITSgeom class, option="All", input from this file only. | |
974 | rl->GetEvent(iEvent); | |
975 | if (!fLoader->TreeS()) fLoader->MakeTree("S"); | |
976 | MakeBranch("S"); | |
977 | SetTreeAddress(); | |
978 | HitsToPreDigits(iEvent,0,-1," ",fOpt," "); | |
979 | } // end for iEvent | |
88cb7938 | 980 | |
85a5290f | 981 | fLoader->UnloadHits(); |
b25cfbb5 | 982 | fLoader->UnloadSDigits(); |
85a5290f | 983 | } |
984 | //______________________________________________________________________ | |
e0fc0305 | 985 | void AliITS::SDigitsToDigits(Option_t *opt){ |
2aea926d | 986 | // Standard Summable digits to Digits function. |
4a5bebc2 | 987 | // Inputs: |
988 | // none. | |
989 | // Outputs: | |
990 | // none. | |
e0fc0305 | 991 | char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
992 | ||
993 | if(!GetITSgeom()) return; // need transformations to do digitization. | |
994 | AliITSgeom *geom = GetITSgeom(); | |
995 | ||
996 | const char *all = strstr(opt,"All"); | |
997 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
88cb7938 | 998 | strstr(opt,"SSD")}; |
e0fc0305 | 999 | if( !det[0] && !det[1] && !det[2] ) all = "All"; |
1000 | else all = 0; | |
aacedc3e | 1001 | static Bool_t setDef = kTRUE; |
1002 | if(setDef) SetDefaultSimulation(); | |
1003 | setDef = kFALSE; | |
e0fc0305 | 1004 | |
1005 | AliITSsimulation *sim = 0; | |
1006 | AliITSDetType *iDetType = 0; | |
88cb7938 | 1007 | TTree *trees = fLoader->TreeS(); |
e0fc0305 | 1008 | if( !(trees && this->GetSDigits()) ){ |
88cb7938 | 1009 | Error("SDigits2Digits","Error: No trees or SDigits. Returning."); |
1010 | return; | |
e0fc0305 | 1011 | } // end if |
1012 | sprintf( name, "%s", this->GetName() ); | |
1013 | TBranch *brchSDigits = trees->GetBranch( name ); | |
1014 | ||
1015 | Int_t id,module; | |
1016 | for(module=0;module<geom->GetIndexMax();module++){ | |
88cb7938 | 1017 | id = geom->GetModuleType(module); |
e0fc0305 | 1018 | if (!all && !det[id]) continue; |
88cb7938 | 1019 | iDetType = DetType(id); |
1020 | sim = (AliITSsimulation*)iDetType->GetSimulationModel(); | |
1021 | if (!sim) { | |
e80bf2b3 | 1022 | Error("SDigit2Digits","The simulation class was not " |
1023 | "instanciated for module %d type %s!",module, | |
1024 | geom->GetModuleTypeName(module)); | |
88cb7938 | 1025 | exit(1); |
1026 | } // end if !sim | |
1027 | sim->InitSimulationModule(module,gAlice->GetEvNumber()); | |
aacedc3e | 1028 | // |
88cb7938 | 1029 | // add summable digits to module |
1030 | this->GetSDigits()->Clear(); | |
1031 | brchSDigits->GetEvent(module); | |
1032 | sim->AddSDigitsToModule(GetSDigits(),0); | |
aacedc3e | 1033 | // |
e0fc0305 | 1034 | // Digitise current module sum(SDigits)->Digits |
1035 | sim->FinishSDigitiseModule(); | |
3bd79107 | 1036 | |
e0fc0305 | 1037 | // fills all branches - wasted disk space |
88cb7938 | 1038 | fLoader->TreeD()->Fill(); |
e0fc0305 | 1039 | this->ResetDigits(); |
1040 | } // end for module | |
1041 | ||
88cb7938 | 1042 | fLoader->TreeD()->GetEntries(); |
ed9afcd2 | 1043 | |
88cb7938 | 1044 | fLoader->TreeD()->AutoSave(); |
e0fc0305 | 1045 | // reset tree |
88cb7938 | 1046 | fLoader->TreeD()->Reset(); |
e0fc0305 | 1047 | |
2aea926d | 1048 | } |
1049 | //______________________________________________________________________ | |
1050 | void AliITS::Hits2Digits(){ | |
1051 | // Standard Hits to Digits function. | |
4a5bebc2 | 1052 | // Inputs: |
1053 | // none. | |
1054 | // Outputs: | |
1055 | // none. | |
2aea926d | 1056 | |
85a5290f | 1057 | fLoader->LoadHits("read"); |
1058 | fLoader->LoadDigits("recreate"); | |
1059 | AliRunLoader* rl = fLoader->GetRunLoader(); | |
1060 | ||
1061 | for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { | |
aacedc3e | 1062 | // Do the Hits to Digits operation. Use Standard input values. |
1063 | // Event number from file, no background hit merging , use size from | |
1064 | // AliITSgeom class, option="All", input from this file only. | |
1065 | rl->GetEvent(iEvent); | |
1066 | if (!fLoader->TreeD()) fLoader->MakeTree("D"); | |
1067 | MakeBranch("D"); | |
1068 | SetTreeAddress(); | |
1069 | HitsToDigits(iEvent,0,-1," ",fOpt," "); | |
1070 | } // end for iEvent | |
85a5290f | 1071 | |
1072 | fLoader->UnloadHits(); | |
1073 | fLoader->UnloadDigits(); | |
2aea926d | 1074 | } |
1075 | //______________________________________________________________________ | |
2aea926d | 1076 | void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size, |
aacedc3e | 1077 | Option_t *option,Option_t *opt, |
1078 | const char *filename){ | |
4a5bebc2 | 1079 | // Keep galice.root for signal and name differently the file for |
2aea926d | 1080 | // background when add! otherwise the track info for signal will be lost ! |
1081 | // the condition below will disappear when the geom class will be | |
4a5bebc2 | 1082 | // initialized for all versions - for the moment it is only for v5 ! |
1083 | // 7 is the SDD beam test version. | |
1084 | // Inputs: | |
1085 | // Int_t evnt Event to be processed. | |
1086 | // Int_t bgrev Background Hit tree number. | |
1087 | // Int_t nmodules Not used. | |
1088 | // Option_t *option String indicating if merging hits or not. To | |
1089 | // merge hits set equal to "Add". Otherwise no | |
1090 | // background hits are considered. | |
1091 | // Test_t *filename File name containing the background hits.. | |
1092 | // Outputs: | |
1093 | // none. | |
1094 | // Return: | |
1095 | // none. | |
2aea926d | 1096 | |
1097 | if(!GetITSgeom()) return; // need transformations to do digitization. | |
1098 | AliITSgeom *geom = GetITSgeom(); | |
1099 | ||
1100 | const char *all = strstr(opt,"All"); | |
1101 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
88cb7938 | 1102 | strstr(opt,"SSD")}; |
2aea926d | 1103 | static Bool_t setDef=kTRUE; |
1104 | if (setDef) SetDefaultSimulation(); | |
1105 | setDef=kFALSE; | |
1106 | ||
1107 | Int_t nmodules; | |
1108 | InitModules(size,nmodules); | |
1109 | FillModules(evNumber,bgrev,nmodules,option,filename); | |
1110 | ||
1111 | AliITSsimulation *sim = 0; | |
1112 | AliITSDetType *iDetType = 0; | |
1113 | AliITSmodule *mod = 0; | |
1114 | Int_t id,module; | |
1115 | for(module=0;module<geom->GetIndexMax();module++){ | |
88cb7938 | 1116 | id = geom->GetModuleType(module); |
2aea926d | 1117 | if (!all && !det[id]) continue; |
88cb7938 | 1118 | iDetType = DetType(id); |
1119 | sim = (AliITSsimulation*)iDetType->GetSimulationModel(); | |
1120 | if (!sim) { | |
e80bf2b3 | 1121 | Error("HitsToSDigits","The simulation class was not " |
1122 | "instanciated for module %d type %s!",module, | |
1123 | geom->GetModuleTypeName(module)); | |
88cb7938 | 1124 | exit(1); |
1125 | } // end if !sim | |
1126 | mod = (AliITSmodule *)fITSmodules->At(module); | |
1127 | sim->SDigitiseModule(mod,module,evNumber); | |
1128 | // fills all branches - wasted disk space | |
1129 | fLoader->TreeS()->Fill(); | |
1130 | ResetSDigits(); | |
2aea926d | 1131 | } // end for module |
1132 | ||
1133 | ClearModules(); | |
1134 | ||
88cb7938 | 1135 | fLoader->TreeS()->GetEntries(); |
1136 | fLoader->TreeS()->AutoSave(); | |
1137 | fLoader->WriteSDigits("OVERWRITE"); | |
2aea926d | 1138 | // reset tree |
88cb7938 | 1139 | fLoader->TreeS()->Reset(); |
2aea926d | 1140 | } |
1141 | //______________________________________________________________________ | |
1142 | void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, | |
aacedc3e | 1143 | Option_t *option,Option_t *opt, |
1144 | const char *filename){ | |
4a5bebc2 | 1145 | // Keep galice.root for signal and name differently the file for |
2aea926d | 1146 | // background when add! otherwise the track info for signal will be lost ! |
1147 | // the condition below will disappear when the geom class will be | |
4a5bebc2 | 1148 | // initialized for all versions - for the moment it is only for v5 ! |
1149 | // 7 is the SDD beam test version. | |
1150 | // Inputs: | |
1151 | // Int_t evnt Event to be processed. | |
1152 | // Int_t bgrev Background Hit tree number. | |
1153 | // Int_t nmodules Not used. | |
1154 | // Option_t *option String indicating if merging hits or not. To | |
1155 | // merge hits set equal to "Add". Otherwise no | |
1156 | // background hits are considered. | |
1157 | // Test_t *filename File name containing the background hits.. | |
1158 | // Outputs: | |
1159 | // none. | |
1160 | // Return: | |
1161 | // none. | |
1162 | ||
04366a57 | 1163 | |
2aea926d | 1164 | if(!GetITSgeom()) return; // need transformations to do digitization. |
1165 | AliITSgeom *geom = GetITSgeom(); | |
1166 | ||
1167 | const char *all = strstr(opt,"All"); | |
1168 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
88cb7938 | 1169 | strstr(opt,"SSD")}; |
2aea926d | 1170 | static Bool_t setDef=kTRUE; |
1171 | if (setDef) SetDefaultSimulation(); | |
1172 | setDef=kFALSE; | |
1173 | ||
1174 | Int_t nmodules; | |
1175 | InitModules(size,nmodules); | |
1176 | FillModules(evNumber,bgrev,nmodules,option,filename); | |
1177 | ||
1178 | AliITSsimulation *sim = 0; | |
1179 | AliITSDetType *iDetType = 0; | |
1180 | AliITSmodule *mod = 0; | |
1181 | Int_t id,module; | |
1182 | for(module=0;module<geom->GetIndexMax();module++){ | |
88cb7938 | 1183 | id = geom->GetModuleType(module); |
2aea926d | 1184 | if (!all && !det[id]) continue; |
88cb7938 | 1185 | iDetType = DetType(id); |
1186 | sim = (AliITSsimulation*)iDetType->GetSimulationModel(); | |
1187 | if (!sim) { | |
e80bf2b3 | 1188 | Error("HitsToDigits","The simulation class was not " |
1189 | "instanciated for module %d type %s!",module, | |
1190 | geom->GetModuleTypeName(module)); | |
88cb7938 | 1191 | exit(1); |
1192 | } // end if !sim | |
1193 | mod = (AliITSmodule *)fITSmodules->At(module); | |
1194 | sim->DigitiseModule(mod,module,evNumber); | |
1195 | // fills all branches - wasted disk space | |
1196 | fLoader->TreeD()->Fill(); | |
1197 | ResetDigits(); | |
2aea926d | 1198 | } // end for module |
4a5bebc2 | 1199 | |
2aea926d | 1200 | ClearModules(); |
3bd79107 | 1201 | |
88cb7938 | 1202 | fLoader->TreeD()->GetEntries(); |
1203 | fLoader->TreeD()->AutoSave(); | |
2aea926d | 1204 | // reset tree |
88cb7938 | 1205 | fLoader->TreeD()->Reset(); |
2aea926d | 1206 | } |
1207 | //______________________________________________________________________ | |
2aea926d | 1208 | void AliITS::ResetDigits(){ |
4a5bebc2 | 1209 | // Reset number of digits and the digits array for the ITS detector. |
1210 | // Inputs: | |
1211 | // none. | |
1212 | // Outputs: | |
1213 | // none. | |
3bd79107 | 1214 | |
2aea926d | 1215 | if (!fDtype) return; |
3bd79107 | 1216 | |
2aea926d | 1217 | Int_t i; |
1218 | for (i=0;i<kNTYPES;i++ ) { | |
aacedc3e | 1219 | ResetDigits(i); |
2aea926d | 1220 | } // end for i |
1221 | } | |
1222 | //______________________________________________________________________ | |
1223 | void AliITS::ResetDigits(Int_t i){ | |
4a5bebc2 | 1224 | // Reset number of digits and the digits array for this branch. |
1225 | // Inputs: | |
1226 | // none. | |
1227 | // Outputs: | |
1228 | // none. | |
828e06c7 | 1229 | |
aacedc3e | 1230 | if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear(); |
1231 | if (fNdtype) fNdtype[i]=0; | |
2aea926d | 1232 | } |
1233 | //______________________________________________________________________ | |
1234 | void AliITS::AddSumDigit(AliITSpListItem &sdig){ | |
4a5bebc2 | 1235 | // Adds the a module full of summable digits to the summable digits tree. |
1236 | // Inputs: | |
1237 | // AliITSpListItem &sdig SDigit to be added to SDigits tree. | |
1238 | // Outputs: | |
1239 | // none. | |
1240 | // Return: | |
1241 | // none. | |
828e06c7 | 1242 | |
2aea926d | 1243 | TClonesArray &lsdig = *fSDigits; |
1244 | new(lsdig[fNSDigits++]) AliITSpListItem(sdig); | |
828e06c7 | 1245 | } |
2aea926d | 1246 | //______________________________________________________________________ |
1247 | void AliITS::AddRealDigit(Int_t id, Int_t *digits){ | |
4a5bebc2 | 1248 | // Add a real digit - as coming from data. |
1249 | // Inputs: | |
1250 | // Int_t id Detector type number. | |
1251 | // Int_t *digits Integer array containing the digits info. See | |
1252 | // AliITSdigit.h | |
1253 | // Outputs: | |
1254 | // none. | |
1255 | // Return: | |
1256 | // none. | |
9c74c52b | 1257 | |
2aea926d | 1258 | TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id)); |
1259 | new(ldigits[fNdtype[id]++]) AliITSdigit(digits); | |
1260 | } | |
1261 | //______________________________________________________________________ | |
1262 | void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){ | |
4a5bebc2 | 1263 | // Add a simulated digit. |
1264 | // Inputs: | |
1265 | // Int_t id Detector type number. | |
1266 | // AliITSdigit *d Digit to be added to the Digits Tree. See | |
1267 | // AliITSdigit.h | |
1268 | // Outputs: | |
1269 | // none. | |
1270 | // Return: | |
1271 | // none. | |
2aea926d | 1272 | |
1273 | TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id)); | |
1274 | ||
1275 | switch(id){ | |
1276 | case 0: | |
88cb7938 | 1277 | new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d)); |
1278 | break; | |
2aea926d | 1279 | case 1: |
88cb7938 | 1280 | new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d)); |
1281 | break; | |
2aea926d | 1282 | case 2: |
88cb7938 | 1283 | new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d)); |
1284 | break; | |
2aea926d | 1285 | } // end switch id |
1286 | } | |
1287 | //______________________________________________________________________ | |
1288 | void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks, | |
88cb7938 | 1289 | Int_t *hits,Float_t *charges){ |
7f1a504b | 1290 | // Add a simulated digit to the list. |
1291 | // Inputs: | |
1292 | // Int_t id Detector type number. | |
1293 | // Float_t phys Physics indicator. See AliITSdigits.h | |
1294 | // Int_t *digits Integer array containing the digits info. See | |
1295 | // AliITSdigit.h | |
1296 | // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()] | |
1297 | // containing the track numbers that contributed to | |
1298 | // this digit. | |
1299 | // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()] | |
1300 | // containing the hit numbers, from AliITSmodule, that | |
1301 | // contributed to this digit. | |
1302 | // Float_t *charge Floating point array of the signals contributed | |
1303 | // to this digit by each track. | |
1304 | // Outputs: | |
1305 | // none. | |
1306 | // Return: | |
1307 | // none. | |
2aea926d | 1308 | |
7f1a504b | 1309 | TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id)); |
1310 | AliITSresponseSDD *resp = 0; | |
1311 | switch(id){ | |
1312 | case 0: | |
aacedc3e | 1313 | new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits); |
1314 | break; | |
7f1a504b | 1315 | case 1: |
aacedc3e | 1316 | resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel(); |
1317 | new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks, | |
1318 | hits,charges,resp); | |
1319 | break; | |
7f1a504b | 1320 | case 2: |
aacedc3e | 1321 | new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits); |
1322 | break; | |
7f1a504b | 1323 | } // end switch id |
2aea926d | 1324 | } |
0421c3d1 | 1325 | //______________________________________________________________________ |
aacedc3e | 1326 | void AliITS::Digits2Raw(){ |
1327 | // convert digits of the current event to raw data | |
0421c3d1 | 1328 | |
1329 | fLoader->LoadDigits(); | |
1330 | TTree* digits = fLoader->TreeD(); | |
1331 | if (!digits) { | |
aacedc3e | 1332 | Error("Digits2Raw", "no digits tree"); |
1333 | return; | |
0421c3d1 | 1334 | } |
1335 | SetTreeAddressD(digits); | |
1336 | ||
1337 | AliITSDDLRawData rawWriter; | |
1338 | //Verbose level | |
1339 | // 0: Silent | |
1340 | // 1: cout messages | |
1341 | // 2: txt files with digits | |
1342 | //BE CAREFUL, verbose level 2 MUST be used only for debugging and | |
1343 | //it is highly suggested to use this mode only for debugging digits files | |
1344 | //reasonably small, because otherwise the size of the txt files can reach | |
1345 | //quickly several MB wasting time and disk space. | |
1346 | rawWriter.SetVerbose(0); | |
1347 | ||
1348 | //SILICON PIXEL DETECTOR | |
1349 | Info("Digits2Raw", "Formatting raw data for SPD"); | |
1350 | rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD")); | |
1351 | ||
1352 | //SILICON DRIFT DETECTOR | |
1353 | Info("Digits2Raw", "Formatting raw data for SDD"); | |
1354 | rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD")); | |
1355 | ||
1356 | //SILICON STRIP DETECTOR | |
1357 | Info("Digits2Raw", "Formatting raw data for SSD"); | |
1358 | rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD")); | |
1359 | ||
1360 | fLoader->UnloadDigits(); | |
1361 | } | |
1362 | ||
2aea926d | 1363 | //______________________________________________________________________ |
1364 | void AliITS::MakeTreeC(Option_t *option){ | |
88cb7938 | 1365 | // Create a separate tree to store the clusters. |
1366 | // Inputs: | |
1367 | // Option_t *option string which must contain "C" otherwise | |
1368 | // no Cluster Tree is created. | |
1369 | // Outputs: | |
1370 | // none. | |
1371 | // Return: | |
1372 | // none. | |
1373 | ||
1374 | AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; | |
1375 | ||
1376 | if (pITSLoader == 0x0) { | |
aacedc3e | 1377 | Error("MakeTreeC","fLoader == 0x0 option=%s",option); |
1378 | return; | |
88cb7938 | 1379 | } |
1380 | if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C"); | |
1381 | MakeBranchC(); | |
1382 | } | |
aacedc3e | 1383 | //---------------------------------------------------------------------- |
1384 | void AliITS::MakeBranchC(){ | |
1385 | //Makes barnches in treeC | |
1386 | AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; | |
1387 | if (pITSLoader == 0x0) { | |
1388 | Error("MakeTreeC","fLoader == 0x0"); | |
1389 | return; | |
1390 | } | |
1391 | TTree * lTC = pITSLoader->TreeC(); | |
1392 | if (lTC == 0x0){ | |
1393 | Error("MakeTreeC","Can not get TreeC from Loader"); | |
1394 | return; | |
1395 | } | |
828e06c7 | 1396 | |
aacedc3e | 1397 | Int_t buffersize = 4000; |
1398 | char branchname[30]; | |
1399 | const char *det[3] = {"SPD","SDD","SSD"}; | |
1400 | char digclass[40]; | |
1401 | char clclass[40]; | |
1402 | ||
2aea926d | 1403 | // one branch for Clusters per type of detector |
aacedc3e | 1404 | Int_t i; |
1405 | for (i=0; i<kNTYPES ;i++) { | |
2aea926d | 1406 | AliITSDetType *iDetType=DetType(i); |
1407 | iDetType->GetClassNames(digclass,clclass); | |
88cb7938 | 1408 | // clusters |
1409 | if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes); | |
aacedc3e | 1410 | if(!ClustersAddress(i)){ |
1411 | fCtype->AddAt(new TClonesArray(clclass,1000),i); | |
1412 | } | |
2aea926d | 1413 | if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]); |
88cb7938 | 1414 | else sprintf(branchname,"%sClusters%d",GetName(),i+1); |
aacedc3e | 1415 | if (fCtype && lTC) { |
1416 | if (lTC->GetBranch(branchname)){ | |
1417 | Warning("MakeBranchC","Branch %s alread exists in TreeC", | |
1418 | branchname); | |
1419 | }else{ | |
1420 | Info("MakeBranchC","Creating branch %s in TreeC",branchname); | |
1421 | lTC->Branch(branchname,&((*fCtype)[i]), buffersize); | |
88cb7938 | 1422 | } |
aacedc3e | 1423 | } // end if fCtype && lTC |
1424 | } // end for i | |
2aea926d | 1425 | } |
1426 | //______________________________________________________________________ | |
1427 | void AliITS::GetTreeC(Int_t event){ | |
aacedc3e | 1428 | // Get the clusters tree for this event and set the branch address. |
1429 | // Inputs: | |
1430 | // Int_t event Event number for the cluster tree. | |
1431 | // Outputs: | |
1432 | // none. | |
1433 | // Return: | |
1434 | // none. | |
1435 | char branchname[30]; | |
1436 | const char *det[3] = {"SPD","SDD","SSD"}; | |
3bd79107 | 1437 | |
aacedc3e | 1438 | AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; |
1439 | TTree * lTC = pITSLoader->TreeC(); | |
2aea926d | 1440 | |
aacedc3e | 1441 | ResetClusters(); |
1442 | if (lTC) { | |
1443 | pITSLoader->CleanRawClusters(); | |
1444 | } // end if TreeC() | |
88cb7938 | 1445 | |
aacedc3e | 1446 | TBranch *branch; |
88cb7938 | 1447 | |
aacedc3e | 1448 | if (lTC) { |
1449 | Int_t i; | |
88cb7938 | 1450 | char digclass[40]; |
1451 | char clclass[40]; | |
1452 | for (i=0; i<kNTYPES; i++) { | |
aacedc3e | 1453 | AliITSDetType *iDetType=DetType(i); |
1454 | iDetType->GetClassNames(digclass,clclass); | |
1455 | // clusters | |
1456 | if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes); | |
1457 | if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i); | |
1458 | if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]); | |
1459 | else sprintf(branchname,"%sClusters%d",GetName(),i+1); | |
1460 | if (fCtype) { | |
93f82b23 | 1461 | branch = lTC->GetBranch(branchname); |
aacedc3e | 1462 | if (branch) branch->SetAddress(&((*fCtype)[i])); |
1463 | } // end if fCtype | |
88cb7938 | 1464 | } // end for i |
aacedc3e | 1465 | } else { |
88cb7938 | 1466 | Error("GetTreeC","cannot find Clusters Tree for event:%d",event); |
aacedc3e | 1467 | } // end if lTC |
2aea926d | 1468 | } |
1469 | //______________________________________________________________________ | |
1470 | void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){ | |
4a5bebc2 | 1471 | // Add a cluster to the list. |
1472 | // Inputs: | |
1473 | // Int_t id Detector type number. | |
1474 | // AliITSRawCluster *c Cluster class to be added to the tree of | |
1475 | // clusters. | |
1476 | // Outputs: | |
1477 | // none. | |
1478 | // Return: | |
1479 | // none. | |
2aea926d | 1480 | |
1481 | TClonesArray &lc = *((TClonesArray*)fCtype->At(id)); | |
1482 | ||
1483 | switch(id){ | |
1484 | case 0: | |
88cb7938 | 1485 | new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c)); |
1486 | break; | |
2aea926d | 1487 | case 1: |
88cb7938 | 1488 | new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c)); |
1489 | break; | |
2aea926d | 1490 | case 2: |
88cb7938 | 1491 | new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c)); |
1492 | break; | |
2aea926d | 1493 | } // end switch id |
1494 | } | |
1495 | //______________________________________________________________________ | |
2aea926d | 1496 | void AliITS::ResetClusters(Int_t i){ |
4a5bebc2 | 1497 | // Reset number of clusters and the clusters array for this branch. |
1498 | // Inputs: | |
1499 | // Int_t i Detector type number. | |
1500 | // Outputs: | |
1501 | // none. | |
1502 | // Return: | |
1503 | // none. | |
3bd79107 | 1504 | |
2aea926d | 1505 | if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear(); |
1506 | if (fNctype) fNctype[i]=0; | |
1507 | } | |
1508 | //______________________________________________________________________ | |
ff0e455e | 1509 | void AliITS::MakeBranchR(const char *file, Option_t *opt){ |
2aea926d | 1510 | // Creates Tree branches for the ITS Reconstructed points. |
4a5bebc2 | 1511 | // Inputs: |
1512 | // cont char *file File name where RecPoints branch is to be written | |
1513 | // to. If blank it write the SDigits to the same | |
1514 | // file in which the Hits were found. | |
1515 | // Outputs: | |
1516 | // none. | |
1517 | // Return: | |
1518 | // none. | |
1519 | Int_t buffsz = 4000; | |
2aea926d | 1520 | char branchname[30]; |
3bd79107 | 1521 | |
2aea926d | 1522 | // only one branch for rec points for all detector types |
ff0e455e | 1523 | Bool_t oFast= (strstr(opt,"Fast")!=0); |
04366a57 | 1524 | Bool_t v2 = (strstr(opt,"v2")!=0); |
1525 | ||
1526 | ||
ff0e455e | 1527 | if(oFast){ |
aacedc3e | 1528 | sprintf(branchname,"%sRecPointsF",GetName()); |
04366a57 | 1529 | } else if(v2){ |
1530 | sprintf(branchname,"Clusters"); | |
ff0e455e | 1531 | } else { |
aacedc3e | 1532 | sprintf(branchname,"%sRecPoints",GetName()); |
ff0e455e | 1533 | } |
aacedc3e | 1534 | |
04366a57 | 1535 | if(v2){ |
1536 | ||
1537 | if(!fClustersV2)fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
1538 | if(fLoader->TreeR()){ | |
1539 | if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
1540 | MakeBranchInTree(fLoader->TreeR(),branchname,&fClustersV2,buffsz,file); | |
1541 | ||
1542 | } | |
1543 | }else{ | |
1544 | if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
1545 | if (fLoader->TreeR()) { | |
aacedc3e | 1546 | if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint", |
1547 | 1000); | |
88cb7938 | 1548 | MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file); |
04366a57 | 1549 | } // end if |
1550 | } | |
2aea926d | 1551 | } |
1552 | //______________________________________________________________________ | |
1553 | void AliITS::SetTreeAddressR(TTree *treeR){ | |
1554 | // Set branch address for the Reconstructed points Trees. | |
4a5bebc2 | 1555 | // Inputs: |
1556 | // TTree *treeR Tree containing the RecPoints. | |
1557 | // Outputs: | |
1558 | // none. | |
1559 | // Return: | |
1560 | // none. | |
2aea926d | 1561 | char branchname[30]; |
3bd79107 | 1562 | |
2aea926d | 1563 | if(!treeR) return; |
aacedc3e | 1564 | if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); |
04366a57 | 1565 | TBranch *branch1; |
1566 | sprintf(branchname,"Clusters"); | |
1567 | branch1 = treeR->GetBranch(branchname); | |
1568 | if(branch1){ | |
1569 | if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
1570 | branch1->SetAddress(&fClustersV2); | |
1571 | } | |
1572 | else{ | |
1573 | TBranch *branch; | |
1574 | sprintf(branchname,"%sRecPoints",GetName()); | |
1575 | branch = treeR->GetBranch(branchname); | |
1576 | if (branch) { | |
ff0e455e | 1577 | branch->SetAddress(&fRecPoints); |
04366a57 | 1578 | }else { |
aacedc3e | 1579 | sprintf(branchname,"%sRecPointsF",GetName()); |
1580 | branch = treeR->GetBranch(branchname); | |
1581 | if (branch) { | |
04366a57 | 1582 | branch->SetAddress(&fRecPoints); |
aacedc3e | 1583 | } |
04366a57 | 1584 | } |
ff0e455e | 1585 | } |
2aea926d | 1586 | } |
1587 | //______________________________________________________________________ | |
1588 | void AliITS::AddRecPoint(const AliITSRecPoint &r){ | |
1589 | // Add a reconstructed space point to the list | |
4a5bebc2 | 1590 | // Inputs: |
1591 | // const AliITSRecPoint &r RecPoint class to be added to the tree | |
1592 | // of reconstructed points TreeR. | |
1593 | // Outputs: | |
1594 | // none. | |
1595 | // Return: | |
1596 | // none. | |
3bd79107 | 1597 | |
2aea926d | 1598 | TClonesArray &lrecp = *fRecPoints; |
1599 | new(lrecp[fNRecPoints++]) AliITSRecPoint(r); | |
3bd79107 | 1600 | } |
2aea926d | 1601 | //______________________________________________________________________ |
04366a57 | 1602 | void AliITS::AddClusterV2(const AliITSclusterV2 &r){ |
1603 | // Add a reconstructed space point to the list | |
1604 | // Inputs: | |
1605 | // const AliITSClusterV2 &r class to be added to the tree | |
1606 | // of reconstructed points TreeR. | |
1607 | // Outputs: | |
1608 | // none. | |
1609 | // Return: | |
1610 | // none. | |
1611 | ||
1612 | TClonesArray &lrecp = *fClustersV2; | |
1613 | new(lrecp[fNClustersV2++]) AliITSclusterV2(r); | |
1614 | } | |
1615 | //______________________________________________________________________ | |
e8189707 | 1616 | void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size, |
aacedc3e | 1617 | Option_t *opt0,Option_t *opt1, |
1618 | const char *flnm){ | |
3bd79107 | 1619 | // keep galice.root for signal and name differently the file for |
1620 | // background when add! otherwise the track info for signal will be lost ! | |
2aea926d | 1621 | // the condition below will disappear when the geom class will be |
4a5bebc2 | 1622 | // initialized for all versions - for the moment it is only for v5 ! |
1623 | // Inputs: | |
1624 | // Int_t evnt Event to be processed. | |
1625 | // Int_t bgrev Background Hit tree number. | |
1626 | // Int_t size Size used by InitModules. See InitModules. | |
1627 | // Option_t *opt0 Option passed to FillModules. See FillModules. | |
1628 | // Option_t *opt1 String indicating if merging hits or not. To | |
1629 | // merge hits set equal to "Add". Otherwise no | |
1630 | // background hits are considered. | |
1631 | // Test_t *flnm File name containing the background hits.. | |
1632 | // Outputs: | |
1633 | // none. | |
1634 | // Return: | |
1635 | // none. | |
1636 | ||
2aea926d | 1637 | if(!GetITSgeom()) return; |
8a92b3ef | 1638 | AliITSLoader *pITSloader = (AliITSLoader*)fLoader; |
2aea926d | 1639 | AliITSgeom *geom = GetITSgeom(); |
1640 | ||
1641 | const char *all = strstr(opt1,"All"); | |
1642 | const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"), | |
88cb7938 | 1643 | strstr(opt1,"SSD")}; |
2aea926d | 1644 | Int_t nmodules; |
1645 | InitModules(size,nmodules); | |
1646 | FillModules(evNumber,bgrev,nmodules,opt0,flnm); | |
1647 | ||
1648 | AliITSsimulation *sim = 0; | |
1649 | AliITSDetType *iDetType = 0; | |
1650 | AliITSmodule *mod = 0; | |
1651 | Int_t id,module; | |
e3b819ce | 1652 | |
1653 | //m.b. : this change is nothing but a nice way to make sure | |
1654 | //the CPU goes up ! | |
88cb7938 | 1655 | |
aacedc3e | 1656 | if(GetDebug()) cout<<"HitsToFastRecPoints: N mod = "<< |
1657 | geom->GetIndexMax()<<endl; | |
e80bf2b3 | 1658 | for(module=0;module<geom->GetIndexMax();module++){ |
88cb7938 | 1659 | id = geom->GetModuleType(module); |
2aea926d | 1660 | if (!all && !det[id]) continue; |
88cb7938 | 1661 | iDetType = DetType(id); |
1662 | sim = (AliITSsimulation*)iDetType->GetSimulationModel(); | |
aacedc3e | 1663 | if (!sim) { |
1664 | Error("HitsToFastPoints","The simulation class was not " | |
1665 | "instanciated for module %d type %x!",module, | |
1666 | geom->GetModuleTypeName(module)); | |
1667 | exit(1); | |
1668 | } // end if !sim | |
88cb7938 | 1669 | mod = (AliITSmodule *)fITSmodules->At(module); |
1670 | sim->CreateFastRecPoints(mod,module,gRandom); | |
1671 | cout<<module<<"\r";fflush(0); | |
8a92b3ef | 1672 | //gAlice->TreeR()->Fill(); |
aacedc3e | 1673 | TTree *lTR = pITSloader->TreeR(); |
93f82b23 | 1674 | TBranch *br=lTR->GetBranch("ITSRecPointsF"); |
88cb7938 | 1675 | br->Fill(); |
1676 | ResetRecPoints(); | |
2aea926d | 1677 | } // end for module |
4a5bebc2 | 1678 | |
2aea926d | 1679 | ClearModules(); |
88cb7938 | 1680 | fLoader->WriteRecPoints("OVERWRITE"); |
2aea926d | 1681 | } |
1682 | //______________________________________________________________________ | |
2aea926d | 1683 | void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){ |
88cb7938 | 1684 | // cluster finding and reconstruction of space points |
1685 | // the condition below will disappear when the geom class will be | |
1686 | // initialized for all versions - for the moment it is only for v5 ! | |
1687 | // 7 is the SDD beam test version | |
1688 | // Inputs: | |
1689 | // Int_t evNumber Event number to be processed. | |
1690 | // Int_t lastentry Offset for module when not all of the modules | |
1691 | // are processed. | |
1692 | // Option_t *opt String indicating which ITS sub-detectors should | |
1693 | // be processed. If ="All" then all of the ITS | |
1694 | // sub detectors are processed. | |
1695 | // Outputs: | |
1696 | // none. | |
1697 | // Return: | |
1698 | // none. | |
1699 | ||
1700 | if(!GetITSgeom()) return; | |
1701 | AliITSgeom *geom = GetITSgeom(); | |
2aea926d | 1702 | |
88cb7938 | 1703 | const char *all = strstr(opt,"All"); |
1704 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
1705 | strstr(opt,"SSD")}; | |
1706 | static Bool_t setRec=kTRUE; | |
1707 | if (setRec) SetDefaultClusterFinders(); | |
1708 | setRec=kFALSE; | |
1709 | ||
1710 | AliITSLoader *pITSloader = (AliITSLoader*)fLoader; | |
1711 | TTree *treeC=pITSloader->TreeC(); | |
1712 | AliITSClusterFinder *rec = 0; | |
1713 | AliITSDetType *iDetType = 0; | |
1714 | Int_t id,module,first=0; | |
1715 | for(module=0;module<geom->GetIndexMax();module++){ | |
ac74f489 | 1716 | id = geom->GetModuleType(module); |
1717 | if (!all && !det[id]) continue; | |
1718 | if(det[id]) first = geom->GetStartDet(id); | |
1719 | iDetType = DetType(id); | |
1720 | rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel(); | |
1721 | TClonesArray *itsDigits = this->DigitsAddress(id); | |
1722 | if (!rec) { | |
aacedc3e | 1723 | Error("DigitsToRecPoints", |
1724 | "The reconstruction class was not instanciated! event=%d", | |
1725 | evNumber); | |
1726 | exit(1); | |
ac74f489 | 1727 | } // end if !rec |
1728 | this->ResetDigits(); | |
93f82b23 | 1729 | TTree *lTD = pITSloader->TreeD(); |
ac74f489 | 1730 | if (all) { |
aacedc3e | 1731 | lTD->GetEvent(lastentry+module); |
ac74f489 | 1732 | }else { |
aacedc3e | 1733 | lTD->GetEvent(lastentry+(module-first)); |
ac74f489 | 1734 | } |
1735 | Int_t ndigits = itsDigits->GetEntriesFast(); | |
aacedc3e | 1736 | if(ndigits>0){ |
1737 | rec->SetDigits(DigitsAddress(id)); | |
1738 | rec->SetClusters(ClustersAddress(id)); | |
1739 | rec->FindRawClusters(module); | |
1740 | } // end if | |
04366a57 | 1741 | pITSloader->TreeR()->Fill(); |
ac74f489 | 1742 | ResetRecPoints(); |
04366a57 | 1743 | ResetClustersV2(); |
ac74f489 | 1744 | treeC->Fill(); |
1745 | ResetClusters(); | |
88cb7938 | 1746 | } // end for module |
828e06c7 | 1747 | |
88cb7938 | 1748 | pITSloader->WriteRecPoints("OVERWRITE"); |
1749 | pITSloader->WriteRawClusters("OVERWRITE"); | |
fe4da5cc | 1750 | } |
04366a57 | 1751 | //______________________________________________________________________ |
1752 | void AliITS::DigitsToRecPoints(AliRawReader* rawReader){ | |
1753 | // cluster finding and reconstruction of space points | |
1754 | // the condition below will disappear when the geom class will be | |
1755 | // initialized for all versions - for the moment it is only for v5 ! | |
1756 | // 7 is the SDD beam test version | |
1757 | // Inputs: | |
1758 | // Int_t evNumber Event number to be processed. | |
1759 | // Int_t lastentry Offset for module when not all of the modules | |
1760 | // are processed. | |
1761 | // Option_t *opt String indicating which ITS sub-detectors should | |
1762 | // be processed. If ="All" then all of the ITS | |
1763 | // sub detectors are processed. | |
1764 | // Outputs: | |
1765 | // none. | |
1766 | // Return: | |
1767 | // none. | |
1768 | if(!GetITSgeom()) return; | |
1769 | AliITSgeom *geom = GetITSgeom(); | |
1770 | ||
1771 | ||
1772 | SetDefaultClusterFindersV2(); | |
1773 | ||
1774 | AliITSLoader *pITSloader = (AliITSLoader*)fLoader; | |
1775 | AliITSClusterFinderV2 *rec = 0; | |
1776 | AliITSDetType *iDetType = 0; | |
1777 | Int_t id=0; | |
1778 | ||
1779 | if(!pITSloader->TreeR()) pITSloader->MakeTree("R"); | |
1780 | TTree* cTree = pITSloader->TreeR(); | |
1781 | TClonesArray *array=new TClonesArray("AliITSclusterV2",1000); | |
1782 | cTree->Branch("Clusters",&array); | |
1783 | delete array; | |
1784 | ||
1785 | TClonesArray** clusters = new TClonesArray*[geom->GetIndexMax()]; | |
1786 | for (Int_t iModule = 0; iModule < geom->GetIndexMax(); iModule++) { | |
1787 | clusters[iModule] = NULL; | |
1788 | } | |
1789 | for(id=0;id<3;id++){ | |
1790 | iDetType = DetType(id); | |
1791 | rec = (AliITSClusterFinderV2*)iDetType->GetReconstructionModel(); | |
1792 | if (!rec) { | |
1793 | Error("DigitsToRecPoints", | |
1794 | "The reconstruction class was not instanciated"); | |
1795 | exit(1); | |
1796 | } | |
1797 | rec->RawdataToClusters(rawReader,clusters); | |
1798 | } | |
1799 | Int_t nClusters =0; | |
1800 | for(Int_t iModule=0;iModule<geom->GetIndexMax();iModule++){ | |
1801 | array = clusters[iModule]; | |
1802 | if(!array){ | |
1803 | Error("DigitsToRecPoints","data for module %d missing!",iModule); | |
1804 | array = new TClonesArray("AliITSclusterV2"); | |
1805 | } | |
1806 | cTree->SetBranchAddress("Clusters",&array); | |
1807 | cTree->Fill(); | |
1808 | nClusters+=array->GetEntriesFast(); | |
1809 | delete array; | |
1810 | } | |
1811 | pITSloader->WriteRecPoints("OVERWRITE"); | |
1812 | ||
1813 | delete[] clusters; | |
1814 | Info("DigitsToRecPoints", "total number of found clustersV2 in ITS: %d\n", | |
1815 | nClusters); | |
1816 | ||
1817 | } | |
1818 | ||
2aea926d | 1819 | //______________________________________________________________________ |
aacedc3e | 1820 | AliLoader* AliITS::MakeLoader(const char* topfoldername){ |
1821 | //builds ITSgetter (AliLoader type) | |
1822 | //if detector wants to use castomized getter, it must overload this method | |
1823 | ||
1824 | Info("MakeLoader","Creating AliITSLoader. Top folder is %s.", | |
1825 | topfoldername); | |
1826 | fLoader = new AliITSLoader(GetName(),topfoldername); | |
1827 | return fLoader; | |
2aea926d | 1828 | } |