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(const TString alirunFileName, const 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),
135 fEventFolderName = fManager->GetInputFolderName(0) ;
136 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
139 fDefaultInit = kFALSE ;
142 //____________________________________________________________________________
143 AliPHOSDigitizer::~AliPHOSDigitizer()
146 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(),fEventFolderName);
147 gime->PhosLoader()->CleanDigitizer();
148 delete [] fInputFileNames ;
149 delete [] fEventNames ;
153 //____________________________________________________________________________
154 void AliPHOSDigitizer::Digitize(const Int_t event)
157 // Makes the digitization of the collected summable digits.
158 // It first creates the array of all PHOS modules
159 // filled with noise (different for EMC, CPV and PPSD) and
160 // then adds contributions from SDigits.
161 // This design avoids scanning over the list of digits to add
162 // contribution to new SDigits only.
164 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
165 TClonesArray * digits = gime->Digits() ;
168 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
169 //Making digits with noise, first EMC
170 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
175 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
177 digits->Expand(nCPV) ;
179 // get first the sdigitizer from the tasks list
180 if ( !gime->SDigitizer() )
181 gime->LoadSDigitizer();
182 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
185 Fatal("Digitize", "SDigitizer with name %s %s not found", fEventFolderName.Data(), GetTitle() ) ;
187 //take all the inputs to add together and load the SDigits
188 TObjArray * sdigArray = new TObjArray(fInput) ;
189 sdigArray->AddAt(gime->SDigits(), 0) ;
191 for(i = 1 ; i < fInput ; i++){
192 TString tempo(fEventNames[i]) ;
194 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
195 gime->Event(event,"S");
196 sdigArray->AddAt(gime->SDigits(), i) ;
199 //Find the first crystall with signal
200 Int_t nextSig = 200000 ;
201 TClonesArray * sdigits ;
202 for(i = 0 ; i < fInput ; i++){
203 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
204 if ( !sdigits->GetEntriesFast() )
206 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
207 if(curNext < nextSig)
211 TArrayI index(fInput) ;
212 index.Reset() ; //Set all indexes to zero
214 AliPHOSDigit * digit ;
215 AliPHOSDigit * curSDigit ;
217 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
219 //Put Noise contribution
220 for(absID = 1 ; absID <= nEMC ; absID++){
221 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
222 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
223 //look if we have to add signal?
224 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
227 //Add SDigits from all inputs
230 Float_t a = digit->GetAmp() ;
231 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
232 //Mark the beginning of the signal
233 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
234 //Mark the end of the ignal
235 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
238 for(i = 0 ; i < fInput ; i++){
239 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
240 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
243 //May be several digits will contribute from the same input
244 while(curSDigit && curSDigit->GetId() == absID){
245 //Shift primary to separate primaries belonging different inputs
246 Int_t primaryoffset ;
248 primaryoffset = fManager->GetMask(i) ;
250 primaryoffset = 10000000*i ;
251 curSDigit->ShiftPrimary(primaryoffset) ;
253 a = curSDigit->GetAmp() ;
254 b = a /fTimeSignalLength ;
255 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
256 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
258 *digit = *digit + *curSDigit ; //add energies
261 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
262 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
268 //calculate and set time
269 Float_t time = FrontEdgeTime(ticks) ;
270 digit->SetTime(time) ;
272 //Find next signal module
274 for(i = 0 ; i < fInput ; i++){
275 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
276 Int_t curNext = nextSig ;
277 if(sdigits->GetEntriesFast() > index[i] ){
278 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
280 if(curNext < nextSig) nextSig = curNext ;
288 //Now CPV digits (different noise and no timing)
289 for(absID = nEMC+1; absID <= nCPV; absID++){
290 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
291 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
292 //look if we have to add signal?
294 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
295 //Add SDigits from all inputs
296 for(i = 0 ; i < fInput ; i++){
297 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
298 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
302 //May be several digits will contribute from the same input
303 while(curSDigit && curSDigit->GetId() == absID){
304 //Shift primary to separate primaries belonging different inputs
305 Int_t primaryoffset ;
307 primaryoffset = fManager->GetMask(i) ;
309 primaryoffset = 10000000*i ;
310 curSDigit->ShiftPrimary(primaryoffset) ;
313 *digit = *digit + *curSDigit ;
315 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
316 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
322 //Find next signal module
324 for(i = 0 ; i < fInput ; i++){
325 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
326 Int_t curNext = nextSig ;
327 if(sdigits->GetEntriesFast() > index[i] )
328 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
329 if(curNext < nextSig) nextSig = curNext ;
335 delete sdigArray ; //We should not delete its contents
337 //remove digits below thresholds
338 for(i = 0 ; i < nEMC ; i++){
339 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
340 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
341 digits->RemoveAt(i) ;
343 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
347 for(i = nEMC; i < nCPV ; i++)
348 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
349 digits->RemoveAt(i) ;
353 Int_t ndigits = digits->GetEntriesFast() ;
354 digits->Expand(ndigits) ;
356 //Set indexes in list of digits and make true digitization of the energy
357 for (i = 0 ; i < ndigits ; i++) {
358 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
359 digit->SetIndexInList(i) ;
360 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
361 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
365 //____________________________________________________________________________
366 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
368 // Returns digitized value of the energy in a cell absId
371 if(absId <= fEmcCrystals){ //digitize as EMC
372 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
373 if(chanel > fNADCemc ) chanel = fNADCemc ;
375 else{ //Digitize as CPV
376 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
377 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
382 //____________________________________________________________________________
383 void AliPHOSDigitizer::Exec(Option_t *option)
385 // Steering method to process digitization for events
386 // in the range from fFirstEvent to fLastEvent.
387 // This range is optionally set by SetEventRange().
388 // if fLastEvent=-1 (by default), then process events until the end.
390 if (!fInit) { // to prevent overwrite existing file
391 Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
395 if (strstr(option,"print")) {
400 if(strstr(option,"tim"))
401 gBenchmark->Start("PHOSDigitizer");
404 fInput = fManager->GetNinputs() ;
406 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
408 if (fLastEvent == -1)
409 fLastEvent = gime->MaxEvent() - 1 ;
411 fLastEvent = TMath::Min(fLastEvent,gime->MaxEvent());
412 Int_t nEvents = fLastEvent - fFirstEvent + 1;
416 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
418 gime->Event(ievent,"S") ;
420 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
424 if(strstr(option,"deb"))
427 //increment the total number of Digits per run
428 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
431 if(strstr(option,"tim")){
432 gBenchmark->Stop("PHOSDigitizer");
434 message = " took %f seconds for Digitizing %f seconds per event\n" ;
435 Info("Exec", message.Data(),
436 gBenchmark->GetCpuTime("PHOSDigitizer"),
437 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents );
441 //____________________________________________________________________________
442 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
444 // Returns the shortest time among all time ticks
446 ticks->Sort() ; //Sort in accordance with times of ticks
448 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
449 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
452 while((t=(AliPHOSTick*) it.Next())){
453 if(t->GetTime() < time) //This tick starts before crossing
458 time = ctick->CrossingTime(fTimeThreshold) ;
463 //____________________________________________________________________________
464 Bool_t AliPHOSDigitizer::Init()
466 // Makes all memory allocations
468 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
470 Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ;
474 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
476 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
478 TString opt("Digits") ;
479 if(gime->VersionExists(opt) ) {
480 Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ;
484 // Post Digitizer to the white board
485 gime->PostDigitizer(this) ;
488 fInput = fManager->GetNinputs() ;
492 fInputFileNames = new TString[fInput] ;
493 fEventNames = new TString[fInput] ;
494 fInputFileNames[0] = GetTitle() ;
495 fEventNames[0] = fEventFolderName.Data() ;
497 for (index = 1 ; index < fInput ; index++) {
498 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
499 TString tempo = fManager->GetInputFolderName(index) ;
500 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added bt fManager
503 //to prevent cleaning of this object while GetEvent is called
504 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
509 //____________________________________________________________________________
510 void AliPHOSDigitizer::InitParameters()
512 // Set initial parameters for Digitizer
515 fEMCDigitThreshold = 0.012 ;
517 fCPVDigitThreshold = 0.09 ;
518 fTimeResolution = 0.5e-9 ;
519 fTimeSignalLength = 1.0e-9 ;
521 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
522 fADCpedestalEmc = 0.005 ; //
523 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
525 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
526 fADCpedestalCpv = 0.012 ; //
527 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
529 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
530 SetEventRange(0,-1) ;
534 //__________________________________________________________________
535 void AliPHOSDigitizer::MixWith(const TString alirunFileName, const TString eventFolderName)
537 // Allows to produce digits by superimposing background and signal event.
538 // It is assumed, that headers file with SIGNAL events is opened in
540 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
541 // Thus we avoid writing (changing) huge and expensive
542 // backgound files: all output will be writen into SIGNAL, i.e.
543 // opened in constructor file.
545 // One can open as many files to mix with as one needs.
546 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
549 if( strcmp(fEventFolderName, "") == 0 )
553 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
556 // looking for file which contains AliRun
557 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
558 Error("MixWith", "File %s does not exist!", alirunFileName.Data()) ;
561 // looking for the file which contains SDigits
562 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
563 TString fileName( gime->GetSDigitsFileName() ) ;
564 if ( eventFolderName != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
565 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
566 if ( (gSystem->AccessPathName(fileName)) ) {
567 Error("MixWith", "The file %s does not exist!", fileName.Data()) ;
570 // need to increase the arrays
571 TString tempo = fInputFileNames[fInput-1] ;
572 delete [] fInputFileNames ;
573 fInputFileNames = new TString[fInput+1] ;
574 fInputFileNames[fInput-1] = tempo ;
576 tempo = fEventNames[fInput-1] ;
577 delete [] fEventNames ;
578 fEventNames = new TString[fInput+1] ;
579 fEventNames[fInput-1] = tempo ;
581 fInputFileNames[fInput] = alirunFileName ;
582 fEventNames[fInput] = eventFolderName ;
586 //__________________________________________________________________
587 void AliPHOSDigitizer::Print()const
589 // Print Digitizer's parameters
590 Info("Print", "\n------------------- %s -------------", GetName() ) ;
591 if( strcmp(fEventFolderName.Data(), "") != 0 ){
592 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
596 nStreams = GetNInputStreams() ;
601 for (index = 0 ; index < nStreams ; index++) {
602 TString tempo(fEventNames[index]) ;
604 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
605 TString fileName( gime->GetSDigitsFileName() ) ;
606 if ( fEventNames[index] != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
607 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
608 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
610 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
611 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
613 printf("\nWith following parameters:\n") ;
614 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
615 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
616 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
617 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
618 printf(" ---------------------------------------------------\n") ;
621 Info("Print", "AliPHOSDigitizer not initialized" ) ;
625 //__________________________________________________________________
626 void AliPHOSDigitizer::PrintDigits(Option_t * option)
628 // Print a table of digits
630 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
631 TClonesArray * digits = gime->Digits() ;
633 Info("PrintDigits", "%d", digits->GetEntriesFast()) ;
634 printf("\nevent %d", gAlice->GetEvNumber()) ;
635 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
638 if(strstr(option,"all")||strstr(option,"EMC")){
640 AliPHOSDigit * digit;
641 printf("\nEMC digits (with primaries):\n") ;
642 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
643 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
645 for (index = 0 ; (index < digits->GetEntriesFast()) &&
646 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
647 digit = (AliPHOSDigit * ) digits->At(index) ;
648 if(digit->GetNprimary() == 0)
650 printf("%6d %8d %6.5e %4d %2d :",
651 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
653 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
654 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
660 if(strstr(option,"all")||strstr(option,"CPV")){
662 //loop over CPV digits
663 AliPHOSDigit * digit;
664 printf("\nCPV digits (with primaries):\n") ;
665 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
666 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
668 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
669 digit = (AliPHOSDigit * ) digits->At(index) ;
670 if(digit->GetId() > maxEmc){
671 printf("%6d %8d %4d %2d :",
672 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
674 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
675 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
684 //__________________________________________________________________
685 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
686 { // Calculates the time signal generated by noise
687 //to be rewritten, now returns just big number
692 //__________________________________________________________________
693 void AliPHOSDigitizer::Unload()
697 for(i = 1 ; i < fInput ; i++){
698 TString tempo(fEventNames[i]) ;
700 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
701 gime->PhosLoader()->UnloadSDigits() ;
704 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
705 gime->PhosLoader()->UnloadDigits() ;
708 //____________________________________________________________________________
709 void AliPHOSDigitizer::WriteDigits()
712 // Makes TreeD in the output file.
713 // Check if branch already exists:
714 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
715 // already existing branches.
716 // else creates branch with Digits, named "PHOS", title "...",
717 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
718 // and names of files, from which digits are made.
720 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
721 const TClonesArray * digits = gime->Digits() ;
722 TTree * treeD = gime->TreeD();
724 // -- create Digits branch
725 Int_t bufferSize = 32000 ;
726 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
727 digitsBranch->SetTitle(fEventFolderName);
728 digitsBranch->Fill() ;
730 gime->WriteDigits("OVERWRITE");
731 gime->WriteDigitizer("OVERWRITE");