]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliRunDigitizer.cxx
Code clean-up (F.Carminati)
[u/mrichter/AliRoot.git] / STEER / AliRunDigitizer.cxx
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 /*
17 $Log$
18 Revision 1.21  2002/10/22 15:02:15  alibrary
19 Introducing Riostream.h
20
21 Revision 1.20  2002/10/14 14:57:32  hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
23
24 Revision 1.13.6.2  2002/07/24 10:08:13  alibrary
25 Updating VirtualMC
26
27 Revision 1.19  2002/07/19 12:46:05  hristov
28 Write file instead of closing it
29
30 Revision 1.18  2002/07/17 08:59:39  jchudoba
31 Do not delete subtasks when AliRunDigitizer is deleted. Owner should delete them itself.
32
33 Revision 1.17  2002/07/16 13:47:53  jchudoba
34 Add methods to get access to names of files used in merging.
35
36 Revision 1.16  2002/06/07 09:18:47  jchudoba
37 Changes to enable merging of ITS fast rec points. Although this class should be responsible for a creation of digits only, other solutions would be more complicated.
38
39 Revision 1.15  2002/04/09 13:38:47  jchudoba
40 Add const to the filename argument
41
42 Revision 1.14  2002/04/04 09:28:04  jchudoba
43 Change default names of TPC trees. Use update instead of recreate for the output file. Overwrite the AliRunDigitizer object in the output if it exists.
44
45 Revision 1.13  2002/02/13 09:03:32  jchudoba
46 Pass option to subtasks. Delete input TTrees. Use gAlice from memory if it is present (user must delete the default one created by aliroot if he/she wants to use gAlice from the input file!). Add new data member to store name of the special TPC TTrees.
47
48 Revision 1.12  2001/12/10 16:40:52  jchudoba
49 Import gAlice from the signal file before InitGlobal() to allow detectors to use it during initialization
50
51 Revision 1.11  2001/12/03 07:10:13  jchudoba
52 Default ctor cannot create new objects, create dummy default ctor which leaves object in not well defined state - to be used only by root for I/O
53
54 Revision 1.10  2001/11/15 11:07:25  jchudoba
55 Set to zero new pointers to TPC and TRD special trees in the default ctor. Add const to all Get functions. Remove unused constant, rename constant according coding rules.
56
57 Revision 1.9  2001/11/15 09:00:11  jchudoba
58 Add special treatment for TPC and TRD, they use different trees than other detectors
59
60 Revision 1.8  2001/10/21 18:38:43  hristov
61 Several pointers were set to zero in the default constructors to avoid memory management problems
62
63 Revision 1.7  2001/10/04 15:56:07  jchudoba
64 TTask inheritance
65
66 Revision 1.4  2001/09/19 06:23:50  jchudoba
67 Move some tasks to AliStream and AliMergeCombi classes
68
69 Revision 1.3  2001/07/30 14:04:18  jchudoba
70 correct bug in the initialization
71
72 Revision 1.2  2001/07/28 10:44:32  hristov
73 Loop variable declared once; typos corrected
74
75 Revision 1.1  2001/07/27 12:59:00  jchudoba
76 Manager class for merging/digitization
77
78 */
79
80 ////////////////////////////////////////////////////////////////////////
81 //
82 // AliRunDigitizer.cxx
83 //
84 // Manager object for merging/digitization
85 //
86 // Instance of this class manages the digitization and/or merging of
87 // Sdigits into Digits. 
88 //
89 // Only one instance of this class is created in the macro:
90 //   AliRunDigitizer * manager = 
91 //      new AliRunDigitizer(nInputStreams,SPERB);
92 // where nInputStreams is number of input streams and SPERB is
93 // signals per background variable, which determines how combinations
94 // of signal and background events are generated.
95 // Then instances of specific detector digitizers are created:
96 //   AliMUONDigitizer *dMUON  = new AliMUONDigitizer(manager)
97 // and the I/O configured (you have to specify input files 
98 // and an output file). The manager connects appropriate trees from 
99 // the input files according a combination returned by AliMergeCombi 
100 // class. It creates TreeD in the output and runs once per 
101 // event Digitize method of all existing AliDetDigitizers 
102 // (without any option). AliDetDigitizers ask manager
103 // for a TTree with input (manager->GetInputTreeS(Int_t i),
104 // merge all inputs, digitize it, and save it in the TreeD 
105 // obtained by manager->GetTreeD(). Output events are stored with 
106 // numbers from 0, this default can be changed by 
107 // manager->SetFirstOutputEventNr(Int_t) method. The particle numbers
108 // in the output are shifted by MASK, which is taken from manager.
109 //
110 // The default output is to the signal file (stream 0). This can be 
111 // changed with the SetOutputFile(TString fn)  method.
112 //
113 // Single input file is permitted. Maximum kMaxStreamsToMerge can be merged.
114 // Input from the memory (on-the-fly merging) is not yet 
115 // supported, as well as access to the input data by invoking methods
116 // on the output data.
117 //
118 // Access to the some data is via gAlice for now (supposing the 
119 // same geometry in all input files), gAlice is taken from the first 
120 // input file on the first stream.
121 //
122 // Example with MUON digitizer, no merging, just digitization
123 //
124 //  AliRunDigitizer * manager = new AliRunDigitizer(1,1);
125 //  manager->SetInputStream(0,"galice.root");
126 //  AliMUONDigitizer *dMUON  = new AliMUONDigitizer(manager);
127 //  manager->Exec("");
128 //
129 // Example with MUON digitizer, merge all events from 
130 //   galice.root (signal) file with events from bgr.root 
131 //   (background) file. Number of merged events is
132 //   min(number of events in galice.root, number of events in bgr.root)
133 //
134 //  AliRunDigitizer * manager = new AliRunDigitizer(2,1);
135 //  manager->SetInputStream(0,"galice.root");
136 //  manager->SetInputStream(1,"bgr.root");
137 //  AliMUONDigitizer *dMUON  = new AliMUONDigitizer(manager);
138 //  manager->Exec("");
139 //
140 // Example with MUON digitizer, save digits in a new file digits.root,
141 //   process only 1 event
142 //
143 //  AliRunDigitizer * manager = new AliRunDigitizer(2,1);
144 //  manager->SetInputStream(0,"galice.root");
145 //  manager->SetInputStream(1,"bgr.root");
146 //  manager->SetOutputFile("digits.root");
147 //  AliMUONDigitizer *dMUON  = new AliMUONDigitizer(manager);
148 //  manager->SetNrOfEventsToWrite(1);
149 //  manager->Exec("");
150 //
151 //////////////////////////////////////////////////////////////////////// 
152
153 // system includes
154
155 #include <Riostream.h>
156
157 // ROOT includes
158
159 #include "TFile.h"
160 #include "TList.h"
161 #include "TParticle.h"
162 #include "TTree.h"
163
164 // AliROOT includes
165
166 #include "AliDigitizer.h"
167 #include "AliHeader.h"
168 #include "AliMergeCombi.h"
169 #include "AliRun.h"
170 #include "AliRunDigitizer.h"
171 #include "AliStream.h"
172
173 ClassImp(AliRunDigitizer)
174
175 //_______________________________________________________________________
176 AliRunDigitizer::AliRunDigitizer():
177   fkMASKSTEP(0),
178   fOutputFileName(0),
179   fOutputDirName(0),
180   fOutput(0),
181   fEvent(0),
182   fNrOfEventsToWrite(0),
183   fNrOfEventsWritten(0),
184   fCopyTreesFromInput(0),
185   fTreeD(0),
186   fTreeDTPC(0),
187   fTreeDTRD(0),
188   fTreeR(0),
189   fNinputs(0),
190   fNinputsGiven(0),
191   fInputStreams(0),
192   fTreeDTPCBaseName(0),
193   fTreeTPCSBaseName(0),
194   fCombi(0),
195   fCombination(0),
196   fCombinationFileName(0),
197   fDebug(0)
198 {
199   //
200   // default ctor, where no new objects can be created
201   // do not use this ctor, it is supplied only for root needs
202   //
203   for (Int_t i=0;i<kMaxStreamsToMerge;i++) {
204     fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=fArrayTreeTRDS[i]=NULL;
205     fInputFiles[i]=0;
206   }
207 }
208
209 //_______________________________________________________________________
210 AliRunDigitizer::AliRunDigitizer(const AliRunDigitizer& dig):
211   TTask(dig),
212   fkMASKSTEP(0),
213   fOutputFileName(0),
214   fOutputDirName(0),
215   fOutput(0),
216   fEvent(0),
217   fNrOfEventsToWrite(0),
218   fNrOfEventsWritten(0),
219   fCopyTreesFromInput(0),
220   fTreeD(0),
221   fTreeDTPC(0),
222   fTreeDTRD(0),
223   fTreeR(0),
224   fNinputs(0),
225   fNinputsGiven(0),
226   fInputStreams(0),
227   fTreeDTPCBaseName(0),
228   fTreeTPCSBaseName(0),
229   fCombi(0),
230   fCombination(0),
231   fCombinationFileName(0),
232   fDebug(0)
233 {
234   //
235   // Copy ctor
236   //
237   dig.Copy(*this);
238 }
239
240 //_______________________________________________________________________
241 void AliRunDigitizer::Copy(AliRunDigitizer&) const
242 {
243   Fatal("Copy","Not installed\n");
244 }
245
246
247 //_______________________________________________________________________
248 AliRunDigitizer::AliRunDigitizer(Int_t nInputStreams, Int_t sperb):
249   TTask("AliRunDigitizer","The manager for Merging"),
250   fkMASKSTEP(10000000),
251   fOutputFileName(""),
252   fOutputDirName("."),
253   fOutput(0),
254   fEvent(0),
255   fNrOfEventsToWrite(-1),
256   fNrOfEventsWritten(0),
257   fCopyTreesFromInput(-1),
258   fTreeD(0),
259   fTreeDTPC(0),
260   fTreeDTRD(0),
261   fTreeR(0),
262   fNinputs(nInputStreams),
263   fNinputsGiven(0),
264   fInputStreams(new TClonesArray("AliStream",nInputStreams)),
265   fTreeDTPCBaseName("TreeD_75x40_100x60_150x60_"),
266   fTreeTPCSBaseName("TreeS_75x40_100x60_150x60_"),
267   fCombi(new AliMergeCombi(nInputStreams,sperb)),
268   fCombination(kMaxStreamsToMerge),
269   fCombinationFileName(0),
270   fDebug(0)
271 {
272   //
273   // ctor which should be used to create a manager for merging/digitization
274   //
275   if (nInputStreams == 0) {
276     Error("AliRunDigitizer","Specify nr of input streams");
277     return;
278   }
279   for (Int_t i=0;i<kMaxStreamsToMerge;i++) {
280     fArrayTreeS[i]=fArrayTreeH[i]=fArrayTreeTPCS[i]=fArrayTreeTRDS[i]=NULL;
281     fCombination[i]=-1;
282   }
283   fkMASK[0] = 0;
284   for (Int_t i=1;i<kMaxStreamsToMerge;i++) {
285     fkMASK[i] = fkMASK[i-1] + fkMASKSTEP;
286   }
287
288   TClonesArray &lInputStreams = *fInputStreams;
289 // the first Input is open RW to be output as well
290   new(lInputStreams[0]) AliStream("UPDATE");
291   for (Int_t i=1;i<nInputStreams;i++) {
292     new(lInputStreams[i]) AliStream("READ");
293   }
294
295   for (Int_t i=0; i<kMaxStreamsToMerge; i++) fInputFiles[i]=0;
296 }
297
298 //_______________________________________________________________________
299 AliRunDigitizer::~AliRunDigitizer() {
300 // dtor
301
302 // do not delete subtasks, let the creator delete them
303   if (GetListOfTasks()) 
304     GetListOfTasks()->Clear("nodelete");
305   
306     delete fInputStreams;
307     delete fCombi;
308 }
309
310 //_______________________________________________________________________
311 void AliRunDigitizer::AddDigitizer(AliDigitizer *digitizer)
312 {
313 // add digitizer to the list of active digitizers
314   this->Add(digitizer);
315 }
316
317 //_______________________________________________________________________
318 void AliRunDigitizer::SetInputStream(Int_t i, const char *inputFile)
319 {
320   if (i > fInputStreams->GetLast()) {
321     Error("SetInputStream","Input stream number too high");
322     return;
323   }
324   static_cast<AliStream*>(fInputStreams->At(i))->AddFile(inputFile);
325 }
326
327 //_______________________________________________________________________
328 void AliRunDigitizer::Digitize(Option_t* option)
329 {
330 // get a new combination of inputs, connect input trees and loop 
331 // over all digitizers
332
333 // take gAlice from the first input file. It is needed to access
334 //  geometry data
335 // If gAlice is already in memory, use it
336   if (!gAlice) {
337     if (!static_cast<AliStream*>(fInputStreams->At(0))->ImportgAlice()) {
338       cerr<<"gAlice object not found in the first file of "
339           <<"the 1st stream"<<endl;
340       return;
341     }
342   }
343   if (!InitGlobal()) {
344     cerr<<"False from InitGlobal"<<endl;
345     return;
346   }
347   Int_t eventsCreated = 0;
348 // loop until there is anything on the input in case fNrOfEventsToWrite < 0
349   while ((eventsCreated++ < fNrOfEventsToWrite) || (fNrOfEventsToWrite < 0)) {
350     if (!ConnectInputTrees()) break;
351     InitEvent();
352 // loop over all registered digitizers and let them do the work
353     ExecuteTasks(option);
354     CleanTasks();
355     FinishEvent();
356   }
357   FinishGlobal();
358 }
359
360 //_______________________________________________________________________
361 Bool_t AliRunDigitizer::ConnectInputTrees()
362 {
363 // fill arrays fArrayTreeS, fArrayTreeH and fArrayTreeTPCS with 
364 // pointers to the correct events according fCombination values
365 // null pointers can be in the output, AliDigitizer has to check it
366
367   TTree *tree;
368   char treeName[50];
369   Int_t serialNr;
370   Int_t eventNr[kMaxStreamsToMerge], delta[kMaxStreamsToMerge];
371   fCombi->Combination(eventNr, delta);
372   for (Int_t i=0;i<fNinputs;i++) {
373     if (delta[i] == 1) {
374       AliStream *iStream = static_cast<AliStream*>(fInputStreams->At(i));
375       if (!iStream->NextEventInStream(serialNr)) return kFALSE;
376       fInputFiles[i]=iStream->CurrentFile();
377       sprintf(treeName,"TreeS%d",serialNr);
378       tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
379       if (fArrayTreeS[i]) {
380         delete fArrayTreeS[i];
381         fArrayTreeS[i] = 0;
382       }
383       fArrayTreeS[i] = tree;
384       sprintf(treeName,"TreeH%d",serialNr);
385       tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
386       if (fArrayTreeH[i]) {
387         delete fArrayTreeH[i];
388         fArrayTreeH[i] = 0;
389       }
390       fArrayTreeH[i] = tree;
391       sprintf(treeName,"%s%d",fTreeTPCSBaseName,serialNr);
392       tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
393       if (fArrayTreeTPCS[i]) {
394         delete fArrayTreeTPCS[i];
395         fArrayTreeTPCS[i] = 0;
396       }
397       fArrayTreeTPCS[i] = tree;
398       sprintf(treeName,"TreeS%d_TRD",serialNr);
399       tree = static_cast<TTree*>(iStream->CurrentFile()->Get(treeName));
400       if (fArrayTreeTRDS[i]) {
401         delete fArrayTreeTRDS[i];
402         fArrayTreeTRDS[i] = 0;
403       }
404       fArrayTreeTRDS[i] = tree;
405     } else if (delta[i] != 0) {
406       Error("ConnectInputTrees","Only delta 0 or 1 is implemented");
407       return kFALSE;
408     }
409   }
410   return kTRUE;
411 }
412
413 //_______________________________________________________________________
414 Bool_t AliRunDigitizer::InitGlobal()
415 {
416 // called once before Digitize() is called, initialize digitizers and output
417
418   TList* subTasks = GetListOfTasks();
419   if (subTasks) {
420     subTasks->ForEach(AliDigitizer,Init)();
421   }  
422   return kTRUE;
423 }
424
425 //_______________________________________________________________________
426 void AliRunDigitizer::SetOutputFile(TString fn)
427 // the output will be to separate file, not to the signal file
428 {
429   fOutputFileName = fn;
430   (static_cast<AliStream*>(fInputStreams->At(0)))->ChangeMode("READ");
431   InitOutputGlobal();
432 }
433
434 //_______________________________________________________________________
435 Bool_t AliRunDigitizer::InitOutputGlobal()
436 {
437 // Creates the output file, called by InitEvent()
438
439   TString fn;
440   fn = fOutputDirName + '/' + fOutputFileName;
441   fOutput = new TFile(fn,"update");
442   if (GetDebug()>2) {
443     cerr<<"AliRunDigitizer::InitOutputGlobal(): file "<<fn.Data()<<" was opened"<<endl;
444   }
445   if (fOutput) return kTRUE;
446   Error("InitOutputGlobal","Could not create output file.");
447   return kFALSE;
448 }
449
450
451 //_______________________________________________________________________
452 void AliRunDigitizer::InitEvent()
453 {
454 // Creates TreeDxx in the output file, called from Digitize() once for 
455 //  each event. xx = fEvent
456
457   if (GetDebug()>2) 
458     cerr<<"AliRunDigitizer::InitEvent: fEvent = "<<fEvent<<endl;
459
460 // if fOutputFileName was not given, write output to signal file
461   if (fOutputFileName == "") {
462     fOutput = (static_cast<AliStream*>(fInputStreams->At(0)))->CurrentFile();
463   }
464   fOutput->cd();
465   char treeName[30];
466   sprintf(treeName,"TreeD%d",fEvent);
467   fTreeD = static_cast<TTree*>(fOutput->Get(treeName));
468   if (!fTreeD) {
469     fTreeD = new TTree(treeName,"Digits");
470     fTreeD->Write(0,TObject::kOverwrite);
471   }
472
473 // tree for ITS fast points
474   sprintf(treeName,"TreeR%d",fEvent);
475   fTreeR = static_cast<TTree*>(fOutput->Get(treeName));
476   if (!fTreeR) {
477     fTreeR = new TTree(treeName,"Reconstruction");
478     fTreeR->Write(0,TObject::kOverwrite);
479   }
480
481 // special tree for TPC
482   sprintf(treeName,"%s%d",fTreeDTPCBaseName,fEvent);
483   fTreeDTPC = static_cast<TTree*>(fOutput->Get(treeName));
484   if (!fTreeDTPC) {
485     fTreeDTPC = new TTree(treeName,"TPC_Digits");
486     fTreeDTPC->Write(0,TObject::kOverwrite);
487   }
488
489 // special tree for TRD
490   sprintf(treeName,"TreeD%d_TRD",fEvent);
491   fTreeDTRD = static_cast<TTree*>(fOutput->Get(treeName));
492   if (!fTreeDTRD) {
493     fTreeDTRD = new TTree(treeName,"TRD_Digits");
494     fTreeDTRD->Write(0,TObject::kOverwrite);
495   }
496
497 }
498
499 //_______________________________________________________________________
500 void AliRunDigitizer::FinishEvent()
501 {
502 // called at the end of loop over digitizers
503
504   Int_t i;
505   fOutput->cd();
506   if (fCopyTreesFromInput > -1) {
507     char treeName[20];
508     i = fCopyTreesFromInput; 
509     sprintf(treeName,"TreeK%d",fCombination[i]);
510     fInputFiles[i]->Get(treeName)->Clone()->Write();
511     sprintf(treeName,"TreeH%d",fCombination[i]);
512     fInputFiles[i]->Get(treeName)->Clone()->Write();
513   }
514   fEvent++;
515   fNrOfEventsWritten++;
516   if (fTreeD) {
517     delete fTreeD;
518     fTreeD = 0;
519   }
520   if (fTreeR) {
521     delete fTreeR;
522     fTreeR = 0;
523   }
524   if (fTreeDTPC) {
525     delete fTreeDTPC;
526     fTreeDTPC = 0;
527   }
528   if (fTreeDTRD) {
529     delete fTreeDTRD;
530     fTreeDTRD = 0;
531   }
532 }
533
534 //_______________________________________________________________________
535 void AliRunDigitizer::FinishGlobal()
536 {
537 // called at the end of Exec
538 // save unique objects to the output file
539
540   fOutput->cd();
541   this->Write(0,TObject::kOverwrite);
542   if (fCopyTreesFromInput > -1) {
543     fInputFiles[fCopyTreesFromInput]->Get("TE")->Clone()->Write();
544     gAlice->Write();
545   }
546   fOutput->Write();
547 }
548
549
550 //_______________________________________________________________________
551 Int_t  AliRunDigitizer::GetNParticles(Int_t event) const
552 {
553 // return number of particles in all input files for a given
554 // event (as numbered in the output file)
555 // return -1 if some file cannot be accessed
556
557   Int_t sum = 0;
558   Int_t sumI;
559   for (Int_t i = 0; i < fNinputs; i++) {
560     sumI = GetNParticles(GetInputEventNumber(event,i), i);
561     if (sumI < 0) return -1;
562     sum += sumI;
563   }
564   return sum;
565 }
566
567 //_______________________________________________________________________
568 Int_t  AliRunDigitizer::GetNParticles(Int_t /* event */, Int_t /* input */) const
569 {
570 // return number of particles in input file input for a given
571 // event (as numbered in this input file)
572 // return -1 if some error
573
574 // Must be revised in the version with AliStream
575
576   return -1;
577
578 /*
579   TFile *file = ConnectInputFile(input);
580   if (!file) {
581     Error("GetNParticles","Cannot open input file");
582     return -1;
583   }
584
585 // find the header and get Nprimaries and Nsecondaries
586   TTree* tE = (TTree *)file->Get("TE") ;
587   if (!tE) {
588     Error("GetNParticles","input file does not contain TE");
589     return -1;
590   }
591   AliHeader* header;
592   header = 0;
593   tE->SetBranchAddress("Header", &header);
594   if (!tE->GetEntry(event)) {
595     Error("GetNParticles","event %d not found",event);
596     return -1;
597   }
598   if (GetDebug()>2) {
599     cerr<<"Nprimary: "<< header->GetNprimary()<<endl;
600     cerr<<"Nsecondary: "<<header->GetNsecondary()<<endl;
601   }
602   return header->GetNprimary() + header->GetNsecondary();
603 */
604 }
605
606 //_______________________________________________________________________
607 Int_t* AliRunDigitizer::GetInputEventNumbers(Int_t event) const
608 {
609 // return pointer to an int array with input event numbers which were
610 // merged in the output event event
611
612 // simplified for now, implement later
613   Int_t * a = new Int_t[kMaxStreamsToMerge];
614   for (Int_t i = 0; i < fNinputs; i++) {
615     a[i] = event;
616   }
617   return a;
618 }
619
620 //_______________________________________________________________________
621 Int_t AliRunDigitizer::GetInputEventNumber(Int_t event, Int_t /* input */) const
622 {
623 // return an event number of an eventInput from input file input
624 // which was merged to create output event event
625
626 // simplified for now, implement later
627   return event;
628 }
629
630 //_______________________________________________________________________
631 TParticle* AliRunDigitizer::GetParticle(Int_t i, Int_t event) const
632 {
633 // return pointer to particle with index i (index with mask)
634
635 // decode the MASK
636   Int_t input = i/fkMASKSTEP;
637   return GetParticle(i,input,GetInputEventNumber(event,input));
638 }
639
640 //_______________________________________________________________________
641 TParticle* AliRunDigitizer::GetParticle(Int_t /* i */, Int_t /* input */, 
642                                         Int_t /* event */) const
643 {
644 // return pointer to particle with index i in the input file input
645 // (index without mask)
646 // event is the event number in the file input
647 // return 0 i fit does not exist
648
649 // Must be revised in the version with AliStream
650
651   return 0;
652 /*
653   TFile *file = ConnectInputFile(input);
654   if (!file) {
655     Error("GetParticle","Cannot open input file");
656     return 0;
657   }
658
659 // find the header and get Nprimaries and Nsecondaries
660   TTree* tE = (TTree *)file->Get("TE") ;
661   if (!tE) {
662     Error("GetParticle","input file does not contain TE");
663     return 0;
664   }
665   AliHeader* header;
666   header = 0;
667   tE->SetBranchAddress("Header", &header);
668   if (!tE->GetEntry(event)) {
669     Error("GetParticle","event %d not found",event);
670     return 0;
671   }
672   
673 // connect TreeK  
674   char treeName[30];
675   sprintf(treeName,"TreeK%d",event);  
676   TTree* tK = static_cast<TTree*>(file->Get(treeName));
677   if (!tK) {
678     Error("GetParticle","input file does not contain TreeK%d",event);
679     return 0;
680   }
681   TParticle *particleBuffer;
682   particleBuffer = 0;
683   tK->SetBranchAddress("Particles", &particleBuffer);
684
685
686 // algorithmic way of getting entry index
687 // (primary particles are filled after secondaries)
688   Int_t entry;
689   if (i<header->GetNprimary())
690     entry = i+header->GetNsecondary();
691   else 
692     entry = i-header->GetNprimary();
693   Int_t bytesRead = tK->GetEntry(entry);
694 //  new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
695   if (bytesRead)
696     return particleBuffer;
697   return  0;
698 */
699 }
700
701 //_______________________________________________________________________
702 void AliRunDigitizer::ExecuteTask(Option_t* option)
703 {
704 // overwrite ExecuteTask to do Digitize only
705
706   if (!IsActive()) return;
707   Digitize(option);
708   fHasExecuted = kTRUE;
709   return;
710 }
711
712 //_______________________________________________________________________
713 TString AliRunDigitizer::GetInputFileName(const Int_t input, const Int_t order) const 
714 {
715 // returns file name of the order-th file in the input stream input
716 // returns empty string if such file does not exist
717 // first input stream is 0
718 // first file in the input stream is 0
719   TString fileName("");
720   if (input >= fNinputs) return fileName;
721   AliStream * stream = static_cast<AliStream*>(fInputStreams->At(input));
722   if (order > stream->GetNInputFiles()) return fileName;
723   fileName = stream->GetFileName(order);
724   return fileName;
725 }