]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute) | |
20 | ////////////////////////////////////////////////////////////////////////////// | |
21 | // This TTask performs digitization of Summable digits (in the PHOS case it is just | |
22 | // the sum of contributions from all primary particles into a given cell). | |
23 | // In addition it performs mixing of summable digits from different events. | |
24 | // The name of the TTask is also the title of the branch that will contain | |
25 | // the created SDigits | |
26 | // The title of the TTAsk is the name of the file that contains the hits from | |
27 | // which the SDigits are created | |
28 | // | |
29 | // For each event two branches are created in TreeD: | |
30 | // "PHOS" - list of digits | |
31 | // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization | |
32 | // | |
33 | // Note, that one can set a title for new digits branch, and repeat digitization with | |
34 | // another set of parameters. | |
35 | // | |
36 | // Use case: | |
37 | // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ; | |
38 | // root[1] d->ExecuteTask() | |
39 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
40 | // //Digitizes SDigitis in all events found in file galice.root | |
41 | // | |
42 | // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ; | |
43 | // // Will read sdigits from galice1.root | |
44 | // root[3] d1->MixWith("galice2.root") | |
45 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
46 | // // Reads another set of sdigits from galice2.root | |
47 | // root[3] d1->MixWith("galice3.root") | |
48 | // // Reads another set of sdigits from galice3.root | |
49 | // root[4] d->ExecuteTask("deb timing") | |
50 | // // Reads SDigits from files galice1.root, galice2.root .... | |
51 | // // mixes them and stores produced Digits in file galice1.root | |
52 | // // deb - prints number of produced digits | |
53 | // // deb all - prints list of produced digits | |
54 | // // timing - prints time used for digitization | |
55 | // | |
56 | ||
57 | // --- ROOT system --- | |
58 | #include "TFile.h" | |
59 | #include "TTree.h" | |
60 | #include "TSystem.h" | |
61 | #include "TROOT.h" | |
62 | #include "TFolder.h" | |
63 | #include "TObjString.h" | |
64 | #include "TBenchmark.h" | |
65 | ||
66 | // --- Standard library --- | |
67 | #include <iomanip.h> | |
68 | ||
69 | // --- AliRoot header files --- | |
70 | ||
71 | #include "AliRun.h" | |
72 | #include "AliRunDigitizer.h" | |
73 | #include "AliPHOSDigit.h" | |
74 | #include "AliPHOS.h" | |
75 | #include "AliPHOSGetter.h" | |
76 | #include "AliPHOSDigitizer.h" | |
77 | #include "AliPHOSSDigitizer.h" | |
78 | #include "AliPHOSGeometry.h" | |
79 | ||
80 | ClassImp(AliPHOSDigitizer) | |
81 | ||
82 | ||
83 | //____________________________________________________________________________ | |
84 | AliPHOSDigitizer::AliPHOSDigitizer() | |
85 | { | |
86 | // ctor | |
87 | ||
88 | fPinNoise = 0.01 ; | |
89 | fEMCDigitThreshold = 0.01 ; | |
90 | fCPVNoise = 0.01; | |
91 | fCPVDigitThreshold = 0.09 ; | |
92 | fTimeResolution = 1.0e-9 ; | |
93 | fDigitsInRun = 0 ; | |
94 | fPedestal = 0.; // Calibration parameters | |
95 | fSlope = 10000000. ; | |
96 | fARD = 0 ; // We work in the standalong mode | |
97 | } | |
98 | ||
99 | //____________________________________________________________________________ | |
100 | AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name) | |
101 | { | |
102 | // ctor | |
103 | SetName(name) ; | |
104 | SetTitle(headerFile) ; | |
105 | fPinNoise = 0.01 ; | |
106 | fEMCDigitThreshold = 0.01 ; | |
107 | fCPVNoise = 0.01; | |
108 | fCPVDigitThreshold = 0.09 ; | |
109 | fDigitsInRun = 0 ; | |
110 | fPedestal = 0.; // Calibration parameters | |
111 | fSlope = 10000000. ; | |
112 | fARD = 0 ; // We work in the standalong mode | |
113 | ||
114 | Init() ; | |
115 | ||
116 | } | |
117 | ||
118 | //____________________________________________________________________________ | |
119 | AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * ard) | |
120 | { | |
121 | // ctor | |
122 | fARD = ard ; | |
123 | SetName("Default"); | |
124 | SetTitle("aliroot") ; | |
125 | ||
126 | fPinNoise = 0.01 ; | |
127 | fEMCDigitThreshold = 0.01 ; | |
128 | fCPVNoise = 0.01; | |
129 | fCPVDigitThreshold = 0.09 ; | |
130 | fDigitsInRun = 0 ; | |
131 | fPedestal = 0.; // Calibration parameters | |
132 | fSlope = 10000000. ; | |
133 | ||
134 | Init() ; | |
135 | ||
136 | } | |
137 | ||
138 | //____________________________________________________________________________ | |
139 | AliPHOSDigitizer::~AliPHOSDigitizer() | |
140 | { | |
141 | // dtor | |
142 | ||
143 | ||
144 | } | |
145 | ||
146 | //____________________________________________________________________________ | |
147 | void AliPHOSDigitizer::Digitize(const Int_t event) | |
148 | { | |
149 | ||
150 | // Makes the digitization of the collected summable digits. | |
151 | // It first creates the array of all PHOS modules | |
152 | // filled with noise (different for EMC, CPV and PPSD) and | |
153 | // then adds contributions from SDigits. | |
154 | // This design avoids scanning over the list of digits to add | |
155 | // contribution to new SDigits only. | |
156 | ||
157 | if( strcmp(GetName(), "") == 0 ) | |
158 | Init() ; | |
159 | ||
160 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; | |
161 | TClonesArray * digits = gime->Digits(GetName()) ; | |
162 | ||
163 | digits->Clear() ; | |
164 | ||
165 | const AliPHOSGeometry *geom = gime->PHOSGeometry() ; | |
166 | ||
167 | //Making digits with noise, first EMC | |
168 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); | |
169 | ||
170 | Int_t nCPV ; | |
171 | Int_t absID ; | |
172 | TString name = geom->GetName() ; | |
173 | ||
174 | nCPV = nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()* | |
175 | geom->GetNModules() ; | |
176 | ||
177 | digits->Expand(nCPV) ; | |
178 | ||
179 | ||
180 | // sdigitize random gaussian noise and add it to all cells (EMCA+CPV+PPSD) | |
181 | // get first the sdigitizer from the tasks list (must have same name as the digitizer) | |
182 | const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName()); | |
183 | if ( !sDigitizer) { | |
184 | cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ; | |
185 | abort() ; | |
186 | } | |
187 | ||
188 | // loop through the sdigits posted to the White Board and add them to the noise | |
189 | TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; | |
190 | TIter next(folderslist) ; | |
191 | TFolder * folder = 0 ; | |
192 | TClonesArray * sdigits = 0 ; | |
193 | Int_t input = 0 ; | |
194 | TObjArray * sdigArray = new TObjArray(2) ; | |
195 | while ( (folder = (TFolder*)next()) ) | |
196 | if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { | |
197 | cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits " | |
198 | << GetName() << " from " << folder->GetName() << endl ; | |
199 | sdigArray->AddAt(sdigits, input) ; | |
200 | input++ ; | |
201 | } | |
202 | ||
203 | //Find the first crystall with sygnal | |
204 | Int_t nextSig = 200000 ; | |
205 | Int_t i; | |
206 | for(i=0; i<input; i++){ | |
207 | sdigits = (TClonesArray *)sdigArray->At(i) ; | |
208 | Int_t curNext = ((AliPHOSDigit *)sdigits->At(0))->GetId() ; | |
209 | if(curNext < nextSig) nextSig = curNext ; | |
210 | } | |
211 | ||
212 | TArrayF * energies = new TArrayF(input); | |
213 | TArrayF * times = new TArrayF(input) ; | |
214 | TArrayI index(input) ; | |
215 | index.Reset() ; //Set all indexes to zero | |
216 | ||
217 | AliPHOSDigit * digit ; | |
218 | AliPHOSDigit * curSDigit ; | |
219 | ||
220 | //Put Noise contribution | |
221 | for(absID = 1; absID <= nEMC; absID++){ | |
222 | Float_t noise = gRandom->Gaus(0., fPinNoise) ; | |
223 | new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ; | |
224 | //look if we have to add signal? | |
225 | if(absID==nextSig){ | |
226 | //Add SDigits from all inputs | |
227 | digit = (AliPHOSDigit *) digits->At(absID-1) ; | |
228 | Int_t contrib = 0 ; | |
229 | energies[contrib] = digit->GetAmp() ; | |
230 | times[contrib] = digit->GetTime() ; | |
231 | //loop over inputs | |
232 | for(i=0; i<input; i++){ | |
233 | curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ; | |
234 | //May be several digits will contribute from the same input | |
235 | while(curSDigit && curSDigit->GetId() == absID){ | |
236 | //Shift primary to separate primaries belonging different inputs | |
237 | Int_t primaryoffset ; | |
238 | if(fARD) | |
239 | primaryoffset = fARD->GetMask(i) ; | |
240 | else | |
241 | primaryoffset = 10000000*i ; | |
242 | curSDigit->ShiftPrimary(primaryoffset) ; | |
243 | ||
244 | *digit = *digit + *curSDigit ; //add energies | |
245 | energies[contrib] = curSDigit->GetAmp() ; | |
246 | times[contrib] = curSDigit->GetTime() ; | |
247 | contrib++ ; | |
248 | index[i]++ ; | |
249 | curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ; | |
250 | } | |
251 | } | |
252 | ||
253 | //calculate and set time | |
254 | Float_t time = FrontEdgeTime(energies, times) ; | |
255 | digit->SetTime(time) ; | |
256 | energies->Reset() ; | |
257 | times->Reset() ; | |
258 | //Find next signal module | |
259 | for(i=0; i<input; i++){ | |
260 | sdigits = ((TClonesArray *)sdigArray->At(i)) ; | |
261 | Int_t curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ; | |
262 | if(curNext < nextSig) nextSig = curNext ; | |
263 | } | |
264 | } | |
265 | } | |
266 | ||
267 | ||
268 | ||
269 | //Now CPV digits (different noise and no timing) | |
270 | for(absID = nEMC+1; absID <= nCPV; absID++){ | |
271 | Float_t noise = gRandom->Gaus(0., fCPVNoise) ; | |
272 | new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ; | |
273 | //look if we have to add signal? | |
274 | if(absID==nextSig){ | |
275 | digit = (AliPHOSDigit *) digits->At(absID-1) ; | |
276 | //Add SDigits from all inputs | |
277 | for(i=0; i<input; i++){ | |
278 | curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ; | |
279 | //May be several digits will contribute from the same input | |
280 | while(curSDigit && curSDigit->GetId() == absID){ | |
281 | //Shift primary to separate primaries belonging different inputs | |
282 | Int_t primaryoffset ; | |
283 | if(fARD) | |
284 | primaryoffset = fARD->GetMask(i) ; | |
285 | else | |
286 | primaryoffset = 10000000*i ; | |
287 | curSDigit->ShiftPrimary(primaryoffset) ; | |
288 | ||
289 | //add energies | |
290 | *digit = *digit + *curSDigit ; | |
291 | index[i]++ ; | |
292 | curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ; | |
293 | } | |
294 | } | |
295 | ||
296 | //Find next signal module | |
297 | for(i=0; i<input; i++){ | |
298 | sdigits = (TClonesArray *)sdigArray->At(i) ; | |
299 | Int_t curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ; | |
300 | if(curNext < nextSig) nextSig = curNext ; | |
301 | } | |
302 | ||
303 | } | |
304 | } | |
305 | delete energies ; | |
306 | delete times ; | |
307 | delete sdigArray ; //We should not delete its contents | |
308 | ||
309 | ||
310 | ||
311 | //remove digits below thresholds | |
312 | for(absID = 0; absID < nEMC ; absID++) | |
313 | if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fEMCDigitThreshold) | |
314 | digits->RemoveAt(absID) ; | |
315 | ||
316 | for(absID = nEMC; absID < nCPV ; absID++) | |
317 | if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fCPVDigitThreshold) | |
318 | digits->RemoveAt(absID) ; | |
319 | ||
320 | digits->Compress() ; | |
321 | ||
322 | Int_t ndigits = digits->GetEntriesFast() ; | |
323 | digits->Expand(ndigits) ; | |
324 | ||
325 | //Set indexes in list of digits | |
326 | for (i = 0 ; i < ndigits ; i++) { | |
327 | AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ; | |
328 | digit->SetIndexInList(i) ; | |
329 | } | |
330 | ||
331 | } | |
332 | ||
333 | //____________________________________________________________________________ | |
334 | void AliPHOSDigitizer::Exec(Option_t *option) | |
335 | { | |
336 | // Managing method | |
337 | ||
338 | if( strcmp(GetName(), "") == 0 ) | |
339 | Init() ; | |
340 | ||
341 | if (strstr(option,"print")) { | |
342 | Print(""); | |
343 | return ; | |
344 | } | |
345 | ||
346 | if(strstr(option,"tim")) | |
347 | gBenchmark->Start("PHOSDigitizer"); | |
348 | ||
349 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; | |
350 | ||
351 | Int_t nevents ; | |
352 | ||
353 | TTree * treeD ; | |
354 | ||
355 | if(fARD){ | |
356 | treeD = fARD->GetTreeD() ; | |
357 | nevents = 1 ; // Will process only one event | |
358 | } | |
359 | else { | |
360 | gAlice->GetEvent(0) ; | |
361 | nevents = (Int_t) gAlice->TreeE()->GetEntries() ; | |
362 | treeD=gAlice->TreeD() ; | |
363 | } | |
364 | if(treeD == 0 ){ | |
365 | cerr << " AliPHOSDigitizer :: Can not find TreeD " << endl ; | |
366 | return ; | |
367 | } | |
368 | ||
369 | //Check, if this branch already exits | |
370 | TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ; | |
371 | TIter next(lob) ; | |
372 | TBranch * branch = 0 ; | |
373 | Bool_t phosfound = kFALSE, digitizerfound = kFALSE ; | |
374 | ||
375 | while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) { | |
376 | if ( (strcmp(branch->GetName(), "PHOS")==0) && | |
377 | (strcmp(branch->GetTitle(), GetName())==0) ) | |
378 | phosfound = kTRUE ; | |
379 | ||
380 | else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && | |
381 | (strcmp(branch->GetTitle(), GetName())==0) ) | |
382 | digitizerfound = kTRUE ; | |
383 | } | |
384 | ||
385 | if ( phosfound ) { | |
386 | cerr << "WARNING: AliPHOSDigitizer -> Digits branch with name " << GetName() | |
387 | << " already exits" << endl ; | |
388 | return ; | |
389 | } | |
390 | if ( digitizerfound ) { | |
391 | cerr << "WARNING: AliPHOSDigitizer -> Digitizer branch with name " << GetName() | |
392 | << " already exits" << endl ; | |
393 | return ; | |
394 | } | |
395 | ||
396 | Int_t ievent ; | |
397 | ||
398 | for(ievent = 0; ievent < nevents; ievent++){ | |
399 | ||
400 | if(fARD){ | |
401 | Int_t input ; | |
402 | for(input = 0 ; input < fARD->GetNinputs(); input ++){ | |
403 | TTree * treeS = fARD->GetInputTreeS(input) ; | |
404 | if(!treeS){ | |
405 | cerr << "AliPHOSDigitizer -> No Input " << endl ; | |
406 | return ; | |
407 | } | |
408 | gime->ReadTreeS(treeS,input) ; | |
409 | } | |
410 | } | |
411 | else | |
412 | gime->Event(ievent,"S") ; | |
413 | ||
414 | Digitize(ievent) ; //Add prepared SDigits to digits and add the noise | |
415 | ||
416 | WriteDigits(ievent) ; | |
417 | ||
418 | if(strstr(option,"deb")) | |
419 | PrintDigits(option); | |
420 | } | |
421 | ||
422 | if(strstr(option,"tim")){ | |
423 | gBenchmark->Stop("PHOSDigitizer"); | |
424 | cout << "AliPHOSDigitizer:" << endl ; | |
425 | cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for Digitizing " | |
426 | << gBenchmark->GetCpuTime("PHOSDigitizer")/nevents << " seconds per event " << endl ; | |
427 | cout << endl ; | |
428 | } | |
429 | ||
430 | } | |
431 | ||
432 | //____________________________________________________________________________ | |
433 | Float_t AliPHOSDigitizer::FrontEdgeTime(TArrayF * energies, TArrayF * times) | |
434 | { // | |
435 | Float_t curtime = times->At(0) ; | |
436 | Float_t time = curtime ; | |
437 | Int_t i = 1 ; | |
438 | while(curtime){ | |
439 | if(time > curtime) time = curtime ; | |
440 | curtime = times->At(i++) ; | |
441 | } | |
442 | return time ; | |
443 | ||
444 | } | |
445 | //____________________________________________________________________________ | |
446 | Bool_t AliPHOSDigitizer::Init() | |
447 | { | |
448 | // Makes all memory allocations | |
449 | // Adds Digitizer task to the folder of PHOS tasks | |
450 | //============================================================= YS | |
451 | // The initialisation is now done by AliPHOSGetter | |
452 | ||
453 | if( strcmp(GetTitle(), "") == 0 ) | |
454 | SetTitle("galice.root") ; | |
455 | ||
456 | // the SDigits name is stored by AliPHOSGetter as the name of the TClones Array | |
457 | // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/branchname and has branchTitle as title. | |
458 | ||
459 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ; | |
460 | if ( gime == 0 ) { | |
461 | cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ; | |
462 | return kFALSE; | |
463 | } | |
464 | ||
465 | // create a folder on the white board //YSAlice/WhiteBoard/Digits/PHOS/headerFile/digitsTitle | |
466 | gime->PostDigits(GetName() ) ; | |
467 | ||
468 | //add Task to //YSAlice/tasks/Digitizer/PHOS | |
469 | gime->PostDigitizer(this) ; | |
470 | ||
471 | //Mark that we will use current header file | |
472 | if(!fARD){ | |
473 | gime->PostSDigits(GetName(),GetTitle()) ; | |
474 | gime->PostSDigitizer(GetName(),GetTitle()) ; | |
475 | } | |
476 | return kTRUE ; | |
477 | } | |
478 | ||
479 | //__________________________________________________________________ | |
480 | void AliPHOSDigitizer::MixWith(const char* headerFile) | |
481 | { | |
482 | // Allows to produce digits by superimposing background and signal event. | |
483 | // It is assumed, that headers file with SIGNAL events is opened in | |
484 | // the constructor. | |
485 | // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed | |
486 | // Thus we avoid writing (changing) huge and expensive | |
487 | // backgound files: all output will be writen into SIGNAL, i.e. | |
488 | // opened in constructor file. | |
489 | // | |
490 | // One can open as many files to mix with as one needs. | |
491 | // However only Sdigits with the same name (i.e. constructed with the same SDigitizer) | |
492 | // can be mixed. | |
493 | ||
494 | if( strcmp(GetName(), "") == 0 ) | |
495 | Init() ; | |
496 | ||
497 | if(fARD){ | |
498 | cout << "Can not use this method under AliRunDigitizer " << endl ; | |
499 | return ; | |
500 | } | |
501 | ||
502 | // check if the specified SDigits do not already exist on the White Board: | |
503 | // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/sDigitsTitle | |
504 | ||
505 | TString path = "YSAlice/WhiteBoard/SDigits/PHOS/" ; | |
506 | path += headerFile ; | |
507 | path += "/" ; | |
508 | path += GetName() ; | |
509 | if ( gROOT->FindObjectAny(path.Data()) ) { | |
510 | cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ; | |
511 | return; | |
512 | } | |
513 | ||
514 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; | |
515 | gime->PostSDigits(GetName(),headerFile) ; | |
516 | ||
517 | // check if the requested file is already open or exist and if SDigits Branch exist | |
518 | TFile * file = (TFile*)gROOT->FindObject(headerFile); | |
519 | if ( !file ) { | |
520 | file = new TFile(headerFile, "READ") ; | |
521 | if (!file) { | |
522 | cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ; | |
523 | return ; | |
524 | } | |
525 | } | |
526 | ||
527 | } | |
528 | ||
529 | //__________________________________________________________________ | |
530 | void AliPHOSDigitizer::Print(Option_t* option)const { | |
531 | // Print Digitizer's parameters | |
532 | if( strcmp(GetName(), "") != 0 ){ | |
533 | ||
534 | cout << "------------------- "<< GetName() << " -------------" << endl ; | |
535 | cout << "Digitizing sDigits from file(s): " <<endl ; | |
536 | ||
537 | TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; | |
538 | TIter next(folderslist) ; | |
539 | TFolder * folder = 0 ; | |
540 | ||
541 | while ( (folder = (TFolder*)next()) ) { | |
542 | if ( folder->FindObject(GetName()) ) | |
543 | cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; | |
544 | } | |
545 | cout << endl ; | |
546 | cout << "Writing digits to " << GetTitle() << endl ; | |
547 | ||
548 | cout << endl ; | |
549 | cout << "With following parameters: " << endl ; | |
550 | cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ; | |
551 | cout << " Threshold in EMC (fEMCDigitThreshold) = " << fEMCDigitThreshold << endl ; ; | |
552 | cout << " Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ; | |
553 | cout << " Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ; | |
554 | cout << "---------------------------------------------------" << endl ; | |
555 | } | |
556 | else | |
557 | cout << "AliPHOSDigitizer not initialized " << endl ; | |
558 | ||
559 | } | |
560 | ||
561 | //__________________________________________________________________ | |
562 | void AliPHOSDigitizer::PrintDigits(Option_t * option){ | |
563 | // Print a table of digits | |
564 | ||
565 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; | |
566 | TClonesArray * digits = gime->Digits() ; | |
567 | ||
568 | cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ; | |
569 | cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ; | |
570 | cout << endl ; | |
571 | if(strstr(option,"all")||strstr(option,"EMC")){ | |
572 | ||
573 | //loop over digits | |
574 | AliPHOSDigit * digit; | |
575 | cout << "Digit Id Amplitude Index " << " Nprim " << " Primaries list " << endl; | |
576 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; | |
577 | Int_t index ; | |
578 | for (index = 0 ; (index < digits->GetEntries()) && | |
579 | (((AliPHOSDigit * ) digits->At(index))->GetId() <= maxEmc) ; index++) { | |
580 | digit = (AliPHOSDigit * ) digits->At(index) ; | |
581 | if(digit->GetNprimary() == 0) continue; | |
582 | cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " " | |
583 | << setw(6) << digit->GetIndexInList() << " " | |
584 | << setw(5) << digit->GetNprimary() <<" "; | |
585 | ||
586 | Int_t iprimary; | |
587 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) | |
588 | cout << setw(5) << digit->GetPrimary(iprimary+1) << " "; | |
589 | cout << endl; | |
590 | } | |
591 | cout << endl; | |
592 | } | |
593 | ||
594 | if(strstr(option,"all")||strstr(option,"CPV")){ | |
595 | ||
596 | //loop over CPV digits | |
597 | AliPHOSDigit * digit; | |
598 | cout << "Digit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl; | |
599 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; | |
600 | Int_t index ; | |
601 | for (index = 0 ; index < digits->GetEntries(); index++) { | |
602 | digit = (AliPHOSDigit * ) digits->At(index) ; | |
603 | if(digit->GetId() > maxEmc){ | |
604 | cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " " | |
605 | << setw(6) << digit->GetIndexInList() << " " | |
606 | << setw(5) << digit->GetNprimary() <<" "; | |
607 | ||
608 | Int_t iprimary; | |
609 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) | |
610 | cout << setw(5) << digit->GetPrimary(iprimary+1) << " "; | |
611 | cout << endl; | |
612 | } | |
613 | } | |
614 | } | |
615 | ||
616 | } | |
617 | ||
618 | //__________________________________________________________________ | |
619 | void AliPHOSDigitizer::SetSDigitsBranch(const char* title) | |
620 | { | |
621 | // we set title (comment) of the SDigits branch in the first! header file | |
622 | if( strcmp(GetName(), "") == 0 ) | |
623 | Init() ; | |
624 | ||
625 | AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ; | |
626 | ||
627 | } | |
628 | //__________________________________________________________________ | |
629 | Float_t AliPHOSDigitizer::TimeOfNoise(void) | |
630 | { // Calculates the time signal generated by noise | |
631 | //to be rewritten, now returns just big number | |
632 | return 1. ; | |
633 | ||
634 | } | |
635 | //____________________________________________________________________________ | |
636 | void AliPHOSDigitizer::Reset() | |
637 | { | |
638 | // sets current event number to the first simulated event | |
639 | ||
640 | if( strcmp(GetName(), "") == 0 ) | |
641 | Init() ; | |
642 | ||
643 | // Int_t inputs ; | |
644 | // for(inputs = 0; inputs < fNinputs ;inputs++) | |
645 | // fIevent->AddAt(-1, inputs ) ; | |
646 | ||
647 | } | |
648 | ||
649 | //____________________________________________________________________________ | |
650 | void AliPHOSDigitizer::WriteDigits(Int_t event) | |
651 | { | |
652 | ||
653 | // Makes TreeD in the output file. | |
654 | // Check if branch already exists: | |
655 | // if yes, exit without writing: ROOT TTree does not support overwriting/updating of | |
656 | // already existing branches. | |
657 | // else creates branch with Digits, named "PHOS", title "...", | |
658 | // and branch "AliPHOSDigitizer", with the same title to keep all the parameters | |
659 | // and names of files, from which digits are made. | |
660 | ||
661 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; | |
662 | TClonesArray * digits = gime->Digits(GetName()) ; | |
663 | ||
664 | TTree * treeD ; | |
665 | ||
666 | if(fARD) | |
667 | treeD = fARD->GetTreeD() ; | |
668 | else | |
669 | treeD = gAlice->TreeD(); | |
670 | ||
671 | // create new branches | |
672 | // -- generate file name if necessary | |
673 | char * file =0; | |
674 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name | |
675 | file = new char[strlen(gAlice->GetBaseFile())+20] ; | |
676 | sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ; | |
677 | } | |
678 | ||
679 | TDirectory *cwd = gDirectory; | |
680 | // -- create Digits branch | |
681 | Int_t bufferSize = 32000 ; | |
682 | TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize); | |
683 | digitsBranch->SetTitle(GetName()); | |
684 | if (file) { | |
685 | digitsBranch->SetFile(file); | |
686 | TIter next( digitsBranch->GetListOfBranches()); | |
687 | TBranch * sbr ; | |
688 | while ((sbr=(TBranch*)next())) { | |
689 | sbr->SetFile(file); | |
690 | } | |
691 | cwd->cd(); | |
692 | } | |
693 | ||
694 | // -- Create Digitizer branch | |
695 | Int_t splitlevel = 0 ; | |
696 | AliPHOSDigitizer * d = gime->Digitizer(GetName()) ; | |
697 | TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel); | |
698 | digitizerBranch->SetTitle(GetName()); | |
699 | if (file) { | |
700 | digitizerBranch->SetFile(file); | |
701 | TIter next( digitizerBranch->GetListOfBranches()); | |
702 | TBranch * sbr; | |
703 | while ((sbr=(TBranch*)next())) { | |
704 | sbr->SetFile(file); | |
705 | } | |
706 | cwd->cd(); | |
707 | } | |
708 | ||
709 | digitsBranch->Fill() ; | |
710 | digitizerBranch->Fill() ; | |
711 | ||
712 | treeD->Write(0,kOverwrite) ; | |
713 | ||
714 | } |