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