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