]>
Commit | Line | Data |
---|---|---|
451f5018 | 1 | /* |
2 | */ | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Author: The ALICE Off-line Project. * | |
8 | * Contributors are mentioned in the code where appropriate. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /* $Id: AliITSU.cxx $ */ | |
20 | ||
21 | ||
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | // // | |
24 | // An overview of the basic philosophy of the ITS code development // | |
25 | // and analysis is show in the figure below. // | |
26 | //Begin_Html // | |
27 | /* | |
28 | <img src="picts/ITS/ITS_Analysis_schema.gif"> | |
29 | </pre> | |
30 | <br clear=left> | |
31 | <font size=+2 color=red> | |
32 | <p>Roberto Barbera is in charge of the ITS Offline code (1999). | |
33 | <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>. | |
34 | </font> | |
35 | <pre> | |
36 | */ | |
37 | //End_Html | |
38 | // | |
39 | // AliITSU. Inner Traking System base class. | |
40 | // This class contains the base procedures for the Inner Tracking System | |
41 | // | |
42 | //Begin_Html | |
43 | /* | |
44 | <img src="picts/ITS/AliITS_Class_Diagram.gif"> | |
45 | </pre> | |
46 | <br clear=left> | |
47 | <font size=+2 color=red> | |
48 | <p>This show the class diagram of the different elements that are part of | |
49 | the AliITS class. | |
50 | </font> | |
51 | <pre> | |
52 | */ | |
53 | //End_Html | |
54 | // | |
55 | // Version: 0 | |
56 | // Written by Rene Brun, Federico Carminati, and Roberto Barbera | |
57 | // | |
58 | // Version: 1 | |
59 | // Modified and documented by Bjorn S. Nilsen | |
60 | // July 11 1999 | |
61 | // | |
62 | // Version: 2 | |
63 | // Modified and documented by A. Bologna | |
64 | // October 18 1999 | |
65 | // | |
66 | // AliITSU is the general base class for the ITS. Also see AliDetector for | |
67 | // futher information. | |
68 | // | |
69 | /////////////////////////////////////////////////////////////////////////////// | |
70 | ||
71 | #include <stdlib.h> | |
72 | #include <TClonesArray.h> | |
73 | #include <TFile.h> | |
74 | #include <TParticle.h> | |
75 | #include <TString.h> | |
76 | #include <TTree.h> | |
77 | #include <TVirtualMC.h> | |
78 | #include "AliDetector.h" | |
79 | #include "AliITSU.h" | |
80 | #include "AliITSLoader.h" | |
81 | #include "AliITSULoader.h" | |
82 | #include "AliITSUHit.h" | |
83 | #include "AliITSUSDigit.h" | |
84 | #include "AliITSUSimulation.h" | |
85 | #include "AliITSUSimulationPix.h" | |
86 | #include "AliITSsimulationFastPoints.h" | |
87 | #include "AliMC.h" | |
88 | #include "AliITSUDigitizer.h" | |
89 | #include "AliITSRecPoint.h" | |
90 | #include "AliRawReader.h" | |
91 | #include "AliRun.h" | |
92 | #include "AliLog.h" | |
93 | #include "AliITSdigit.h" | |
94 | #include "AliITSUModule.h" | |
95 | #include "AliITSUDigitPix.h" | |
96 | #include "AliITSsegmentation.h" | |
97 | #include "AliITSUSegmentationPix.h" | |
98 | #include "AliITSUSimuParam.h" | |
99 | #include "AliITSFOSignalsSPD.h" | |
100 | ||
101 | ClassImp(AliITSU) | |
102 | ||
103 | //______________________________________________________________________ | |
104 | AliITSU::AliITSU() : | |
105 | AliDetector() | |
106 | ,fEuclidOut(0) | |
107 | ,fNLayers(0) | |
108 | ,fIdSens(0) | |
109 | ,fLayerName(0) | |
110 | ,fTiming(kFALSE) | |
111 | ,fSimuParam(0) | |
112 | ,fGeomTGeo(0) | |
113 | ,fModA(0) | |
114 | ,fpSDigits(0) | |
115 | ,fSDigits(0) | |
116 | ,fDetHits(0) | |
117 | ,fModuleHits(0) | |
118 | ,fDetDigits(0) | |
119 | ,fSensMap(0) | |
120 | ,fSimulation(0) | |
121 | ,fSegmentation(0) | |
122 | ,fCalibration(0) | |
123 | ,fRunNumber(0) | |
124 | ,fSimInitDone(kFALSE) | |
125 | { | |
126 | // Default initializer for ITS | |
127 | } | |
128 | ||
129 | //______________________________________________________________________ | |
130 | AliITSU::AliITSU(const Char_t *title, Int_t nlay) : | |
131 | AliDetector("ITS",title) | |
132 | ,fEuclidOut(0) | |
133 | ,fNLayers(nlay) | |
134 | ,fIdSens(0) | |
135 | ,fLayerName(0) | |
136 | ,fTiming(kFALSE) | |
137 | ,fSimuParam(0) | |
138 | ,fGeomTGeo(0) | |
139 | ,fModA(0) | |
140 | ,fpSDigits(0) | |
141 | ,fSDigits(0) | |
142 | ,fDetHits(0) | |
143 | ,fModuleHits(0) | |
144 | ,fDetDigits(0) | |
145 | ,fSensMap(0) | |
146 | ,fSimulation(0) | |
147 | ,fSegmentation(0) | |
148 | ,fCalibration(0) | |
149 | ,fRunNumber(0) | |
150 | ,fSimInitDone(kFALSE) | |
151 | { | |
152 | // The standard Constructor for the ITS class. | |
153 | } | |
154 | ||
155 | ||
156 | //______________________________________________________________________ | |
157 | AliITSU::~AliITSU() | |
158 | { | |
159 | // Default destructor for ITS. | |
160 | // | |
161 | delete fHits; | |
162 | delete fModuleHits; | |
163 | delete fSimuParam; | |
164 | delete fSensMap; | |
165 | if (fSimulation) fSimulation->Delete(); | |
166 | delete fSimulation; | |
167 | delete fSegmentation; | |
168 | delete[] fLayerName; // Array of TStrings | |
169 | delete[] fIdSens; | |
170 | // | |
171 | int nmod = fGeomTGeo ? fGeomTGeo->GetNModules() : 0; | |
172 | if (fModuleHits) fModuleHits->Delete(); | |
173 | delete fModuleHits; | |
174 | if(fModA){ | |
175 | for(Int_t j=0; j<nmod; j++){ | |
176 | fModA[j]->Delete(); | |
177 | delete fModA[j]; | |
178 | } | |
179 | delete[] fModA; | |
180 | } | |
181 | if (fpSDigits) { fpSDigits->Delete(); delete fpSDigits; } | |
182 | if (fSDigits) { fSDigits->Delete(); delete fSDigits; } | |
183 | delete fGeomTGeo; | |
184 | // | |
185 | } | |
186 | ||
187 | //______________________________________________________________________ | |
188 | AliDigitizer* AliITSU::CreateDigitizer(AliDigitizationInput* manager) const | |
189 | { | |
190 | // Creates the AliITSDigitizer in a standard way for use via AliModule. | |
191 | // This function can not be included in the .h file because of problems | |
192 | // with the order of inclusion (recursive). | |
193 | // Inputs: | |
194 | // AliDigitizationInput *manager The Manger class for Digitization | |
195 | // Output: | |
196 | // none. | |
197 | // Return: | |
198 | // A new AliITSRunDigitizer (cast as a AliDigitizer). | |
199 | // | |
200 | if (!IsSimInitDone()) AliFatal("Simulation is not initialized"); | |
201 | return new AliITSUDigitizer(manager); | |
202 | } | |
203 | ||
204 | //______________________________________________________________________ | |
205 | void AliITSU::Init() | |
206 | { | |
207 | // Initializer ITS after it has been built | |
208 | // This routine initializes the AliITS class. It is intended to be | |
209 | // called from the Init function in AliITSv?. Besides displaying a banner | |
210 | // indicating that it has been called it initializes the array fIdSens | |
211 | // and sets the default segmentation, response, digit and raw cluster | |
212 | // classes therefore it should be called after a call to CreateGeometry. | |
213 | // | |
214 | if (!fIdSens) fIdSens = new Int_t[fNLayers]; | |
215 | for(int i=0;i<fNLayers;i++) fIdSens[i] = gMC ? gMC->VolId(fLayerName[i]) : 0; | |
216 | // | |
217 | } | |
218 | ||
219 | //______________________________________________________________________ | |
220 | void AliITSU::MakeBranch(Option_t* option) | |
221 | { | |
222 | // Creates Tree branches for the ITS. | |
223 | // Inputs: | |
224 | // Option_t *option String of Tree types S,D, and/or R. | |
225 | // const char *file String of the file name where these branches | |
226 | // are to be stored. If blank then these branches | |
227 | // are written to the same tree as the Hits were | |
228 | // read from. | |
229 | // Outputs: | |
230 | // none. | |
231 | // Return: | |
232 | // none. | |
233 | ||
234 | Bool_t cH = (strstr(option,"H")!=0); | |
235 | Bool_t cS = (strstr(option,"S")!=0); | |
236 | Bool_t cD = (strstr(option,"D")!=0); | |
237 | ||
238 | if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560); | |
239 | AliDetector::MakeBranch(option); | |
240 | ||
241 | if(cS) MakeBranchS(0); | |
242 | if(cD) MakeBranchD(0); | |
243 | // | |
244 | } | |
245 | ||
246 | //___________________________________________________________________ | |
247 | void AliITSU::MakeBranchS(const char* fl) | |
248 | { | |
249 | // Creates Tree Branch for the ITS summable digits. | |
250 | // Inputs: | |
251 | // cont char *fl File name where SDigits branch is to be written | |
252 | // to. If blank it write the SDigits to the same | |
253 | // file in which the Hits were found. | |
254 | // | |
255 | Int_t buffersize = 4000; | |
256 | char branchname[31]; | |
257 | // | |
258 | // only one branch for SDigits. | |
259 | snprintf(branchname,30,"%s",GetName()); | |
260 | if(fLoader->TreeS()) MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl); | |
261 | // | |
262 | } | |
263 | ||
264 | //______________________________________________________________________ | |
265 | void AliITSU::MakeBranchD(const char* file) | |
266 | { | |
267 | //Make branch for digits | |
268 | MakeBranchInTreeD(fLoader->TreeD(),file); | |
269 | } | |
270 | ||
271 | //___________________________________________________________________ | |
272 | void AliITSU:: MakeBranchInTreeD(TTree* treeD, const char* file) | |
273 | { | |
274 | // Creates Tree branches for the ITS. | |
275 | // | |
276 | if (!treeD) {AliFatal("No tree provided");} | |
277 | Int_t buffersize = 4000; | |
278 | if (!fDetDigits) InitArrays(); | |
279 | // | |
280 | for (Int_t i=0;i<kNDetTypes;i++) { | |
281 | ResetDigits(i); | |
282 | TClonesArray* darr = (TClonesArray*)fDetDigits->At(i); | |
283 | AliDetector::MakeBranchInTree(treeD,Form("%sDigits%s",GetName(),fGeomTGeo->GetDetTypeName(i)), | |
284 | &darr,buffersize,file); | |
285 | } | |
286 | // | |
287 | } | |
288 | ||
289 | //______________________________________________________________________ | |
290 | void AliITSU::InitArrays() | |
291 | { | |
292 | // initialize arrays | |
293 | // | |
294 | fHits = new TClonesArray("AliITSUHit",1560); // from AliDetector | |
295 | if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits); | |
296 | if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName()); | |
297 | // | |
298 | fDetDigits = new TObjArray(kNDetTypes); | |
299 | for (Int_t i=0;i<kNDetTypes;i++) fDetDigits->AddAt(new TClonesArray(GetDigitClassName(i),100),i); | |
300 | // | |
301 | fSDigits = new TClonesArray("AliITSUSDigit",100); | |
302 | // | |
303 | fDetHits = new TClonesArray("AliITSUHit",100); | |
304 | // | |
305 | fModuleHits = new TObjArray(fGeomTGeo->GetNModules()); | |
306 | for (int i=0;i<fGeomTGeo->GetNModules();i++) fModuleHits->AddLast( new AliITSUModule(i,fGeomTGeo) ); | |
307 | // | |
308 | } | |
309 | ||
310 | //______________________________________________________________________ | |
311 | void AliITSU::SetTreeAddress() | |
312 | { | |
313 | // Set branch address for the Trees. | |
314 | TTree *treeS = fLoader->TreeS(); | |
315 | if (treeS) treeS->GetBranch(GetName())->SetAddress(&fSDigits); | |
316 | // | |
317 | TTree *treeD = fLoader->TreeD(); | |
318 | if (treeD) { | |
319 | if (!fDetDigits) InitArrays(); | |
320 | for (int i=0;i<kNDetTypes;i++) { | |
321 | TString brname = Form("%sDigits%s",GetName(),GetDetTypeName(i)); | |
322 | TBranch* br = treeD->GetBranch(brname.Data()); | |
323 | if (!br) AliFatal(Form("Did not find branch for %s",brname.Data())); | |
324 | TClonesArray* darr = (TClonesArray*)fDetDigits->At(i); | |
325 | br->SetAddress(&darr); | |
326 | } | |
327 | } | |
328 | if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560); | |
329 | AliDetector::SetTreeAddress(); | |
330 | // | |
331 | } | |
332 | ||
333 | //______________________________________________________________________ | |
334 | void AliITSU::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
335 | { | |
336 | // Add an ITS hit | |
337 | // The function to add information to the AliITSUHit class. See the | |
338 | // AliITSUHit class for a full description. This function allocates the | |
339 | // necessary new space for the hit information and passes the variable | |
340 | // track, and the pointers *vol and *hits to the AliITSUHit constructor | |
341 | // function. | |
342 | // Inputs: | |
343 | // Int_t track Track number which produced this hit. | |
344 | // Int_t *vol Array of Integer Hit information. See AliITSUHit.h | |
345 | // Float_t *hits Array of Floating Hit information. see AliITSUHit.h | |
346 | TClonesArray &lhits = *fHits; | |
347 | new(lhits[fNhits++]) AliITSUHit(fIshunt,track,vol,hits); | |
348 | // | |
349 | } | |
350 | ||
351 | //______________________________________________________________________ | |
352 | void AliITSU::FillModules(Int_t bgrev, Option_t *option, const char *filename) | |
353 | { | |
354 | // fill the modules with the sorted by module hits; add hits from | |
355 | // background if option=Add. | |
356 | // | |
357 | static TTree *trH1=0; //Tree with background hits | |
358 | static Bool_t first=kTRUE; | |
359 | static TFile *file = 0; | |
360 | const char *addBgr = strstr(option,"Add"); | |
361 | // | |
362 | if (addBgr ) { | |
363 | if(first) { | |
364 | file = new TFile(filename); | |
365 | first=kFALSE; | |
366 | } | |
367 | file->cd(); | |
368 | file->ls(); | |
369 | // Get Hits Tree header from file | |
370 | if (trH1) {delete trH1; trH1=0;} | |
371 | // | |
372 | char treeName[21]; | |
373 | snprintf(treeName,20,"TreeH%d",bgrev); | |
374 | trH1 = (TTree*)gDirectory->Get(treeName); | |
375 | if (!trH1) Error("FillModules","cannot find Hits Tree for event:%d",bgrev); | |
376 | // Set branch addresses | |
377 | } // end if addBgr | |
378 | ||
379 | FillModules(fLoader->TreeH(),0); // fill from this file's tree. | |
380 | // | |
381 | if (addBgr ) { | |
382 | FillModules(trH1,10000000); // Default mask 10M. | |
383 | TTree *fAli=fLoader->GetRunLoader()->TreeK(); | |
384 | TFile *fileAli=0; | |
385 | if (fAli) { | |
386 | fileAli = fAli->GetCurrentFile(); | |
387 | fileAli->cd(); | |
388 | } | |
389 | } // end if add | |
390 | // | |
391 | } | |
392 | ||
393 | //______________________________________________________________________ | |
394 | void AliITSU::FillModules(TTree *treeH, Int_t /*mask*/) | |
395 | { | |
396 | // fill the modules with the sorted by module hits; | |
397 | // can be called many times to do a merging | |
398 | // Inputs: | |
399 | // TTree *treeH The tree containing the hits to be copied into | |
400 | // the modules. | |
401 | // Int_t mask The track number mask to indecate which file | |
402 | // this hits came from. | |
403 | // | |
404 | if (treeH == 0x0) { AliError("Tree H is NULL"); return; } | |
405 | // | |
406 | Int_t lay,lad,det,index; | |
407 | AliITSUHit *itsHit=0; | |
408 | char branchname[21]; | |
409 | snprintf(branchname,20,"%s",GetName()); | |
410 | TBranch *branch = treeH->GetBranch(branchname); | |
411 | if (!branch) {Error("FillModules","%s branch in TreeH not found",branchname); return;} // end if !branch | |
412 | // | |
413 | branch->SetAddress(&fHits); | |
414 | Int_t nTracks =(Int_t) treeH->GetEntries(); | |
415 | Int_t iPrimTrack,h; | |
416 | for (iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++) { | |
417 | ResetHits(); | |
418 | Int_t nBytes = treeH->GetEvent(iPrimTrack); | |
419 | if (nBytes <= 0) continue; | |
420 | Int_t nHits = fHits->GetEntriesFast(); | |
421 | for (h=0; h<nHits; h++){ | |
422 | itsHit = (AliITSUHit *)fHits->UncheckedAt(h); | |
423 | itsHit->GetDetectorID(lay,lad,det); | |
424 | index = fGeomTGeo->GetModuleIndex(--lay,--lad,--det); // !!! AliITSHit counts indices from 1! | |
425 | itsHit = new( (*fDetHits)[fDetHits->GetEntriesFast()] ) AliITSUHit(*itsHit); | |
426 | itsHit->SetUniqueID(h); | |
427 | GetModule(index)->AddHit(itsHit); | |
428 | // do we need to add a mask? | |
429 | // itsHit->SetTrack(itsHit->GetTrack()+mask); | |
430 | } // end loop over hits | |
431 | } // end loop over tracks | |
432 | } | |
433 | ||
434 | //______________________________________________________________________ | |
435 | void AliITSU::ClearModules() | |
436 | { | |
437 | // clear accumulated hits | |
438 | if (!fModuleHits || !fDetHits) AliFatal("Hits accumulation arrays are not defined"); | |
439 | for (int i=fGeomTGeo->GetNModules();i--;) GetModule(i)->Clear(); | |
440 | fDetHits->Clear(); | |
441 | } | |
442 | ||
443 | //______________________________________________________________________ | |
444 | void AliITSU::Hits2SDigits() | |
445 | { | |
446 | // Standard Hits to summable Digits function. | |
447 | // Inputs: | |
448 | // none. | |
449 | // Outputs: | |
450 | // none. | |
451 | if (!IsSimInitDone()) InitSimulation(); | |
452 | fLoader->LoadHits("read"); | |
453 | fLoader->LoadSDigits("recreate"); | |
454 | AliRunLoader* rl = fLoader->GetRunLoader(); | |
455 | // | |
456 | for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { | |
457 | rl->GetEvent(iEvent); | |
458 | if (!fLoader->TreeS()) fLoader->MakeTree("S"); | |
459 | MakeBranch("S"); | |
460 | SetTreeAddress(); | |
461 | Hits2SDigits(iEvent,0," "," "); | |
462 | } // end for iEvent | |
463 | // | |
464 | fLoader->UnloadHits(); | |
465 | fLoader->UnloadSDigits(); | |
466 | // | |
467 | } | |
468 | ||
469 | //______________________________________________________________________ | |
470 | void AliITSU::Hits2SDigits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename) | |
471 | { | |
472 | // Keep galice.root for signal and name differently the file for | |
473 | // background when add! otherwise the track info for signal will be lost ! | |
474 | // Inputs: | |
475 | // Int_t evnt Event to be processed. | |
476 | // Int_t bgrev Background Hit tree number. | |
477 | // Int_t nmodules Not used. | |
478 | // Option_t *option String indicating if merging hits or not. To | |
479 | // merge hits set equal to "Add". Otherwise no | |
480 | // background hits are considered. | |
481 | // Test_t *filename File name containing the background hits.. | |
482 | // | |
483 | if (!IsSimInitDone()) InitSimulation(); | |
484 | FillModules(bgrev,option,filename); | |
485 | // | |
486 | Int_t nmodules = fGeomTGeo->GetNModules(); | |
487 | for(int module=0;module<nmodules;module++) { | |
488 | int id = fGeomTGeo->GetModuleDetTypeID(module); | |
489 | AliITSUSimulation* sim = GetSimulationModel(id); | |
490 | if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id)); | |
491 | sim->SDigitiseModule( GetModule(module), module, evNumber, GetSegmentation(id)); | |
492 | fLoader->TreeS()->Fill(); // fills all branches - wasted disk space | |
493 | ResetSDigits(); | |
494 | } | |
495 | // | |
496 | ClearModules(); | |
497 | // | |
498 | fLoader->TreeS()->GetEntries(); | |
499 | fLoader->TreeS()->AutoSave(); | |
500 | fLoader->WriteSDigits("OVERWRITE"); | |
501 | fLoader->TreeS()->Reset(); | |
502 | } | |
503 | ||
504 | //______________________________________________________________________ | |
505 | void AliITSU::Hits2Digits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename) | |
506 | { | |
507 | // Keep galice.root for signal and name differently the file for | |
508 | // background when add! otherwise the track info for signal will be lost ! | |
509 | // Inputs: | |
510 | // Int_t evnt Event to be processed. | |
511 | // Int_t bgrev Background Hit tree number. | |
512 | // Option_t *option String indicating if merging hits or not. To | |
513 | // merge hits set equal to "Add". Otherwise no | |
514 | // background hits are considered. | |
515 | // Test_t *filename File name containing the background hits.. | |
516 | // Outputs: | |
517 | // | |
518 | if (!IsSimInitDone()) InitSimulation(); | |
519 | FillModules(bgrev,option,filename); | |
520 | // | |
521 | Int_t nmodules = fGeomTGeo->GetNModules(); | |
522 | for (Int_t module=0;module<nmodules;module++) { | |
523 | int id = fGeomTGeo->GetModuleDetTypeID(module); | |
524 | AliITSUSimulation* sim = GetSimulationModel(id); | |
525 | if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id)); | |
526 | sim->DigitiseModule( GetModule(module) ,module, evNumber, GetSegmentation(id)); | |
527 | // fills all branches - wasted disk space | |
528 | fLoader->TreeD()->Fill(); | |
529 | ResetDigits(); | |
530 | } // end for module | |
531 | // | |
532 | ClearModules(); | |
533 | // | |
534 | // WriteFOSignals(); // Add Fast-OR signals to event (only one object per event) | |
535 | fLoader->TreeD()->GetEntries(); | |
536 | fLoader->TreeD()->AutoSave(); | |
537 | fLoader->TreeD()->Reset(); | |
538 | // | |
539 | } | |
540 | ||
541 | //_____________________________________________________________________ | |
542 | void AliITSU::Hits2FastRecPoints(Int_t bgrev,Option_t *opt,const char *flnm) | |
543 | { | |
544 | // keep galice.root for signal and name differently the file for | |
545 | // background when add! otherwise the track info for signal will be lost ! | |
546 | // Inputs: | |
547 | // Int_t evnt Event to be processed. | |
548 | // Int_t bgrev Background Hit tree number. | |
549 | // Option_t *opt Option passed to FillModules. See FillModules. | |
550 | // Test_t *flnm File name containing the background hits.. | |
551 | // Outputs: | |
552 | // none. | |
553 | // Return: | |
554 | // none. | |
555 | if (!IsSimInitDone()) InitSimulation(); | |
556 | AliITSULoader *pITSloader = (AliITSULoader*)fLoader; | |
557 | Int_t nmodules = fGeomTGeo->GetNModules(); | |
558 | FillModules(bgrev,opt,flnm); | |
559 | // | |
560 | TTree *lTR = pITSloader->TreeR(); | |
561 | if(!lTR) { | |
562 | pITSloader->MakeTree("R"); | |
563 | lTR = pITSloader->TreeR(); | |
564 | } | |
565 | // | |
566 | TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000); | |
567 | TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray); | |
568 | branch->SetAddress(&ptarray); | |
569 | for (int module=0;module<nmodules;module++){ | |
570 | int id = fGeomTGeo->GetModuleDetTypeID(module); | |
571 | AliITSUSimulation* sim = GetSimulationModel(id); | |
572 | if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id)); | |
573 | sim->CreateFastRecPoints( GetModule(module) ,module,gRandom,ptarray); | |
574 | lTR->Fill(); | |
575 | ptarray->Clear(); | |
576 | } // end for module | |
577 | // | |
578 | ClearModules(); | |
579 | fLoader->WriteRecPoints("OVERWRITE"); | |
580 | delete ptarray; | |
581 | } | |
582 | ||
583 | //_____________________________________________________________________ | |
584 | Int_t AliITSU::Hits2Clusters(TTree *hTree, TTree *cTree) | |
585 | { | |
586 | /* RS: TODO | |
587 | // This function creates ITS clusters | |
588 | if (!IsSimInitDone()) InitSimulation(); | |
589 | Int_t mmax = 0; | |
590 | FillModules(hTree,0); | |
591 | // | |
592 | TClonesArray *points = new TClonesArray("AliITSRecPoint",1000); | |
593 | TBranch *branch=cTree->GetBranch("ITSRecPoints"); | |
594 | if (!branch) cTree->Branch("ITSRecPoints",&points); | |
595 | else branch->SetAddress(&points); | |
596 | // | |
597 | AliITSsimulationFastPoints sim; | |
598 | Int_t ncl=0; | |
599 | for (Int_t m=0; m<mmax; m++) { | |
600 | sim.CreateFastRecPoints(GetModule(m),m,gRandom,points); | |
601 | ncl+=points->GetEntriesFast(); | |
602 | cTree->Fill(); | |
603 | points->Clear(); | |
604 | } | |
605 | // | |
606 | ClearModules(); | |
607 | // | |
608 | AliDebug(1,Form("Number of found fast clusters : %d",ncl)); | |
609 | //cTree->Write(); | |
610 | delete points; | |
611 | */ | |
612 | return 0; | |
613 | } | |
614 | ||
615 | //_____________________________________________________________________ | |
616 | void AliITSU::CheckLabels(Int_t lab[3]) const //RSDONE | |
617 | { | |
618 | // Tries to find mother's labels | |
619 | // | |
620 | if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit | |
621 | // | |
622 | Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); | |
623 | for (Int_t i=0;i<3;i++){ | |
624 | Int_t label = lab[i]; | |
625 | if (label>=0 && label<ntracks) { | |
626 | TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label); | |
627 | if (part->P() < 0.005) { | |
628 | Int_t m=part->GetFirstMother(); | |
629 | if (m<0) continue; | |
630 | if (part->GetStatusCode()>0) continue; | |
631 | lab[i]=m; | |
632 | } | |
633 | } | |
634 | } | |
635 | // | |
636 | } | |
637 | ||
638 | //______________________________________________________________________ | |
639 | void AliITSU::ResetDigits() //RSDONE? | |
640 | { | |
641 | // Reset number of digits and the digits array for the ITS detector. | |
642 | if (fDetDigits) for (int i=kNDetTypes;i--;) ResetDigits(i); | |
643 | // | |
644 | } | |
645 | ||
646 | //______________________________________________________________________ | |
647 | void AliITSU::ResetDigits(Int_t branch) | |
648 | { | |
649 | // Reset number of digits and the digits array for this branch. | |
650 | if (fDetDigits) ((TClonesArray*)fDetDigits->At(branch))->Clear(); | |
651 | // | |
652 | } | |
653 | ||
654 | //______________________________________________________________________ | |
655 | void AliITSU::AddSumDigit(AliITSUSDigit &sdig) | |
656 | { | |
657 | // Adds the module summable digits to the summable digits tree. | |
658 | new( (*fSDigits)[fSDigits->GetEntriesFast()]) AliITSUSDigit(sdig); | |
659 | // | |
660 | } | |
661 | ||
662 | //______________________________________________________________________ | |
663 | void AliITSU::AddSimDigit(Int_t branch, AliITSdigit *d) | |
664 | { | |
665 | // Add a simulated digit. | |
666 | // Inputs: | |
667 | // Int_t id Detector type number. | |
668 | // AliITSdigit *d Digit to be added to the Digits Tree. See | |
669 | // AliITSdigit.h | |
670 | TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch)); | |
671 | int nd = ldigits.GetEntriesFast(); | |
672 | switch(branch){ | |
673 | case AliITSUGeomTGeo::kDetTypePixUpg: | |
674 | new(ldigits[nd]) AliITSUDigitPix(*((AliITSUDigitPix*)d)); | |
675 | break; | |
676 | default: | |
677 | AliFatal(Form("Unknown digits branch %d",branch)); | |
678 | } | |
679 | } | |
680 | ||
681 | //______________________________________________________________________ | |
682 | void AliITSU::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks, | |
683 | Int_t *hits,Float_t *charges, Int_t sigexpanded) | |
684 | { | |
685 | // Add a simulated digit to the list. | |
686 | // Inputs: | |
687 | // Int_t id Detector type number. | |
688 | // Float_t phys Physics indicator. See AliITSdigits.h | |
689 | // Int_t *digits Integer array containing the digits info. See | |
690 | // AliITSdigit.h | |
691 | // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()] | |
692 | // containing the track numbers that contributed to | |
693 | // this digit. | |
694 | // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()] | |
695 | // containing the hit numbers, from AliITSmodule, that | |
696 | // contributed to this digit. | |
697 | // Float_t *charge Floating point array of the signals contributed | |
698 | // to this digit by each track. | |
699 | TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch)); | |
700 | int nd = ldigits.GetEntriesFast(); | |
701 | switch(branch){ | |
702 | case AliITSUGeomTGeo::kDetTypePixUpg: | |
703 | new(ldigits[nd]) AliITSUDigitPix(digits,tracks,hits); | |
704 | break; | |
705 | default: | |
706 | AliFatal(Form("Unknown digits branch %d",branch)); | |
707 | } | |
708 | // | |
709 | } | |
710 | ||
711 | //______________________________________________________________________ | |
712 | void AliITSU::Digits2Raw() | |
713 | { | |
714 | AliError("Not ready"); | |
715 | } | |
716 | ||
717 | //______________________________________________________________________ | |
718 | AliLoader* AliITSU::MakeLoader(const char* topfoldername) | |
719 | { | |
720 | //builds ITSgetter (AliLoader type) | |
721 | //if detector wants to use castomized getter, it must overload this method | |
722 | ||
723 | AliDebug(1,Form("Creating AliITSULoader. Top folder is %s.",topfoldername)); | |
724 | fLoader = new AliITSULoader(GetName(),topfoldername); | |
725 | return fLoader; | |
726 | } | |
727 | ||
728 | //______________________________________________________________________ | |
729 | Bool_t AliITSU::Raw2SDigits(AliRawReader* rawReader) | |
730 | { | |
731 | AliError("Not ready"); | |
732 | return kFALSE; | |
733 | } | |
734 | ||
735 | //______________________________________________________________________ | |
736 | /* | |
737 | AliTriggerDetector* AliITSU::CreateTriggerDetector() const | |
738 | { | |
739 | // create an AliITSTrigger object (and set trigger conditions as input) | |
740 | return new AliITSTrigger(fDetTypeSim->GetTriggerConditions()); | |
741 | } | |
742 | */ | |
743 | ||
744 | //______________________________________________________________________ | |
745 | void AliITSU::WriteFOSignals() | |
746 | { | |
747 | // This method write FO signals in Digits tree both in Hits2Digits | |
748 | // or SDigits2Digits | |
749 | AliError("Not ready"); | |
750 | // fDetTypeSim->ProcessNoiseForFastOr(); | |
751 | } | |
752 | ||
753 | //_______________________________________________________________________ | |
754 | void AliITSU::SDigits2Digits() | |
755 | { | |
756 | // Standard Summable digits to Digits function. | |
757 | // | |
758 | if (!IsSimInitDone()) InitSimulation(); | |
759 | TTree* trees = fLoader->TreeS(); | |
760 | if( !(trees && fSDigits) ) AliFatal("Error: No trees or SDigits."); | |
761 | TBranch* brchSDigits = trees->GetBranch(GetName()); | |
762 | // | |
763 | int nmodules = fGeomTGeo->GetNModules(); | |
764 | for (int module=0;module<nmodules;module++) { | |
765 | int id = fGeomTGeo->GetModuleDetTypeID(module); | |
766 | AliITSUSimulation *sim = GetSimulationModel(id); | |
767 | if(!sim){ | |
768 | AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id)); | |
769 | exit(1); | |
770 | } | |
771 | sim->InitSimulationModule(module,gAlice->GetEvNumber(),GetSegmentation(id)); | |
772 | fSDigits->Clear(); | |
773 | brchSDigits->GetEvent(module); | |
774 | sim->AddSDigitsToModule(fSDigits,0); | |
775 | sim->FinishSDigitiseModule(); | |
776 | fLoader->TreeD()->Fill(); | |
777 | ResetDigits(); | |
778 | } | |
779 | // WriteFOSignals(); | |
780 | fLoader->TreeD()->GetEntries(); | |
781 | fLoader->TreeD()->AutoSave(); | |
782 | fLoader->TreeD()->Reset(); | |
783 | } | |
784 | ||
785 | //_______________________________________________________________________ | |
786 | void AliITSU::InitSimulation() | |
787 | { | |
788 | // Initialize arrays, segmentations ets, needed for simulation | |
789 | // Equivalent of old AliITSDetTypeSim construction | |
790 | // | |
791 | if (fSimInitDone) {AliInfo("Already done"); return;} | |
792 | // | |
793 | fGeomTGeo = new AliITSUGeomTGeo(kTRUE); | |
794 | fSimuParam = new AliITSUSimuParam(); | |
795 | fSensMap = new AliITSUSensMap("AliITSUSDigit",0,0); | |
796 | fSimulation = new TObjArray(kNDetTypes); | |
797 | fSegmentation = new TObjArray(); | |
798 | AliITSUSegmentationPix::LoadSegmentations(fSegmentation, AliITSUGeomTGeo::GetITSsegmentationFileName()); | |
799 | fSegmentation->SetOwner(kTRUE); | |
800 | // | |
801 | // add known simulation types used in the setup | |
802 | for (int i=fNLayers;i--;) { | |
803 | int sType = fGeomTGeo->GetLayerDetTypeID(i)/AliITSUGeomTGeo::kMaxSegmPerDetType; | |
804 | if (fSimulation->At(sType)) continue; | |
805 | // | |
806 | AliITSUSimulation* simUpg = 0; | |
807 | switch (sType) { | |
808 | case AliITSUGeomTGeo::kDetTypePixUpg : | |
809 | simUpg = new AliITSUSimulationPix(fSimuParam,fSensMap); | |
810 | break; | |
811 | default: AliFatal(Form("No %d detector type is defined",sType)); | |
812 | }; | |
813 | fSimulation->AddAtAndExpand(simUpg,sType); | |
814 | } | |
815 | // | |
816 | InitArrays(); | |
817 | // | |
818 | fSimInitDone = kTRUE; | |
819 | // | |
820 | } |