]>
Commit | Line | Data |
---|---|---|
990119d6 | 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 | ||
702ab87e | 18 | /* History of cvs commits: |
19 | * | |
20 | * $Log$ | |
8661738e | 21 | * Revision 1.100 2007/10/10 09:05:10 schutz |
22 | * Changing name QualAss to QA | |
23 | * | |
b8274834 | 24 | * Revision 1.99 2007/09/30 17:08:20 schutz |
25 | * Introducing the notion of QA data acquisition cycle (needed by online) | |
26 | * | |
5b188f2f | 27 | * Revision 1.98 2007/09/26 14:22:17 cvetan |
28 | * Important changes to the reconstructor classes. Complete elimination of the run-loaders, which are now steered only from AliReconstruction. Removal of the corresponding Reconstruct() and FillESD() methods. | |
29 | * | |
d76c31f4 | 30 | * Revision 1.97 2007/08/07 14:12:03 kharlov |
31 | * Quality assurance added (Yves Schutz) | |
32 | * | |
ddd1a39c | 33 | * Revision 1.96 2007/04/28 10:43:36 policheh |
34 | * Dead channels simulation: digit energy sets to 0. | |
35 | * | |
1c6a163f | 36 | * Revision 1.95 2007/04/10 07:20:52 kharlov |
37 | * Decalibration should use the same CDB as calibration in AliPHOSClusterizerv1 | |
38 | * | |
1a197b77 | 39 | * Revision 1.94 2007/02/01 10:34:47 hristov |
40 | * Removing warnings on Solaris x86 | |
41 | * | |
ad4aeaf4 | 42 | * Revision 1.93 2006/10/17 13:17:01 kharlov |
43 | * Replace AliInfo by AliDebug | |
44 | * | |
d6e8d7d3 | 45 | * Revision 1.92 2006/08/28 10:01:56 kharlov |
46 | * Effective C++ warnings fixed (Timur Pocheptsov) | |
47 | * | |
3663622c | 48 | * Revision 1.91 2006/04/29 20:25:30 hristov |
49 | * Decalibration is implemented (Yu.Kharlov) | |
50 | * | |
877695e7 | 51 | * Revision 1.90 2006/04/22 10:30:17 hristov |
52 | * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov) | |
53 | * | |
27a73a5d | 54 | * Revision 1.89 2006/04/11 15:22:59 hristov |
55 | * run number in query set to -1: forces AliCDBManager to use its run number (A.Colla) | |
56 | * | |
28871337 | 57 | * Revision 1.88 2006/03/13 14:05:43 kharlov |
58 | * Calibration objects for EMC and CPV | |
59 | * | |
fc6706cb | 60 | * Revision 1.87 2005/08/24 15:33:49 kharlov |
61 | * Calibration data for raw digits | |
62 | * | |
a8ec0771 | 63 | * Revision 1.86 2005/07/12 20:07:35 hristov |
64 | * Changes needed to run simulation and reconstrruction in the same AliRoot session | |
65 | * | |
7c193632 | 66 | * Revision 1.85 2005/05/28 14:19:04 schutz |
67 | * Compilation warnings fixed by T.P. | |
68 | * | |
702ab87e | 69 | */ |
88cb7938 | 70 | |
990119d6 | 71 | //_________________________________________________________________________ |
990119d6 | 72 | //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute) |
73 | ////////////////////////////////////////////////////////////////////////////// | |
a4e98857 | 74 | // This TTask performs digitization of Summable digits (in the PHOS case it is just |
75 | // the sum of contributions from all primary particles into a given cell). | |
990119d6 | 76 | // In addition it performs mixing of summable digits from different events. |
7b7c1533 | 77 | // The name of the TTask is also the title of the branch that will contain |
78 | // the created SDigits | |
79 | // The title of the TTAsk is the name of the file that contains the hits from | |
80 | // which the SDigits are created | |
bca3b32a | 81 | // |
82 | // For each event two branches are created in TreeD: | |
83 | // "PHOS" - list of digits | |
84 | // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization | |
85 | // | |
a4e98857 | 86 | // Note, that one can set a title for new digits branch, and repeat digitization with |
bca3b32a | 87 | // another set of parameters. |
88 | // | |
a4e98857 | 89 | // Use case: |
990119d6 | 90 | // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ; |
91 | // root[1] d->ExecuteTask() | |
92 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
93 | // //Digitizes SDigitis in all events found in file galice.root | |
bca3b32a | 94 | // |
8cb3533f | 95 | // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ; |
96 | // // Will read sdigits from galice1.root | |
97 | // root[3] d1->MixWith("galice2.root") | |
990119d6 | 98 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
a4e98857 | 99 | // // Reads another set of sdigits from galice2.root |
8cb3533f | 100 | // root[3] d1->MixWith("galice3.root") |
a4e98857 | 101 | // // Reads another set of sdigits from galice3.root |
8cb3533f | 102 | // root[4] d->ExecuteTask("deb timing") |
103 | // // Reads SDigits from files galice1.root, galice2.root .... | |
104 | // // mixes them and stores produced Digits in file galice1.root | |
105 | // // deb - prints number of produced digits | |
106 | // // deb all - prints list of produced digits | |
107 | // // timing - prints time used for digitization | |
990119d6 | 108 | // |
990119d6 | 109 | |
110 | // --- ROOT system --- | |
990119d6 | 111 | #include "TTree.h" |
112 | #include "TSystem.h" | |
8cb3533f | 113 | #include "TBenchmark.h" |
e957fea8 | 114 | #include "TRandom.h" |
ba54256b | 115 | |
990119d6 | 116 | // --- Standard library --- |
117 | ||
118 | // --- AliRoot header files --- | |
351dd634 | 119 | #include "AliLog.h" |
3f81a70b | 120 | #include "AliRunDigitizer.h" |
990119d6 | 121 | #include "AliPHOSDigit.h" |
7b7c1533 | 122 | #include "AliPHOSGetter.h" |
990119d6 | 123 | #include "AliPHOSDigitizer.h" |
124 | #include "AliPHOSSDigitizer.h" | |
8cb3533f | 125 | #include "AliPHOSGeometry.h" |
7437a0f7 | 126 | #include "AliPHOSTick.h" |
b8274834 | 127 | #include "AliPHOSQADataMaker.h" |
990119d6 | 128 | |
129 | ClassImp(AliPHOSDigitizer) | |
130 | ||
131 | ||
132 | //____________________________________________________________________________ | |
3663622c | 133 | AliPHOSDigitizer::AliPHOSDigitizer() : |
134 | AliDigitizer("",""), | |
135 | fDefaultInit(kTRUE), | |
136 | fDigitsInRun(0), | |
137 | fInit(kFALSE), | |
138 | fInput(0), | |
139 | fInputFileNames(0x0), | |
140 | fEventNames(0x0), | |
141 | fEmcCrystals(0), | |
142 | fPinNoise(0.f), | |
143 | fEMCDigitThreshold(0.f), | |
144 | fCPVNoise(0.f), | |
145 | fCPVDigitThreshold(0.f), | |
146 | fTimeResolution(0.f), | |
147 | fTimeThreshold(0.f), | |
148 | fTimeSignalLength(0.f), | |
149 | fADCchanelEmc(0.f), | |
150 | fADCpedestalEmc(0.f), | |
151 | fNADCemc(0), | |
152 | fADCchanelCpv(0.f), | |
153 | fADCpedestalCpv(0.f), | |
154 | fNADCcpv(0), | |
155 | fEventFolderName(""), | |
156 | fFirstEvent(0), | |
ddd1a39c | 157 | fLastEvent(0), |
158 | fQADM (0x0), | |
159 | fEventCounter(0) | |
990119d6 | 160 | { |
161 | // ctor | |
8d0f3f77 | 162 | InitParameters() ; |
fbf811ec | 163 | fManager = 0 ; // We work in the standalong mode |
88cb7938 | 164 | } |
3f81a70b | 165 | |
166 | //____________________________________________________________________________ | |
e191bb57 | 167 | AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName, |
168 | TString eventFolderName): | |
3663622c | 169 | AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(), alirunFileName), |
170 | fDefaultInit(kFALSE), | |
171 | fDigitsInRun(0), | |
172 | fInit(kFALSE), | |
173 | fInput(0), | |
174 | fInputFileNames(0x0), | |
175 | fEventNames(0x0), | |
176 | fEmcCrystals(0), | |
177 | fPinNoise(0.f), | |
178 | fEMCDigitThreshold(0.f), | |
179 | fCPVNoise(0.f), | |
180 | fCPVDigitThreshold(0.f), | |
181 | fTimeResolution(0.f), | |
182 | fTimeThreshold(0.f), | |
183 | fTimeSignalLength(0.f), | |
184 | fADCchanelEmc(0.f), | |
185 | fADCpedestalEmc(0.f), | |
186 | fNADCemc(0), | |
187 | fADCchanelCpv(0.f), | |
188 | fADCpedestalCpv(0.f), | |
189 | fNADCcpv(0), | |
190 | fEventFolderName(eventFolderName), | |
191 | fFirstEvent(0), | |
ddd1a39c | 192 | fLastEvent(0), |
193 | fQADM (0x0), | |
194 | fEventCounter(0) | |
3f81a70b | 195 | { |
196 | // ctor | |
8d0f3f77 | 197 | InitParameters() ; |
3f81a70b | 198 | Init() ; |
92f521a9 | 199 | fDefaultInit = kFALSE ; |
88cb7938 | 200 | fManager = 0 ; // We work in the standalong mode |
ddd1a39c | 201 | //Initialize the quality assurance data maker only once |
b8274834 | 202 | fQADM = new AliPHOSQADataMaker() ; |
5b188f2f | 203 | //FIXME: get the run number |
204 | Int_t run = 0 ; | |
205 | //EMXIF | |
b8274834 | 206 | GetQADataMaker()->Init(AliQA::kDIGITS, run, fgkCycles) ; |
207 | GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ; | |
88cb7938 | 208 | } |
209 | ||
210 | //____________________________________________________________________________ | |
3663622c | 211 | AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d) : |
212 | AliDigitizer(d), | |
213 | fDefaultInit(d.fDefaultInit), | |
214 | fDigitsInRun(d.fDigitsInRun), | |
215 | fInit(d.fInit), | |
216 | fInput(d.fInput), | |
217 | fInputFileNames(0x0),//? | |
218 | fEventNames(0x0),//? | |
219 | fEmcCrystals(d.fEmcCrystals), | |
220 | fPinNoise(d.fPinNoise), | |
221 | fEMCDigitThreshold(d.fEMCDigitThreshold), | |
222 | fCPVNoise(d.fCPVNoise), | |
223 | fCPVDigitThreshold(d.fCPVDigitThreshold), | |
224 | fTimeResolution(d.fTimeResolution), | |
225 | fTimeThreshold(d.fTimeThreshold), | |
226 | fTimeSignalLength(d.fTimeSignalLength), | |
227 | fADCchanelEmc(d.fADCchanelEmc), | |
228 | fADCpedestalEmc(d.fADCpedestalEmc), | |
229 | fNADCemc(d.fNADCemc), | |
230 | fADCchanelCpv(d.fADCchanelCpv), | |
231 | fADCpedestalCpv(d.fADCpedestalCpv), | |
232 | fNADCcpv(d.fNADCcpv), | |
233 | fEventFolderName(d.fEventFolderName), | |
234 | fFirstEvent(d.fFirstEvent), | |
ddd1a39c | 235 | fLastEvent(d.fLastEvent), |
236 | fQADM (d.fQADM), | |
237 | fEventCounter(0) | |
238 | ||
88cb7938 | 239 | { |
240 | // copyy ctor | |
88cb7938 | 241 | SetName(d.GetName()) ; |
242 | SetTitle(d.GetTitle()) ; | |
ddd1a39c | 243 | //Initialize the quality assurance data maker only once |
5b188f2f | 244 | //FIXME: get the run number |
245 | Int_t run = 0 ; | |
246 | //EMXIF | |
b8274834 | 247 | GetQADataMaker()->Init(AliQA::kDIGITS, run, fgkCycles) ; |
248 | GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ; | |
990119d6 | 249 | } |
250 | ||
990119d6 | 251 | //____________________________________________________________________________ |
3663622c | 252 | AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd) : |
253 | AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()), | |
254 | fDefaultInit(kFALSE), | |
255 | fDigitsInRun(0), | |
256 | fInit(kFALSE), | |
257 | fInput(0), | |
258 | fInputFileNames(0x0), | |
259 | fEventNames(0x0), | |
260 | fEmcCrystals(0), | |
261 | fPinNoise(0.f), | |
262 | fEMCDigitThreshold(0.f), | |
263 | fCPVNoise(0.f), | |
264 | fCPVDigitThreshold(0.f), | |
265 | fTimeResolution(0.f), | |
266 | fTimeThreshold(0.f), | |
267 | fTimeSignalLength(0.f), | |
268 | fADCchanelEmc(0.f), | |
269 | fADCpedestalEmc(0.f), | |
270 | fNADCemc(0), | |
271 | fADCchanelCpv(0.f), | |
272 | fADCpedestalCpv(0.f), | |
273 | fNADCcpv(0), | |
274 | fEventFolderName(fManager->GetInputFolderName(0)), | |
275 | fFirstEvent(0), | |
ddd1a39c | 276 | fLastEvent(0), |
277 | fQADM (0x0), | |
278 | fEventCounter(0) | |
279 | ||
990119d6 | 280 | { |
45fa49ca | 281 | // ctor Init() is called by RunDigitizer |
88cb7938 | 282 | fManager = rd ; |
88cb7938 | 283 | SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0)); |
b22e4735 | 284 | InitParameters() ; |
fbf811ec | 285 | fDefaultInit = kFALSE ; |
ddd1a39c | 286 | //Initialize the quality assurance data maker only once |
b8274834 | 287 | fQADM = new AliPHOSQADataMaker() ; |
5b188f2f | 288 | //FIXME: get the run number |
289 | Int_t run = 0 ; | |
290 | //EMXIF | |
b8274834 | 291 | GetQADataMaker()->Init(AliQA::kDIGITS, run) ; |
292 | GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ; | |
990119d6 | 293 | } |
294 | ||
295 | //____________________________________________________________________________ | |
296 | AliPHOSDigitizer::~AliPHOSDigitizer() | |
297 | { | |
7c193632 | 298 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; |
299 | ||
300 | // Clean Digitizer from the white board | |
301 | gime->PhosLoader()->CleanDigitizer() ; | |
990119d6 | 302 | // dtor |
88cb7938 | 303 | delete [] fInputFileNames ; |
304 | delete [] fEventNames ; | |
ddd1a39c | 305 | |
306 | delete fQADM ; | |
307 | ||
990119d6 | 308 | } |
309 | ||
310 | //____________________________________________________________________________ | |
fc7e2f43 | 311 | void AliPHOSDigitizer::Digitize(Int_t event) |
a4e98857 | 312 | { |
313 | ||
314 | // Makes the digitization of the collected summable digits. | |
315 | // It first creates the array of all PHOS modules | |
dc986a1d | 316 | // filled with noise (different for EMC, and CPV) and |
a4e98857 | 317 | // then adds contributions from SDigits. |
318 | // This design avoids scanning over the list of digits to add | |
319 | // contribution to new SDigits only. | |
990119d6 | 320 | |
f98c06a1 | 321 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; |
45fa49ca | 322 | Int_t ReadEvent = event ; |
323 | if (fManager) | |
324 | ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ; | |
d6e8d7d3 | 325 | AliDebug(1,Form("Adding event %d from input stream 0 %s %s", |
326 | ReadEvent, GetTitle(), fEventFolderName.Data())) ; | |
45fa49ca | 327 | gime->Event(ReadEvent, "S") ; |
88cb7938 | 328 | TClonesArray * digits = gime->Digits() ; |
7b7c1533 | 329 | digits->Clear() ; |
990119d6 | 330 | |
7b7c1533 | 331 | const AliPHOSGeometry *geom = gime->PHOSGeometry() ; |
990119d6 | 332 | //Making digits with noise, first EMC |
333 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); | |
334 | ||
335 | Int_t nCPV ; | |
990119d6 | 336 | Int_t absID ; |
990119d6 | 337 | |
88cb7938 | 338 | nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ; |
339 | ||
9688c1dd | 340 | digits->Expand(nCPV) ; |
8cb3533f | 341 | |
88cb7938 | 342 | // get first the sdigitizer from the tasks list |
343 | if ( !gime->SDigitizer() ) | |
344 | gime->LoadSDigitizer(); | |
345 | AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(); | |
346 | ||
347 | if ( !sDigitizer ) | |
351dd634 | 348 | AliFatal(Form("SDigitizer with name %s %s not found", |
349 | GetTitle(), fEventFolderName.Data() )) ; | |
88cb7938 | 350 | |
351 | //take all the inputs to add together and load the SDigits | |
352 | TObjArray * sdigArray = new TObjArray(fInput) ; | |
353 | sdigArray->AddAt(gime->SDigits(), 0) ; | |
354 | Int_t i ; | |
355 | for(i = 1 ; i < fInput ; i++){ | |
356 | TString tempo(fEventNames[i]) ; | |
357 | tempo += i ; | |
ad4aeaf4 | 358 | AliPHOSGetter * gime1 = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ; |
45fa49ca | 359 | if (fManager) |
360 | ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ; | |
351dd634 | 361 | AliInfo(Form("Adding event %d from input stream %d %s %s", |
362 | ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ; | |
ad4aeaf4 | 363 | gime1->Event(ReadEvent,"S"); |
364 | sdigArray->AddAt(gime1->SDigits(), i) ; | |
38bb0fd5 | 365 | } |
9688c1dd | 366 | |
27a73a5d | 367 | //Find the first crystal with signal |
9688c1dd | 368 | Int_t nextSig = 200000 ; |
88cb7938 | 369 | TClonesArray * sdigits ; |
370 | for(i = 0 ; i < fInput ; i++){ | |
371 | sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ; | |
a6eedfad | 372 | if ( !sdigits->GetEntriesFast() ) |
7a9d98f9 | 373 | continue ; |
88cb7938 | 374 | Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ; |
375 | if(curNext < nextSig) | |
376 | nextSig = curNext ; | |
9688c1dd | 377 | } |
88cb7938 | 378 | |
379 | TArrayI index(fInput) ; | |
9688c1dd | 380 | index.Reset() ; //Set all indexes to zero |
88cb7938 | 381 | |
9688c1dd | 382 | AliPHOSDigit * digit ; |
383 | AliPHOSDigit * curSDigit ; | |
88cb7938 | 384 | |
7437a0f7 | 385 | TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ; |
88cb7938 | 386 | |
9688c1dd | 387 | //Put Noise contribution |
88cb7938 | 388 | for(absID = 1 ; absID <= nEMC ; absID++){ |
9688c1dd | 389 | Float_t noise = gRandom->Gaus(0., fPinNoise) ; |
27a73a5d | 390 | // YVK: do not digitize amplitudes for EMC |
391 | // new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ; | |
392 | new((*digits)[absID-1]) AliPHOSDigit( -1, absID, noise, TimeOfNoise() ) ; | |
9688c1dd | 393 | //look if we have to add signal? |
88cb7938 | 394 | digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ; |
395 | ||
9688c1dd | 396 | if(absID==nextSig){ |
397 | //Add SDigits from all inputs | |
7437a0f7 | 398 | ticks->Clear() ; |
9688c1dd | 399 | Int_t contrib = 0 ; |
27a73a5d | 400 | Float_t a = digit->GetEnergy() ; |
88cb7938 | 401 | Float_t b = TMath::Abs( a / fTimeSignalLength) ; |
402 | //Mark the beginning of the signal | |
7437a0f7 | 403 | new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b); |
27a73a5d | 404 | //Mark the end of the signal |
7437a0f7 | 405 | new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b); |
88cb7938 | 406 | |
9688c1dd | 407 | //loop over inputs |
88cb7938 | 408 | for(i = 0 ; i < fInput ; i++){ |
409 | if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] ) | |
410 | curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ; | |
5c9dfca0 | 411 | else |
412 | curSDigit = 0 ; | |
9688c1dd | 413 | //May be several digits will contribute from the same input |
414 | while(curSDigit && curSDigit->GetId() == absID){ | |
415 | //Shift primary to separate primaries belonging different inputs | |
416 | Int_t primaryoffset ; | |
9891b76e | 417 | if(fManager) |
418 | primaryoffset = fManager->GetMask(i) ; | |
9688c1dd | 419 | else |
21c293b7 | 420 | primaryoffset = 10000000*i ; |
421 | curSDigit->ShiftPrimary(primaryoffset) ; | |
7437a0f7 | 422 | |
27a73a5d | 423 | a = curSDigit->GetEnergy() ; |
7437a0f7 | 424 | b = a /fTimeSignalLength ; |
425 | new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b); | |
426 | new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); | |
88cb7938 | 427 | |
3663622c | 428 | *digit += *curSDigit ; //add energies |
27a73a5d | 429 | |
9688c1dd | 430 | index[i]++ ; |
88cb7938 | 431 | if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] ) |
432 | curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ; | |
5c9dfca0 | 433 | else |
434 | curSDigit = 0 ; | |
9688c1dd | 435 | } |
436 | } | |
88cb7938 | 437 | |
9688c1dd | 438 | //calculate and set time |
7437a0f7 | 439 | Float_t time = FrontEdgeTime(ticks) ; |
9688c1dd | 440 | digit->SetTime(time) ; |
88cb7938 | 441 | |
9688c1dd | 442 | //Find next signal module |
7437a0f7 | 443 | nextSig = 200000 ; |
88cb7938 | 444 | for(i = 0 ; i < fInput ; i++){ |
445 | sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ; | |
5c9dfca0 | 446 | Int_t curNext = nextSig ; |
447 | if(sdigits->GetEntriesFast() > index[i] ){ | |
88cb7938 | 448 | curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ; |
5c9dfca0 | 449 | } |
9688c1dd | 450 | if(curNext < nextSig) nextSig = curNext ; |
7b7c1533 | 451 | } |
452 | } | |
990119d6 | 453 | } |
3f81a70b | 454 | |
7437a0f7 | 455 | ticks->Delete() ; |
456 | delete ticks ; | |
88cb7938 | 457 | |
9688c1dd | 458 | //Now CPV digits (different noise and no timing) |
459 | for(absID = nEMC+1; absID <= nCPV; absID++){ | |
460 | Float_t noise = gRandom->Gaus(0., fCPVNoise) ; | |
461 | new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ; | |
462 | //look if we have to add signal? | |
463 | if(absID==nextSig){ | |
88cb7938 | 464 | digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ; |
9688c1dd | 465 | //Add SDigits from all inputs |
88cb7938 | 466 | for(i = 0 ; i < fInput ; i++){ |
467 | if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] ) | |
468 | curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ; | |
5c9dfca0 | 469 | else |
470 | curSDigit = 0 ; | |
a6eedfad | 471 | |
9688c1dd | 472 | //May be several digits will contribute from the same input |
473 | while(curSDigit && curSDigit->GetId() == absID){ | |
474 | //Shift primary to separate primaries belonging different inputs | |
475 | Int_t primaryoffset ; | |
9891b76e | 476 | if(fManager) |
477 | primaryoffset = fManager->GetMask(i) ; | |
9688c1dd | 478 | else |
479 | primaryoffset = 10000000*i ; | |
480 | curSDigit->ShiftPrimary(primaryoffset) ; | |
481 | ||
482 | //add energies | |
3663622c | 483 | *digit += *curSDigit ; |
9688c1dd | 484 | index[i]++ ; |
88cb7938 | 485 | if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] ) |
486 | curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ; | |
5c9dfca0 | 487 | else |
488 | curSDigit = 0 ; | |
9688c1dd | 489 | } |
490 | } | |
a6eedfad | 491 | |
9688c1dd | 492 | //Find next signal module |
a6eedfad | 493 | nextSig = 200000 ; |
88cb7938 | 494 | for(i = 0 ; i < fInput ; i++){ |
495 | sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ; | |
5c9dfca0 | 496 | Int_t curNext = nextSig ; |
497 | if(sdigits->GetEntriesFast() > index[i] ) | |
88cb7938 | 498 | curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ; |
9688c1dd | 499 | if(curNext < nextSig) nextSig = curNext ; |
500 | } | |
501 | ||
502 | } | |
503 | } | |
88cb7938 | 504 | |
505 | delete sdigArray ; //We should not delete its contents | |
9688c1dd | 506 | |
990119d6 | 507 | //remove digits below thresholds |
88cb7938 | 508 | for(i = 0 ; i < nEMC ; i++){ |
548f0134 | 509 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ; |
877695e7 | 510 | DecalibrateEMC(digit); |
27a73a5d | 511 | if(digit->GetEnergy() < fEMCDigitThreshold) |
a6eedfad | 512 | digits->RemoveAt(i) ; |
aaf8a71c | 513 | else |
514 | digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ; | |
515 | } | |
516 | ||
a6eedfad | 517 | |
518 | for(i = nEMC; i < nCPV ; i++) | |
27a73a5d | 519 | // if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold ) |
520 | if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < fCPVDigitThreshold ) | |
a6eedfad | 521 | digits->RemoveAt(i) ; |
9688c1dd | 522 | |
7b7c1533 | 523 | digits->Compress() ; |
990119d6 | 524 | |
7b7c1533 | 525 | Int_t ndigits = digits->GetEntriesFast() ; |
7b7c1533 | 526 | digits->Expand(ndigits) ; |
990119d6 | 527 | |
3758d9fc | 528 | //Set indexes in list of digits and make true digitization of the energy |
990119d6 | 529 | for (i = 0 ; i < ndigits ; i++) { |
548f0134 | 530 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ; |
990119d6 | 531 | digit->SetIndexInList(i) ; |
27a73a5d | 532 | if(digit->GetId() > fEmcCrystals){ //digitize CPV only |
877695e7 | 533 | digit->SetAmp(DigitizeCPV(digit->GetEnergy(),digit->GetId()) ) ; |
27a73a5d | 534 | } |
990119d6 | 535 | } |
1c6a163f | 536 | |
537 | Int_t relId[4]; | |
538 | ||
539 | //set amplitudes in bad channels to zero | |
540 | for(i = 0 ; i <digits->GetEntries(); i++){ | |
541 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ; | |
542 | gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId); | |
543 | if(relId[1] == 0) // Emc | |
544 | if(gime->CalibData()->IsBadChannelEmc(relId[0],relId[3],relId[2])) digit->SetEnergy(0.); | |
545 | } | |
546 | ||
7b7c1533 | 547 | } |
548f0134 | 548 | |
3758d9fc | 549 | //____________________________________________________________________________ |
877695e7 | 550 | void AliPHOSDigitizer::DecalibrateEMC(AliPHOSDigit *digit) |
3758d9fc | 551 | { |
877695e7 | 552 | // Decalibrate EMC digit, i.e. change its energy by a factor read from CDB |
553 | ||
554 | AliPHOSGetter* gime = AliPHOSGetter::Instance(); | |
555 | ||
556 | if(!gime->CalibData()) { | |
557 | AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); | |
558 | gime->SetCalibData(cdb); | |
559 | } | |
560 | ||
561 | //Determine rel.position of the cell absolute ID | |
562 | Int_t relId[4]; | |
563 | gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId); | |
564 | Int_t module=relId[0]; | |
565 | Int_t row =relId[2]; | |
566 | Int_t column=relId[3]; | |
567 | Float_t decalibration = gime->CalibData()->GetADCchannelEmc(module,column,row); | |
1a197b77 | 568 | Float_t energy = digit->GetEnergy() / decalibration; |
877695e7 | 569 | digit->SetEnergy(energy); |
570 | } | |
571 | //____________________________________________________________________________ | |
572 | Int_t AliPHOSDigitizer::DigitizeCPV(Float_t charge, Int_t absId) | |
573 | { | |
574 | // Returns digitized value of the CPV charge in a pad absId | |
0bc3b8ed | 575 | |
a8ec0771 | 576 | AliPHOSGetter* gime = AliPHOSGetter::Instance(); |
577 | ||
fc6706cb | 578 | if(!gime->CalibData()) { |
28871337 | 579 | AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); // use AliCDBManager's run number |
fc6706cb | 580 | gime->SetCalibData(cdb); |
581 | } | |
582 | ||
a8ec0771 | 583 | //Determine rel.position of the cell absId |
584 | Int_t relId[4]; | |
585 | gime->PHOSGeometry()->AbsToRelNumbering(absId,relId); | |
586 | Int_t module=relId[0]; | |
27a73a5d | 587 | Int_t row =relId[2]; |
a8ec0771 | 588 | Int_t column=relId[3]; |
589 | ||
877695e7 | 590 | Int_t channel = 0; |
a8ec0771 | 591 | |
877695e7 | 592 | if(absId > fEmcCrystals){ //digitize CPV only |
a8ec0771 | 593 | |
594 | //reading calibration data for cell absId. | |
595 | //If no calibration DB found, accept default values. | |
596 | ||
fc6706cb | 597 | if(gime->CalibData()) { |
27a73a5d | 598 | fADCpedestalCpv = gime->CalibData()->GetADCpedestalCpv(module,column,row); |
877695e7 | 599 | fADCchanelCpv = gime->CalibData()->GetADCchannelCpv( module,column,row); |
fc6706cb | 600 | } |
601 | ||
877695e7 | 602 | channel = (Int_t) TMath::Ceil((charge - fADCpedestalCpv)/fADCchanelCpv) ; |
603 | if(channel > fNADCcpv ) channel = fNADCcpv ; | |
3758d9fc | 604 | } |
877695e7 | 605 | return channel ; |
3758d9fc | 606 | } |
548f0134 | 607 | |
7b7c1533 | 608 | //____________________________________________________________________________ |
609 | void AliPHOSDigitizer::Exec(Option_t *option) | |
610 | { | |
212d1c0f | 611 | // Steering method to process digitization for events |
612 | // in the range from fFirstEvent to fLastEvent. | |
613 | // This range is optionally set by SetEventRange(). | |
45fa49ca | 614 | // if fLastEvent=-1, then process events until the end. |
615 | // by default fLastEvent = fFirstEvent (process only one event) | |
88cb7938 | 616 | |
617 | if (!fInit) { // to prevent overwrite existing file | |
351dd634 | 618 | AliError(Form("Give a version name different from %s", |
619 | fEventFolderName.Data() )) ; | |
88cb7938 | 620 | return ; |
621 | } | |
990119d6 | 622 | |
7b7c1533 | 623 | if (strstr(option,"print")) { |
88cb7938 | 624 | Print(); |
7b7c1533 | 625 | return ; |
8cb3533f | 626 | } |
990119d6 | 627 | |
8661738e | 628 | // check the QA result for Hits and SDigits |
629 | AliQA * qa = AliQA::Instance(AliQA::kPHOS) ; | |
630 | if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kFATAL)) { | |
631 | AliFatal("QA status in Hits and/or SDIGITS was Fatal") ; | |
632 | } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kERROR)) { | |
633 | AliError("QA status in Hits and/or SDIGITS was Error") ; | |
634 | } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kWARNING) ) { | |
635 | AliWarning("QA status in Hits and/or SDIGITS was Warning") ; | |
636 | } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kINFO) ) { | |
637 | AliInfo("QA status in Hits and/or SDIGITS was Info") ; | |
638 | } | |
639 | ||
640 | if(strstr(option,"tim")) | |
641 | gBenchmark->Start("PHOSDigitizer"); | |
3f81a70b | 642 | |
fb43ada4 | 643 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; |
88cb7938 | 644 | |
5b4d2c50 | 645 | // Post Digitizer to the white board |
646 | gime->PostDigitizer(this) ; | |
647 | ||
212d1c0f | 648 | if (fLastEvent == -1) |
649 | fLastEvent = gime->MaxEvent() - 1 ; | |
396a348e | 650 | else if (fManager) |
651 | fLastEvent = fFirstEvent ; | |
45fa49ca | 652 | |
212d1c0f | 653 | Int_t nEvents = fLastEvent - fFirstEvent + 1; |
654 | ||
7b7c1533 | 655 | Int_t ievent ; |
88cb7938 | 656 | |
212d1c0f | 657 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { |
ddd1a39c | 658 | fEventCounter++ ; |
88cb7938 | 659 | gime->Event(ievent,"S") ; |
b22e4735 | 660 | |
7b7c1533 | 661 | Digitize(ievent) ; //Add prepared SDigits to digits and add the noise |
88cb7938 | 662 | |
ddd1a39c | 663 | //makes the quality assurance data |
b8274834 | 664 | if (GetQADataMaker()->IsCycleDone() ) { |
665 | GetQADataMaker()->EndOfCycle(AliQA::kDIGITS) ; | |
666 | GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ; | |
5b188f2f | 667 | } |
b8274834 | 668 | GetQADataMaker()->Exec(AliQA::kDIGITS, gime->Digits()) ; |
669 | GetQADataMaker()->Increment() ; | |
ddd1a39c | 670 | |
90cceaf6 | 671 | WriteDigits() ; |
88cb7938 | 672 | |
01a599c9 | 673 | if(strstr(option,"deb")) |
674 | PrintDigits(option); | |
94de8339 | 675 | |
676 | //increment the total number of Digits per run | |
677 | fDigitsInRun += gime->Digits()->GetEntriesFast() ; | |
88cb7938 | 678 | } |
ddd1a39c | 679 | |
680 | //Write the quality assurance data only after the last event | |
5b188f2f | 681 | if ( fEventCounter == gime->MaxEvent() ) { |
b8274834 | 682 | GetQADataMaker()->EndOfCycle(AliQA::kDIGITS) ; |
683 | GetQADataMaker()->Finish(AliQA::kDIGITS) ; | |
5b188f2f | 684 | } |
88cb7938 | 685 | |
5b4d2c50 | 686 | gime->PhosLoader()->CleanDigitizer(); |
687 | ||
8cb3533f | 688 | if(strstr(option,"tim")){ |
689 | gBenchmark->Stop("PHOSDigitizer"); | |
21cd0c07 | 690 | TString message ; |
691 | message = " took %f seconds for Digitizing %f seconds per event\n" ; | |
351dd634 | 692 | AliInfo(Form( message.Data(), |
21cd0c07 | 693 | gBenchmark->GetCpuTime("PHOSDigitizer"), |
351dd634 | 694 | gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents )); |
21cd0c07 | 695 | } |
990119d6 | 696 | } |
697 | ||
9688c1dd | 698 | //____________________________________________________________________________ |
0bc3b8ed | 699 | Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const |
700 | { | |
701 | // Returns the shortest time among all time ticks | |
702 | ||
7437a0f7 | 703 | ticks->Sort() ; //Sort in accordance with times of ticks |
704 | TIter it(ticks) ; | |
705 | AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ; | |
706 | Float_t time = ctick->CrossingTime(fTimeThreshold) ; | |
707 | ||
708 | AliPHOSTick * t ; | |
709 | while((t=(AliPHOSTick*) it.Next())){ | |
710 | if(t->GetTime() < time) //This tick starts before crossing | |
711 | *ctick+=*t ; | |
712 | else | |
713 | return time ; | |
714 | ||
715 | time = ctick->CrossingTime(fTimeThreshold) ; | |
9688c1dd | 716 | } |
717 | return time ; | |
9688c1dd | 718 | } |
8d0f3f77 | 719 | |
7b7c1533 | 720 | //____________________________________________________________________________ |
3f81a70b | 721 | Bool_t AliPHOSDigitizer::Init() |
8d0f3f77 | 722 | { |
fbf811ec | 723 | // Makes all memory allocations |
88cb7938 | 724 | fInit = kTRUE ; |
725 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; | |
8d0f3f77 | 726 | if ( gime == 0 ) { |
351dd634 | 727 | AliFatal(Form("Could not obtain the Getter object for file %s and event %s !", |
728 | GetTitle(), fEventFolderName.Data())); | |
8d0f3f77 | 729 | return kFALSE; |
730 | } | |
731 | ||
732 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; | |
b22e4735 | 733 | |
88cb7938 | 734 | fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ; |
8d0f3f77 | 735 | |
88cb7938 | 736 | TString opt("Digits") ; |
737 | if(gime->VersionExists(opt) ) { | |
351dd634 | 738 | AliError(Form("Give a version name different from %s", |
739 | fEventFolderName.Data() )) ; | |
88cb7938 | 740 | fInit = kFALSE ; |
741 | } | |
742 | ||
45fa49ca | 743 | fFirstEvent = 0 ; |
744 | fLastEvent = fFirstEvent ; | |
88cb7938 | 745 | if (fManager) |
746 | fInput = fManager->GetNinputs() ; | |
747 | else | |
748 | fInput = 1 ; | |
749 | ||
750 | fInputFileNames = new TString[fInput] ; | |
751 | fEventNames = new TString[fInput] ; | |
752 | fInputFileNames[0] = GetTitle() ; | |
753 | fEventNames[0] = fEventFolderName.Data() ; | |
754 | Int_t index ; | |
755 | for (index = 1 ; index < fInput ; index++) { | |
756 | fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0); | |
757 | TString tempo = fManager->GetInputFolderName(index) ; | |
45fa49ca | 758 | fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager |
8d0f3f77 | 759 | } |
88cb7938 | 760 | |
761 | //to prevent cleaning of this object while GetEvent is called | |
762 | gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); | |
763 | ||
764 | return fInit ; | |
8d0f3f77 | 765 | } |
766 | ||
767 | //____________________________________________________________________________ | |
768 | void AliPHOSDigitizer::InitParameters() | |
a4e98857 | 769 | { |
45fa49ca | 770 | // Set initial parameters Digitizer |
0bc3b8ed | 771 | |
27a73a5d | 772 | fPinNoise = 0.004 ; // [GeV] |
773 | fEMCDigitThreshold = 0.012 ; // [GeV] | |
774 | fCPVNoise = 0.01; // [aux units] | |
775 | fCPVDigitThreshold = 0.09 ; // [aux units] | |
776 | fTimeResolution = 0.5e-9 ; // [sec] | |
777 | fTimeSignalLength = 1.0e-9 ; // [sec] | |
3758d9fc | 778 | fDigitsInRun = 0 ; |
877695e7 | 779 | fADCchanelEmc = 1.0; // Coefficient between real and measured energies in EMC |
780 | fADCpedestalEmc = 0. ; // | |
3758d9fc | 781 | fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC |
782 | ||
783 | fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais' | |
784 | fADCpedestalCpv = 0.012 ; // | |
785 | fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC | |
786 | ||
27a73a5d | 787 | // fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude |
788 | fTimeThreshold = 0.001 ; // [GeV] | |
212d1c0f | 789 | SetEventRange(0,-1) ; |
8cb3533f | 790 | |
990119d6 | 791 | } |
7b7c1533 | 792 | |
990119d6 | 793 | //__________________________________________________________________ |
fc7e2f43 | 794 | void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName) |
a4e98857 | 795 | { |
ba54256b | 796 | // Allows to produce digits by superimposing background and signal event. |
bca3b32a | 797 | // It is assumed, that headers file with SIGNAL events is opened in |
a4e98857 | 798 | // the constructor. |
799 | // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed | |
800 | // Thus we avoid writing (changing) huge and expensive | |
bca3b32a | 801 | // backgound files: all output will be writen into SIGNAL, i.e. |
802 | // opened in constructor file. | |
803 | // | |
a4e98857 | 804 | // One can open as many files to mix with as one needs. |
7b7c1533 | 805 | // However only Sdigits with the same name (i.e. constructed with the same SDigitizer) |
806 | // can be mixed. | |
bca3b32a | 807 | |
88cb7938 | 808 | if( strcmp(fEventFolderName, "") == 0 ) |
8cb3533f | 809 | Init() ; |
810 | ||
9891b76e | 811 | if(fManager){ |
88cb7938 | 812 | Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ; |
3f81a70b | 813 | return ; |
814 | } | |
88cb7938 | 815 | // looking for file which contains AliRun |
816 | if (gSystem->AccessPathName(alirunFileName)) {// file does not exist | |
351dd634 | 817 | AliError(Form("File %s does not exist!", alirunFileName.Data())) ; |
88cb7938 | 818 | return ; |
990119d6 | 819 | } |
88cb7938 | 820 | // looking for the file which contains SDigits |
821 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
822 | TString fileName( gime->GetSDigitsFileName() ) ; | |
e191bb57 | 823 | if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name |
88cb7938 | 824 | fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ; |
825 | if ( (gSystem->AccessPathName(fileName)) ) { | |
351dd634 | 826 | AliError(Form("The file %s does not exist!", fileName.Data())) ; |
88cb7938 | 827 | return ; |
7b7c1533 | 828 | } |
88cb7938 | 829 | // need to increase the arrays |
830 | TString tempo = fInputFileNames[fInput-1] ; | |
831 | delete [] fInputFileNames ; | |
832 | fInputFileNames = new TString[fInput+1] ; | |
833 | fInputFileNames[fInput-1] = tempo ; | |
834 | ||
835 | tempo = fEventNames[fInput-1] ; | |
836 | delete [] fEventNames ; | |
837 | fEventNames = new TString[fInput+1] ; | |
838 | fEventNames[fInput-1] = tempo ; | |
839 | ||
840 | fInputFileNames[fInput] = alirunFileName ; | |
841 | fEventNames[fInput] = eventFolderName ; | |
842 | fInput++ ; | |
990119d6 | 843 | } |
7b7c1533 | 844 | |
990119d6 | 845 | //__________________________________________________________________ |
702ab87e | 846 | void AliPHOSDigitizer::Print(const Option_t *)const |
21cd0c07 | 847 | { |
dd5c4038 | 848 | // Print Digitizer's parameters |
351dd634 | 849 | AliInfo(Form("\n------------------- %s -------------", GetName() )) ; |
88cb7938 | 850 | if( strcmp(fEventFolderName.Data(), "") != 0 ){ |
851 | printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ; | |
852 | ||
853 | Int_t nStreams ; | |
854 | if (fManager) | |
855 | nStreams = GetNInputStreams() ; | |
856 | else | |
857 | nStreams = fInput ; | |
858 | ||
859 | Int_t index = 0 ; | |
860 | for (index = 0 ; index < nStreams ; index++) { | |
861 | TString tempo(fEventNames[index]) ; | |
862 | tempo += index ; | |
863 | AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ; | |
864 | TString fileName( gime->GetSDigitsFileName() ) ; | |
e191bb57 | 865 | if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name |
88cb7938 | 866 | fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ; |
867 | printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ; | |
868 | } | |
869 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; | |
870 | printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ; | |
871 | ||
872 | printf("\nWith following parameters:\n") ; | |
27a73a5d | 873 | printf(" Electronics noise in EMC (fPinNoise) = %f GeV\n", fPinNoise ) ; |
874 | printf(" Threshold in EMC (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ; | |
875 | printf(" Noise in CPV (fCPVNoise) = %f aux units\n", fCPVNoise ) ; | |
876 | printf(" Threshold in CPV (fCPVDigitThreshold) = %f aux units\n",fCPVDigitThreshold ) ; | |
88cb7938 | 877 | printf(" ---------------------------------------------------\n") ; |
990119d6 | 878 | } |
8cb3533f | 879 | else |
351dd634 | 880 | AliInfo(Form("AliPHOSDigitizer not initialized" )) ; |
8cb3533f | 881 | |
882 | } | |
88cb7938 | 883 | |
8cb3533f | 884 | //__________________________________________________________________ |
21cd0c07 | 885 | void AliPHOSDigitizer::PrintDigits(Option_t * option) |
886 | { | |
3bf72d32 | 887 | // Print a table of digits |
21cd0c07 | 888 | |
88cb7938 | 889 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; |
3bf72d32 | 890 | TClonesArray * digits = gime->Digits() ; |
891 | ||
351dd634 | 892 | AliInfo(Form("%d", digits->GetEntriesFast())) ; |
88cb7938 | 893 | printf("\nevent %d", gAlice->GetEvNumber()) ; |
894 | printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ; | |
895 | ||
11f9c5ff | 896 | |
3bf72d32 | 897 | if(strstr(option,"all")||strstr(option,"EMC")){ |
8cb3533f | 898 | //loop over digits |
899 | AliPHOSDigit * digit; | |
88cb7938 | 900 | printf("\nEMC digits (with primaries):\n") ; |
901 | printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ; | |
9688c1dd | 902 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; |
8cb3533f | 903 | Int_t index ; |
a6eedfad | 904 | for (index = 0 ; (index < digits->GetEntriesFast()) && |
88cb7938 | 905 | (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) { |
7b7c1533 | 906 | digit = (AliPHOSDigit * ) digits->At(index) ; |
21cd0c07 | 907 | if(digit->GetNprimary() == 0) |
908 | continue; | |
27a73a5d | 909 | // printf("%6d %8d %6.5e %4d %2d :", |
910 | // digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; // YVK | |
911 | printf("%6d %.4f %6.5e %4d %2d :", | |
912 | digit->GetId(), digit->GetEnergy(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; | |
8cb3533f | 913 | Int_t iprimary; |
21cd0c07 | 914 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
88cb7938 | 915 | printf("%d ",digit->GetPrimary(iprimary+1) ) ; |
21cd0c07 | 916 | } |
81d5f731 | 917 | printf("\n") ; |
21cd0c07 | 918 | } |
9688c1dd | 919 | } |
3bf72d32 | 920 | |
9688c1dd | 921 | if(strstr(option,"all")||strstr(option,"CPV")){ |
8cb3533f | 922 | |
9688c1dd | 923 | //loop over CPV digits |
924 | AliPHOSDigit * digit; | |
88cb7938 | 925 | printf("\nCPV digits (with primaries):\n") ; |
926 | printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ; | |
9688c1dd | 927 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; |
928 | Int_t index ; | |
a6eedfad | 929 | for (index = 0 ; index < digits->GetEntriesFast(); index++) { |
9688c1dd | 930 | digit = (AliPHOSDigit * ) digits->At(index) ; |
931 | if(digit->GetId() > maxEmc){ | |
81d5f731 | 932 | printf("%6d %8d %4d %2d :", |
11f9c5ff | 933 | digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ; |
9688c1dd | 934 | Int_t iprimary; |
21cd0c07 | 935 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
88cb7938 | 936 | printf("%d ",digit->GetPrimary(iprimary+1) ) ; |
21cd0c07 | 937 | } |
81d5f731 | 938 | printf("\n") ; |
21cd0c07 | 939 | } |
9688c1dd | 940 | } |
8cb3533f | 941 | } |
88cb7938 | 942 | |
8cb3533f | 943 | } |
7b7c1533 | 944 | |
9688c1dd | 945 | //__________________________________________________________________ |
0bc3b8ed | 946 | Float_t AliPHOSDigitizer::TimeOfNoise(void) const |
9688c1dd | 947 | { // Calculates the time signal generated by noise |
26a2ef9d | 948 | //PH Info("TimeOfNoise", "Change me") ; |
04f0bda3 | 949 | return gRandom->Rndm() * 1.28E-5; |
8cb3533f | 950 | } |
7b7c1533 | 951 | |
88cb7938 | 952 | //__________________________________________________________________ |
953 | void AliPHOSDigitizer::Unload() | |
954 | { | |
955 | ||
956 | Int_t i ; | |
957 | for(i = 1 ; i < fInput ; i++){ | |
958 | TString tempo(fEventNames[i]) ; | |
959 | tempo += i ; | |
960 | AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ; | |
961 | gime->PhosLoader()->UnloadSDigits() ; | |
962 | } | |
963 | ||
964 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; | |
965 | gime->PhosLoader()->UnloadDigits() ; | |
966 | } | |
967 | ||
7b7c1533 | 968 | //____________________________________________________________________________ |
90cceaf6 | 969 | void AliPHOSDigitizer::WriteDigits() |
7b7c1533 | 970 | { |
971 | ||
972 | // Makes TreeD in the output file. | |
973 | // Check if branch already exists: | |
974 | // if yes, exit without writing: ROOT TTree does not support overwriting/updating of | |
975 | // already existing branches. | |
976 | // else creates branch with Digits, named "PHOS", title "...", | |
977 | // and branch "AliPHOSDigitizer", with the same title to keep all the parameters | |
978 | // and names of files, from which digits are made. | |
979 | ||
f98c06a1 | 980 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; |
88cb7938 | 981 | const TClonesArray * digits = gime->Digits() ; |
982 | TTree * treeD = gime->TreeD(); | |
983 | ||
7b7c1533 | 984 | // -- create Digits branch |
985 | Int_t bufferSize = 32000 ; | |
2524c56f | 986 | TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize); |
88cb7938 | 987 | digitsBranch->SetTitle(fEventFolderName); |
988 | digitsBranch->Fill() ; | |
fbf811ec | 989 | |
88cb7938 | 990 | gime->WriteDigits("OVERWRITE"); |
991 | gime->WriteDigitizer("OVERWRITE"); | |
992 | ||
993 | Unload() ; | |
b3690abb | 994 | |
7b7c1533 | 995 | } |