-// 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;