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.89 2006/04/11 15:22:59 hristov
22 * run number in query set to -1: forces AliCDBManager to use its run number (A.Colla)
24 * Revision 1.88 2006/03/13 14:05:43 kharlov
25 * Calibration objects for EMC and CPV
27 * Revision 1.87 2005/08/24 15:33:49 kharlov
28 * Calibration data for raw digits
30 * Revision 1.86 2005/07/12 20:07:35 hristov
31 * Changes needed to run simulation and reconstrruction in the same AliRoot session
33 * Revision 1.85 2005/05/28 14:19:04 schutz
34 * Compilation warnings fixed by T.P.
38 //_________________________________________________________________________
39 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
40 //////////////////////////////////////////////////////////////////////////////
41 // This TTask performs digitization of Summable digits (in the PHOS case it is just
42 // the sum of contributions from all primary particles into a given cell).
43 // In addition it performs mixing of summable digits from different events.
44 // The name of the TTask is also the title of the branch that will contain
45 // the created SDigits
46 // The title of the TTAsk is the name of the file that contains the hits from
47 // which the SDigits are created
49 // For each event two branches are created in TreeD:
50 // "PHOS" - list of digits
51 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
53 // Note, that one can set a title for new digits branch, and repeat digitization with
54 // another set of parameters.
57 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
58 // root[1] d->ExecuteTask()
59 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
60 // //Digitizes SDigitis in all events found in file galice.root
62 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
63 // // Will read sdigits from galice1.root
64 // root[3] d1->MixWith("galice2.root")
65 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
66 // // Reads another set of sdigits from galice2.root
67 // root[3] d1->MixWith("galice3.root")
68 // // Reads another set of sdigits from galice3.root
69 // root[4] d->ExecuteTask("deb timing")
70 // // Reads SDigits from files galice1.root, galice2.root ....
71 // // mixes them and stores produced Digits in file galice1.root
72 // // deb - prints number of produced digits
73 // // deb all - prints list of produced digits
74 // // timing - prints time used for digitization
77 // --- ROOT system ---
80 #include "TBenchmark.h"
83 // --- Standard library ---
85 // --- AliRoot header files ---
87 #include "AliRunDigitizer.h"
88 #include "AliPHOSDigit.h"
89 #include "AliPHOSGetter.h"
90 #include "AliPHOSDigitizer.h"
91 #include "AliPHOSSDigitizer.h"
92 #include "AliPHOSGeometry.h"
93 #include "AliPHOSTick.h"
95 ClassImp(AliPHOSDigitizer)
98 //____________________________________________________________________________
99 AliPHOSDigitizer::AliPHOSDigitizer():AliDigitizer("",""),
101 fInputFileNames(0x0),
106 fDefaultInit = kTRUE ;
107 fManager = 0 ; // We work in the standalong mode
108 fEventFolderName = "" ;
111 //____________________________________________________________________________
112 AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
113 TString eventFolderName):
114 AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(),
116 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
121 fDefaultInit = kFALSE ;
122 fManager = 0 ; // We work in the standalong mode
125 //____________________________________________________________________________
126 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
131 SetName(d.GetName()) ;
132 SetTitle(d.GetTitle()) ;
133 fPinNoise = d.fPinNoise ;
134 fEMCDigitThreshold = d.fEMCDigitThreshold ;
135 fCPVNoise = d.fCPVNoise ;
136 fCPVDigitThreshold = d.fCPVDigitThreshold ;
137 fTimeResolution = d.fTimeResolution ;
138 fTimeThreshold = d.fTimeThreshold ;
139 fTimeSignalLength = d.fTimeSignalLength ;
140 fADCchanelEmc = d.fADCchanelEmc ;
141 fADCpedestalEmc = d.fADCpedestalEmc ;
142 fNADCemc = d.fNADCemc ;
143 fADCchanelCpv = d.fADCchanelCpv ;
144 fADCpedestalCpv = d.fADCpedestalCpv ;
145 fNADCcpv = d.fNADCcpv ;
146 fEventFolderName = d.fEventFolderName;
149 //____________________________________________________________________________
150 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
151 AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()),
154 // ctor Init() is called by RunDigitizer
156 fEventFolderName = fManager->GetInputFolderName(0) ;
157 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
159 fDefaultInit = kFALSE ;
162 //____________________________________________________________________________
163 AliPHOSDigitizer::~AliPHOSDigitizer()
165 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
167 // Clean Digitizer from the white board
168 gime->PhosLoader()->CleanDigitizer() ;
170 delete [] fInputFileNames ;
171 delete [] fEventNames ;
175 //____________________________________________________________________________
176 void AliPHOSDigitizer::Digitize(Int_t event)
179 // Makes the digitization of the collected summable digits.
180 // It first creates the array of all PHOS modules
181 // filled with noise (different for EMC, and CPV) and
182 // then adds contributions from SDigits.
183 // This design avoids scanning over the list of digits to add
184 // contribution to new SDigits only.
186 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
187 Int_t ReadEvent = event ;
189 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
190 AliInfo(Form("Adding event %d from input stream 0 %s %s",
191 ReadEvent, GetTitle(), fEventFolderName.Data())) ;
192 gime->Event(ReadEvent, "S") ;
193 TClonesArray * digits = gime->Digits() ;
196 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
197 //Making digits with noise, first EMC
198 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
203 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
205 digits->Expand(nCPV) ;
207 // get first the sdigitizer from the tasks list
208 if ( !gime->SDigitizer() )
209 gime->LoadSDigitizer();
210 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
213 AliFatal(Form("SDigitizer with name %s %s not found",
214 GetTitle(), fEventFolderName.Data() )) ;
216 //take all the inputs to add together and load the SDigits
217 TObjArray * sdigArray = new TObjArray(fInput) ;
218 sdigArray->AddAt(gime->SDigits(), 0) ;
220 for(i = 1 ; i < fInput ; i++){
221 TString tempo(fEventNames[i]) ;
223 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
225 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
226 AliInfo(Form("Adding event %d from input stream %d %s %s",
227 ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
228 gime->Event(ReadEvent,"S");
229 sdigArray->AddAt(gime->SDigits(), i) ;
232 //Find the first crystal with signal
233 Int_t nextSig = 200000 ;
234 TClonesArray * sdigits ;
235 for(i = 0 ; i < fInput ; i++){
236 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
237 if ( !sdigits->GetEntriesFast() )
239 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
240 if(curNext < nextSig)
244 TArrayI index(fInput) ;
245 index.Reset() ; //Set all indexes to zero
247 AliPHOSDigit * digit ;
248 AliPHOSDigit * curSDigit ;
250 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
252 //Put Noise contribution
253 for(absID = 1 ; absID <= nEMC ; absID++){
254 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
255 // YVK: do not digitize amplitudes for EMC
256 // new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
257 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, noise, TimeOfNoise() ) ;
258 //look if we have to add signal?
259 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
262 //Add SDigits from all inputs
265 Float_t a = digit->GetEnergy() ;
266 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
267 //Mark the beginning of the signal
268 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
269 //Mark the end of the signal
270 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
273 for(i = 0 ; i < fInput ; i++){
274 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
275 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
278 //May be several digits will contribute from the same input
279 while(curSDigit && curSDigit->GetId() == absID){
280 //Shift primary to separate primaries belonging different inputs
281 Int_t primaryoffset ;
283 primaryoffset = fManager->GetMask(i) ;
285 primaryoffset = 10000000*i ;
286 curSDigit->ShiftPrimary(primaryoffset) ;
288 a = curSDigit->GetEnergy() ;
289 b = a /fTimeSignalLength ;
290 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
291 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
293 *digit = *digit + *curSDigit ; //add energies
296 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
297 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
303 //calculate and set time
304 Float_t time = FrontEdgeTime(ticks) ;
305 digit->SetTime(time) ;
307 //Find next signal module
309 for(i = 0 ; i < fInput ; i++){
310 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
311 Int_t curNext = nextSig ;
312 if(sdigits->GetEntriesFast() > index[i] ){
313 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
315 if(curNext < nextSig) nextSig = curNext ;
323 //Now CPV digits (different noise and no timing)
324 for(absID = nEMC+1; absID <= nCPV; absID++){
325 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
326 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
327 //look if we have to add signal?
329 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
330 //Add SDigits from all inputs
331 for(i = 0 ; i < fInput ; i++){
332 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
333 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
337 //May be several digits will contribute from the same input
338 while(curSDigit && curSDigit->GetId() == absID){
339 //Shift primary to separate primaries belonging different inputs
340 Int_t primaryoffset ;
342 primaryoffset = fManager->GetMask(i) ;
344 primaryoffset = 10000000*i ;
345 curSDigit->ShiftPrimary(primaryoffset) ;
348 *digit = *digit + *curSDigit ;
350 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
351 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
357 //Find next signal module
359 for(i = 0 ; i < fInput ; i++){
360 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
361 Int_t curNext = nextSig ;
362 if(sdigits->GetEntriesFast() > index[i] )
363 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
364 if(curNext < nextSig) nextSig = curNext ;
370 delete sdigArray ; //We should not delete its contents
372 //remove digits below thresholds
373 for(i = 0 ; i < nEMC ; i++){
374 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
375 // YVK: amplitude is in energy units
376 // if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
377 if(digit->GetEnergy() < fEMCDigitThreshold)
378 digits->RemoveAt(i) ;
380 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
384 for(i = nEMC; i < nCPV ; i++)
385 // if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
386 if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < fCPVDigitThreshold )
387 digits->RemoveAt(i) ;
391 Int_t ndigits = digits->GetEntriesFast() ;
392 digits->Expand(ndigits) ;
394 //Set indexes in list of digits and make true digitization of the energy
395 for (i = 0 ; i < ndigits ; i++) {
396 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
397 digit->SetIndexInList(i) ;
398 if(digit->GetId() > fEmcCrystals){ //digitize CPV only
399 digit->SetAmp(DigitizeEnergy(digit->GetEnergy(),digit->GetId()) ) ;
404 //____________________________________________________________________________
405 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
407 // Returns digitized value of the energy in a cell absId
409 AliPHOSGetter* gime = AliPHOSGetter::Instance();
411 if(!gime->CalibData()) {
412 //AliPHOSCalibData* cdb = new AliPHOSCalibData(gAlice->GetRunNumber()); // original
413 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); // use AliCDBManager's run number
414 gime->SetCalibData(cdb);
417 //Determine rel.position of the cell absId
419 gime->PHOSGeometry()->AbsToRelNumbering(absId,relId);
420 Int_t module=relId[0];
422 Int_t column=relId[3];
426 if(absId <= fEmcCrystals){ //digitize as EMC
428 //reading calibration data for cell absId.
429 //If no calibration DB found, accept default values.
431 if(gime->CalibData()) {
432 fADCpedestalEmc = gime->CalibData()->GetADCpedestalEmc(module,column,row);
433 fADCchanelEmc = gime->CalibData()->GetADCchannelEmc(module,column,row);
436 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
437 if(chanel > fNADCemc ) chanel = fNADCemc ;
439 else{ //Digitize as CPV
440 if(gime->CalibData()) {
441 fADCpedestalCpv = gime->CalibData()->GetADCpedestalCpv(module,column,row);
442 fADCchanelCpv = gime->CalibData()->GetADCchannelCpv(module,column,row);
445 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
446 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
451 //____________________________________________________________________________
452 void AliPHOSDigitizer::Exec(Option_t *option)
454 // Steering method to process digitization for events
455 // in the range from fFirstEvent to fLastEvent.
456 // This range is optionally set by SetEventRange().
457 // if fLastEvent=-1, then process events until the end.
458 // by default fLastEvent = fFirstEvent (process only one event)
460 if (!fInit) { // to prevent overwrite existing file
461 AliError(Form("Give a version name different from %s",
462 fEventFolderName.Data() )) ;
466 if (strstr(option,"print")) {
471 if(strstr(option,"tim"))
472 gBenchmark->Start("PHOSDigitizer");
474 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
476 // Post Digitizer to the white board
477 gime->PostDigitizer(this) ;
479 if (fLastEvent == -1)
480 fLastEvent = gime->MaxEvent() - 1 ;
482 fLastEvent = fFirstEvent ;
484 Int_t nEvents = fLastEvent - fFirstEvent + 1;
488 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
490 gime->Event(ievent,"S") ;
492 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
496 if(strstr(option,"deb"))
499 //increment the total number of Digits per run
500 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
503 gime->PhosLoader()->CleanDigitizer();
505 if(strstr(option,"tim")){
506 gBenchmark->Stop("PHOSDigitizer");
508 message = " took %f seconds for Digitizing %f seconds per event\n" ;
509 AliInfo(Form( message.Data(),
510 gBenchmark->GetCpuTime("PHOSDigitizer"),
511 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents ));
515 //____________________________________________________________________________
516 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
518 // Returns the shortest time among all time ticks
520 ticks->Sort() ; //Sort in accordance with times of ticks
522 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
523 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
526 while((t=(AliPHOSTick*) it.Next())){
527 if(t->GetTime() < time) //This tick starts before crossing
532 time = ctick->CrossingTime(fTimeThreshold) ;
537 //____________________________________________________________________________
538 Bool_t AliPHOSDigitizer::Init()
540 // Makes all memory allocations
542 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
544 AliFatal(Form("Could not obtain the Getter object for file %s and event %s !",
545 GetTitle(), fEventFolderName.Data()));
549 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
551 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
553 TString opt("Digits") ;
554 if(gime->VersionExists(opt) ) {
555 AliError(Form("Give a version name different from %s",
556 fEventFolderName.Data() )) ;
561 fLastEvent = fFirstEvent ;
563 fInput = fManager->GetNinputs() ;
567 fInputFileNames = new TString[fInput] ;
568 fEventNames = new TString[fInput] ;
569 fInputFileNames[0] = GetTitle() ;
570 fEventNames[0] = fEventFolderName.Data() ;
572 for (index = 1 ; index < fInput ; index++) {
573 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
574 TString tempo = fManager->GetInputFolderName(index) ;
575 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
578 //to prevent cleaning of this object while GetEvent is called
579 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
584 //____________________________________________________________________________
585 void AliPHOSDigitizer::InitParameters()
587 // Set initial parameters Digitizer
589 fPinNoise = 0.004 ; // [GeV]
590 fEMCDigitThreshold = 0.012 ; // [GeV]
591 fCPVNoise = 0.01; // [aux units]
592 fCPVDigitThreshold = 0.09 ; // [aux units]
593 fTimeResolution = 0.5e-9 ; // [sec]
594 fTimeSignalLength = 1.0e-9 ; // [sec]
596 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
597 fADCpedestalEmc = 0.005 ; //
598 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
600 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
601 fADCpedestalCpv = 0.012 ; //
602 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
604 // fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
605 fTimeThreshold = 0.001 ; // [GeV]
606 SetEventRange(0,-1) ;
610 //__________________________________________________________________
611 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
613 // Allows to produce digits by superimposing background and signal event.
614 // It is assumed, that headers file with SIGNAL events is opened in
616 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
617 // Thus we avoid writing (changing) huge and expensive
618 // backgound files: all output will be writen into SIGNAL, i.e.
619 // opened in constructor file.
621 // One can open as many files to mix with as one needs.
622 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
625 if( strcmp(fEventFolderName, "") == 0 )
629 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
632 // looking for file which contains AliRun
633 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
634 AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
637 // looking for the file which contains SDigits
638 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
639 TString fileName( gime->GetSDigitsFileName() ) ;
640 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
641 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
642 if ( (gSystem->AccessPathName(fileName)) ) {
643 AliError(Form("The file %s does not exist!", fileName.Data())) ;
646 // need to increase the arrays
647 TString tempo = fInputFileNames[fInput-1] ;
648 delete [] fInputFileNames ;
649 fInputFileNames = new TString[fInput+1] ;
650 fInputFileNames[fInput-1] = tempo ;
652 tempo = fEventNames[fInput-1] ;
653 delete [] fEventNames ;
654 fEventNames = new TString[fInput+1] ;
655 fEventNames[fInput-1] = tempo ;
657 fInputFileNames[fInput] = alirunFileName ;
658 fEventNames[fInput] = eventFolderName ;
662 //__________________________________________________________________
663 void AliPHOSDigitizer::Print(const Option_t *)const
665 // Print Digitizer's parameters
666 AliInfo(Form("\n------------------- %s -------------", GetName() )) ;
667 if( strcmp(fEventFolderName.Data(), "") != 0 ){
668 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
672 nStreams = GetNInputStreams() ;
677 for (index = 0 ; index < nStreams ; index++) {
678 TString tempo(fEventNames[index]) ;
680 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
681 TString fileName( gime->GetSDigitsFileName() ) ;
682 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
683 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
684 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
686 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
687 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
689 printf("\nWith following parameters:\n") ;
690 printf(" Electronics noise in EMC (fPinNoise) = %f GeV\n", fPinNoise ) ;
691 printf(" Threshold in EMC (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ;
692 printf(" Noise in CPV (fCPVNoise) = %f aux units\n", fCPVNoise ) ;
693 printf(" Threshold in CPV (fCPVDigitThreshold) = %f aux units\n",fCPVDigitThreshold ) ;
694 printf(" ---------------------------------------------------\n") ;
697 AliInfo(Form("AliPHOSDigitizer not initialized" )) ;
701 //__________________________________________________________________
702 void AliPHOSDigitizer::PrintDigits(Option_t * option)
704 // Print a table of digits
706 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
707 TClonesArray * digits = gime->Digits() ;
709 AliInfo(Form("%d", digits->GetEntriesFast())) ;
710 printf("\nevent %d", gAlice->GetEvNumber()) ;
711 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
714 if(strstr(option,"all")||strstr(option,"EMC")){
716 AliPHOSDigit * digit;
717 printf("\nEMC digits (with primaries):\n") ;
718 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
719 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
721 for (index = 0 ; (index < digits->GetEntriesFast()) &&
722 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
723 digit = (AliPHOSDigit * ) digits->At(index) ;
724 if(digit->GetNprimary() == 0)
726 // printf("%6d %8d %6.5e %4d %2d :",
727 // digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; // YVK
728 printf("%6d %.4f %6.5e %4d %2d :",
729 digit->GetId(), digit->GetEnergy(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
731 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
732 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
738 if(strstr(option,"all")||strstr(option,"CPV")){
740 //loop over CPV digits
741 AliPHOSDigit * digit;
742 printf("\nCPV digits (with primaries):\n") ;
743 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
744 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
746 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
747 digit = (AliPHOSDigit * ) digits->At(index) ;
748 if(digit->GetId() > maxEmc){
749 printf("%6d %8d %4d %2d :",
750 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
752 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
753 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
762 //__________________________________________________________________
763 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
764 { // Calculates the time signal generated by noise
765 //PH Info("TimeOfNoise", "Change me") ;
766 return gRandom->Rndm() * 1.28E-5;
769 //__________________________________________________________________
770 void AliPHOSDigitizer::Unload()
774 for(i = 1 ; i < fInput ; i++){
775 TString tempo(fEventNames[i]) ;
777 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
778 gime->PhosLoader()->UnloadSDigits() ;
781 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
782 gime->PhosLoader()->UnloadDigits() ;
785 //____________________________________________________________________________
786 void AliPHOSDigitizer::WriteDigits()
789 // Makes TreeD in the output file.
790 // Check if branch already exists:
791 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
792 // already existing branches.
793 // else creates branch with Digits, named "PHOS", title "...",
794 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
795 // and names of files, from which digits are made.
797 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
798 const TClonesArray * digits = gime->Digits() ;
799 TTree * treeD = gime->TreeD();
801 // -- create Digits branch
802 Int_t bufferSize = 32000 ;
803 TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
804 digitsBranch->SetTitle(fEventFolderName);
805 digitsBranch->Fill() ;
807 gime->WriteDigits("OVERWRITE");
808 gime->WriteDigitizer("OVERWRITE");