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 **************************************************************************/
19 //_________________________________________________________________________
20 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
21 //////////////////////////////////////////////////////////////////////////////
22 // This TTask performs digitization of Summable digits (in the PHOS case it is just
23 // the sum of contributions from all primary particles into a given cell).
24 // In addition it performs mixing of summable digits from different events.
25 // The name of the TTask is also the title of the branch that will contain
26 // the created SDigits
27 // The title of the TTAsk is the name of the file that contains the hits from
28 // which the SDigits are created
30 // For each event two branches are created in TreeD:
31 // "PHOS" - list of digits
32 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
34 // Note, that one can set a title for new digits branch, and repeat digitization with
35 // another set of parameters.
38 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
39 // root[1] d->ExecuteTask()
40 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
41 // //Digitizes SDigitis in all events found in file galice.root
43 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
44 // // Will read sdigits from galice1.root
45 // root[3] d1->MixWith("galice2.root")
46 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
47 // // Reads another set of sdigits from galice2.root
48 // root[3] d1->MixWith("galice3.root")
49 // // Reads another set of sdigits from galice3.root
50 // root[4] d->ExecuteTask("deb timing")
51 // // Reads SDigits from files galice1.root, galice2.root ....
52 // // mixes them and stores produced Digits in file galice1.root
53 // // deb - prints number of produced digits
54 // // deb all - prints list of produced digits
55 // // timing - prints time used for digitization
58 // --- ROOT system ---
61 #include "TBenchmark.h"
64 // --- Standard library ---
66 // --- AliRoot header files ---
68 #include "AliRunDigitizer.h"
69 #include "AliPHOSDigit.h"
70 #include "AliPHOSGetter.h"
71 #include "AliPHOSDigitizer.h"
72 #include "AliPHOSSDigitizer.h"
73 #include "AliPHOSGeometry.h"
74 #include "AliPHOSTick.h"
76 ClassImp(AliPHOSDigitizer)
79 //____________________________________________________________________________
80 AliPHOSDigitizer::AliPHOSDigitizer():AliDigitizer("",""),
87 fDefaultInit = kTRUE ;
88 fManager = 0 ; // We work in the standalong mode
89 fEventFolderName = "" ;
92 //____________________________________________________________________________
93 AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName, TString eventFolderName):
94 AliDigitizer("PHOS"+AliConfig::fgkDigitizerTaskName, alirunFileName),
95 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
100 fDefaultInit = kFALSE ;
101 fManager = 0 ; // We work in the standalong mode
104 //____________________________________________________________________________
105 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
110 SetName(d.GetName()) ;
111 SetTitle(d.GetTitle()) ;
112 fPinNoise = d.fPinNoise ;
113 fEMCDigitThreshold = d.fEMCDigitThreshold ;
114 fCPVNoise = d.fCPVNoise ;
115 fCPVDigitThreshold = d.fCPVDigitThreshold ;
116 fTimeResolution = d.fTimeResolution ;
117 fTimeThreshold = d.fTimeThreshold ;
118 fTimeSignalLength = d.fTimeSignalLength ;
119 fADCchanelEmc = d.fADCchanelEmc ;
120 fADCpedestalEmc = d.fADCpedestalEmc ;
121 fNADCemc = d.fNADCemc ;
122 fADCchanelCpv = d.fADCchanelCpv ;
123 fADCpedestalCpv = d.fADCpedestalCpv ;
124 fNADCcpv = d.fNADCcpv ;
125 fEventFolderName = d.fEventFolderName;
128 //____________________________________________________________________________
129 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
130 AliDigitizer(rd,"PHOS"+AliConfig::fgkDigitizerTaskName),
133 // ctor Init() is called by RunDigitizer
135 fEventFolderName = fManager->GetInputFolderName(0) ;
136 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
138 fDefaultInit = kFALSE ;
141 //____________________________________________________________________________
142 AliPHOSDigitizer::~AliPHOSDigitizer()
145 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(),fEventFolderName);
146 gime->PhosLoader()->CleanDigitizer();
147 delete [] fInputFileNames ;
148 delete [] fEventNames ;
152 //____________________________________________________________________________
153 void AliPHOSDigitizer::Digitize(Int_t event)
156 // Makes the digitization of the collected summable digits.
157 // It first creates the array of all PHOS modules
158 // filled with noise (different for EMC, CPV and PPSD) and
159 // then adds contributions from SDigits.
160 // This design avoids scanning over the list of digits to add
161 // contribution to new SDigits only.
163 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
164 Int_t ReadEvent = event ;
166 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
167 Info("Digitize", "Adding event %d from input stream 0 %s", ReadEvent, fEventFolderName.Data()) ;
168 gime->Event(ReadEvent, "S") ;
169 TClonesArray * digits = gime->Digits() ;
172 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
173 //Making digits with noise, first EMC
174 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
179 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
181 digits->Expand(nCPV) ;
183 // get first the sdigitizer from the tasks list
184 if ( !gime->SDigitizer() )
185 gime->LoadSDigitizer();
186 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
189 Fatal("Digitize", "SDigitizer with name %s %s not found", fEventFolderName.Data(), GetTitle() ) ;
191 //take all the inputs to add together and load the SDigits
192 TObjArray * sdigArray = new TObjArray(fInput) ;
193 sdigArray->AddAt(gime->SDigits(), 0) ;
195 for(i = 1 ; i < fInput ; i++){
196 TString tempo(fEventNames[i]) ;
198 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
200 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
201 Info("Digitize", "Adding event %d from input stream %d %s", ReadEvent, i, fInputFileNames[i].Data()) ;
202 gime->Event(ReadEvent,"S");
203 sdigArray->AddAt(gime->SDigits(), i) ;
206 //Find the first crystall with signal
207 Int_t nextSig = 200000 ;
208 TClonesArray * sdigits ;
209 for(i = 0 ; i < fInput ; i++){
210 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
211 if ( !sdigits->GetEntriesFast() )
213 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
214 if(curNext < nextSig)
218 TArrayI index(fInput) ;
219 index.Reset() ; //Set all indexes to zero
221 AliPHOSDigit * digit ;
222 AliPHOSDigit * curSDigit ;
224 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
226 //Put Noise contribution
227 for(absID = 1 ; absID <= nEMC ; absID++){
228 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
229 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
230 //look if we have to add signal?
231 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
234 //Add SDigits from all inputs
237 Float_t a = digit->GetAmp() ;
238 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
239 //Mark the beginning of the signal
240 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
241 //Mark the end of the ignal
242 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
245 for(i = 0 ; i < fInput ; i++){
246 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
247 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
250 //May be several digits will contribute from the same input
251 while(curSDigit && curSDigit->GetId() == absID){
252 //Shift primary to separate primaries belonging different inputs
253 Int_t primaryoffset ;
255 primaryoffset = fManager->GetMask(i) ;
257 primaryoffset = 10000000*i ;
258 curSDigit->ShiftPrimary(primaryoffset) ;
260 a = curSDigit->GetAmp() ;
261 b = a /fTimeSignalLength ;
262 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
263 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
265 *digit = *digit + *curSDigit ; //add energies
268 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
269 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
275 //calculate and set time
276 Float_t time = FrontEdgeTime(ticks) ;
277 digit->SetTime(time) ;
279 //Find next signal module
281 for(i = 0 ; i < fInput ; i++){
282 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
283 Int_t curNext = nextSig ;
284 if(sdigits->GetEntriesFast() > index[i] ){
285 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
287 if(curNext < nextSig) nextSig = curNext ;
295 //Now CPV digits (different noise and no timing)
296 for(absID = nEMC+1; absID <= nCPV; absID++){
297 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
298 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
299 //look if we have to add signal?
301 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
302 //Add SDigits from all inputs
303 for(i = 0 ; i < fInput ; i++){
304 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
305 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
309 //May be several digits will contribute from the same input
310 while(curSDigit && curSDigit->GetId() == absID){
311 //Shift primary to separate primaries belonging different inputs
312 Int_t primaryoffset ;
314 primaryoffset = fManager->GetMask(i) ;
316 primaryoffset = 10000000*i ;
317 curSDigit->ShiftPrimary(primaryoffset) ;
320 *digit = *digit + *curSDigit ;
322 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
323 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
329 //Find next signal module
331 for(i = 0 ; i < fInput ; i++){
332 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
333 Int_t curNext = nextSig ;
334 if(sdigits->GetEntriesFast() > index[i] )
335 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
336 if(curNext < nextSig) nextSig = curNext ;
342 delete sdigArray ; //We should not delete its contents
344 //remove digits below thresholds
345 for(i = 0 ; i < nEMC ; i++){
346 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
347 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
348 digits->RemoveAt(i) ;
350 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
354 for(i = nEMC; i < nCPV ; i++)
355 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
356 digits->RemoveAt(i) ;
360 Int_t ndigits = digits->GetEntriesFast() ;
361 digits->Expand(ndigits) ;
363 //Set indexes in list of digits and make true digitization of the energy
364 for (i = 0 ; i < ndigits ; i++) {
365 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
366 digit->SetIndexInList(i) ;
367 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
368 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
372 //____________________________________________________________________________
373 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
375 // Returns digitized value of the energy in a cell absId
378 if(absId <= fEmcCrystals){ //digitize as EMC
379 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
380 if(chanel > fNADCemc ) chanel = fNADCemc ;
382 else{ //Digitize as CPV
383 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
384 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
389 //____________________________________________________________________________
390 void AliPHOSDigitizer::Exec(Option_t *option)
392 // Steering method to process digitization for events
393 // in the range from fFirstEvent to fLastEvent.
394 // This range is optionally set by SetEventRange().
395 // if fLastEvent=-1, then process events until the end.
396 // by default fLastEvent = fFirstEvent (process only one event)
398 if (!fInit) { // to prevent overwrite existing file
399 Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
403 if (strstr(option,"print")) {
408 if(strstr(option,"tim"))
409 gBenchmark->Start("PHOSDigitizer");
411 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
413 if (fLastEvent == -1)
414 fLastEvent = gime->MaxEvent() - 1 ;
416 fLastEvent = fFirstEvent ;
418 Int_t nEvents = fLastEvent - fFirstEvent + 1;
422 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
424 gime->Event(ievent,"S") ;
426 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
430 if(strstr(option,"deb"))
433 //increment the total number of Digits per run
434 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
437 if(strstr(option,"tim")){
438 gBenchmark->Stop("PHOSDigitizer");
440 message = " took %f seconds for Digitizing %f seconds per event\n" ;
441 Info("Exec", message.Data(),
442 gBenchmark->GetCpuTime("PHOSDigitizer"),
443 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents );
447 //____________________________________________________________________________
448 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
450 // Returns the shortest time among all time ticks
452 ticks->Sort() ; //Sort in accordance with times of ticks
454 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
455 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
458 while((t=(AliPHOSTick*) it.Next())){
459 if(t->GetTime() < time) //This tick starts before crossing
464 time = ctick->CrossingTime(fTimeThreshold) ;
469 //____________________________________________________________________________
470 Bool_t AliPHOSDigitizer::Init()
472 // Makes all memory allocations
474 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
476 Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ;
480 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
482 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
484 TString opt("Digits") ;
485 if(gime->VersionExists(opt) ) {
486 Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ;
490 // Post Digitizer to the white board
491 gime->PostDigitizer(this) ;
494 fLastEvent = fFirstEvent ;
496 fInput = fManager->GetNinputs() ;
500 fInputFileNames = new TString[fInput] ;
501 fEventNames = new TString[fInput] ;
502 fInputFileNames[0] = GetTitle() ;
503 fEventNames[0] = fEventFolderName.Data() ;
505 for (index = 1 ; index < fInput ; index++) {
506 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
507 TString tempo = fManager->GetInputFolderName(index) ;
508 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
511 //to prevent cleaning of this object while GetEvent is called
512 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
517 //____________________________________________________________________________
518 void AliPHOSDigitizer::InitParameters()
520 // Set initial parameters Digitizer
523 fEMCDigitThreshold = 0.012 ;
525 fCPVDigitThreshold = 0.09 ;
526 fTimeResolution = 0.5e-9 ;
527 fTimeSignalLength = 1.0e-9 ;
529 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
530 fADCpedestalEmc = 0.005 ; //
531 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
533 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
534 fADCpedestalCpv = 0.012 ; //
535 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
537 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
538 SetEventRange(0,-1) ;
542 //__________________________________________________________________
543 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
545 // Allows to produce digits by superimposing background and signal event.
546 // It is assumed, that headers file with SIGNAL events is opened in
548 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
549 // Thus we avoid writing (changing) huge and expensive
550 // backgound files: all output will be writen into SIGNAL, i.e.
551 // opened in constructor file.
553 // One can open as many files to mix with as one needs.
554 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
557 if( strcmp(fEventFolderName, "") == 0 )
561 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
564 // looking for file which contains AliRun
565 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
566 Error("MixWith", "File %s does not exist!", alirunFileName.Data()) ;
569 // looking for the file which contains SDigits
570 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
571 TString fileName( gime->GetSDigitsFileName() ) ;
572 if ( eventFolderName != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
573 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
574 if ( (gSystem->AccessPathName(fileName)) ) {
575 Error("MixWith", "The file %s does not exist!", fileName.Data()) ;
578 // need to increase the arrays
579 TString tempo = fInputFileNames[fInput-1] ;
580 delete [] fInputFileNames ;
581 fInputFileNames = new TString[fInput+1] ;
582 fInputFileNames[fInput-1] = tempo ;
584 tempo = fEventNames[fInput-1] ;
585 delete [] fEventNames ;
586 fEventNames = new TString[fInput+1] ;
587 fEventNames[fInput-1] = tempo ;
589 fInputFileNames[fInput] = alirunFileName ;
590 fEventNames[fInput] = eventFolderName ;
594 //__________________________________________________________________
595 void AliPHOSDigitizer::Print()const
597 // Print Digitizer's parameters
598 Info("Print", "\n------------------- %s -------------", GetName() ) ;
599 if( strcmp(fEventFolderName.Data(), "") != 0 ){
600 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
604 nStreams = GetNInputStreams() ;
609 for (index = 0 ; index < nStreams ; index++) {
610 TString tempo(fEventNames[index]) ;
612 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
613 TString fileName( gime->GetSDigitsFileName() ) ;
614 if ( fEventNames[index] != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
615 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
616 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
618 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
619 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
621 printf("\nWith following parameters:\n") ;
622 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
623 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
624 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
625 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
626 printf(" ---------------------------------------------------\n") ;
629 Info("Print", "AliPHOSDigitizer not initialized" ) ;
633 //__________________________________________________________________
634 void AliPHOSDigitizer::PrintDigits(Option_t * option)
636 // Print a table of digits
638 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
639 TClonesArray * digits = gime->Digits() ;
641 Info("PrintDigits", "%d", digits->GetEntriesFast()) ;
642 printf("\nevent %d", gAlice->GetEvNumber()) ;
643 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
646 if(strstr(option,"all")||strstr(option,"EMC")){
648 AliPHOSDigit * digit;
649 printf("\nEMC digits (with primaries):\n") ;
650 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
651 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
653 for (index = 0 ; (index < digits->GetEntriesFast()) &&
654 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
655 digit = (AliPHOSDigit * ) digits->At(index) ;
656 if(digit->GetNprimary() == 0)
658 printf("%6d %8d %6.5e %4d %2d :",
659 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
661 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
662 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
668 if(strstr(option,"all")||strstr(option,"CPV")){
670 //loop over CPV digits
671 AliPHOSDigit * digit;
672 printf("\nCPV digits (with primaries):\n") ;
673 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
674 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
676 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
677 digit = (AliPHOSDigit * ) digits->At(index) ;
678 if(digit->GetId() > maxEmc){
679 printf("%6d %8d %4d %2d :",
680 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
682 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
683 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
692 //__________________________________________________________________
693 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
694 { // Calculates the time signal generated by noise
695 //to be rewritten, now returns just big number
700 //__________________________________________________________________
701 void AliPHOSDigitizer::Unload()
705 for(i = 1 ; i < fInput ; i++){
706 TString tempo(fEventNames[i]) ;
708 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
709 gime->PhosLoader()->UnloadSDigits() ;
712 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
713 gime->PhosLoader()->UnloadDigits() ;
716 //____________________________________________________________________________
717 void AliPHOSDigitizer::WriteDigits()
720 // Makes TreeD in the output file.
721 // Check if branch already exists:
722 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
723 // already existing branches.
724 // else creates branch with Digits, named "PHOS", title "...",
725 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
726 // and names of files, from which digits are made.
728 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
729 const TClonesArray * digits = gime->Digits() ;
730 TTree * treeD = gime->TreeD();
732 // -- create Digits branch
733 Int_t bufferSize = 32000 ;
734 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
735 digitsBranch->SetTitle(fEventFolderName);
736 digitsBranch->Fill() ;
738 gime->WriteDigits("OVERWRITE");
739 gime->WriteDigitizer("OVERWRITE");