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