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 //_________________________________________________________________________
19 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
20 //////////////////////////////////////////////////////////////////////////////
21 // This TTask performs digitization of Summable digits (in the PHOS case it is just
22 // the sum of contributions from all primary particles into a given cell).
23 // In addition it performs mixing of summable digits from different events.
24 // The name of the TTask is also the title of the branch that will contain
25 // the created SDigits
26 // The title of the TTAsk is the name of the file that contains the hits from
27 // which the SDigits are created
29 // For each event two branches are created in TreeD:
30 // "PHOS" - list of digits
31 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
33 // Note, that one can set a title for new digits branch, and repeat digitization with
34 // another set of parameters.
37 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
38 // root[1] d->ExecuteTask()
39 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
40 // //Digitizes SDigitis in all events found in file galice.root
42 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
43 // // Will read sdigits from galice1.root
44 // root[3] d1->MixWith("galice2.root")
45 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
46 // // Reads another set of sdigits from galice2.root
47 // root[3] d1->MixWith("galice3.root")
48 // // Reads another set of sdigits from galice3.root
49 // root[4] d->ExecuteTask("deb timing")
50 // // Reads SDigits from files galice1.root, galice2.root ....
51 // // mixes them and stores produced Digits in file galice1.root
52 // // deb - prints number of produced digits
53 // // deb all - prints list of produced digits
54 // // timing - prints time used for digitization
57 // --- ROOT system ---
63 #include "TObjString.h"
64 #include "TGeometry.h"
65 #include "TBenchmark.h"
67 // --- Standard library ---
70 // --- AliRoot header files ---
73 #include "AliHeader.h"
74 #include "AliStream.h"
75 #include "AliRunDigitizer.h"
76 #include "AliPHOSDigit.h"
78 #include "AliPHOSGetter.h"
79 #include "AliPHOSDigitizer.h"
80 #include "AliPHOSSDigitizer.h"
81 #include "AliPHOSGeometry.h"
82 #include "AliPHOSTick.h"
84 ClassImp(AliPHOSDigitizer)
87 //____________________________________________________________________________
88 AliPHOSDigitizer::AliPHOSDigitizer()
92 fDefaultInit = kTRUE ;
93 fManager = 0 ; // We work in the standalong mode
95 // fHitsFileName = "" ;
96 // fSDigitsFileName = "" ;
99 //____________________________________________________________________________
100 AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile, const char * name, const Bool_t toSplit)
104 SetTitle(headerFile) ;
106 fManager = 0 ; // We work in the standalong mode
111 fDefaultInit = kFALSE ;
112 // fSDigitsFileName = headerFile ;
113 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
114 // gime->Event(0, "S") ;
115 // fHitsFileName = gime->SDigitizer()->GetTitle() ;
118 //____________________________________________________________________________
119 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * ard):AliDigitizer(ard)
122 SetTitle(ard->GetInputFileName(0,0)) ;
124 fDefaultInit = kFALSE ;
127 if (ard->GetOutputFile()) {
128 SetName(ard->GetOutputFile().Data());
135 // fSDigitsFileName = fManager->GetInputFileName(0, 0) ;
136 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance(fSDigitsFileName, GetName()) ;
137 // gime->Event(0,"S") ;
138 // fHitsFileName = gime->SDigitizer()->GetTitle() ;
142 //____________________________________________________________________________
143 AliPHOSDigitizer::~AliPHOSDigitizer()
146 // fDefaultInit = kTRUE if Digitizer created by default ctor (to get just the parameters)
148 // if (!fDefaultInit) {
149 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
151 // // remove the task from the folder list
152 // gime->RemoveTask("S",GetName()) ;
153 // gime->RemoveTask("D",GetName()) ;
155 // // remove the Digits from the folder list
156 // gime->RemoveObjects("D", GetName()) ;
158 // // remove the SDigits from the folder list
159 // gime->RemoveSDigits() ;
162 // gime->CloseFile() ;
168 //____________________________________________________________________________
169 void AliPHOSDigitizer::Digitize(const Int_t event)
172 // Makes the digitization of the collected summable digits.
173 // It first creates the array of all PHOS modules
174 // filled with noise (different for EMC, CPV and PPSD) and
175 // then adds contributions from SDigits.
176 // This design avoids scanning over the list of digits to add
177 // contribution to new SDigits only.
179 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
180 TClonesArray * digits = gime->Digits(GetName()) ;
184 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
185 //Making digits with noise, first EMC
186 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
190 TString name = geom->GetName() ;
192 nCPV = nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*
193 geom->GetNModules() ;
195 digits->Expand(nCPV) ;
197 // get first the sdigitizer from the tasks list (must have same name as the digitizer)
198 const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName());
200 cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ;
204 // loop through the sdigits posted to the White Board and add them to the noise
205 TCollection * folderslist = gime->SDigitsFolder()->GetListOfFolders() ;
206 TIter next(folderslist) ;
207 TFolder * folder = 0 ;
208 TClonesArray * sdigits = 0 ;
210 TObjArray * sdigArray = new TObjArray(2) ;
211 while ( (folder = (TFolder*)next()) ) {
212 if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) {
213 TString fileName(folder->GetName()) ;
214 fileName.ReplaceAll("_","/") ;
215 // cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits "
216 // << GetName() << " from " << fileName << endl ;
217 sdigArray->AddAt(sdigits, input) ;
222 //Find the first crystall with signal
223 Int_t nextSig = 200000 ;
225 for(i=0; i<input; i++){
226 sdigits = (TClonesArray *)sdigArray->At(i) ;
227 if ( !sdigits->GetEntriesFast() )
229 Int_t curNext = ((AliPHOSDigit *)sdigits->At(0))->GetId() ;
230 if(curNext < nextSig)
234 TArrayI index(input) ;
235 index.Reset() ; //Set all indexes to zero
237 AliPHOSDigit * digit ;
238 AliPHOSDigit * curSDigit ;
240 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
242 //Put Noise contribution
243 for(absID = 1; absID <= nEMC; absID++){
244 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
245 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
246 //look if we have to add signal?
247 digit = (AliPHOSDigit *) digits->At(absID-1) ;
250 //Add SDigits from all inputs
253 Float_t a = digit->GetAmp() ;
254 Float_t b = TMath::Abs( a /fTimeSignalLength) ;
255 //Mark the beginnign of the signal
256 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
257 //Mark the end of the ignal
258 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
261 for(i=0; i<input; i++){
262 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
263 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
266 //May be several digits will contribute from the same input
267 while(curSDigit && curSDigit->GetId() == absID){
268 //Shift primary to separate primaries belonging different inputs
269 Int_t primaryoffset ;
271 primaryoffset = fManager->GetMask(i) ;
273 primaryoffset = 10000000*i ;
274 curSDigit->ShiftPrimary(primaryoffset) ;
276 a = curSDigit->GetAmp() ;
277 b = a /fTimeSignalLength ;
278 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
279 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
281 *digit = *digit + *curSDigit ; //add energies
284 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
285 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
291 //calculate and set time
292 Float_t time = FrontEdgeTime(ticks) ;
293 digit->SetTime(time) ;
295 //Find next signal module
297 for(i=0; i<input; i++){
298 sdigits = ((TClonesArray *)sdigArray->At(i)) ;
299 Int_t curNext = nextSig ;
300 if(sdigits->GetEntriesFast() > index[i] ){
301 curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ;
304 if(curNext < nextSig) nextSig = curNext ;
313 //Now CPV digits (different noise and no timing)
314 for(absID = nEMC+1; absID <= nCPV; absID++){
315 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
316 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
317 //look if we have to add signal?
319 digit = (AliPHOSDigit *) digits->At(absID-1) ;
320 //Add SDigits from all inputs
321 for(i=0; i<input; i++){
322 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
323 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
327 //May be several digits will contribute from the same input
328 while(curSDigit && curSDigit->GetId() == absID){
329 //Shift primary to separate primaries belonging different inputs
330 Int_t primaryoffset ;
332 primaryoffset = fManager->GetMask(i) ;
334 primaryoffset = 10000000*i ;
335 curSDigit->ShiftPrimary(primaryoffset) ;
338 *digit = *digit + *curSDigit ;
340 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
341 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
347 //Find next signal module
349 for(i=0; i<input; i++){
350 sdigits = (TClonesArray *)sdigArray->At(i) ;
351 Int_t curNext = nextSig ;
352 if(sdigits->GetEntriesFast() > index[i] )
353 curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ;
354 if(curNext < nextSig) nextSig = curNext ;
359 delete sdigArray ; //We should not delete its contents
363 //remove digits below thresholds
364 for(i = 0; i < nEMC ; i++){
365 digit = (AliPHOSDigit*) digits->At(i) ;
366 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
367 digits->RemoveAt(i) ;
369 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
373 for(i = nEMC; i < nCPV ; i++)
374 if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(i))->GetAmp()) < fCPVDigitThreshold)
375 digits->RemoveAt(i) ;
379 Int_t ndigits = digits->GetEntriesFast() ;
380 digits->Expand(ndigits) ;
382 //Set indexes in list of digits and make true digitization of the energy
383 for (i = 0 ; i < ndigits ; i++) {
384 AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ;
385 digit->SetIndexInList(i) ;
386 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
387 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
391 //____________________________________________________________________________
392 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
395 if(absId <= fEmcCrystals){ //digitize as EMC
396 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
397 if(chanel > fNADCemc ) chanel = fNADCemc ;
399 else{ //Digitize as CPV
400 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
401 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
405 //____________________________________________________________________________
406 void AliPHOSDigitizer::Exec(Option_t *option)
410 if(strcmp(GetName(), "") == 0 )
412 if (strstr(option,"print")) {
417 if(strstr(option,"tim"))
418 gBenchmark->Start("PHOSDigitizer");
420 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
427 treeD = fManager->GetTreeD() ;
428 nevents = 1 ; // Will process only one event
430 //Check, if this branch already exits
432 TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ;
434 TBranch * branch = 0 ;
435 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
437 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
438 if ( (strcmp(branch->GetName(), "PHOS")==0) &&
439 (strcmp(branch->GetTitle(), GetName())==0) )
442 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) &&
443 (strcmp(branch->GetTitle(), GetName())==0) )
444 digitizerfound = kTRUE ;
448 cerr << "WARNING: AliPHOSDigitizer -> Digits branch with name " << GetName()
449 << " already exits" << endl ;
452 if ( digitizerfound ) {
453 cerr << "WARNING: AliPHOSDigitizer -> Digitizer branch with name " << GetName()
454 << " already exits" << endl ;
459 else { //PHOS standalone
460 if(gime->BranchExists("Digits") )
462 nevents=gime->MaxEvent() ;
467 for(ievent = 0; ievent < nevents; ievent++){
472 for(input = 0 ; input < fManager->GetNinputs(); input ++){
473 TTree * treeS = fManager->GetInputTreeS(input) ;
475 cerr << "AliPHOSDigitizer::Exec -> No Input " << endl ;
478 gime->ReadTreeS(treeS,input) ;
483 gime->Event(ievent,"S") ;
485 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
487 WriteDigits(ievent) ;
489 if(strstr(option,"deb"))
492 //increment the total number of Digits per run
493 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
496 if(strstr(option,"tim")){
497 gBenchmark->Stop("PHOSDigitizer");
498 cout << "AliPHOSDigitizer:" << endl ;
499 cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for Digitizing "
500 << gBenchmark->GetCpuTime("PHOSDigitizer")/nevents << " seconds per event " << endl ;
506 //____________________________________________________________________________
507 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks)
509 ticks->Sort() ; //Sort in accordance with times of ticks
511 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
512 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
515 while((t=(AliPHOSTick*) it.Next())){
516 if(t->GetTime() < time) //This tick starts before crossing
521 time = ctick->CrossingTime(fTimeThreshold) ;
526 //____________________________________________________________________________
527 Bool_t AliPHOSDigitizer::Init()
529 // Makes all memory allocations
531 if( strcmp(GetTitle(), "") == 0 )
532 SetTitle("galice.root") ;
534 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName(), fToSplit) ;
536 cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ;
540 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
542 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
544 // Post Digits to the white board
545 gime->PostDigits(GetName() ) ;
547 // Post Digitizer to the white board
548 gime->PostDigitizer(this) ;
552 // construct the name of the file as /path/PHOS.SDigits.root
553 //First - extract full path if necessary
554 TString digitsFileName(GetTitle()) ;
555 Ssiz_t islash = digitsFileName.Last('/') ;
556 if(islash<digitsFileName.Length())
557 digitsFileName.Remove(islash+1,digitsFileName.Length()) ;
560 // Next - append the file name
561 digitsFileName+="PHOS.Digits." ;
562 if((strcmp(GetName(),"Default")!=0)&&(strcmp(GetName(),"")!=0)){
563 digitsFileName+=GetName() ;
564 digitsFileName+="." ;
566 digitsFileName+="root" ;
567 // Finally - check if the file already opened or open the file
568 fSplitFile = static_cast<TFile*>(gROOT->GetFile(digitsFileName.Data()));
570 fSplitFile = TFile::Open(digitsFileName.Data(),"update") ;
573 //Mark that we will use current header file
575 gime->PostSDigits(GetName(),GetTitle()) ;
576 gime->PostSDigitizer(GetName(),GetTitle()) ;
581 //____________________________________________________________________________
582 void AliPHOSDigitizer::InitParameters()
585 fEMCDigitThreshold = 0.012 ;
587 fCPVDigitThreshold = 0.09 ;
588 fTimeResolution = 0.5e-9 ;
589 fTimeSignalLength = 1.0e-9 ;
591 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
592 fADCpedestalEmc = 0.005 ; //
593 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
595 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
596 fADCpedestalCpv = 0.012 ; //
597 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
599 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
603 //__________________________________________________________________
604 void AliPHOSDigitizer::MixWith(const char* headerFile)
606 // Allows to produce digits by superimposing background and signal event.
607 // It is assumed, that headers file with SIGNAL events is opened in
609 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
610 // Thus we avoid writing (changing) huge and expensive
611 // backgound files: all output will be writen into SIGNAL, i.e.
612 // opened in constructor file.
614 // One can open as many files to mix with as one needs.
615 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
618 if( strcmp(GetName(), "") == 0 )
622 cout << "Can not use this method under AliRunDigitizer " << endl ;
626 // check if the specified SDigits do not already exist on the White Board:
627 // //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
629 TString path = "Folders/RunMC/Event/Data/PHOS/SDigits" ;
633 if ( gROOT->FindObjectAny(path.Data()) ) {
634 cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ;
638 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
639 gime->PostSDigits(GetName(),headerFile) ;
641 // check if the requested file is already open or exist and if SDigits Branch exist
642 TFile * file = (TFile*)gROOT->FindObject(headerFile);
644 file = new TFile(headerFile, "READ") ;
646 cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ;
653 // //__________________________________________________________________
654 // void AliPHOSDigitizer::SetSplitFile(const TString splitFileName)
656 // // Diverts the Digits in a file separate from the hits file
658 // // I guess it is not going to work if we do merging
659 // // if (fManager) {
660 // // cerr << "ERROR: AliPHOSDigitizer::SetSplitFile -> Not yet available in case of merging activated " << endl ;
664 // cout << "AliPHOSDigitizer::SetSplitFile " << gDirectory->GetName() << endl ;
665 // cout << "AliPHOSDigitizer::SetSplitFile " << gAlice->GetTreeDFileName() << endl ;
666 // cout << "AliPHOSDigitizer::SetSplitFile " << splitFileName.Data() << endl ;
668 // SetTitle(splitFileName) ;
670 // TDirectory * cwd = gDirectory ;
671 // if ( !(gAlice->GetTreeDFileName() == splitFileName) ) {
672 // if (gAlice->GetTreeDFile() )
673 // gAlice->GetTreeDFile()->Close() ;
676 // fSplitFile = gAlice->InitTreeFile("D",splitFileName.Data());
677 // fSplitFile->cd() ;
678 // gAlice->Write(0, TObject::kOverwrite);
680 // TTree *treeE = gAlice->TreeE();
682 // cerr << "ERROR: AliPHOSDigitizer::SetSplitFile -> No TreeE found "<<endl;
687 // AliHeader *header = new AliHeader();
688 // treeE->SetBranchAddress("Header", &header);
689 // treeE->SetBranchStatus("*",1);
690 // TTree *treeENew = treeE->CloneTree();
691 // treeENew->Write(0, TObject::kOverwrite);
694 // TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
696 // cerr << "ERROR: AliPHOSDigitizer::SetSplitFile -> AliceGeom was not found in the input file "<<endl;
699 // AliceGeom->Write(0, TObject::kOverwrite);
701 // gAlice->MakeTree("D",fSplitFile);
703 // cout << "INFO: AliPHOSDigitizer::SetSPlitMode -> Digits will be stored in " << splitFileName.Data() << endl ;
706 //__________________________________________________________________
707 void AliPHOSDigitizer::Print(Option_t* option)const {
708 // Print Digitizer's parameters
709 if( strcmp(GetName(), "") != 0 ){
712 cout << "------------------- "<< GetName() << " -------------" << endl ;
714 const Int_t nStreams = GetNInputStreams() ;
717 for (index = 0 ; index < nStreams ; index++)
718 cout << "Adding SDigits " << GetName() << " from " << fManager->GetInputFileName(index, 0) << endl ;
721 cout << "Writing digits to " << fManager->GetInputFileName(0, 0) << endl ;
723 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
724 // gime->Folder("sdigits") ;
725 // cout << "Digitizing sDigits from file(s): " <<endl ;
726 // TCollection * folderslist = gime->Folder("sdigits")->GetListOfFolders() ;
727 // TIter next(folderslist) ;
728 // TFolder * folder = 0 ;
730 // while ( (folder = (TFolder*)next()) ) {
731 // if ( folder->FindObject(GetName()) )
732 // cout << "Adding SDigits " << GetName() << " from " << GetSDigitsFileName() << endl ;
735 cout << "Writing digits to " << GetTitle() << endl ;
738 cout << "With following parameters: " << endl ;
739 cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ;
740 cout << " Threshold in EMC (fEMCDigitThreshold) = " << fEMCDigitThreshold << endl ; ;
741 cout << " Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ;
742 cout << " Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ;
743 cout << "---------------------------------------------------" << endl ;
746 cout << "AliPHOSDigitizer not initialized " << endl ;
750 //__________________________________________________________________
751 void AliPHOSDigitizer::PrintDigits(Option_t * option){
752 // Print a table of digits
754 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
755 TClonesArray * digits = gime->Digits() ;
757 cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ;
758 cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ;
760 if(strstr(option,"all")||strstr(option,"EMC")){
763 AliPHOSDigit * digit;
764 cout << "EMC digits (with primaries): " << endl ;
765 cout << "Digit Id Amplitude Index Nprim Primaries list " << endl;
766 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
768 for (index = 0 ; (index < digits->GetEntriesFast()) &&
769 (((AliPHOSDigit * ) digits->At(index))->GetId() <= maxEmc) ; index++) {
770 digit = (AliPHOSDigit * ) digits->At(index) ;
771 if(digit->GetNprimary() == 0) continue;
772 cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " "
773 << setw(6) << digit->GetIndexInList() << " "
774 << setw(5) << digit->GetNprimary() <<" ";
777 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
778 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
784 if(strstr(option,"all")||strstr(option,"CPV")){
786 //loop over CPV digits
787 AliPHOSDigit * digit;
788 cout << "CPV digits: " << endl ;
789 cout << "Digit Id Amplitude Index Nprim Primaries list " << endl;
790 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
792 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
793 digit = (AliPHOSDigit * ) digits->At(index) ;
794 if(digit->GetId() > maxEmc){
795 cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " "
796 << setw(6) << digit->GetIndexInList() << " "
797 << setw(5) << digit->GetNprimary() <<" ";
800 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
801 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
809 // //__________________________________________________________________
810 // void AliPHOSDigitizer::SetSDigitsBranch(const char* title)
812 // // we set title (comment) of the SDigits branch in the first! header file
813 // if( strcmp(GetName(), "") == 0 )
816 // AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ;
819 //__________________________________________________________________
820 Float_t AliPHOSDigitizer::TimeOfNoise(void)
821 { // Calculates the time signal generated by noise
822 //to be rewritten, now returns just big number
826 // //____________________________________________________________________________
827 // void AliPHOSDigitizer::Reset()
829 // // sets current event number to the first simulated event
831 // if( strcmp(GetName(), "") == 0 )
835 // // for(inputs = 0; inputs < fNinputs ;inputs++)
836 // // fIevent->AddAt(-1, inputs ) ;
840 //____________________________________________________________________________
841 void AliPHOSDigitizer::WriteDigits(Int_t event)
844 // Makes TreeD in the output file.
845 // Check if branch already exists:
846 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
847 // already existing branches.
848 // else creates branch with Digits, named "PHOS", title "...",
849 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
850 // and names of files, from which digits are made.
852 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
853 const TClonesArray * digits = gime->Digits(GetName()) ;
857 treeD = fManager->GetTreeD() ;
859 if((gAlice->TreeD() == 0) || (fSplitFile)) // we should not create TreeD if it is already here
860 gAlice->MakeTree("D", fSplitFile); // We overwrite TreeD in split file in the case of second reconstruction
863 treeD = gAlice->TreeD();
866 // -- create Digits branch
867 Int_t bufferSize = 32000 ;
868 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
869 digitsBranch->SetTitle(GetName());
871 // -- Create Digitizer branch
872 Int_t splitlevel = 0 ;
873 const AliPHOSDigitizer * d = gime->Digitizer(GetName()) ;
874 TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel);
875 digitizerBranch->SetTitle(GetName());
877 digitsBranch->Fill() ;
878 digitizerBranch->Fill() ;