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