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.91 2006/04/29 20:25:30 hristov
22 * Decalibration is implemented (Yu.Kharlov)
24 * Revision 1.90 2006/04/22 10:30:17 hristov
25 * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
27 * Revision 1.89 2006/04/11 15:22:59 hristov
28 * run number in query set to -1: forces AliCDBManager to use its run number (A.Colla)
30 * Revision 1.88 2006/03/13 14:05:43 kharlov
31 * Calibration objects for EMC and CPV
33 * Revision 1.87 2005/08/24 15:33:49 kharlov
34 * Calibration data for raw digits
36 * Revision 1.86 2005/07/12 20:07:35 hristov
37 * Changes needed to run simulation and reconstrruction in the same AliRoot session
39 * Revision 1.85 2005/05/28 14:19:04 schutz
40 * Compilation warnings fixed by T.P.
44 //_________________________________________________________________________
45 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
46 //////////////////////////////////////////////////////////////////////////////
47 // This TTask performs digitization of Summable digits (in the PHOS case it is just
48 // the sum of contributions from all primary particles into a given cell).
49 // In addition it performs mixing of summable digits from different events.
50 // The name of the TTask is also the title of the branch that will contain
51 // the created SDigits
52 // The title of the TTAsk is the name of the file that contains the hits from
53 // which the SDigits are created
55 // For each event two branches are created in TreeD:
56 // "PHOS" - list of digits
57 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
59 // Note, that one can set a title for new digits branch, and repeat digitization with
60 // another set of parameters.
63 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
64 // root[1] d->ExecuteTask()
65 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
66 // //Digitizes SDigitis in all events found in file galice.root
68 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
69 // // Will read sdigits from galice1.root
70 // root[3] d1->MixWith("galice2.root")
71 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
72 // // Reads another set of sdigits from galice2.root
73 // root[3] d1->MixWith("galice3.root")
74 // // Reads another set of sdigits from galice3.root
75 // root[4] d->ExecuteTask("deb timing")
76 // // Reads SDigits from files galice1.root, galice2.root ....
77 // // mixes them and stores produced Digits in file galice1.root
78 // // deb - prints number of produced digits
79 // // deb all - prints list of produced digits
80 // // timing - prints time used for digitization
83 // --- ROOT system ---
86 #include "TBenchmark.h"
89 // --- Standard library ---
91 // --- AliRoot header files ---
93 #include "AliRunDigitizer.h"
94 #include "AliPHOSDigit.h"
95 #include "AliPHOSGetter.h"
96 #include "AliPHOSDigitizer.h"
97 #include "AliPHOSSDigitizer.h"
98 #include "AliPHOSGeometry.h"
99 #include "AliPHOSTick.h"
101 ClassImp(AliPHOSDigitizer)
104 //____________________________________________________________________________
105 AliPHOSDigitizer::AliPHOSDigitizer() :
111 fInputFileNames(0x0),
115 fEMCDigitThreshold(0.f),
117 fCPVDigitThreshold(0.f),
118 fTimeResolution(0.f),
120 fTimeSignalLength(0.f),
122 fADCpedestalEmc(0.f),
125 fADCpedestalCpv(0.f),
127 fEventFolderName(""),
133 fManager = 0 ; // We work in the standalong mode
136 //____________________________________________________________________________
137 AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
138 TString eventFolderName):
139 AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(), alirunFileName),
140 fDefaultInit(kFALSE),
144 fInputFileNames(0x0),
148 fEMCDigitThreshold(0.f),
150 fCPVDigitThreshold(0.f),
151 fTimeResolution(0.f),
153 fTimeSignalLength(0.f),
155 fADCpedestalEmc(0.f),
158 fADCpedestalCpv(0.f),
160 fEventFolderName(eventFolderName),
167 fDefaultInit = kFALSE ;
168 fManager = 0 ; // We work in the standalong mode
171 //____________________________________________________________________________
172 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d) :
174 fDefaultInit(d.fDefaultInit),
175 fDigitsInRun(d.fDigitsInRun),
178 fInputFileNames(0x0),//?
180 fEmcCrystals(d.fEmcCrystals),
181 fPinNoise(d.fPinNoise),
182 fEMCDigitThreshold(d.fEMCDigitThreshold),
183 fCPVNoise(d.fCPVNoise),
184 fCPVDigitThreshold(d.fCPVDigitThreshold),
185 fTimeResolution(d.fTimeResolution),
186 fTimeThreshold(d.fTimeThreshold),
187 fTimeSignalLength(d.fTimeSignalLength),
188 fADCchanelEmc(d.fADCchanelEmc),
189 fADCpedestalEmc(d.fADCpedestalEmc),
190 fNADCemc(d.fNADCemc),
191 fADCchanelCpv(d.fADCchanelCpv),
192 fADCpedestalCpv(d.fADCpedestalCpv),
193 fNADCcpv(d.fNADCcpv),
194 fEventFolderName(d.fEventFolderName),
195 fFirstEvent(d.fFirstEvent),
196 fLastEvent(d.fLastEvent)
199 SetName(d.GetName()) ;
200 SetTitle(d.GetTitle()) ;
203 //____________________________________________________________________________
204 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd) :
205 AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()),
206 fDefaultInit(kFALSE),
210 fInputFileNames(0x0),
214 fEMCDigitThreshold(0.f),
216 fCPVDigitThreshold(0.f),
217 fTimeResolution(0.f),
219 fTimeSignalLength(0.f),
221 fADCpedestalEmc(0.f),
224 fADCpedestalCpv(0.f),
226 fEventFolderName(fManager->GetInputFolderName(0)),
230 // ctor Init() is called by RunDigitizer
232 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
234 fDefaultInit = kFALSE ;
237 //____________________________________________________________________________
238 AliPHOSDigitizer::~AliPHOSDigitizer()
240 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
242 // Clean Digitizer from the white board
243 gime->PhosLoader()->CleanDigitizer() ;
245 delete [] fInputFileNames ;
246 delete [] fEventNames ;
250 //____________________________________________________________________________
251 void AliPHOSDigitizer::Digitize(Int_t event)
254 // Makes the digitization of the collected summable digits.
255 // It first creates the array of all PHOS modules
256 // filled with noise (different for EMC, and CPV) and
257 // then adds contributions from SDigits.
258 // This design avoids scanning over the list of digits to add
259 // contribution to new SDigits only.
261 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
262 Int_t ReadEvent = event ;
264 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
265 AliInfo(Form("Adding event %d from input stream 0 %s %s",
266 ReadEvent, GetTitle(), fEventFolderName.Data())) ;
267 gime->Event(ReadEvent, "S") ;
268 TClonesArray * digits = gime->Digits() ;
271 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
272 //Making digits with noise, first EMC
273 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
278 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
280 digits->Expand(nCPV) ;
282 // get first the sdigitizer from the tasks list
283 if ( !gime->SDigitizer() )
284 gime->LoadSDigitizer();
285 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
288 AliFatal(Form("SDigitizer with name %s %s not found",
289 GetTitle(), fEventFolderName.Data() )) ;
291 //take all the inputs to add together and load the SDigits
292 TObjArray * sdigArray = new TObjArray(fInput) ;
293 sdigArray->AddAt(gime->SDigits(), 0) ;
295 for(i = 1 ; i < fInput ; i++){
296 TString tempo(fEventNames[i]) ;
298 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
300 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
301 AliInfo(Form("Adding event %d from input stream %d %s %s",
302 ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
303 gime->Event(ReadEvent,"S");
304 sdigArray->AddAt(gime->SDigits(), i) ;
307 //Find the first crystal with signal
308 Int_t nextSig = 200000 ;
309 TClonesArray * sdigits ;
310 for(i = 0 ; i < fInput ; i++){
311 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
312 if ( !sdigits->GetEntriesFast() )
314 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
315 if(curNext < nextSig)
319 TArrayI index(fInput) ;
320 index.Reset() ; //Set all indexes to zero
322 AliPHOSDigit * digit ;
323 AliPHOSDigit * curSDigit ;
325 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
327 //Put Noise contribution
328 for(absID = 1 ; absID <= nEMC ; absID++){
329 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
330 // YVK: do not digitize amplitudes for EMC
331 // new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
332 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, noise, TimeOfNoise() ) ;
333 //look if we have to add signal?
334 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
337 //Add SDigits from all inputs
340 Float_t a = digit->GetEnergy() ;
341 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
342 //Mark the beginning of the signal
343 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
344 //Mark the end of the signal
345 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
348 for(i = 0 ; i < fInput ; i++){
349 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
350 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
353 //May be several digits will contribute from the same input
354 while(curSDigit && curSDigit->GetId() == absID){
355 //Shift primary to separate primaries belonging different inputs
356 Int_t primaryoffset ;
358 primaryoffset = fManager->GetMask(i) ;
360 primaryoffset = 10000000*i ;
361 curSDigit->ShiftPrimary(primaryoffset) ;
363 a = curSDigit->GetEnergy() ;
364 b = a /fTimeSignalLength ;
365 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
366 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
368 *digit += *curSDigit ; //add energies
371 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
372 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
378 //calculate and set time
379 Float_t time = FrontEdgeTime(ticks) ;
380 digit->SetTime(time) ;
382 //Find next signal module
384 for(i = 0 ; i < fInput ; i++){
385 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
386 Int_t curNext = nextSig ;
387 if(sdigits->GetEntriesFast() > index[i] ){
388 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
390 if(curNext < nextSig) nextSig = curNext ;
398 //Now CPV digits (different noise and no timing)
399 for(absID = nEMC+1; absID <= nCPV; absID++){
400 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
401 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
402 //look if we have to add signal?
404 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
405 //Add SDigits from all inputs
406 for(i = 0 ; i < fInput ; i++){
407 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
408 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
412 //May be several digits will contribute from the same input
413 while(curSDigit && curSDigit->GetId() == absID){
414 //Shift primary to separate primaries belonging different inputs
415 Int_t primaryoffset ;
417 primaryoffset = fManager->GetMask(i) ;
419 primaryoffset = 10000000*i ;
420 curSDigit->ShiftPrimary(primaryoffset) ;
423 *digit += *curSDigit ;
425 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
426 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
432 //Find next signal module
434 for(i = 0 ; i < fInput ; i++){
435 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
436 Int_t curNext = nextSig ;
437 if(sdigits->GetEntriesFast() > index[i] )
438 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
439 if(curNext < nextSig) nextSig = curNext ;
445 delete sdigArray ; //We should not delete its contents
447 //remove digits below thresholds
448 for(i = 0 ; i < nEMC ; i++){
449 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
450 DecalibrateEMC(digit);
451 if(digit->GetEnergy() < fEMCDigitThreshold)
452 digits->RemoveAt(i) ;
454 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
458 for(i = nEMC; i < nCPV ; i++)
459 // if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
460 if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < fCPVDigitThreshold )
461 digits->RemoveAt(i) ;
465 Int_t ndigits = digits->GetEntriesFast() ;
466 digits->Expand(ndigits) ;
468 //Set indexes in list of digits and make true digitization of the energy
469 for (i = 0 ; i < ndigits ; i++) {
470 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
471 digit->SetIndexInList(i) ;
472 if(digit->GetId() > fEmcCrystals){ //digitize CPV only
473 digit->SetAmp(DigitizeCPV(digit->GetEnergy(),digit->GetId()) ) ;
478 //____________________________________________________________________________
479 void AliPHOSDigitizer::DecalibrateEMC(AliPHOSDigit *digit)
481 // Decalibrate EMC digit, i.e. change its energy by a factor read from CDB
483 AliPHOSGetter* gime = AliPHOSGetter::Instance();
485 if(!gime->CalibData()) {
486 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1);
487 gime->SetCalibData(cdb);
490 //Determine rel.position of the cell absolute ID
492 gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
493 Int_t module=relId[0];
495 Int_t column=relId[3];
496 Float_t decalibration = gime->CalibData()->GetADCchannelEmc(module,column,row);
497 Float_t energy = digit->GetEnergy() * decalibration;
498 digit->SetEnergy(energy);
500 //____________________________________________________________________________
501 Int_t AliPHOSDigitizer::DigitizeCPV(Float_t charge, Int_t absId)
503 // Returns digitized value of the CPV charge in a pad absId
505 AliPHOSGetter* gime = AliPHOSGetter::Instance();
507 if(!gime->CalibData()) {
508 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); // use AliCDBManager's run number
509 gime->SetCalibData(cdb);
512 //Determine rel.position of the cell absId
514 gime->PHOSGeometry()->AbsToRelNumbering(absId,relId);
515 Int_t module=relId[0];
517 Int_t column=relId[3];
521 if(absId > fEmcCrystals){ //digitize CPV only
523 //reading calibration data for cell absId.
524 //If no calibration DB found, accept default values.
526 if(gime->CalibData()) {
527 fADCpedestalCpv = gime->CalibData()->GetADCpedestalCpv(module,column,row);
528 fADCchanelCpv = gime->CalibData()->GetADCchannelCpv( module,column,row);
531 channel = (Int_t) TMath::Ceil((charge - fADCpedestalCpv)/fADCchanelCpv) ;
532 if(channel > fNADCcpv ) channel = fNADCcpv ;
537 //____________________________________________________________________________
538 void AliPHOSDigitizer::Exec(Option_t *option)
540 // Steering method to process digitization for events
541 // in the range from fFirstEvent to fLastEvent.
542 // This range is optionally set by SetEventRange().
543 // if fLastEvent=-1, then process events until the end.
544 // by default fLastEvent = fFirstEvent (process only one event)
546 if (!fInit) { // to prevent overwrite existing file
547 AliError(Form("Give a version name different from %s",
548 fEventFolderName.Data() )) ;
552 if (strstr(option,"print")) {
557 if(strstr(option,"tim"))
558 gBenchmark->Start("PHOSDigitizer");
560 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
562 // Post Digitizer to the white board
563 gime->PostDigitizer(this) ;
565 if (fLastEvent == -1)
566 fLastEvent = gime->MaxEvent() - 1 ;
568 fLastEvent = fFirstEvent ;
570 Int_t nEvents = fLastEvent - fFirstEvent + 1;
574 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
576 gime->Event(ievent,"S") ;
578 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
582 if(strstr(option,"deb"))
585 //increment the total number of Digits per run
586 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
589 gime->PhosLoader()->CleanDigitizer();
591 if(strstr(option,"tim")){
592 gBenchmark->Stop("PHOSDigitizer");
594 message = " took %f seconds for Digitizing %f seconds per event\n" ;
595 AliInfo(Form( message.Data(),
596 gBenchmark->GetCpuTime("PHOSDigitizer"),
597 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents ));
601 //____________________________________________________________________________
602 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
604 // Returns the shortest time among all time ticks
606 ticks->Sort() ; //Sort in accordance with times of ticks
608 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
609 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
612 while((t=(AliPHOSTick*) it.Next())){
613 if(t->GetTime() < time) //This tick starts before crossing
618 time = ctick->CrossingTime(fTimeThreshold) ;
623 //____________________________________________________________________________
624 Bool_t AliPHOSDigitizer::Init()
626 // Makes all memory allocations
628 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
630 AliFatal(Form("Could not obtain the Getter object for file %s and event %s !",
631 GetTitle(), fEventFolderName.Data()));
635 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
637 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
639 TString opt("Digits") ;
640 if(gime->VersionExists(opt) ) {
641 AliError(Form("Give a version name different from %s",
642 fEventFolderName.Data() )) ;
647 fLastEvent = fFirstEvent ;
649 fInput = fManager->GetNinputs() ;
653 fInputFileNames = new TString[fInput] ;
654 fEventNames = new TString[fInput] ;
655 fInputFileNames[0] = GetTitle() ;
656 fEventNames[0] = fEventFolderName.Data() ;
658 for (index = 1 ; index < fInput ; index++) {
659 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
660 TString tempo = fManager->GetInputFolderName(index) ;
661 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
664 //to prevent cleaning of this object while GetEvent is called
665 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
670 //____________________________________________________________________________
671 void AliPHOSDigitizer::InitParameters()
673 // Set initial parameters Digitizer
675 fPinNoise = 0.004 ; // [GeV]
676 fEMCDigitThreshold = 0.012 ; // [GeV]
677 fCPVNoise = 0.01; // [aux units]
678 fCPVDigitThreshold = 0.09 ; // [aux units]
679 fTimeResolution = 0.5e-9 ; // [sec]
680 fTimeSignalLength = 1.0e-9 ; // [sec]
682 fADCchanelEmc = 1.0; // Coefficient between real and measured energies in EMC
683 fADCpedestalEmc = 0. ; //
684 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
686 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
687 fADCpedestalCpv = 0.012 ; //
688 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
690 // fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
691 fTimeThreshold = 0.001 ; // [GeV]
692 SetEventRange(0,-1) ;
696 //__________________________________________________________________
697 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
699 // Allows to produce digits by superimposing background and signal event.
700 // It is assumed, that headers file with SIGNAL events is opened in
702 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
703 // Thus we avoid writing (changing) huge and expensive
704 // backgound files: all output will be writen into SIGNAL, i.e.
705 // opened in constructor file.
707 // One can open as many files to mix with as one needs.
708 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
711 if( strcmp(fEventFolderName, "") == 0 )
715 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
718 // looking for file which contains AliRun
719 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
720 AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
723 // looking for the file which contains SDigits
724 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
725 TString fileName( gime->GetSDigitsFileName() ) ;
726 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
727 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
728 if ( (gSystem->AccessPathName(fileName)) ) {
729 AliError(Form("The file %s does not exist!", fileName.Data())) ;
732 // need to increase the arrays
733 TString tempo = fInputFileNames[fInput-1] ;
734 delete [] fInputFileNames ;
735 fInputFileNames = new TString[fInput+1] ;
736 fInputFileNames[fInput-1] = tempo ;
738 tempo = fEventNames[fInput-1] ;
739 delete [] fEventNames ;
740 fEventNames = new TString[fInput+1] ;
741 fEventNames[fInput-1] = tempo ;
743 fInputFileNames[fInput] = alirunFileName ;
744 fEventNames[fInput] = eventFolderName ;
748 //__________________________________________________________________
749 void AliPHOSDigitizer::Print(const Option_t *)const
751 // Print Digitizer's parameters
752 AliInfo(Form("\n------------------- %s -------------", GetName() )) ;
753 if( strcmp(fEventFolderName.Data(), "") != 0 ){
754 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
758 nStreams = GetNInputStreams() ;
763 for (index = 0 ; index < nStreams ; index++) {
764 TString tempo(fEventNames[index]) ;
766 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
767 TString fileName( gime->GetSDigitsFileName() ) ;
768 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
769 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
770 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
772 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
773 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
775 printf("\nWith following parameters:\n") ;
776 printf(" Electronics noise in EMC (fPinNoise) = %f GeV\n", fPinNoise ) ;
777 printf(" Threshold in EMC (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ;
778 printf(" Noise in CPV (fCPVNoise) = %f aux units\n", fCPVNoise ) ;
779 printf(" Threshold in CPV (fCPVDigitThreshold) = %f aux units\n",fCPVDigitThreshold ) ;
780 printf(" ---------------------------------------------------\n") ;
783 AliInfo(Form("AliPHOSDigitizer not initialized" )) ;
787 //__________________________________________________________________
788 void AliPHOSDigitizer::PrintDigits(Option_t * option)
790 // Print a table of digits
792 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
793 TClonesArray * digits = gime->Digits() ;
795 AliInfo(Form("%d", digits->GetEntriesFast())) ;
796 printf("\nevent %d", gAlice->GetEvNumber()) ;
797 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
800 if(strstr(option,"all")||strstr(option,"EMC")){
802 AliPHOSDigit * digit;
803 printf("\nEMC digits (with primaries):\n") ;
804 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
805 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
807 for (index = 0 ; (index < digits->GetEntriesFast()) &&
808 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
809 digit = (AliPHOSDigit * ) digits->At(index) ;
810 if(digit->GetNprimary() == 0)
812 // printf("%6d %8d %6.5e %4d %2d :",
813 // digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; // YVK
814 printf("%6d %.4f %6.5e %4d %2d :",
815 digit->GetId(), digit->GetEnergy(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
817 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
818 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
824 if(strstr(option,"all")||strstr(option,"CPV")){
826 //loop over CPV digits
827 AliPHOSDigit * digit;
828 printf("\nCPV digits (with primaries):\n") ;
829 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
830 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
832 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
833 digit = (AliPHOSDigit * ) digits->At(index) ;
834 if(digit->GetId() > maxEmc){
835 printf("%6d %8d %4d %2d :",
836 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
838 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
839 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
848 //__________________________________________________________________
849 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
850 { // Calculates the time signal generated by noise
851 //PH Info("TimeOfNoise", "Change me") ;
852 return gRandom->Rndm() * 1.28E-5;
855 //__________________________________________________________________
856 void AliPHOSDigitizer::Unload()
860 for(i = 1 ; i < fInput ; i++){
861 TString tempo(fEventNames[i]) ;
863 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
864 gime->PhosLoader()->UnloadSDigits() ;
867 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
868 gime->PhosLoader()->UnloadDigits() ;
871 //____________________________________________________________________________
872 void AliPHOSDigitizer::WriteDigits()
875 // Makes TreeD in the output file.
876 // Check if branch already exists:
877 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
878 // already existing branches.
879 // else creates branch with Digits, named "PHOS", title "...",
880 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
881 // and names of files, from which digits are made.
883 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
884 const TClonesArray * digits = gime->Digits() ;
885 TTree * treeD = gime->TreeD();
887 // -- create Digits branch
888 Int_t bufferSize = 32000 ;
889 TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
890 digitsBranch->SetTitle(fEventFolderName);
891 digitsBranch->Fill() ;
893 gime->WriteDigits("OVERWRITE");
894 gime->WriteDigitizer("OVERWRITE");