1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /* History of cvs commits:
21 * Revision 1.90 2006/04/22 10:30:17 hristov
22 * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
24 * Revision 1.89 2006/04/11 15:22:59 hristov
25 * run number in query set to -1: forces AliCDBManager to use its run number (A.Colla)
27 * Revision 1.88 2006/03/13 14:05:43 kharlov
28 * Calibration objects for EMC and CPV
30 * Revision 1.87 2005/08/24 15:33:49 kharlov
31 * Calibration data for raw digits
33 * Revision 1.86 2005/07/12 20:07:35 hristov
34 * Changes needed to run simulation and reconstrruction in the same AliRoot session
36 * Revision 1.85 2005/05/28 14:19:04 schutz
37 * Compilation warnings fixed by T.P.
41 //_________________________________________________________________________
42 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
43 //////////////////////////////////////////////////////////////////////////////
44 // This TTask performs digitization of Summable digits (in the PHOS case it is just
45 // the sum of contributions from all primary particles into a given cell).
46 // In addition it performs mixing of summable digits from different events.
47 // The name of the TTask is also the title of the branch that will contain
48 // the created SDigits
49 // The title of the TTAsk is the name of the file that contains the hits from
50 // which the SDigits are created
52 // For each event two branches are created in TreeD:
53 // "PHOS" - list of digits
54 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
56 // Note, that one can set a title for new digits branch, and repeat digitization with
57 // another set of parameters.
60 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
61 // root[1] d->ExecuteTask()
62 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
63 // //Digitizes SDigitis in all events found in file galice.root
65 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
66 // // Will read sdigits from galice1.root
67 // root[3] d1->MixWith("galice2.root")
68 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
69 // // Reads another set of sdigits from galice2.root
70 // root[3] d1->MixWith("galice3.root")
71 // // Reads another set of sdigits from galice3.root
72 // root[4] d->ExecuteTask("deb timing")
73 // // Reads SDigits from files galice1.root, galice2.root ....
74 // // mixes them and stores produced Digits in file galice1.root
75 // // deb - prints number of produced digits
76 // // deb all - prints list of produced digits
77 // // timing - prints time used for digitization
80 // --- ROOT system ---
83 #include "TBenchmark.h"
86 // --- Standard library ---
88 // --- AliRoot header files ---
90 #include "AliRunDigitizer.h"
91 #include "AliPHOSDigit.h"
92 #include "AliPHOSGetter.h"
93 #include "AliPHOSDigitizer.h"
94 #include "AliPHOSSDigitizer.h"
95 #include "AliPHOSGeometry.h"
96 #include "AliPHOSTick.h"
98 ClassImp(AliPHOSDigitizer)
101 //____________________________________________________________________________
102 AliPHOSDigitizer::AliPHOSDigitizer():AliDigitizer("",""),
104 fInputFileNames(0x0),
109 fDefaultInit = kTRUE ;
110 fManager = 0 ; // We work in the standalong mode
111 fEventFolderName = "" ;
114 //____________________________________________________________________________
115 AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
116 TString eventFolderName):
117 AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(),
119 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
124 fDefaultInit = kFALSE ;
125 fManager = 0 ; // We work in the standalong mode
128 //____________________________________________________________________________
129 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
134 SetName(d.GetName()) ;
135 SetTitle(d.GetTitle()) ;
136 fPinNoise = d.fPinNoise ;
137 fEMCDigitThreshold = d.fEMCDigitThreshold ;
138 fCPVNoise = d.fCPVNoise ;
139 fCPVDigitThreshold = d.fCPVDigitThreshold ;
140 fTimeResolution = d.fTimeResolution ;
141 fTimeThreshold = d.fTimeThreshold ;
142 fTimeSignalLength = d.fTimeSignalLength ;
143 fADCchanelEmc = d.fADCchanelEmc ;
144 fADCpedestalEmc = d.fADCpedestalEmc ;
145 fNADCemc = d.fNADCemc ;
146 fADCchanelCpv = d.fADCchanelCpv ;
147 fADCpedestalCpv = d.fADCpedestalCpv ;
148 fNADCcpv = d.fNADCcpv ;
149 fEventFolderName = d.fEventFolderName;
152 //____________________________________________________________________________
153 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
154 AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()),
157 // ctor Init() is called by RunDigitizer
159 fEventFolderName = fManager->GetInputFolderName(0) ;
160 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
162 fDefaultInit = kFALSE ;
165 //____________________________________________________________________________
166 AliPHOSDigitizer::~AliPHOSDigitizer()
168 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
170 // Clean Digitizer from the white board
171 gime->PhosLoader()->CleanDigitizer() ;
173 delete [] fInputFileNames ;
174 delete [] fEventNames ;
178 //____________________________________________________________________________
179 void AliPHOSDigitizer::Digitize(Int_t event)
182 // Makes the digitization of the collected summable digits.
183 // It first creates the array of all PHOS modules
184 // filled with noise (different for EMC, and CPV) and
185 // then adds contributions from SDigits.
186 // This design avoids scanning over the list of digits to add
187 // contribution to new SDigits only.
189 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
190 Int_t ReadEvent = event ;
192 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
193 AliInfo(Form("Adding event %d from input stream 0 %s %s",
194 ReadEvent, GetTitle(), fEventFolderName.Data())) ;
195 gime->Event(ReadEvent, "S") ;
196 TClonesArray * digits = gime->Digits() ;
199 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
200 //Making digits with noise, first EMC
201 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
206 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
208 digits->Expand(nCPV) ;
210 // get first the sdigitizer from the tasks list
211 if ( !gime->SDigitizer() )
212 gime->LoadSDigitizer();
213 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
216 AliFatal(Form("SDigitizer with name %s %s not found",
217 GetTitle(), fEventFolderName.Data() )) ;
219 //take all the inputs to add together and load the SDigits
220 TObjArray * sdigArray = new TObjArray(fInput) ;
221 sdigArray->AddAt(gime->SDigits(), 0) ;
223 for(i = 1 ; i < fInput ; i++){
224 TString tempo(fEventNames[i]) ;
226 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
228 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
229 AliInfo(Form("Adding event %d from input stream %d %s %s",
230 ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
231 gime->Event(ReadEvent,"S");
232 sdigArray->AddAt(gime->SDigits(), i) ;
235 //Find the first crystal with signal
236 Int_t nextSig = 200000 ;
237 TClonesArray * sdigits ;
238 for(i = 0 ; i < fInput ; i++){
239 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
240 if ( !sdigits->GetEntriesFast() )
242 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
243 if(curNext < nextSig)
247 TArrayI index(fInput) ;
248 index.Reset() ; //Set all indexes to zero
250 AliPHOSDigit * digit ;
251 AliPHOSDigit * curSDigit ;
253 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
255 //Put Noise contribution
256 for(absID = 1 ; absID <= nEMC ; absID++){
257 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
258 // YVK: do not digitize amplitudes for EMC
259 // new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
260 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, noise, TimeOfNoise() ) ;
261 //look if we have to add signal?
262 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
265 //Add SDigits from all inputs
268 Float_t a = digit->GetEnergy() ;
269 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
270 //Mark the beginning of the signal
271 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
272 //Mark the end of the signal
273 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
276 for(i = 0 ; i < fInput ; i++){
277 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
278 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
281 //May be several digits will contribute from the same input
282 while(curSDigit && curSDigit->GetId() == absID){
283 //Shift primary to separate primaries belonging different inputs
284 Int_t primaryoffset ;
286 primaryoffset = fManager->GetMask(i) ;
288 primaryoffset = 10000000*i ;
289 curSDigit->ShiftPrimary(primaryoffset) ;
291 a = curSDigit->GetEnergy() ;
292 b = a /fTimeSignalLength ;
293 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
294 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
296 *digit = *digit + *curSDigit ; //add energies
299 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
300 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
306 //calculate and set time
307 Float_t time = FrontEdgeTime(ticks) ;
308 digit->SetTime(time) ;
310 //Find next signal module
312 for(i = 0 ; i < fInput ; i++){
313 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
314 Int_t curNext = nextSig ;
315 if(sdigits->GetEntriesFast() > index[i] ){
316 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
318 if(curNext < nextSig) nextSig = curNext ;
326 //Now CPV digits (different noise and no timing)
327 for(absID = nEMC+1; absID <= nCPV; absID++){
328 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
329 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
330 //look if we have to add signal?
332 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
333 //Add SDigits from all inputs
334 for(i = 0 ; i < fInput ; i++){
335 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
336 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
340 //May be several digits will contribute from the same input
341 while(curSDigit && curSDigit->GetId() == absID){
342 //Shift primary to separate primaries belonging different inputs
343 Int_t primaryoffset ;
345 primaryoffset = fManager->GetMask(i) ;
347 primaryoffset = 10000000*i ;
348 curSDigit->ShiftPrimary(primaryoffset) ;
351 *digit = *digit + *curSDigit ;
353 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
354 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
360 //Find next signal module
362 for(i = 0 ; i < fInput ; i++){
363 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
364 Int_t curNext = nextSig ;
365 if(sdigits->GetEntriesFast() > index[i] )
366 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
367 if(curNext < nextSig) nextSig = curNext ;
373 delete sdigArray ; //We should not delete its contents
375 //remove digits below thresholds
376 for(i = 0 ; i < nEMC ; i++){
377 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
378 DecalibrateEMC(digit);
379 if(digit->GetEnergy() < fEMCDigitThreshold)
380 digits->RemoveAt(i) ;
382 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
386 for(i = nEMC; i < nCPV ; i++)
387 // if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
388 if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < fCPVDigitThreshold )
389 digits->RemoveAt(i) ;
393 Int_t ndigits = digits->GetEntriesFast() ;
394 digits->Expand(ndigits) ;
396 //Set indexes in list of digits and make true digitization of the energy
397 for (i = 0 ; i < ndigits ; i++) {
398 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
399 digit->SetIndexInList(i) ;
400 if(digit->GetId() > fEmcCrystals){ //digitize CPV only
401 digit->SetAmp(DigitizeCPV(digit->GetEnergy(),digit->GetId()) ) ;
406 //____________________________________________________________________________
407 void AliPHOSDigitizer::DecalibrateEMC(AliPHOSDigit *digit)
409 // Decalibrate EMC digit, i.e. change its energy by a factor read from CDB
411 AliPHOSGetter* gime = AliPHOSGetter::Instance();
413 if(!gime->CalibData()) {
414 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1);
415 gime->SetCalibData(cdb);
418 //Determine rel.position of the cell absolute ID
420 gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
421 Int_t module=relId[0];
423 Int_t column=relId[3];
424 Float_t decalibration = gime->CalibData()->GetADCchannelEmc(module,column,row);
425 Float_t energy = digit->GetEnergy() * decalibration;
426 digit->SetEnergy(energy);
428 //____________________________________________________________________________
429 Int_t AliPHOSDigitizer::DigitizeCPV(Float_t charge, Int_t absId)
431 // Returns digitized value of the CPV charge in a pad absId
433 AliPHOSGetter* gime = AliPHOSGetter::Instance();
435 if(!gime->CalibData()) {
436 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); // use AliCDBManager's run number
437 gime->SetCalibData(cdb);
440 //Determine rel.position of the cell absId
442 gime->PHOSGeometry()->AbsToRelNumbering(absId,relId);
443 Int_t module=relId[0];
445 Int_t column=relId[3];
449 if(absId > fEmcCrystals){ //digitize CPV only
451 //reading calibration data for cell absId.
452 //If no calibration DB found, accept default values.
454 if(gime->CalibData()) {
455 fADCpedestalCpv = gime->CalibData()->GetADCpedestalCpv(module,column,row);
456 fADCchanelCpv = gime->CalibData()->GetADCchannelCpv( module,column,row);
459 channel = (Int_t) TMath::Ceil((charge - fADCpedestalCpv)/fADCchanelCpv) ;
460 if(channel > fNADCcpv ) channel = fNADCcpv ;
465 //____________________________________________________________________________
466 void AliPHOSDigitizer::Exec(Option_t *option)
468 // Steering method to process digitization for events
469 // in the range from fFirstEvent to fLastEvent.
470 // This range is optionally set by SetEventRange().
471 // if fLastEvent=-1, then process events until the end.
472 // by default fLastEvent = fFirstEvent (process only one event)
474 if (!fInit) { // to prevent overwrite existing file
475 AliError(Form("Give a version name different from %s",
476 fEventFolderName.Data() )) ;
480 if (strstr(option,"print")) {
485 if(strstr(option,"tim"))
486 gBenchmark->Start("PHOSDigitizer");
488 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
490 // Post Digitizer to the white board
491 gime->PostDigitizer(this) ;
493 if (fLastEvent == -1)
494 fLastEvent = gime->MaxEvent() - 1 ;
496 fLastEvent = fFirstEvent ;
498 Int_t nEvents = fLastEvent - fFirstEvent + 1;
502 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
504 gime->Event(ievent,"S") ;
506 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
510 if(strstr(option,"deb"))
513 //increment the total number of Digits per run
514 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
517 gime->PhosLoader()->CleanDigitizer();
519 if(strstr(option,"tim")){
520 gBenchmark->Stop("PHOSDigitizer");
522 message = " took %f seconds for Digitizing %f seconds per event\n" ;
523 AliInfo(Form( message.Data(),
524 gBenchmark->GetCpuTime("PHOSDigitizer"),
525 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents ));
529 //____________________________________________________________________________
530 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
532 // Returns the shortest time among all time ticks
534 ticks->Sort() ; //Sort in accordance with times of ticks
536 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
537 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
540 while((t=(AliPHOSTick*) it.Next())){
541 if(t->GetTime() < time) //This tick starts before crossing
546 time = ctick->CrossingTime(fTimeThreshold) ;
551 //____________________________________________________________________________
552 Bool_t AliPHOSDigitizer::Init()
554 // Makes all memory allocations
556 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
558 AliFatal(Form("Could not obtain the Getter object for file %s and event %s !",
559 GetTitle(), fEventFolderName.Data()));
563 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
565 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
567 TString opt("Digits") ;
568 if(gime->VersionExists(opt) ) {
569 AliError(Form("Give a version name different from %s",
570 fEventFolderName.Data() )) ;
575 fLastEvent = fFirstEvent ;
577 fInput = fManager->GetNinputs() ;
581 fInputFileNames = new TString[fInput] ;
582 fEventNames = new TString[fInput] ;
583 fInputFileNames[0] = GetTitle() ;
584 fEventNames[0] = fEventFolderName.Data() ;
586 for (index = 1 ; index < fInput ; index++) {
587 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
588 TString tempo = fManager->GetInputFolderName(index) ;
589 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
592 //to prevent cleaning of this object while GetEvent is called
593 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
598 //____________________________________________________________________________
599 void AliPHOSDigitizer::InitParameters()
601 // Set initial parameters Digitizer
603 fPinNoise = 0.004 ; // [GeV]
604 fEMCDigitThreshold = 0.012 ; // [GeV]
605 fCPVNoise = 0.01; // [aux units]
606 fCPVDigitThreshold = 0.09 ; // [aux units]
607 fTimeResolution = 0.5e-9 ; // [sec]
608 fTimeSignalLength = 1.0e-9 ; // [sec]
610 fADCchanelEmc = 1.0; // Coefficient between real and measured energies in EMC
611 fADCpedestalEmc = 0. ; //
612 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
614 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
615 fADCpedestalCpv = 0.012 ; //
616 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
618 // fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
619 fTimeThreshold = 0.001 ; // [GeV]
620 SetEventRange(0,-1) ;
624 //__________________________________________________________________
625 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
627 // Allows to produce digits by superimposing background and signal event.
628 // It is assumed, that headers file with SIGNAL events is opened in
630 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
631 // Thus we avoid writing (changing) huge and expensive
632 // backgound files: all output will be writen into SIGNAL, i.e.
633 // opened in constructor file.
635 // One can open as many files to mix with as one needs.
636 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
639 if( strcmp(fEventFolderName, "") == 0 )
643 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
646 // looking for file which contains AliRun
647 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
648 AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
651 // looking for the file which contains SDigits
652 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
653 TString fileName( gime->GetSDigitsFileName() ) ;
654 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
655 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
656 if ( (gSystem->AccessPathName(fileName)) ) {
657 AliError(Form("The file %s does not exist!", fileName.Data())) ;
660 // need to increase the arrays
661 TString tempo = fInputFileNames[fInput-1] ;
662 delete [] fInputFileNames ;
663 fInputFileNames = new TString[fInput+1] ;
664 fInputFileNames[fInput-1] = tempo ;
666 tempo = fEventNames[fInput-1] ;
667 delete [] fEventNames ;
668 fEventNames = new TString[fInput+1] ;
669 fEventNames[fInput-1] = tempo ;
671 fInputFileNames[fInput] = alirunFileName ;
672 fEventNames[fInput] = eventFolderName ;
676 //__________________________________________________________________
677 void AliPHOSDigitizer::Print(const Option_t *)const
679 // Print Digitizer's parameters
680 AliInfo(Form("\n------------------- %s -------------", GetName() )) ;
681 if( strcmp(fEventFolderName.Data(), "") != 0 ){
682 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
686 nStreams = GetNInputStreams() ;
691 for (index = 0 ; index < nStreams ; index++) {
692 TString tempo(fEventNames[index]) ;
694 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
695 TString fileName( gime->GetSDigitsFileName() ) ;
696 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
697 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
698 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
700 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
701 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
703 printf("\nWith following parameters:\n") ;
704 printf(" Electronics noise in EMC (fPinNoise) = %f GeV\n", fPinNoise ) ;
705 printf(" Threshold in EMC (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ;
706 printf(" Noise in CPV (fCPVNoise) = %f aux units\n", fCPVNoise ) ;
707 printf(" Threshold in CPV (fCPVDigitThreshold) = %f aux units\n",fCPVDigitThreshold ) ;
708 printf(" ---------------------------------------------------\n") ;
711 AliInfo(Form("AliPHOSDigitizer not initialized" )) ;
715 //__________________________________________________________________
716 void AliPHOSDigitizer::PrintDigits(Option_t * option)
718 // Print a table of digits
720 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
721 TClonesArray * digits = gime->Digits() ;
723 AliInfo(Form("%d", digits->GetEntriesFast())) ;
724 printf("\nevent %d", gAlice->GetEvNumber()) ;
725 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
728 if(strstr(option,"all")||strstr(option,"EMC")){
730 AliPHOSDigit * digit;
731 printf("\nEMC digits (with primaries):\n") ;
732 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
733 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
735 for (index = 0 ; (index < digits->GetEntriesFast()) &&
736 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
737 digit = (AliPHOSDigit * ) digits->At(index) ;
738 if(digit->GetNprimary() == 0)
740 // printf("%6d %8d %6.5e %4d %2d :",
741 // digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; // YVK
742 printf("%6d %.4f %6.5e %4d %2d :",
743 digit->GetId(), digit->GetEnergy(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
745 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
746 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
752 if(strstr(option,"all")||strstr(option,"CPV")){
754 //loop over CPV digits
755 AliPHOSDigit * digit;
756 printf("\nCPV digits (with primaries):\n") ;
757 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
758 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
760 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
761 digit = (AliPHOSDigit * ) digits->At(index) ;
762 if(digit->GetId() > maxEmc){
763 printf("%6d %8d %4d %2d :",
764 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
766 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
767 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
776 //__________________________________________________________________
777 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
778 { // Calculates the time signal generated by noise
779 //PH Info("TimeOfNoise", "Change me") ;
780 return gRandom->Rndm() * 1.28E-5;
783 //__________________________________________________________________
784 void AliPHOSDigitizer::Unload()
788 for(i = 1 ; i < fInput ; i++){
789 TString tempo(fEventNames[i]) ;
791 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
792 gime->PhosLoader()->UnloadSDigits() ;
795 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
796 gime->PhosLoader()->UnloadDigits() ;
799 //____________________________________________________________________________
800 void AliPHOSDigitizer::WriteDigits()
803 // Makes TreeD in the output file.
804 // Check if branch already exists:
805 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
806 // already existing branches.
807 // else creates branch with Digits, named "PHOS", title "...",
808 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
809 // and names of files, from which digits are made.
811 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
812 const TClonesArray * digits = gime->Digits() ;
813 TTree * treeD = gime->TreeD();
815 // -- create Digits branch
816 Int_t bufferSize = 32000 ;
817 TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
818 digitsBranch->SetTitle(fEventFolderName);
819 digitsBranch->Fill() ;
821 gime->WriteDigits("OVERWRITE");
822 gime->WriteDigitizer("OVERWRITE");