]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigitizer.cxx
new html documentatin
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigitizer.cxx
CommitLineData
990119d6 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
990119d6 19//*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
20//////////////////////////////////////////////////////////////////////////////
21// Class performs digitization of Summable digits (in the PHOS case this is just
8cb3533f 22// sum of contributions of all primary particles into given cell).
990119d6 23// In addition it performs mixing of summable digits from different events.
24// Examples of use:
25// root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
26// root[1] d->ExecuteTask()
27// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
28// //Digitizes SDigitis in all events found in file galice.root
29// //Depending on variable "CONFIG_SPLIT_FILE" reads branches stored in galice.root
30// //or in PHOS.SDigits.root
8cb3533f 31// root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
32// // Will read sdigits from galice1.root
33// root[3] d1->MixWith("galice2.root")
990119d6 34// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
8cb3533f 35// // Reads another portion of sdigits from galice2.root
36// root[3] d1->MixWith("galice3.root")
37// // Reads another portion of sdigits from galice3.root
38// root[4] d->ExecuteTask("deb timing")
39// // Reads SDigits from files galice1.root, galice2.root ....
40// // mixes them and stores produced Digits in file galice1.root
41// // deb - prints number of produced digits
42// // deb all - prints list of produced digits
43// // timing - prints time used for digitization
990119d6 44//
8cb3533f 45// For each event two branches are created in TreeD:
46// "PHOS" - list of digits
47// "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
990119d6 48//
8cb3533f 49// Note, that one can specify new file name for digits branch, and repeat digitization with
50// another set of parameters.
990119d6 51
52// --- ROOT system ---
8cb3533f 53#include "TFile.h"
990119d6 54#include "TTree.h"
55#include "TSystem.h"
8cb3533f 56#include "TROOT.h"
57#include "TFolder.h"
58#include "TObjString.h"
59#include "TBenchmark.h"
990119d6 60// --- Standard library ---
8cb3533f 61#include <iomanip.h>
990119d6 62
63// --- AliRoot header files ---
64
8cb3533f 65#include "AliRun.h"
990119d6 66#include "AliPHOSDigit.h"
67#include "AliPHOSHit.h"
68#include "AliPHOSv1.h"
69#include "AliPHOSDigitizer.h"
70#include "AliPHOSSDigitizer.h"
8cb3533f 71#include "AliPHOSGeometry.h"
990119d6 72
73ClassImp(AliPHOSDigitizer)
74
75
76//____________________________________________________________________________
77 AliPHOSDigitizer::AliPHOSDigitizer():TTask("AliPHOSDigitizer","")
78{
79 // ctor
80
81 fSDigitizer = 0 ;
82 fNinputs = 1 ;
83 fPinNoise = 0.01 ;
84 fEMCDigitThreshold = 0.01 ;
85 fCPVNoise = 0.01;
86 fCPVDigitThreshold = 0.09 ;
87 fPPSDNoise = 0.0000001;
88 fPPSDDigitThreshold = 0.0000002 ;
89 fInitialized = kFALSE ;
8cb3533f 90
91 fHeaderFiles = 0;
92 fSDigitsTitles = 0;
93 fSDigits = 0 ;
94 fDigits = 0;
990119d6 95
96}
97//____________________________________________________________________________
8cb3533f 98void AliPHOSDigitizer::Init(){
990119d6 99// Mades all memory allocations and defiles,
100// whether first (default) file will be output file (isOutFile !=0)
101
102 if(!fInitialized){
8cb3533f 103
104 cout << "In Init" << endl ;
990119d6 105
106 fHeaderFiles = new TClonesArray("TObjString",1) ;
107 new((*fHeaderFiles)[0]) TObjString("galice.root") ;
8cb3533f 108
109 //Test, if this file already open
110
111 TFile *file = (TFile*) gROOT->GetFile(((TObjString *) fHeaderFiles->At(0))->GetString() ) ;
112
113 if(file == 0){
990119d6 114 file = new TFile(((TObjString *) fHeaderFiles->At(0))->GetString(),"update") ;
8cb3533f 115 gAlice = (AliRun *) file->Get("gAlice") ;
116 }
990119d6 117 else
118 file = new TFile(((TObjString *) fHeaderFiles->At(0))->GetString()) ;
8cb3533f 119
990119d6 120 file->cd() ;
8cb3533f 121
122 fSDigitsTitles = new TClonesArray("TObjString",1);
123 new((*fSDigitsTitles)[0]) TObjString("") ;
990119d6 124
125 fSDigits = new TClonesArray("TClonesArray",1) ;
126 new((*fSDigits)[0]) TClonesArray("AliPHOSDigit",1000) ;
8cb3533f 127
128 fDigitsTitle = "" ;
990119d6 129
130 fDigits = new TClonesArray("AliPHOSDigit",200000) ;
131
132 fIevent = new TArrayI(1) ;
133 fIevent->AddAt(-1,0 ) ;
134 fIeventMax = new TArrayI(1) ;
8cb3533f 135
136 fIeventMax->AddAt((Int_t) gAlice->TreeE()->GetEntries(), 0 );
137
138 // add Task to //root/Tasks folder
139 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
140 roottasks->Add(this) ;
141
990119d6 142 fInitialized = kTRUE ;
143 }
8cb3533f 144
990119d6 145}
146
990119d6 147//____________________________________________________________________________
8cb3533f 148AliPHOSDigitizer::AliPHOSDigitizer(const char *HeaderFile,const char *sDigitsTitle):
149 TTask("AliPHOSDigitizer","")
990119d6 150{
151 // ctor
8cb3533f 152 fHeaderFiles = new TClonesArray("TObjString",1) ;
990119d6 153 new((*fHeaderFiles)[0]) TObjString(HeaderFile) ;
8cb3533f 154
155 // Header file, where result will be stored
156 TFile * file = (TFile*) gROOT->GetFile(((TObjString *) fHeaderFiles->At(0))->GetString() ) ;
157 if(file==0){
158 file = new TFile(((TObjString *) fHeaderFiles->At(0))->GetString(),"update") ;
159 gAlice = (AliRun *) file->Get("gAlice") ; //If not read yet
160 }
161
990119d6 162 file->cd() ;
163
8cb3533f 164 fSDigitsTitles = new TClonesArray("TObjString",1); // Title name of the SDigits branch
165 new((*fSDigitsTitles)[0]) TObjString(sDigitsTitle) ;
990119d6 166
167 fSDigits = new TClonesArray("TClonesArray",1) ; // here list of SDigits wil be stored
168 new((*fSDigits)[0]) TClonesArray("AliPHOSDigit",1000) ;
169
170 fDigits = new TClonesArray("AliPHOSDigit",200000) ;
8cb3533f 171
172 fDigitsTitle = "" ;
173
990119d6 174 fIevent = new TArrayI(1) ;
175 fIevent->AddAt(-1,0 ) ;
176 fIeventMax = new TArrayI(1) ;
8cb3533f 177
990119d6 178 // Get number of events to process
179 fIeventMax->AddAt((Int_t) gAlice->TreeE()->GetEntries(), 0 );
8cb3533f 180
990119d6 181 fNinputs = 1 ;
8cb3533f 182
990119d6 183 fPinNoise = 0.01 ;
184 fEMCDigitThreshold = 0.01 ;
185 fCPVNoise = 0.01;
186 fCPVDigitThreshold = 0.09 ;
187 fPPSDNoise = 0.0000001;
188 fPPSDDigitThreshold = 0.0000002 ;
8cb3533f 189
990119d6 190 // add Task to //root/Tasks folder
191 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
192 roottasks->Add(this) ;
193 fInitialized = kTRUE ;
8cb3533f 194
990119d6 195}
196
197//____________________________________________________________________________
198 AliPHOSDigitizer::~AliPHOSDigitizer()
199{
200 // dtor
8cb3533f 201
202 if(fHeaderFiles) delete fHeaderFiles ;
203 if(fSDigitsTitles) delete fSDigitsTitles ;
204 if(fSDigits) delete fSDigits ;
205 if(fDigits) delete fDigits ;
206}
207//____________________________________________________________________________
208void AliPHOSDigitizer::Reset() {
209 //sets current event number to the beginning
210
211 if(!fInitialized)
212 Init() ;
213
214 Int_t inputs ;
215 for(inputs = 0; inputs < fNinputs ;inputs++)
216 fIevent->AddAt(-1, inputs ) ;
217
990119d6 218}
219//____________________________________________________________________________
220Bool_t AliPHOSDigitizer::Combinator() {
221
222 //Makes all desirable combinations Signal+Background,
223 // returns kFALSE when all combinations are made
224 // May be useful to introduce some options like "One-to-One", "All-to-One" and "All-to-All" ?
225
226 //realizing "One-to-One" option...
227
228 if(!fInitialized)
8cb3533f 229 Init() ;
990119d6 230
231 Int_t inputs ;
232 Bool_t endNotReached = kTRUE ;
233
234 for(inputs = 0; (inputs < fNinputs) && endNotReached ;inputs++){
235 if(fIevent->At(inputs)+1 < fIeventMax->At(inputs))
236 fIevent->AddAt(fIevent->At(inputs)+1, inputs ) ;
237 else
8cb3533f 238 if(inputs == 0)
239 endNotReached = kFALSE ;
240 else //for inputs other than base one start from the beginning
241 fIevent->AddAt(0, inputs ) ;
242
990119d6 243 }
244 return endNotReached ;
8cb3533f 245
990119d6 246}
247
248//____________________________________________________________________________
249void AliPHOSDigitizer::Digitize(Option_t *option) {
250
251 //Makes the digitization of the collected summable digits
252
253 if(!fInitialized)
8cb3533f 254 Init() ;
990119d6 255
256 fDigits->Clear() ;
257
258 AliPHOS * PHOS = (AliPHOS *) gAlice->GetDetector("PHOS") ;
259 AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance( PHOS->GetGeometry()->GetName(), PHOS->GetGeometry()->GetTitle() );
260
261 //Making digits with noise, first EMC
262 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
263
264 Int_t nCPV ;
265 Int_t nPPSD ;
266 Int_t absID ;
267 TString name = geom->GetName() ;
268
269 if ( name == "IHEP" || name == "MIXT" )
270 nCPV =nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*
271 geom->GetNCPVModules()*geom->GetNumberOfCPVLayers() ;
272 else
273 nCPV = nEMC;
274
275 if ( name == "GPS2" || name == "MIXT" )
276 nPPSD =nCPV+2*geom->GetNPPSDModules()*geom->GetNumberOfModulesPhi()*geom->GetNumberOfModulesZ()*
277 geom->GetNumberOfPadsPhi()*geom->GetNumberOfPadsZ() ;
278 else
279 nPPSD = nCPV;
8cb3533f 280
281
282 fDigits->Expand(nPPSD) ;
283
990119d6 284
285 for(absID = 1; absID <= nEMC; absID++){
286 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
287 new((*fDigits)[absID-1]) AliPHOSDigit( -1,absID,fSDigitizer->Digitize(noise) ) ;
288 }
289
290 for(absID = nEMC+1; absID <= nCPV; absID++){
291 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
292 new((*fDigits)[absID-1]) AliPHOSDigit( -1,absID,fSDigitizer->Digitize(noise) ) ;
293 }
294
295 for(absID = nCPV+1; absID <= nPPSD; absID++){
296 Float_t noise = gRandom->Gaus(0., fPPSDNoise) ;
297 new((*fDigits)[absID-1]) AliPHOSDigit( -1,absID,fSDigitizer->Digitize(noise) ) ;
298 }
299
300
301 // Now look throught (unsorted) list of SDigits and add corresponding digits
302 AliPHOSDigit *curSDigit ;
303 AliPHOSDigit *digit ;
304
305 Int_t inputs;
306 for(inputs = 0; inputs< fNinputs ; inputs++){ //loop over (possible) merge sources
307
308 TClonesArray * sdigits= (TClonesArray *)fSDigits->At(inputs) ;
309 Int_t isdigit ;
8cb3533f 310
990119d6 311 Int_t nSDigits = sdigits->GetEntries() ;
312 for(isdigit=0;isdigit< nSDigits; isdigit++){
313 curSDigit = (AliPHOSDigit *)sdigits->At(isdigit) ;
314 if(inputs) //Shift primaries for non-background sdigits
315 curSDigit->ShiftPrimary(inputs) ;
316 digit = (AliPHOSDigit *)fDigits->At(curSDigit->GetId() - 1);
317 *digit = *digit + *curSDigit ;
318 }
319 }
320
321
990119d6 322 //remove digits below thresholds
323 for(absID = 0; absID < nEMC ; absID++)
324 if(fSDigitizer->Calibrate(((AliPHOSDigit*)fDigits->At(absID))->GetAmp()) < fEMCDigitThreshold)
325 fDigits->RemoveAt(absID) ;
326 for(absID = nEMC; absID < nCPV ; absID++)
327 if(fSDigitizer->Calibrate(((AliPHOSDigit*)fDigits->At(absID))->GetAmp()) < fCPVDigitThreshold)
328 fDigits->RemoveAt(absID) ;
329 for(absID = nCPV; absID < nPPSD ; absID++)
330 if(fSDigitizer->Calibrate(((AliPHOSDigit *)fDigits->At(absID))->GetAmp()) < fPPSDDigitThreshold)
331 fDigits->RemoveAt(absID) ;
332
333 fDigits->Compress() ;
334
8cb3533f 335 Int_t ndigits = fDigits->GetEntriesFast() ;
336
990119d6 337 fDigits->Expand(ndigits) ;
338
339
340 //Set indexes in list of digits
341 Int_t i ;
342 for (i = 0 ; i < ndigits ; i++) {
343 AliPHOSDigit * digit = (AliPHOSDigit *) fDigits->At(i) ;
344 digit->SetIndexInList(i) ;
345 }
346}
347//____________________________________________________________________________
348void AliPHOSDigitizer::WriteDigits(){
349
350 //Made TreeD in the output file if necessary and writes digiths there.
351
8cb3533f 352 gAlice->GetEvent(fIevent->At(0)) ; // Suitable only for One-To-One mixing
353 gAlice->SetEvent(fIevent->At(0)) ; // for all-to-all will produce a lot of branches in TreeD
990119d6 354
355 if(gAlice->TreeD()==0)
356 gAlice->MakeTree("D") ;
990119d6 357
8cb3533f 358
359 //Check, if this branch already exits?
360 TBranch * digitsBranch = 0;
361 TBranch * digitizerBranch = 0;
362
363 TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
364 Int_t ibranch;
365 Bool_t phosNotFound = kTRUE ;
366 Bool_t digitizerNotFound = kTRUE ;
367
368 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
369
370 if(phosNotFound){
371 digitsBranch=(TBranch *) branches->At(ibranch) ;
372 if( (strcmp("PHOS",digitsBranch->GetName())==0 ) &&
373 (fDigitsTitle.CompareTo(digitsBranch->GetTitle()) == 0) )
374 phosNotFound = kFALSE ;
990119d6 375 }
8cb3533f 376 if(digitizerNotFound){
377 digitizerBranch = (TBranch *) branches->At(ibranch) ;
378 if( (strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) &&
379 (fDigitsTitle.CompareTo(digitizerBranch->GetTitle()) == 0))
380 digitizerNotFound = kFALSE ;
381 }
382 }
990119d6 383
8cb3533f 384
385 if(!(digitizerNotFound && phosNotFound)){
386 cout << "AliPHOSDigitizer error: " << endl ;
387 cout << " can not update/overwrite existing branches "<< endl ;
388 cout << " do not write " << endl ;
389 return ;
390 }
391
392 // create new branches
393
394 //First generate file name
395 char * file =0;
396 if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
397 file = new char[strlen(gAlice->GetBaseFile())+20] ;
398 sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ;
399 }
400
401 TDirectory *cwd = gDirectory;
402
403 //First create list of sdigits
404 Int_t bufferSize = 32000 ;
405 digitsBranch = gAlice->TreeD()->Branch("PHOS",&fDigits,bufferSize);
406 digitsBranch->SetTitle(fDigitsTitle.Data());
407 if (file) {
408 digitsBranch->SetFile(file);
409 TIter next( digitsBranch->GetListOfBranches());
410 while ((digitsBranch=(TBranch*)next())) {
411 digitsBranch->SetFile(file);
412 }
413 cwd->cd();
414 }
415
416 //second - create Digitizer
990119d6 417 Int_t splitlevel = 0 ;
8cb3533f 418 AliPHOSDigitizer * d = this ;
419 digitizerBranch = gAlice->TreeD()->Branch("AliPHOSDigitizer","AliPHOSDigitizer",
420 &d,bufferSize,splitlevel);
421 digitizerBranch->SetTitle(fDigitsTitle.Data());
422 if (file) {
423 digitizerBranch->SetFile(file);
424 TIter next( digitizerBranch->GetListOfBranches());
425 while ((digitizerBranch=(TBranch*)next())) {
426 digitizerBranch->SetFile(file);
427 }
428 cwd->cd();
429 }
990119d6 430
431 gAlice->TreeD()->Fill() ;
8cb3533f 432
990119d6 433 gAlice->TreeD()->Write(0,kOverwrite) ;
434}
435
436//____________________________________________________________________________
437void AliPHOSDigitizer::Exec(Option_t *option) {
438 //manager
8cb3533f 439 if(!fInitialized) Init() ;
990119d6 440
8cb3533f 441 if(strstr(option,"tim"))
442 gBenchmark->Start("PHOSDigitizer");
443
444 //reset events numbers to start from the beginnig
445 Reset() ;
990119d6 446
447 while(Combinator()){
448
449 if(!ReadSDigits()) //read sdigits event(s) evaluated by Combinator() from file(s)
450 return ;
451
452 Digitize(option) ; //Add prepared SDigits to digits and add the noise
453 WriteDigits() ;
8cb3533f 454
455 if(strstr(option,"deb"))
456 PrintDigits(option);
990119d6 457
8cb3533f 458 }
990119d6 459
8cb3533f 460 if(strstr(option,"tim")){
461 gBenchmark->Stop("PHOSDigitizer");
462 cout << "AliPHOSDigitizer:" << endl ;
463 cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for SDigitizing "
464 << gBenchmark->GetCpuTime("PHOSDigitizer")/(fIeventMax->At(0)) << " seconds per event " << endl ;
465 cout << endl ;
466 }
990119d6 467
468}
469
470//__________________________________________________________________
471Bool_t AliPHOSDigitizer::ReadSDigits(){
472// Reads summable digits from the opened files for the particular set of events given by fIevent
473
8cb3533f 474 if(!fInitialized) Init() ;
990119d6 475
476 Int_t inputs ;
477 for(inputs = fNinputs-1; inputs >= 0; inputs --){
478
479 Int_t event = fIevent->At(inputs) ;
480
481 TFile * file = (TFile*) gROOT->GetFile(((TObjString *) fHeaderFiles->At(inputs))->GetString() ) ;
482 file->cd() ;
483
484 // Get SDigits Tree header from file
485 char treeName[20];
486 sprintf(treeName,"TreeS%d",event);
487 TTree * treeS = (TTree*)file->Get(treeName);
488
489 if(treeS==0){
490 cout << "Error at AliPHOSDigitizer: no "<<treeName << " in file " << file->GetName() << endl ;
491 cout << "Do nothing " << endl ;
492 return kFALSE ;
493 }
494
495 TBranch * sdigitsBranch = 0;
496 TBranch * sdigitizerBranch = 0;
497
498 TObjArray * branches = treeS->GetListOfBranches() ;
499 Int_t ibranch;
500 Bool_t phosNotFound = kTRUE ;
501 Bool_t sdigitizerNotFound = kTRUE ;
502
503 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
8cb3533f 504
990119d6 505 if(phosNotFound){
506 sdigitsBranch=(TBranch *) branches->At(ibranch) ;
8cb3533f 507 if(( strcmp("PHOS",sdigitsBranch->GetName())==0 ) &&
508 ((TObjString*) fSDigitsTitles->At(inputs))->GetString().CompareTo(sdigitsBranch->GetTitle())== 0 )
509 phosNotFound = kFALSE ;
510
990119d6 511 }
8cb3533f 512
990119d6 513 if(sdigitizerNotFound){
514 sdigitizerBranch = (TBranch *) branches->At(ibranch) ;
8cb3533f 515 if(( strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0) &&
516 ((TObjString*) fSDigitsTitles->At(inputs))->GetString().CompareTo(sdigitizerBranch->GetTitle())== 0 )
517 sdigitizerNotFound = kFALSE ;
518
990119d6 519 }
990119d6 520 }
8cb3533f 521
990119d6 522 if(sdigitizerNotFound || phosNotFound){
523 cout << "Can't find Branch with sdigits or SDigitizer in the file " ;
8cb3533f 524 if( ((TObjString*)fSDigitsTitles->At(inputs))->GetString().IsNull() )
990119d6 525 cout << file->GetName() << endl ;
526 else
8cb3533f 527 cout << ((TObjString*)fSDigitsTitles->At(inputs))->GetString().Data() << endl ;
990119d6 528 cout << "Do nothing" <<endl ;
529 return kFALSE ;
530 }
8cb3533f 531
990119d6 532 TClonesArray * sdigits = (TClonesArray*) fSDigits->At(inputs) ;
533 sdigitsBranch->SetAddress(&sdigits) ;
534
535 AliPHOSSDigitizer *sDigitizer = new AliPHOSSDigitizer();
536 sdigitizerBranch->SetAddress(&sDigitizer) ;
537 treeS->GetEvent(0) ;
8cb3533f 538
990119d6 539 if(fSDigitizer == 0)
540 fSDigitizer = sDigitizer ;
541 else
542 if(!((*fSDigitizer)==(*sDigitizer)) ){
543 cout << "ERROR: you are using sdigits made with different SDigitizers" << endl ;
544 fSDigitizer->Print("") ;
545 sDigitizer->Print("") ;
546 cout << "Do Nothing " << endl ;
547 return kFALSE ;
548 }
549
550 }
8cb3533f 551 fPedestal = fSDigitizer->GetPedestalParameter() ;
552 fSlope = fSDigitizer->GetCalibrationParameter() ;
990119d6 553
990119d6 554 return kTRUE ;
555
556}
557//__________________________________________________________________
8cb3533f 558void AliPHOSDigitizer::MixWith(char* HeaderFile, char* sDigitsTitle){
990119d6 559//
560
561 if(!fInitialized)
8cb3533f 562 Init() ;
563
990119d6 564
565 if(HeaderFile == 0){
566 cout << "Specify at least header file to merge"<< endl ;
567 return ;
568 }
569
570 Int_t inputs ;
571 for(inputs = 0; inputs < fNinputs ; inputs++){
572 if(strcmp(((TObjString *)fHeaderFiles->At(inputs))->GetString(),HeaderFile) == 0 ){
8cb3533f 573 if(sDigitsTitle == 0){
574 if(((TObjString*)fSDigitsTitles->At(inputs))->GetString().CompareTo("") == 0){
990119d6 575 cout << "Entry already exists, do not add" << endl ;
576 return ;
577 }
578 }
579 else
8cb3533f 580 if(((TObjString*)fSDigitsTitles->At(inputs))->GetString().CompareTo(sDigitsTitle)){
581 cout << "Entry already exists, do not add" << endl ;
582 return;
583 }
990119d6 584 }
585 }
586
587 fHeaderFiles->Expand(fNinputs+1) ;
588 new((*fHeaderFiles)[fNinputs]) TObjString(HeaderFile) ;
990119d6 589
8cb3533f 590
591 TFile * file = new TFile(((TObjString *) fHeaderFiles->At(fNinputs))->GetString()) ;
592
990119d6 593 file->cd() ;
8cb3533f 594
595 fSDigitsTitles->Expand(fNinputs+1) ;
596 new((*fSDigitsTitles)[fNinputs]) TObjString(sDigitsTitle) ;
597
990119d6 598 fSDigits->Expand(fNinputs+1) ;
599 new((*fSDigits)[fNinputs]) TClonesArray("AliPHOSDigit",1000) ;
8cb3533f 600
990119d6 601 fIevent->Set(fNinputs+1) ;
602 fIevent->AddAt(-1, fNinputs) ;
8cb3533f 603
990119d6 604 fIeventMax->Set(fNinputs+1) ;
8cb3533f 605
606 TTree * te = (TTree *) file->Get("TE") ;
607 fIeventMax->AddAt((Int_t) te->GetEntries(), fNinputs );
608
990119d6 609 fNinputs++ ;
8cb3533f 610
990119d6 611}
612//__________________________________________________________________
8cb3533f 613void AliPHOSDigitizer::Print(Option_t* option)const {
614
615 if(fInitialized){
616
617 cout << "------------------- "<< GetName() << " -------------" << endl ;
618 cout << "Digitizing sDigits from file(s): " <<endl ;
619 Int_t input ;
620 for(input = 0; input < fNinputs ; input++) {
621 cout << " " << ((TObjString *) fHeaderFiles->At(input))->GetString() <<
622 " Branch title:" << ((TObjString *) fSDigitsTitles->At(input))->GetString() << endl ;
623 }
624 cout << endl ;
625 cout << "Writing digits to " << ((TObjString *) fHeaderFiles->At(0))->GetString() << endl ;
626
627 cout << endl ;
628 cout << "With following parameters: " << endl ;
629 cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ;
630 cout << " Threshold in EMC (fEMCDigitThreshold) = " << fEMCDigitThreshold << endl ; ;
631 cout << " Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ;
632 cout << " Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ;
633 cout << " Noise in PPSD (fPPSDNoise) = " << fPPSDNoise << endl ;
634 cout << " Threshold in PPSD (fPPSDDigitThreshold) = " << fPPSDDigitThreshold << endl ;
635 cout << "---------------------------------------------------" << endl ;
990119d6 636 }
8cb3533f 637 else
638 cout << "AliPHOSDigitizer not initialized " << endl ;
639
640}
641//__________________________________________________________________
642void AliPHOSDigitizer::PrintDigits(Option_t * option){
643
644 cout << "AliPHOSDigitiser:"<< endl ;
645 cout << " Number of entries in Digits list " << fDigits->GetEntriesFast() << endl ;
990119d6 646 cout << endl ;
8cb3533f 647 if(strstr(option,"all")){
648
649 //loop over digits
650 AliPHOSDigit * digit;
651 cout << "Digit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl;
652 Int_t index ;
653 for (index = 0 ; index < fDigits->GetEntries() ; index++) {
654 digit = (AliPHOSDigit * ) fDigits->At(index) ;
655 cout << setw(8) << digit->GetId() << " " << setw(3) << digit->GetAmp() << " "
656 << setw(6) << digit->GetIndexInList() << " "
657 << setw(5) << digit->GetNprimary() <<" ";
658
659 Int_t iprimary;
660 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
661 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
662 cout << endl;
663 }
664
665 }
666}
667//__________________________________________________________________
668void AliPHOSDigitizer::SetSDigitsBranch(const char* title){
669 // we set name of the SDigits branch file in the first! header file
670 if(!fInitialized) Init() ;
990119d6 671
8cb3533f 672 ((TObjString*) fSDigitsTitles->At(0) )->SetString((char*)title) ;
990119d6 673
8cb3533f 674}
675//__________________________________________________________________
676void AliPHOSDigitizer::SetDigitsBranch(const char* title){
677 //Sets the name of the file to which Digits branch will be diverted
678 if(!fInitialized) Init() ;
679
680 fDigitsTitle = title ;
990119d6 681
682}