]>
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 | |
143d1056 | 68 | #include <stdlib.h> |
caf37aec | 69 | #include <TClonesArray.h> |
9c74c52b | 70 | #include <TFile.h> |
7d62fb64 | 71 | #include <TParticle.h> |
d5da1ecf | 72 | #include <TString.h> |
88cb7938 | 73 | #include <TTree.h> |
88cb7938 | 74 | #include <TVirtualMC.h> |
7d62fb64 | 75 | #include "AliDetector.h" |
3bd79107 | 76 | #include "AliITS.h" |
7d62fb64 | 77 | #include "AliITSDetTypeSim.h" |
f77f13c8 | 78 | #include "AliITSDDLRawData.h" |
88cb7938 | 79 | #include "AliITSLoader.h" |
88cb7938 | 80 | #include "AliITShit.h" |
81 | #include "AliITSmodule.h" | |
7d62fb64 | 82 | #include "AliITSpListItem.h" |
83 | #include "AliITSsimulation.h" | |
84 | #include "AliITSsimulationFastPoints.h" | |
5d12ce38 | 85 | #include "AliMC.h" |
7d62fb64 | 86 | #include "AliITSDigitizer.h" |
87 | #include "AliITSRecPoint.h" | |
0b5bf101 | 88 | #include "AliITSsegmentationSPD.h" |
89 | #include "AliITSsegmentationSDD.h" | |
dee45d79 | 90 | #include "AliITSsimulationSDD.h" |
91 | #include "AliITSCalibrationSDD.h" | |
8b3448d3 | 92 | #include "AliITSCalibrationSSD.h" |
0b5bf101 | 93 | #include "AliITSsegmentationSSD.h" |
94 | #include "AliITSRawStreamSPD.h" | |
95 | #include "AliITSRawStreamSSD.h" | |
96 | #include "AliITSRawStreamSDD.h" | |
0b5bf101 | 97 | #include "AliRawReader.h" |
f77f13c8 | 98 | #include "AliRun.h" |
7d62fb64 | 99 | #include "AliLog.h" |
ef7ff1f9 | 100 | #include "AliITSInitGeometry.h" |
ad7f2bfa | 101 | #include "AliITSFOSignalsSPD.h" |
828e06c7 | 102 | |
3bd79107 | 103 | ClassImp(AliITS) |
3bd79107 | 104 | |
2aea926d | 105 | //______________________________________________________________________ |
ed9289c8 | 106 | AliITS::AliITS() : AliDetector(), |
107 | fDetTypeSim(0), | |
108 | fEuclidOut(0), | |
109 | fOpt("All"), | |
110 | fIdN(0), | |
111 | fIdSens(0), | |
112 | fIdName(0), | |
012f0f4c | 113 | fITSmodules(0), |
c8af5b8f | 114 | fTiming(kFALSE), |
115 | fSimuParam(0) | |
ed9289c8 | 116 | { |
7d62fb64 | 117 | // Default initializer for ITS |
118 | // The default constructor of the AliITS class. In addition to | |
119 | // creating the AliITS class it zeros the variables fIshunt (a member | |
120 | // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers | |
121 | // fIdSens, and fIdName. The AliDetector default constructor | |
122 | // is also called. | |
123 | ||
aa044888 | 124 | // SetDetectors(); // default to fOpt="All". This variable not written out. |
e939a978 | 125 | //PH SetMarkerColor(kRed); |
fe4da5cc | 126 | } |
2aea926d | 127 | //______________________________________________________________________ |
c8af5b8f | 128 | AliITS::AliITS(const Char_t *title): |
129 | AliDetector("ITS",title), | |
130 | fDetTypeSim(0), | |
131 | fEuclidOut(0), | |
132 | fOpt("All"), | |
133 | fIdN(0), | |
134 | fIdSens(0), | |
135 | fIdName(0), | |
136 | fITSmodules(0), | |
137 | fTiming(kFALSE), | |
138 | fSimuParam(0) | |
012f0f4c | 139 | { |
140 | // The standard Constructor for the ITS class. | |
141 | // It also zeros the variables | |
142 | // fIshunt (a member of AliDetector class), fEuclidOut, and zeros | |
143 | // the pointers fIdSens and fIdName. To help in displaying hits via the | |
144 | // ROOT macro display.C AliITS also sets the marker color to red. The | |
145 | // variables passes with this constructor, const char *name and *title, | |
146 | // are used by the constructor of AliDetector class. See AliDetector | |
147 | // class for a description of these parameters and its constructor | |
148 | // functions. | |
149 | // Inputs: | |
150 | // Char_t *title Simulation title for the ITS | |
151 | // Outputs: | |
152 | // none. | |
153 | // Return: | |
154 | // none. | |
155 | ||
156 | fHits = new TClonesArray("AliITShit",1560); // from AliDetector | |
157 | if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits); | |
158 | //fNhits=0; //done in AliDetector(name,title) | |
159 | SetDetectors(); // default to fOpt="All". This variable not written out. | |
160 | fDetTypeSim = new AliITSDetTypeSim(); | |
161 | //PH SetMarkerColor(kRed); | |
162 | if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName()); | |
163 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); | |
164 | } | |
165 | //______________________________________________________________________ | |
c8af5b8f | 166 | AliITS::AliITS(const char *name, const char *title): |
167 | AliDetector(name,title), | |
168 | fDetTypeSim(0), | |
169 | fEuclidOut(0), | |
170 | fOpt("All"), | |
171 | fIdN(0), | |
172 | fIdSens(0), | |
173 | fIdName(0), | |
174 | fITSmodules(0), | |
175 | fTiming(kFALSE), | |
176 | fSimuParam(0) | |
ed9289c8 | 177 | { |
7d62fb64 | 178 | // The standard Constructor for the ITS class. |
179 | // It also zeros the variables | |
180 | // fIshunt (a member of AliDetector class), fEuclidOut, and zeros | |
181 | // the pointers fIdSens and fIdName. To help in displaying hits via the | |
182 | // ROOT macro display.C AliITS also sets the marker color to red. The | |
183 | // variables passes with this constructor, const char *name and *title, | |
184 | // are used by the constructor of AliDetector class. See AliDetector | |
185 | // class for a description of these parameters and its constructor | |
186 | // functions. | |
187 | ||
7d62fb64 | 188 | fHits = new TClonesArray("AliITShit",1560); |
189 | if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits); | |
ed9289c8 | 190 | //fNhits=0; //done in AliDetector(name,title) |
7d62fb64 | 191 | |
7d62fb64 | 192 | SetDetectors(); // default to fOpt="All". This variable not written out. |
ed9289c8 | 193 | |
7d62fb64 | 194 | fDetTypeSim = new AliITSDetTypeSim(); |
e939a978 | 195 | //PH SetMarkerColor(kRed); |
023ae34b | 196 | if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName()); |
197 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); | |
fe4da5cc | 198 | |
3bd79107 | 199 | } |
2aea926d | 200 | //______________________________________________________________________ |
58005f18 | 201 | AliITS::~AliITS(){ |
4a5bebc2 | 202 | // Default destructor for ITS. |
2aea926d | 203 | // The default destructor of the AliITS class. In addition to deleting |
7d62fb64 | 204 | // the AliITS class it deletes the memory pointed to by |
205 | // fIdSens, fIdName, fDetTypeSim and it's contents. | |
4a5bebc2 | 206 | // Inputs: |
207 | // none. | |
208 | // Outputs: | |
209 | // none. | |
210 | // Return: | |
211 | // none. | |
023ae34b | 212 | |
88cb7938 | 213 | if (fHits) { |
214 | fHits->Delete(); | |
215 | delete fHits; | |
216 | fHits=0; | |
217 | } | |
88cb7938 | 218 | if(fITSmodules) { |
219 | this->ClearModules(); | |
220 | delete fITSmodules; | |
279a35d7 | 221 | fITSmodules = 0; |
88cb7938 | 222 | }// end if fITSmodules!=0 |
223 | ||
7d62fb64 | 224 | delete[] fIdName; // Array of TStrings |
225 | delete[] fIdSens; | |
226 | ||
227 | if (fDetTypeSim){ | |
228 | delete fDetTypeSim; | |
229 | fDetTypeSim = 0; | |
c8af5b8f | 230 | } |
231 | if(fSimuParam){ | |
232 | delete fSimuParam; | |
233 | fSimuParam=0; | |
234 | } | |
3bd79107 | 235 | } |
2aea926d | 236 | //______________________________________________________________________ |
aacedc3e | 237 | AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{ |
238 | // Creates the AliITSDigitizer in a standard way for use via AliModule. | |
239 | // This function can not be included in the .h file because of problems | |
240 | // with the order of inclusion (recursive). | |
4a5bebc2 | 241 | // Inputs: |
aacedc3e | 242 | // AliRunDigitizer *manager The Manger class for Digitization |
243 | // Output: | |
244 | // none. | |
4a5bebc2 | 245 | // Return: |
aacedc3e | 246 | // A new AliITSRunDigitizer (cast as a AliDigitizer). |
3bd79107 | 247 | |
aacedc3e | 248 | return new AliITSDigitizer(manager); |
3bd79107 | 249 | } |
2aea926d | 250 | //______________________________________________________________________ |
251 | void AliITS::Init(){ | |
4a5bebc2 | 252 | // Initializer ITS after it has been built |
2aea926d | 253 | // This routine initializes the AliITS class. It is intended to be |
254 | // called from the Init function in AliITSv?. Besides displaying a banner | |
255 | // indicating that it has been called it initializes the array fIdSens | |
256 | // and sets the default segmentation, response, digit and raw cluster | |
257 | // classes therefore it should be called after a call to CreateGeometry. | |
4a5bebc2 | 258 | // Inputs: |
259 | // none. | |
260 | // Outputs: | |
261 | // none. | |
262 | // Return: | |
263 | // none. | |
3bd79107 | 264 | Int_t i; |
2aea926d | 265 | // Array of TStrings |
0e73d04c | 266 | if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]); |
7d62fb64 | 267 | |
7d62fb64 | 268 | } |
2aea926d | 269 | //______________________________________________________________________ |
270 | void AliITS::SetDefaults(){ | |
4a5bebc2 | 271 | // sets the default segmentation, response, digit and raw cluster classes. |
272 | // Inputs: | |
273 | // none. | |
274 | // Outputs: | |
275 | // none. | |
276 | // Return: | |
277 | // none. | |
023ae34b | 278 | AliInfoClass("AliITS::Setting Defaults"); |
7d62fb64 | 279 | if(!fDetTypeSim) { |
280 | Error("SetDefaults()","fDetTypeSim is 0!"); | |
281 | return; | |
282 | } | |
283 | ||
284 | fDetTypeSim->SetDefaults(); | |
c8af5b8f | 285 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 286 | |
3bd79107 | 287 | } |
2aea926d | 288 | //______________________________________________________________________ |
289 | void AliITS::SetDefaultSimulation(){ | |
4a5bebc2 | 290 | // sets the default simulation. |
291 | // Inputs: | |
292 | // none. | |
293 | // Outputs: | |
294 | // none. | |
295 | // Return: | |
296 | // none. | |
7d62fb64 | 297 | if(!fDetTypeSim) { |
298 | Error("SetDefaultSimulation()","fDetTypeSim is 0!"); | |
299 | return; | |
300 | } | |
301 | ||
302 | fDetTypeSim->SetDefaultSimulation(); | |
c8af5b8f | 303 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
04366a57 | 304 | |
04366a57 | 305 | } |
306 | ||
307 | ||
2aea926d | 308 | //______________________________________________________________________ |
88cb7938 | 309 | void AliITS::MakeBranch(Option_t* option){ |
2aea926d | 310 | // Creates Tree branches for the ITS. |
4a5bebc2 | 311 | // Inputs: |
312 | // Option_t *option String of Tree types S,D, and/or R. | |
313 | // const char *file String of the file name where these branches | |
314 | // are to be stored. If blank then these branches | |
315 | // are written to the same tree as the Hits were | |
316 | // read from. | |
317 | // Outputs: | |
318 | // none. | |
319 | // Return: | |
320 | // none. | |
7d62fb64 | 321 | if(!fDetTypeSim) { |
322 | Error("MakeBranch","fDetTypeSim is 0!"); | |
323 | return; | |
324 | } | |
04366a57 | 325 | |
7d62fb64 | 326 | Bool_t cH = (strstr(option,"H")!=0); |
327 | Bool_t cS = (strstr(option,"S")!=0); | |
328 | Bool_t cD = (strstr(option,"D")!=0); | |
329 | ||
330 | if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560); | |
331 | AliDetector::MakeBranch(option); | |
332 | ||
333 | if(cS) MakeBranchS(0); | |
334 | if(cD) MakeBranchD(0); | |
335 | ||
336 | ||
337 | } | |
338 | //___________________________________________________________________ | |
339 | void AliITS::MakeBranchS(const char* fl){ | |
340 | ||
341 | // Creates Tree Branch for the ITS summable digits. | |
342 | // Inputs: | |
343 | // cont char *fl File name where SDigits branch is to be written | |
344 | // to. If blank it write the SDigits to the same | |
345 | // file in which the Hits were found. | |
346 | ||
347 | ||
348 | if(!fDetTypeSim){ | |
349 | Error("MakeBranchS","fDetTypeSim is 0!"); | |
350 | } | |
351 | Int_t buffersize = 4000; | |
352 | char branchname[30]; | |
353 | ||
354 | // only one branch for SDigits. | |
355 | sprintf(branchname,"%s",GetName()); | |
356 | ||
357 | if(fLoader->TreeS()){ | |
7d62fb64 | 358 | TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits(); |
359 | MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl); | |
360 | } | |
361 | } | |
362 | //______________________________________________________________________ | |
363 | void AliITS::MakeBranchD(const char* file){ | |
364 | ||
365 | //Make branch for digits | |
366 | if(!fDetTypeSim) { | |
367 | Warning("MakeBranchD","fDetTypeSim is 0!"); | |
368 | return; | |
369 | } | |
023ae34b | 370 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 371 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 372 | MakeBranchInTreeD(fLoader->TreeD(),file); |
373 | } | |
374 | ||
375 | //___________________________________________________________________ | |
376 | void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){ | |
377 | // Creates Tree branches for the ITS. | |
378 | ||
379 | if(!fDetTypeSim){ | |
380 | Error("MakeBranchS","fDetTypeSim is 0!"); | |
381 | } | |
023ae34b | 382 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 383 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 384 | |
385 | const Char_t *det[3] = {"SPD","SDD","SSD"}; | |
a6e0ebfe | 386 | const Char_t* digclass; |
7d62fb64 | 387 | Int_t buffersize = 4000; |
388 | Char_t branchname[30]; | |
389 | ||
390 | if(!fDetTypeSim->GetDigits()){ | |
391 | fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES)); | |
392 | } | |
393 | for(Int_t i=0;i<fgkNTYPES;i++){ | |
394 | digclass = fDetTypeSim->GetDigitClassName(i); | |
395 | TString classn = digclass; | |
396 | if(!((fDetTypeSim->GetDigits())->At(i))){ | |
397 | (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i); | |
398 | } | |
399 | else ResetDigits(i); | |
400 | if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]); | |
401 | else sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
402 | TObjArray* dig = DigitsAddress(i); | |
403 | if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file); | |
404 | } | |
2aea926d | 405 | |
fe4da5cc | 406 | } |
2aea926d | 407 | //______________________________________________________________________ |
408 | void AliITS::SetTreeAddress(){ | |
409 | // Set branch address for the Trees. | |
4a5bebc2 | 410 | // Inputs: |
411 | // none. | |
412 | // Outputs: | |
413 | // none. | |
414 | // Return: | |
415 | // none. | |
023ae34b | 416 | |
7d62fb64 | 417 | if(!fDetTypeSim) { |
418 | Error("SetTreeAddress","fDetTypeSim is 0!"); | |
419 | return; | |
420 | } | |
421 | ||
023ae34b | 422 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 423 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 424 | |
425 | TTree *treeS = fLoader->TreeS(); | |
426 | TTree *treeD = fLoader->TreeD(); | |
427 | if (fLoader->TreeH() && (fHits == 0x0)) { | |
428 | fHits = new TClonesArray("AliITShit", 1560); | |
429 | } | |
430 | AliDetector::SetTreeAddress(); | |
431 | ||
432 | fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName()); | |
433 | fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName()); | |
fe4da5cc | 434 | } |
2aea926d | 435 | //______________________________________________________________________ |
2aea926d | 436 | void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){ |
437 | // Add an ITS hit | |
438 | // The function to add information to the AliITShit class. See the | |
439 | // AliITShit class for a full description. This function allocates the | |
440 | // necessary new space for the hit information and passes the variable | |
441 | // track, and the pointers *vol and *hits to the AliITShit constructor | |
442 | // function. | |
4a5bebc2 | 443 | // Inputs: |
444 | // Int_t track Track number which produced this hit. | |
445 | // Int_t *vol Array of Integer Hit information. See AliITShit.h | |
446 | // Float_t *hits Array of Floating Hit information. see AliITShit.h | |
447 | // Outputs: | |
448 | // none. | |
449 | // Return: | |
450 | // none. | |
7d62fb64 | 451 | TClonesArray &lhits = *fHits; |
452 | new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits); | |
3bd79107 | 453 | } |
9c74c52b | 454 | |
2aea926d | 455 | //______________________________________________________________________ |
456 | void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules, | |
8e8eae84 | 457 | Option_t *option, const char *filename){ |
7d62fb64 | 458 | // fill the modules with the sorted by module hits; add hits from |
459 | // background if option=Add. | |
460 | ||
461 | static TTree *trH1; //Tree with background hits | |
462 | static Bool_t first=kTRUE; | |
463 | static TFile *file; | |
464 | const char *addBgr = strstr(option,"Add"); | |
465 | ||
466 | evnt = nmodules; // Dummy use of variables to remove warnings | |
467 | if (addBgr ) { | |
468 | if(first) { | |
469 | file=new TFile(filename); | |
470 | } // end if first | |
471 | first=kFALSE; | |
472 | file->cd(); | |
473 | file->ls(); | |
474 | // Get Hits Tree header from file | |
475 | if(trH1) delete trH1; | |
476 | trH1=0; | |
477 | ||
478 | char treeName[20]; | |
479 | sprintf(treeName,"TreeH%d",bgrev); | |
480 | trH1 = (TTree*)gDirectory->Get(treeName); | |
481 | if (!trH1) { | |
482 | Error("FillModules","cannot find Hits Tree for event:%d",bgrev); | |
483 | } // end if !trH1 | |
484 | // Set branch addresses | |
485 | } // end if addBgr | |
486 | ||
487 | FillModules(fLoader->TreeH(),0); // fill from this file's tree. | |
3bd79107 | 488 | |
7d62fb64 | 489 | if (addBgr ) { |
490 | FillModules(trH1,10000000); // Default mask 10M. | |
491 | TTree *fAli=fLoader->GetRunLoader()->TreeK(); | |
492 | TFile *fileAli=0; | |
493 | if (fAli) fileAli =fAli->GetCurrentFile(); | |
494 | fileAli->cd(); | |
495 | } // end if add | |
496 | ||
497 | ||
3bd79107 | 498 | } |
2aea926d | 499 | //______________________________________________________________________ |
b4012daf | 500 | void AliITS::FillModules(TTree *treeH, Int_t mask) { |
501 | // fill the modules with the sorted by module hits; | |
502 | // can be called many times to do a merging | |
503 | // Inputs: | |
504 | // TTree *treeH The tree containing the hits to be copied into | |
505 | // the modules. | |
506 | // Int_t mask The track number mask to indecate which file | |
507 | // this hits came from. | |
508 | // Outputs: | |
509 | // none. | |
510 | // Return: | |
511 | // none. | |
512 | ||
88cb7938 | 513 | if (treeH == 0x0) |
514 | { | |
515 | Error("FillModules","Tree is NULL"); | |
516 | } | |
b4012daf | 517 | Int_t lay,lad,det,index; |
518 | AliITShit *itsHit=0; | |
519 | AliITSmodule *mod=0; | |
520 | char branchname[20]; | |
521 | sprintf(branchname,"%s",GetName()); | |
522 | TBranch *branch = treeH->GetBranch(branchname); | |
523 | if (!branch) { | |
88cb7938 | 524 | Error("FillModules","%s branch in TreeH not found",branchname); |
525 | return; | |
b4012daf | 526 | } // end if !branch |
527 | branch->SetAddress(&fHits); | |
528 | Int_t nTracks =(Int_t) treeH->GetEntries(); | |
529 | Int_t iPrimTrack,h; | |
530 | for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){ | |
88cb7938 | 531 | ResetHits(); |
532 | Int_t nBytes = treeH->GetEvent(iPrimTrack); | |
533 | if (nBytes <= 0) continue; | |
534 | Int_t nHits = fHits->GetEntriesFast(); | |
535 | for(h=0; h<nHits; h++){ | |
536 | itsHit = (AliITShit *)fHits->UncheckedAt(h); | |
537 | itsHit->GetDetectorID(lay,lad,det); | |
7d62fb64 | 538 | if (GetITSgeom()) { |
539 | index = GetITSgeom()->GetModuleIndex(lay,lad,det); | |
88cb7938 | 540 | } else { |
541 | index=det-1; // This should not be used. | |
542 | } // end if [You must have fITSgeom for this to work!] | |
543 | mod = GetModule(index); | |
544 | itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask. | |
545 | mod->AddHit(itsHit,iPrimTrack,h); | |
546 | } // end loop over hits | |
b4012daf | 547 | } // end loop over tracks |
548 | } | |
7d62fb64 | 549 | |
b4012daf | 550 | //______________________________________________________________________ |
6f5308d9 | 551 | Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){ |
7d62fb64 | 552 | // Initialize the modules array. |
4a5bebc2 | 553 | // Inputs: |
7d62fb64 | 554 | // Int_t size Size of array of the number of modules to be |
555 | // created. If size <=0 then the number of modules | |
556 | // is gotten from AliITSgeom class kept in fITSgeom. | |
4a5bebc2 | 557 | // Outputs: |
7d62fb64 | 558 | // Int_t &nmodules The number of modules existing. |
4a5bebc2 | 559 | // Return: |
560 | // none. | |
2ab0c725 | 561 | |
7d62fb64 | 562 | if(fITSmodules){ |
563 | fITSmodules->Delete(); | |
564 | delete fITSmodules; | |
565 | } // end fir fITSmoudles | |
88cb7938 | 566 | |
7d62fb64 | 567 | if(!fDetTypeSim) { |
568 | Error("InitModules","fDetTypeSim is null!"); | |
6f5308d9 | 569 | return kFALSE; |
7d62fb64 | 570 | } |
c8af5b8f | 571 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
828e06c7 | 572 | |
7d62fb64 | 573 | Int_t nl,indexMAX,index; |
574 | ||
575 | if(size<=0){ // default to using data stored in AliITSgeom | |
576 | if(fDetTypeSim->GetITSgeom()==0) { | |
577 | Error("InitModules","fITSgeom not defined"); | |
6f5308d9 | 578 | return kFALSE; |
7d62fb64 | 579 | } // end if fITSgeom==0 |
580 | nl = fDetTypeSim->GetITSgeom()->GetNlayers(); | |
581 | indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax(); | |
582 | nmodules = indexMAX; | |
583 | fITSmodules = new TObjArray(indexMAX); | |
584 | for(index=0;index<indexMAX;index++){ | |
585 | fITSmodules->AddAt( new AliITSmodule(index),index); | |
586 | } // end for index | |
587 | }else{ | |
588 | fITSmodules = new TObjArray(size); | |
589 | for(index=0;index<size;index++) { | |
590 | fITSmodules->AddAt( new AliITSmodule(index),index); | |
591 | } // end for index | |
592 | ||
593 | nmodules = size; | |
594 | } // end i size<=0 | |
6f5308d9 | 595 | return kTRUE; |
2aea926d | 596 | } |
597 | //______________________________________________________________________ | |
598 | void AliITS::Hits2SDigits(){ | |
599 | // Standard Hits to summable Digits function. | |
4a5bebc2 | 600 | // Inputs: |
601 | // none. | |
602 | // Outputs: | |
603 | // none. | |
7d62fb64 | 604 | |
2aea926d | 605 | |
7d62fb64 | 606 | if(!fDetTypeSim) { |
607 | Error("Hits2SDigits","fDetTypeSim is null!"); | |
ad7f2bfa | 608 | return; |
7d62fb64 | 609 | } |
610 | ||
611 | SetDefaults(); | |
612 | fLoader->LoadHits("read"); | |
613 | fLoader->LoadSDigits("recreate"); | |
614 | AliRunLoader* rl = fLoader->GetRunLoader(); | |
023ae34b | 615 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 616 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
617 | ||
7d62fb64 | 618 | for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { |
aacedc3e | 619 | // Do the Hits to Digits operation. Use Standard input values. |
620 | // Event number from file, no background hit merging , use size from | |
621 | // AliITSgeom class, option="All", input from this file only. | |
7d62fb64 | 622 | rl->GetEvent(iEvent); |
623 | if (!fLoader->TreeS()) fLoader->MakeTree("S"); | |
624 | MakeBranch("S"); | |
625 | SetTreeAddress(); | |
626 | HitsToPreDigits(iEvent,0,-1," ",fOpt," "); | |
627 | } // end for iEvent | |
e0fc0305 | 628 | |
7d62fb64 | 629 | fLoader->UnloadHits(); |
630 | fLoader->UnloadSDigits(); | |
631 | ||
2aea926d | 632 | } |
633 | //______________________________________________________________________ | |
634 | void AliITS::Hits2Digits(){ | |
2aea926d | 635 | |
7d62fb64 | 636 | //Conversion from hits to digits |
637 | if(!fDetTypeSim) { | |
638 | Error("Hits2SDigits","fDetTypeSim is 0!"); | |
639 | return; | |
640 | } | |
641 | ||
023ae34b | 642 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 643 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 644 | SetDefaults(); |
645 | ||
646 | fLoader->LoadHits("read"); | |
647 | fLoader->LoadDigits("recreate"); | |
648 | AliRunLoader* rl = fLoader->GetRunLoader(); | |
649 | for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { | |
650 | rl->GetEvent(iEvent); | |
651 | if (!fLoader->TreeD()) fLoader->MakeTree("D"); | |
652 | MakeBranch("D"); | |
653 | SetTreeAddress(); | |
654 | HitsToDigits(iEvent,0,-1," ",fOpt," "); | |
655 | } | |
656 | ||
657 | fLoader->UnloadHits(); | |
658 | fLoader->UnloadDigits(); | |
659 | ||
2aea926d | 660 | } |
7d62fb64 | 661 | |
2aea926d | 662 | //______________________________________________________________________ |
7d62fb64 | 663 | void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, |
664 | Option_t *option,Option_t *opt, | |
665 | const char *filename){ | |
4a5bebc2 | 666 | // Keep galice.root for signal and name differently the file for |
2aea926d | 667 | // background when add! otherwise the track info for signal will be lost ! |
668 | // the condition below will disappear when the geom class will be | |
4a5bebc2 | 669 | // initialized for all versions - for the moment it is only for v5 ! |
670 | // 7 is the SDD beam test version. | |
671 | // Inputs: | |
672 | // Int_t evnt Event to be processed. | |
673 | // Int_t bgrev Background Hit tree number. | |
674 | // Int_t nmodules Not used. | |
675 | // Option_t *option String indicating if merging hits or not. To | |
676 | // merge hits set equal to "Add". Otherwise no | |
677 | // background hits are considered. | |
678 | // Test_t *filename File name containing the background hits.. | |
679 | // Outputs: | |
680 | // none. | |
681 | // Return: | |
682 | // none. | |
2aea926d | 683 | |
7d62fb64 | 684 | if(!fDetTypeSim) { |
685 | Error("HitsToDigits","fDetTypeSim is null!"); | |
686 | return; | |
687 | } | |
023ae34b | 688 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 689 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 690 | if(!GetITSgeom()) return; // need transformations to do digitization. |
691 | AliITSgeom *geom = GetITSgeom(); | |
692 | ||
693 | const char *all = strstr(opt,"All"); | |
694 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
695 | strstr(opt,"SSD")}; | |
696 | static Bool_t setDef=kTRUE; | |
697 | if (setDef) SetDefaultSimulation(); | |
698 | setDef=kFALSE; | |
699 | ||
700 | Int_t nmodules; | |
701 | InitModules(size,nmodules); | |
702 | FillModules(evNumber,bgrev,nmodules,option,filename); | |
ad7f2bfa | 703 | |
704 | // Reset Fast-OR signals for this event | |
705 | fDetTypeSim->ResetFOSignals(); | |
7d62fb64 | 706 | |
707 | AliITSsimulation *sim = 0; | |
708 | AliITSmodule *mod = 0; | |
709 | Int_t id; | |
710 | for(Int_t module=0;module<geom->GetIndexMax();module++){ | |
711 | id = geom->GetModuleType(module); | |
712 | if (!all && !det[id]) continue; | |
713 | sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id); | |
714 | if (!sim) { | |
715 | Error("HitsToDigits","The simulation class was not " | |
716 | "instanciated for module %d type %s!",module, | |
717 | geom->GetModuleTypeName(module)); | |
718 | exit(1); | |
719 | } // end if !sim | |
720 | mod = (AliITSmodule *)fITSmodules->At(module); | |
721 | sim->DigitiseModule(mod,module,evNumber); | |
722 | // fills all branches - wasted disk space | |
723 | fLoader->TreeD()->Fill(); | |
724 | ResetDigits(); | |
725 | } // end for module | |
726 | ||
727 | ClearModules(); | |
a0d76912 | 728 | |
ad7f2bfa | 729 | // Add random noise to FO signals |
730 | if (all || det[0]) { // SPD present | |
731 | fDetTypeSim->ProcessNoiseForFastOr(); | |
732 | } | |
733 | ||
734 | // Add Fast-OR signals to event (only one object per event) | |
735 | if (all || det[0]) { // SPD present | |
736 | fDetTypeSim->WriteFOSignals(); | |
737 | } | |
738 | ||
739 | ||
7d62fb64 | 740 | fLoader->TreeD()->GetEntries(); |
741 | fLoader->TreeD()->AutoSave(); | |
742 | // reset tree | |
743 | fLoader->TreeD()->Reset(); | |
2aea926d | 744 | } |
7d62fb64 | 745 | //_____________________________________________________________________ |
746 | void AliITS::Hits2PreDigits(){ | |
747 | // Turn hits into SDigits | |
748 | ||
749 | if(!fDetTypeSim) { | |
750 | Error("Hits2SDigits","fDetTypeSim is 0!"); | |
751 | return; | |
752 | } | |
753 | ||
023ae34b | 754 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 755 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 756 | SetDefaults(); |
757 | ||
758 | HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(), | |
759 | 0,-1," ",fOpt," "); | |
760 | } | |
761 | ||
2aea926d | 762 | //______________________________________________________________________ |
7d62fb64 | 763 | void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size, |
764 | Option_t *option,Option_t *opt, | |
765 | const char *filename){ | |
4a5bebc2 | 766 | // Keep galice.root for signal and name differently the file for |
2aea926d | 767 | // background when add! otherwise the track info for signal will be lost ! |
768 | // the condition below will disappear when the geom class will be | |
4a5bebc2 | 769 | // initialized for all versions - for the moment it is only for v5 ! |
770 | // 7 is the SDD beam test version. | |
771 | // Inputs: | |
772 | // Int_t evnt Event to be processed. | |
773 | // Int_t bgrev Background Hit tree number. | |
774 | // Int_t nmodules Not used. | |
775 | // Option_t *option String indicating if merging hits or not. To | |
776 | // merge hits set equal to "Add". Otherwise no | |
777 | // background hits are considered. | |
778 | // Test_t *filename File name containing the background hits.. | |
779 | // Outputs: | |
780 | // none. | |
781 | // Return: | |
782 | // none. | |
783 | ||
7d62fb64 | 784 | |
785 | if(!fDetTypeSim) { | |
786 | Error("HitsToPreDigits","fDetTypeSim is null!"); | |
787 | return; | |
788 | } | |
023ae34b | 789 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
c8af5b8f | 790 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 791 | |
792 | if(!GetITSgeom()){ | |
793 | Error("HitsToPreDigits","fGeom is null!"); | |
794 | return; // need transformations to do digitization. | |
795 | } | |
796 | AliITSgeom *geom = GetITSgeom(); | |
797 | ||
798 | const char *all = strstr(opt,"All"); | |
799 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
800 | strstr(opt,"SSD")}; | |
801 | static Bool_t setDef=kTRUE; | |
802 | if (setDef) SetDefaultSimulation(); | |
803 | setDef=kFALSE; | |
804 | ||
805 | Int_t nmodules; | |
806 | InitModules(size,nmodules); | |
807 | FillModules(evNumber,bgrev,nmodules,option,filename); | |
808 | ||
809 | ||
810 | AliITSsimulation *sim = 0; | |
811 | AliITSmodule *mod = 0; | |
812 | Int_t id,module; | |
813 | for(module=0;module<geom->GetIndexMax();module++){ | |
814 | id = geom->GetModuleType(module); | |
815 | if (!all && !det[id]) continue; | |
816 | sim = (AliITSsimulation*)GetSimulationModel(id); | |
817 | if (!sim) { | |
818 | Error("HitsToPreDigits","The simulation class was not " | |
819 | "instanciated for module %d type %s!",module, | |
820 | geom->GetModuleTypeName(module)); | |
821 | exit(1); | |
822 | } // end if !sim | |
823 | mod = (AliITSmodule *)fITSmodules->At(module); | |
824 | sim->SDigitiseModule(mod,module,evNumber); | |
825 | // fills all branches - wasted disk space | |
826 | fLoader->TreeS()->Fill(); | |
827 | fDetTypeSim->ResetSDigits(); | |
828 | } // end for module | |
04366a57 | 829 | |
7d62fb64 | 830 | ClearModules(); |
831 | ||
832 | ||
833 | fLoader->TreeS()->GetEntries(); | |
834 | fLoader->TreeS()->AutoSave(); | |
835 | fLoader->WriteSDigits("OVERWRITE"); | |
836 | // reset tree | |
837 | fLoader->TreeS()->Reset(); | |
2aea926d | 838 | } |
7d62fb64 | 839 | |
840 | //_____________________________________________________________________ | |
841 | void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size, | |
842 | Option_t *opt0,Option_t *opt1, | |
843 | const char *flnm){ | |
844 | // keep galice.root for signal and name differently the file for | |
845 | // background when add! otherwise the track info for signal will be lost ! | |
846 | // the condition below will disappear when the geom class will be | |
847 | // initialized for all versions - for the moment it is only for v5 ! | |
848 | // Inputs: | |
849 | // Int_t evnt Event to be processed. | |
850 | // Int_t bgrev Background Hit tree number. | |
851 | // Int_t size Size used by InitModules. See InitModules. | |
852 | // Option_t *opt0 Option passed to FillModules. See FillModules. | |
853 | // Option_t *opt1 String indicating if merging hits or not. To | |
854 | // merge hits set equal to "Add". Otherwise no | |
855 | // background hits are considered. | |
856 | // Test_t *flnm File name containing the background hits.. | |
857 | // Outputs: | |
858 | // none. | |
859 | // Return: | |
860 | // none. | |
861 | ||
862 | ||
00a7cc50 | 863 | |
7d62fb64 | 864 | if(!GetITSgeom()){ |
865 | Error("HitsToPreDigits","fGeom is null!"); | |
866 | return; // need transformations to do digitization. | |
867 | } | |
868 | AliITSgeom *geom = GetITSgeom(); | |
869 | ||
870 | AliITSLoader *pITSloader = (AliITSLoader*)fLoader; | |
871 | ||
872 | const char *all = strstr(opt1,"All"); | |
873 | const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"), | |
874 | strstr(opt1,"SSD")}; | |
875 | Int_t nmodules; | |
876 | InitModules(size,nmodules); | |
877 | FillModules(evNumber,bgrev,nmodules,opt0,flnm); | |
878 | ||
879 | AliITSsimulation *sim = 0; | |
880 | AliITSmodule *mod = 0; | |
881 | Int_t id,module; | |
882 | ||
883 | TTree *lTR = pITSloader->TreeR(); | |
00a7cc50 | 884 | if(!lTR) { |
885 | pITSloader->MakeTree("R"); | |
886 | lTR = pITSloader->TreeR(); | |
887 | } | |
888 | ||
7d62fb64 | 889 | TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000); |
00a7cc50 | 890 | TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray); |
891 | branch->SetAddress(&ptarray); | |
7d62fb64 | 892 | //m.b. : this change is nothing but a nice way to make sure |
023ae34b | 893 | //the CPU goes up ! |
7d62fb64 | 894 | for(module=0;module<geom->GetIndexMax();module++){ |
895 | id = geom->GetModuleType(module); | |
896 | if (!all && !det[id]) continue; | |
897 | sim = (AliITSsimulation*)GetSimulationModel(id); | |
898 | if (!sim) { | |
899 | Error("HitsToFastPoints","The simulation class was not " | |
900 | "instanciated for module %d type %x!",module, | |
901 | geom->GetModuleTypeName(module)); | |
902 | exit(1); | |
903 | } // end if !sim | |
904 | mod = (AliITSmodule *)fITSmodules->At(module); | |
905 | sim->CreateFastRecPoints(mod,module,gRandom,ptarray); | |
906 | lTR->Fill(); | |
f1bfe73f | 907 | ptarray->Clear(); |
7d62fb64 | 908 | } // end for module |
909 | ||
910 | ClearModules(); | |
911 | fLoader->WriteRecPoints("OVERWRITE"); | |
912 | delete ptarray; | |
913 | } | |
914 | //_____________________________________________________________________ | |
915 | Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) { | |
916 | //------------------------------------------------------------ | |
917 | // This function creates ITS clusters | |
918 | //------------------------------------------------------------ | |
919 | if(!GetITSgeom()){ | |
920 | Error("HitsToPreDigits","fGeom is null!"); | |
921 | return 1; // need transformations to do digitization. | |
922 | } | |
923 | AliITSgeom *geom=GetITSgeom(); | |
924 | Int_t mmax=geom->GetIndexMax(); | |
925 | ||
926 | InitModules(-1,mmax); | |
927 | FillModules(hTree,0); | |
928 | ||
7d62fb64 | 929 | TClonesArray *points = new TClonesArray("AliITSRecPoint",1000); |
00a7cc50 | 930 | TBranch *branch=cTree->GetBranch("ITSRecPoints"); |
931 | if (!branch) cTree->Branch("ITSRecPoints",&points); | |
932 | else branch->SetAddress(&points); | |
7d62fb64 | 933 | |
934 | AliITSsimulationFastPoints sim; | |
935 | Int_t ncl=0; | |
936 | for (Int_t m=0; m<mmax; m++) { | |
937 | AliITSmodule *mod=GetModule(m); | |
938 | sim.CreateFastRecPoints(mod,m,gRandom,points); | |
00a7cc50 | 939 | ncl+=points->GetEntriesFast(); |
7d62fb64 | 940 | cTree->Fill(); |
7d62fb64 | 941 | points->Clear(); |
942 | } | |
943 | ||
15e6a32c | 944 | AliDebug(1,Form("Number of found fast clusters : %d",ncl)); |
7d62fb64 | 945 | |
946 | //cTree->Write(); | |
947 | ||
7d62fb64 | 948 | delete points; |
949 | return 0; | |
950 | } | |
7d62fb64 | 951 | |
7d62fb64 | 952 | //_____________________________________________________________________ |
953 | void AliITS::CheckLabels(Int_t lab[3]) const { | |
954 | //------------------------------------------------------------ | |
955 | // Tries to find mother's labels | |
956 | //------------------------------------------------------------ | |
957 | ||
958 | if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit | |
959 | ||
960 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); | |
961 | for (Int_t i=0;i<3;i++){ | |
962 | Int_t label = lab[i]; | |
963 | if (label>=0 && label<ntracks) { | |
964 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
965 | if (part->P() < 0.005) { | |
966 | Int_t m=part->GetFirstMother(); | |
967 | if (m<0) { | |
968 | continue; | |
969 | } | |
970 | if (part->GetStatusCode()>0) { | |
971 | continue; | |
972 | } | |
973 | lab[i]=m; | |
974 | } | |
975 | } | |
976 | } | |
977 | ||
978 | } | |
979 | ||
980 | //______________________________________________________________________ | |
981 | void AliITS::SDigitsToDigits(Option_t *opt){ | |
ad7f2bfa | 982 | // Standard Summable digits to Digits function. |
983 | // Inputs: | |
984 | // none. | |
985 | // Outputs: | |
986 | // none. | |
987 | if (!fDetTypeSim) { | |
988 | AliError("fDetTypeSim is 0!"); | |
989 | return; | |
990 | } | |
7d62fb64 | 991 | |
ad7f2bfa | 992 | const char *all = strstr(opt,"All"); |
993 | const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"), | |
994 | strstr(opt,"SSD")}; | |
995 | ||
996 | // Reset Fast-OR signals for this event | |
997 | fDetTypeSim->ResetFOSignals(); | |
998 | ||
999 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); | |
1000 | SetDefaults(); | |
c8af5b8f | 1001 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
ad7f2bfa | 1002 | fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName()); |
1003 | ||
1004 | // Add random noise to FO signals | |
1005 | if (all || det[0]) { // SPD present | |
1006 | fDetTypeSim->ProcessNoiseForFastOr(); | |
1007 | } | |
1008 | // Add Fast-OR signals to event (only one object per event) | |
1009 | if (all || det[0]) { // SPD present | |
1010 | fDetTypeSim->WriteFOSignals(); | |
1011 | } | |
7d62fb64 | 1012 | } |
1013 | ||
2aea926d | 1014 | //______________________________________________________________________ |
2aea926d | 1015 | void AliITS::ResetDigits(){ |
4a5bebc2 | 1016 | // Reset number of digits and the digits array for the ITS detector. |
1017 | // Inputs: | |
1018 | // none. | |
1019 | // Outputs: | |
1020 | // none. | |
7d62fb64 | 1021 | if(!fDetTypeSim) { |
1022 | Error("ResetDigits","fDetTypeSim is 0!"); | |
1023 | return; | |
1024 | } | |
1025 | ||
1026 | fDetTypeSim->ResetDigits(); | |
3bd79107 | 1027 | |
1028 | ||
2aea926d | 1029 | } |
1030 | //______________________________________________________________________ | |
7d62fb64 | 1031 | void AliITS::ResetDigits(Int_t branch){ |
4a5bebc2 | 1032 | // Reset number of digits and the digits array for this branch. |
1033 | // Inputs: | |
1034 | // none. | |
1035 | // Outputs: | |
1036 | // none. | |
828e06c7 | 1037 | |
7d62fb64 | 1038 | if(!fDetTypeSim) { |
1039 | Error("ResetDigits","fDetTypeSim is 0!"); | |
1040 | return; | |
1041 | } | |
1042 | ||
1043 | fDetTypeSim->ResetDigits(branch); | |
1044 | ||
2aea926d | 1045 | } |
1046 | //______________________________________________________________________ | |
1047 | void AliITS::AddSumDigit(AliITSpListItem &sdig){ | |
4a5bebc2 | 1048 | // Adds the a module full of summable digits to the summable digits tree. |
1049 | // Inputs: | |
1050 | // AliITSpListItem &sdig SDigit to be added to SDigits tree. | |
1051 | // Outputs: | |
1052 | // none. | |
1053 | // Return: | |
1054 | // none. | |
828e06c7 | 1055 | |
7d62fb64 | 1056 | if(!fDetTypeSim) { |
1057 | Error("AddSumDigit","fDetTypeSim is 0!"); | |
1058 | return; | |
1059 | } | |
1060 | fDetTypeSim->AddSumDigit(sdig); | |
1061 | ||
2aea926d | 1062 | } |
1063 | //______________________________________________________________________ | |
7d62fb64 | 1064 | void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){ |
4a5bebc2 | 1065 | // Add a simulated digit. |
1066 | // Inputs: | |
1067 | // Int_t id Detector type number. | |
1068 | // AliITSdigit *d Digit to be added to the Digits Tree. See | |
1069 | // AliITSdigit.h | |
1070 | // Outputs: | |
1071 | // none. | |
1072 | // Return: | |
1073 | // none. | |
2aea926d | 1074 | |
7d62fb64 | 1075 | if(!fDetTypeSim) { |
1076 | Error("AddSimDigit","fDetTypeSim is 0!"); | |
1077 | return; | |
1078 | } | |
1079 | fDetTypeSim->AddSimDigit(branch,d); | |
1080 | ||
2aea926d | 1081 | } |
1082 | //______________________________________________________________________ | |
7d62fb64 | 1083 | void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks, |
83ec5e27 | 1084 | Int_t *hits,Float_t *charges, Int_t sigexpanded){ |
7f1a504b | 1085 | // Add a simulated digit to the list. |
1086 | // Inputs: | |
1087 | // Int_t id Detector type number. | |
1088 | // Float_t phys Physics indicator. See AliITSdigits.h | |
1089 | // Int_t *digits Integer array containing the digits info. See | |
1090 | // AliITSdigit.h | |
1091 | // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()] | |
1092 | // containing the track numbers that contributed to | |
1093 | // this digit. | |
1094 | // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()] | |
1095 | // containing the hit numbers, from AliITSmodule, that | |
1096 | // contributed to this digit. | |
1097 | // Float_t *charge Floating point array of the signals contributed | |
1098 | // to this digit by each track. | |
1099 | // Outputs: | |
1100 | // none. | |
1101 | // Return: | |
1102 | // none. | |
2aea926d | 1103 | |
7d62fb64 | 1104 | if(!fDetTypeSim) { |
1105 | Error("AddSimDigit","fDetTypeSim is 0!"); | |
1106 | return; | |
1107 | } | |
83ec5e27 | 1108 | fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded); |
7d62fb64 | 1109 | |
2aea926d | 1110 | } |
0421c3d1 | 1111 | //______________________________________________________________________ |
aacedc3e | 1112 | void AliITS::Digits2Raw(){ |
1113 | // convert digits of the current event to raw data | |
0421c3d1 | 1114 | |
7d62fb64 | 1115 | if(!fDetTypeSim) { |
1116 | Error("Digits2Raw","fDetTypeSim is 0!"); | |
1117 | return; | |
1118 | } | |
023ae34b | 1119 | fDetTypeSim->SetLoader((AliITSLoader*)fLoader); |
7d62fb64 | 1120 | SetDefaults(); |
c8af5b8f | 1121 | if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam); |
7d62fb64 | 1122 | fDetTypeSim->GetLoader()->LoadDigits(); |
1123 | TTree* digits = fDetTypeSim->GetLoader()->TreeD(); | |
0421c3d1 | 1124 | if (!digits) { |
aacedc3e | 1125 | Error("Digits2Raw", "no digits tree"); |
1126 | return; | |
0421c3d1 | 1127 | } |
7d62fb64 | 1128 | fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName()); |
ad7f2bfa | 1129 | |
1130 | // Get the FO signals for this event | |
1131 | AliITSFOSignalsSPD* foSignals = NULL; | |
1132 | AliRunLoader* runLoader = AliRunLoader::Instance(); | |
1133 | AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader"); | |
1134 | if (!itsLoader) { | |
1135 | AliError("ITS loader is NULL."); | |
1136 | } | |
a0d76912 | 1137 | else { |
1138 | if(!itsLoader->TreeD()) AliError(" !!! No TreeD available !!!"); | |
1139 | foSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD"); | |
1140 | if(!foSignals) AliError("FO signals not retrieved"); | |
1141 | } | |
1142 | ||
ad7f2bfa | 1143 | Bool_t deleteFOsignalsLater = kFALSE; |
1144 | if (!foSignals) { | |
1145 | AliError("FO signals not available. No FO bits will be written."); | |
1146 | foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object | |
1147 | deleteFOsignalsLater = kTRUE; | |
1148 | } | |
1149 | ||
1150 | ||
979b5a5f | 1151 | AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD(); |
d9ed1779 | 1152 | Char_t rawSDD=fDetTypeSim->GetSimuParam()->GetSDDRawDataFormat(); |
0421c3d1 | 1153 | AliITSDDLRawData rawWriter; |
d9ed1779 | 1154 | |
1155 | rawWriter.SetSDDRawFormat(rawSDD); | |
0421c3d1 | 1156 | //Verbose level |
1157 | // 0: Silent | |
1158 | // 1: cout messages | |
1159 | // 2: txt files with digits | |
1160 | //BE CAREFUL, verbose level 2 MUST be used only for debugging and | |
1161 | //it is highly suggested to use this mode only for debugging digits files | |
1162 | //reasonably small, because otherwise the size of the txt files can reach | |
1163 | //quickly several MB wasting time and disk space. | |
1164 | rawWriter.SetVerbose(0); | |
1165 | ||
1166 | //SILICON PIXEL DETECTOR | |
15e6a32c | 1167 | AliDebug(1,"Formatting raw data for SPD"); |
ad7f2bfa | 1168 | rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals); |
1169 | if(deleteFOsignalsLater) delete foSignals; | |
0421c3d1 | 1170 | |
1171 | //SILICON DRIFT DETECTOR | |
d9ed1779 | 1172 | AliDebug(1,Form("Formatting raw data for SDD - Format code =%d",rawSDD)); |
979b5a5f | 1173 | rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd); |
0421c3d1 | 1174 | |
1175 | //SILICON STRIP DETECTOR | |
15e6a32c | 1176 | AliDebug(1,"Formatting raw data for SSD"); |
0421c3d1 | 1177 | rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD")); |
1178 | ||
1179 | fLoader->UnloadDigits(); | |
2aea926d | 1180 | } |
2aea926d | 1181 | //______________________________________________________________________ |
aacedc3e | 1182 | AliLoader* AliITS::MakeLoader(const char* topfoldername){ |
1183 | //builds ITSgetter (AliLoader type) | |
1184 | //if detector wants to use castomized getter, it must overload this method | |
1185 | ||
64f311fe | 1186 | AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.", |
1187 | topfoldername)); | |
aacedc3e | 1188 | fLoader = new AliITSLoader(GetName(),topfoldername); |
1189 | return fLoader; | |
2aea926d | 1190 | } |
ad7f2bfa | 1191 | //______________________________________________________________________ |
0b5bf101 | 1192 | Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) |
1193 | { | |
1194 | // | |
1195 | // Converts RAW data to SDigits | |
1196 | // | |
1197 | // Get TreeS | |
1198 | // | |
1199 | Int_t last = -1; | |
1200 | Int_t size = GetITSgeom()->GetIndexMax(); | |
1201 | TClonesArray** modA = new TClonesArray*[size]; | |
1202 | for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000); | |
1203 | ||
33c3c91a | 1204 | AliLoader* loader = (AliRunLoader::Instance())->GetLoader("ITSLoader"); |
ad7f2bfa | 1205 | if (!loader){ |
0b5bf101 | 1206 | Error("Open","Can not get ITS loader from Run Loader"); |
1207 | return kFALSE; | |
1208 | } | |
1209 | ||
1210 | TTree* tree = 0; | |
1211 | tree = loader->TreeS(); | |
ad7f2bfa | 1212 | if (!tree){ |
0b5bf101 | 1213 | loader->MakeTree("S"); |
1214 | tree = loader->TreeS(); | |
1215 | } | |
1216 | // | |
1217 | // Array for SDigits | |
1218 | // | |
1219 | TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits; | |
1220 | Int_t bufsize = 32000; | |
1221 | tree->Branch("ITS", &itsSDigits, bufsize); | |
1222 | Int_t npx = 0; | |
1223 | // | |
1224 | // SPD | |
1225 | // | |
1226 | AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0); | |
6a3ca9e7 | 1227 | if(!segSPD){ |
1228 | AliWarning("Set AliITS defaults"); | |
1229 | SetDefaults(); | |
1230 | segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0); | |
1231 | } | |
0b5bf101 | 1232 | npx = segSPD->Npx(); |
1233 | Double_t thr, sigma; | |
1234 | ||
1235 | AliITSRawStreamSPD inputSPD(rawReader); | |
1236 | while(1){ | |
1237 | Bool_t next = inputSPD.Next(); | |
1238 | if (!next) break; | |
1239 | ||
1240 | Int_t module = inputSPD.GetModuleID(); | |
1241 | Int_t column = inputSPD.GetColumn(); | |
1242 | Int_t row = inputSPD.GetRow(); | |
1243 | Int_t index = npx * column + row; | |
1244 | ||
1245 | if (module >= size) continue; | |
1246 | ||
1247 | last = (modA[module])->GetEntries(); | |
1248 | TClonesArray& dum = *modA[module]; | |
bb292d31 | 1249 | fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma); |
0b5bf101 | 1250 | thr += 1.; |
1251 | new (dum[last]) AliITSpListItem(-1, -1, module, index, thr); | |
1252 | } | |
1253 | rawReader->Reset(); | |
1254 | ||
1255 | // | |
1256 | // SDD | |
1257 | // | |
1258 | AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1); | |
1259 | npx = segSDD->Npx(); | |
dee45d79 | 1260 | Int_t scalef=AliITSsimulationSDD::ScaleFourier(segSDD); |
1261 | Int_t firstSDD=AliITSgeomTGeo::GetModuleIndex(3,1,1); | |
1262 | Int_t firstSSD=AliITSgeomTGeo::GetModuleIndex(5,1,1); | |
1263 | ||
a4998655 | 1264 | AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader); |
dee45d79 | 1265 | for(Int_t iMod=firstSDD; iMod<firstSSD; iMod++){ |
1266 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(iMod); | |
1267 | Bool_t isZeroSupp=cal->GetZeroSupp(); | |
1268 | if(isZeroSupp){ | |
1269 | for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,cal->GetZSLowThreshold(iSid)); | |
1270 | }else{ | |
1271 | for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,0); | |
1272 | } | |
1273 | } | |
1274 | ||
979b5a5f | 1275 | AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD(); |
a4998655 | 1276 | inputSDD->SetDDLModuleMap(ddlmap); |
dee45d79 | 1277 | while(inputSDD->Next()){ |
a4998655 | 1278 | if(inputSDD->IsCompletedModule()==kFALSE && |
1279 | inputSDD->IsCompletedDDL()==kFALSE){ | |
0b5bf101 | 1280 | |
a4998655 | 1281 | Int_t module = inputSDD->GetModuleID(); |
dee45d79 | 1282 | Int_t anode = inputSDD->GetCoord1()+segSDD->NpzHalf()*inputSDD->GetChannel(); |
a4998655 | 1283 | Int_t time = inputSDD->GetCoord2(); |
1284 | Int_t signal10 = inputSDD->GetSignal(); | |
dee45d79 | 1285 | Int_t index = AliITSpList::GetIndex(anode,time,scalef*npx); |
a4998655 | 1286 | |
1287 | if (module >= size) continue; | |
1288 | last = modA[module]->GetEntries(); | |
1289 | TClonesArray& dum = *modA[module]; | |
1290 | new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10)); | |
1291 | ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10)); | |
1292 | } | |
0b5bf101 | 1293 | } |
a4998655 | 1294 | delete inputSDD; |
0b5bf101 | 1295 | rawReader->Reset(); |
a4998655 | 1296 | |
0b5bf101 | 1297 | // |
1298 | // SSD | |
1299 | // | |
1300 | AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2); | |
1301 | npx = segSSD->Npx(); | |
1302 | AliITSRawStreamSSD inputSSD(rawReader); | |
1303 | while(1){ | |
1304 | Bool_t next = inputSSD.Next(); | |
1305 | if (!next) break; | |
1306 | ||
1307 | Int_t module = inputSSD.GetModuleID(); | |
1308 | Int_t side = inputSSD.GetSideFlag(); | |
1309 | Int_t strip = inputSSD.GetStrip(); | |
1310 | Int_t signal = inputSSD.GetSignal(); | |
1311 | Int_t index = npx * side + strip; | |
1312 | ||
1313 | if (module >= size) continue; | |
1314 | ||
1315 | last = modA[module]->GetEntries(); | |
1316 | TClonesArray& dum = *modA[module]; | |
1317 | new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal)); | |
1318 | } | |
1319 | rawReader->Reset(); | |
8b3448d3 | 1320 | AliITSpListItem* sdig = 0; |
0b5bf101 | 1321 | |
8b3448d3 | 1322 | Int_t firstssd = GetITSgeom()->GetStartDet(kSSD); |
1323 | Double_t adcToEv = 1.; | |
0b5bf101 | 1324 | for (Int_t mod = 0; mod < size; mod++) |
8b3448d3 | 1325 | { |
1326 | if(mod>=firstssd) { | |
1327 | AliITSCalibrationSSD* calssd = (AliITSCalibrationSSD*)fDetTypeSim->GetCalibrationModel(mod); | |
1328 | adcToEv = 1./calssd->GetSSDDEvToADC(1.); | |
1329 | } | |
1330 | Int_t nsdig = modA[mod]->GetEntries(); | |
1331 | for (Int_t ie = 0; ie < nsdig; ie++) { | |
1332 | sdig = (AliITSpListItem*) (modA[mod]->At(ie)); | |
1333 | Int_t digsig = sdig->GetSignal(); | |
1334 | if(mod>=firstssd) digsig*=adcToEv; // for SSD: convert back charge from ADC to electron | |
1335 | new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), digsig); | |
0b5bf101 | 1336 | Float_t sig = sdig->GetSignalAfterElect(); |
8b3448d3 | 1337 | if(mod>=firstssd) sig*=adcToEv; |
0b5bf101 | 1338 | if (sig > 0.) { |
1339 | sdig = (AliITSpListItem*)aSDigits[ie]; | |
1340 | sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig)); | |
1341 | } | |
1342 | } | |
1343 | ||
1344 | tree->Fill(); | |
1345 | aSDigits.Clear(); | |
1346 | modA[mod]->Clear(); | |
1347 | } | |
1348 | loader->WriteSDigits("OVERWRITE"); | |
1349 | delete modA; | |
1350 | return kTRUE; | |
1351 | } | |
1352 | ||
1353 | ||
ef7ff1f9 | 1354 | //______________________________________________________________________ |
1355 | void AliITS::UpdateInternalGeometry(){ | |
1356 | ||
ed9289c8 | 1357 | //reads new geometry from TGeo |
012f0f4c | 1358 | // AliDebug(1,"Delete ITSgeom and create a new one reading TGeo"); |
1359 | ||
108bd0fe | 1360 | AliITSVersion_t version = (AliITSVersion_t)IsVersion(); |
1361 | Int_t minor = 0; | |
012f0f4c | 1362 | if(version==kvPPRasymmFMD) minor=2; // default minor version for this geom. |
1363 | AliITSInitGeometry initgeom; | |
1364 | AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor); | |
ef7ff1f9 | 1365 | SetITSgeom(geom); |
ef7ff1f9 | 1366 | } |
ad7f2bfa | 1367 | //______________________________________________________________________ |
1368 | AliTriggerDetector* AliITS::CreateTriggerDetector() const { | |
1369 | // create an AliITSTrigger object (and set trigger conditions as input) | |
1370 | return new AliITSTrigger(fDetTypeSim->GetTriggerConditions()); | |
1371 | } |