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