-// receives the name of the input file. Opens it and stores pointer
-// to it, returns kFALSE if fails
-// if inputFile = MEMORY, uses pointers from gAlice - not yet implemented
-
-// input cannot be output - open READ only
- TFile *file = new((*fInputFiles)[fNinputs]) TFile(inputFile,"READ");
-
- if (GetDebug()>2) cerr<<"AliRunDigitizer::SetInput: file = "<<file<<endl;
- if (!file->IsOpen()) {
- cerr<<"ERROR: AliRunDigitizer::SetInput: cannot open file "
- <<inputFile<<endl;
- return kFALSE;
- }
-
-// find Header and get nr of events there
- TTree * te = (TTree *) file->Get("TE") ;
- if (!te) {
- cerr<<"ERROR: AliRunDigitizer::SetInput: input file does "
- <<"not contain TE"<<endl;
- return kFALSE;
- }
- Int_t nEntries = (Int_t) te->GetEntries();
-
- if (GetDebug()>2) cerr<<"AliRunDigitizer::SetInput: nEntries = "
- <<nEntries<<endl;
- if (nEntries < 1) {
- cerr<<"ERROR: AliRunDigitizer::SetInput: input file does "
- <<"not contain any event"<<endl;
- return kFALSE;
- }
-
- if (nEntries < fMinNEvents) fNrOfEventsToWrite = fMinNEvents = nEntries;
-
-// find gAlice object if it is a first input file
-// this is only temporary solution, we need gAlice to access detector
-// geometry parameters. Unfortunately I have to include AliRun header file.
- if (fNinputs == 0) {
- gAlice = (AliRun*)file->Get("gAlice");
- if (GetDebug() > 2) cerr<<"gAlice taken from the first input: "
- <<gAlice<<endl;
- if (!gAlice) {
- cerr<<"ERROR: AliRunDigitizer::SetInput: first input file "
- <<"does not contain gAlice object"<<endl;
- return kFALSE;
- }
- }
-
-// store this file name if it is OK
- new((*fInputFileNames)[fNinputs]) TObjString(inputFile);
- fNinputs++;
- if (GetDebug() > 2) cerr<<"fNinputs = "<<fNinputs<<endl;
- return kTRUE;
-}
-
-////////////////////////////////////////////////////////////////////////
-Bool_t AliRunDigitizer::MakeCombination()
-{
-// make a new combination of events from different files
-
- Int_t type = fCombinationType;
- if (fNrOfEventsWritten >= fNrOfEventsToWrite) return kFALSE;
-
- switch (type) {
-
- case 1:
-// type = 1: 1-1-1 - take the same event number from each file
- if (fCombination[0]<fMinNEvents-1) {
- for (Int_t i=0;i<fNinputs;i++) fCombination[i]++;
- return kTRUE;
- }
- if (GetDebug()>2)
- cerr<<"AliRunDigitizer::MakeCombination: Warning: "
- <<"maximum number of Events in an input file "
- <<"was reached."<<endl;
- break;
-
- case 2:
-// type = 2: read from the file combinations.ascii
-// not yet implemented 100% correctly - requires 4 entries in the row
- static FILE *fp ;
- static Int_t linesRead;
- if (!fp) {
- fp = fopen(fCombinationFileName.Data(),"r");
- linesRead = 0;
- }
- if (!fp) {
- cerr<<"AliRunDigitizer::MakeCombination ERROR: "
- <<"Cannot open input file with combinations."<<endl;
- return kFALSE;
- }
- Int_t var[4], nInputs;
- char line[80];
-// since I do not close or rewind the file, the position should be correct
- if (fgets(line,80,fp)) {
- nInputs = sscanf(&line[0],"%d%d%d%d",&var[0],&var[1],&var[2],&var[3]);
- if (nInputs != fNinputs) {
- cerr<<"AliRunDigitizer::MakeCombination ERROR: "
- <<"Nr. of input files is different from nr "
- <<"integers defining the combination"<<endl;
- return kFALSE;
- }
- while(nInputs--) {
- fCombination[nInputs] = var[nInputs];
- }
- return kTRUE;
- } else {
- cerr<<"AliRunDigitizer::MakeCombination ERROR: "
- <<"no more input in the file with combinations"<<endl;
- return kFALSE;
- }
-
- default:
- cerr<<"AliRunDigitizer::MakeCombination: ERROR: "
- <<"wrong type of required combination type: "<<type<<endl;
- }
- return kFALSE;
-}
-
-////////////////////////////////////////////////////////////////////////
-void AliRunDigitizer::PrintCombination()
-{
-// debug method to print current combination
-
- cerr<<"AliRunDigitizer::PrintCombination: Current events combination:"<<endl;
- for (Int_t i=0;i<fNinputs;i++) {
- cerr<<"File: "<<((TObjString *)fInputFileNames->At(i))->GetString()<<"\tEvent: "<<fCombination[i]<<endl;