#include "setup.h" #include "hades.h" #include "hlddiskfilesource.h" #include "hldrfiofilesource.h" #include "hldsockremotesource.h" #include "hrfiorootsource.h" #include "hrootsource.h" #include "hstartunpacker.h" #include "hrichunpackerraw99.h" #include "hrichunpackercal99.h" #include "htofunpacker.h" #include "htofinounpacker.h" #include "hshowerunpacker.h" #include "hmatchuunpacker.h" #include "hrichIPUparthresholds.h" #include "hrichIPUparlocmax.h" #include "hrichdigitisationpar.h" #include "hrichcorrelatorpar.h" #include "hcategory.h" #include "hevent.h" #include "hparasciifileio.h" #include "hparrootfileio.h" extern TString *detectors; extern TString *beamtime; extern Hades *myHades; extern Bool_t firstRemoteSource; extern Bool_t firstRFIOSource; extern Bool_t firstRootSource; extern Bool_t secondRFIOsource; extern Char_t node[200]; extern TString *firstFiles[20]; extern TString *firstDir[20]; extern TString *firstArchive[20]; extern TString *firstRobot[20]; extern TString *secondFiles[20]; extern TString *secondDir[20]; extern TString *secondArchive[20]; extern TString *secondRobot[20]; extern Int_t primaryInput; extern Int_t secondaryInput; extern Int_t refRunId; extern Char_t outname[200]; extern Int_t compLevel; extern TString *notPersistentCat; extern Bool_t batchJob; extern Char_t outfile[200]; extern TString *outputDir; extern Bool_t makeTree; extern TString *masterTaskConfig; extern TString *richIPUthrContext; extern TString *richIPUlocContext; extern TString *richDigitisationContext; extern TString *richCorrelatorContext; extern TString *dboutfile; extern TString *dbouttype; extern Int_t globalRunId; extern Bool_t mdcDebug; extern Bool_t mdcConsistency; extern Bool_t mdcQuiet; Bool_t setupDetectors(void) { if(myHades) { spec = myHades->getSetup(); rtdb = myHades->getRuntimeDb(); if(detectors->Contains("RICH")) { rich = new HRichDetector(); for(Int_t i=0;i<6;i++) rich->setModules(i,richMods); spec->addDetector(rich); } if(detectors->Contains("MDC")) { mdc = new HMdcDetector(); if((beamtime->CompareTo("sep03") == 0) || (beamtime->CompareTo("jan04") == 0)) { mdcMods=mod_sep03; }; if(beamtime->CompareTo("nov02") == 0) { mdcMods=mod_nov02; } if(beamtime->CompareTo("nov01") == 0) { mdcMods=mod_nov01; } for(Int_t i=0;i<6;i++) mdc->setModules(i, mdcMods[i]); spec->addDetector(mdc); } if(detectors->Contains("TOF")) { tof = new HTofDetector(); for (Int_t is=0; is<6; is++) tof->setModules(is,tofMods); spec->addDetector(tof); } if(detectors->Contains("TOFINO")) { tofino = new HTofinoDetector(); for (Int_t is=0; is<6; is++) tofino->setModules(is,tofinoMods[is]); spec->addDetector(tofino); } if(detectors->Contains("SHOWER")) { shower = new HShowerDetector(); for (Int_t is=0; is<6; is++) shower->setModules(is,showerMods); spec->addDetector(shower); } if(detectors->Contains("START")) { if((beamtime->CompareTo("sep03") == 0) || (beamtime->CompareTo("jan04") == 0)) { startMods=startMods_sep03; }; if(beamtime->CompareTo("nov02") == 0) { startMods=startMods_nov02; } if(beamtime->CompareTo("nov01") == 0) { startMods=startMods_nov01; } start = new HStartDetector(); start->setModules(-1,startMods); spec->addDetector(start); tBox = new HTBoxDetector(); tBox->setModules(-1,trigMods); spec->addDetector(tBox); } if(detectors->Contains("TRIGGER")) { trigger = new HTriggerDetector(); spec->addDetector(trigger); } return kTRUE; } else return kFALSE; } Bool_t setupDatasource(void) { if (!firstRemoteSource) { if(!firstRFIOSource) { if(!firstRootSource) { firstSource = new HldDiskFileSource(); } else { firstSource = new HRootSource(); } } else { firstSource = new HldRFIOFileSource(); } } else { firstSource = new HldSockRemoteSource(node); } myHades->setDataSource(firstSource); if(masterTaskConfig->CompareTo("merge")==0) { if(!secondRFIOsource) { secondSource = new HRootSource(); } else { secondSource = new HRFIORootSource(); } myHades->setSecondDataSource(secondSource); } if(masterTaskConfig->CompareTo("simulation") == 0) { ((HRootSource*)firstSource)->setGlobalRefId(refRunId); ((HRootSource*)firstSource)->replaceHeaderVersion(0,kTRUE); } return kTRUE; } Bool_t setupFiles(void) { Char_t infile[200]; TString *inputFile; if (!firstRemoteSource) { TList *fList = NULL; TIterator *iter = NULL; for(Int_t i=0;i<20;i++) { if(firstDir[i]->Length() != 0) { if(firstRFIOSource) { ((HldRFIOFileSource *)firstSource)->setArchive(firstArchive[i]->Data()); ((HldRFIOFileSource *)firstSource)->setRobot(firstRobot[i]->Data()); } if(!firstRootSource) ((HldDiskFileSource *)firstSource)->setDirectory((Text_t *)firstDir[i]->Data()); else ((HRootSource *)firstSource)->setDirectory((Text_t *)firstDir[i]->Data()); if(firstFiles[i]->Length() != 0) { fList = new TList(); iter = fList->MakeIterator(); splitFiles(firstFiles[i],&fList); while((inputFile = (TString *)iter->Next()) != NULL) { strcpy(infile,inputFile->Data()); if(!firstRootSource) { strcat(infile,".hld"); ((HldDiskFileSource *)firstSource)->addFile(infile,getExistingRefRunId(infile, beamtime->Data(), primaryInput, secondaryInput, refRunId, oracle)); } else { strcat(infile,".root"); ((HRootSource *)firstSource)->addFile(infile); } } delete fList; delete iter; } } else break; } } else rtdb->addRun(1); if(masterTaskConfig->CompareTo("merge") == 0) { TList *fList = NULL; TIterator *iter = NULL; for(Int_t i=0;i<20;i++) { if(secondRFIOsource) { TString t = TString(secondArchive[i]->Data())+":"+secondRobot[i]->Data()+":"; ((HRFIORootSource *)secondSource)->setArchive((char *)t.Data()); } if(secondDir[i]->Length() != 0) { ((HRootSource *)secondSource)->setDirectory((Text_t *)secondDir[i]->Data()); if(secondFiles[i]->Length() != 0) { fList = new TList(); iter = fList->MakeIterator(); splitFiles(secondFiles[i],&fList); while((inputFile = (TString *)iter->Next()) != NULL) { strcpy(infile,inputFile->Data()); strcat(infile,".root"); ((HRootSource *)secondSource)->addFile(infile); } delete fList; delete iter; } } else break; } } return kFALSE; } Bool_t setupParContext(void) { if(detectors->Contains("RICH")) { riputhr = (HRichIPUParThresholds*)rtdb->getContainer("RichIPUParThresholds"); riputhr->setParamContext(richIPUthrContext->Data()); ripuloc = (HRichIPUParLocMax*)rtdb->getContainer("RichIPUParLocMax"); ripuloc->setParamContext(richIPUlocContext->Data()); if((masterTaskConfig->CompareTo("simulation") == 0) || (masterTaskConfig->CompareTo("merge") == 0)) { riputhr2 = new HRichIPUParThresholds("RichIPUParThresholds_RICHIPUEmulation","","RICHIPUEmulation"); rtdb->addContainer(riputhr2); ripuloc2 = new HRichIPUParLocMax("RichIPUParLocMax_RICHIPUEmulation","","RICHIPUEmulation"); rtdb->addContainer(ripuloc2); HRichDigitisationPar *p1 = (HRichDigitisationPar*)rtdb->getContainer("RichDigitisationParameters"); p1->setParamContext(richDigitisationContext->Data()); } // SPECIAL PARAM CONTEXT HRichCorrelatorPar *p = (HRichCorrelatorPar*)rtdb->getContainer("RichCorrelatorParameters"); p->setParamContext(richCorrelatorContext->Data()); } return kTRUE; } Bool_t setupUnpacker(void) { if(firstSource) { if(detectors->Contains("START")) { ((HldSource*)firstSource)->addUnpacker(new HStartUnpacker(412)); } if(detectors->Contains("RICH")) { for(Int_t i=0; richUnpackers[i]; i++) { ((HldSource*)firstSource)->addUnpacker( new HRichUnpackerCal99(richUnpackers[i]) ); ((HldSource*)firstSource)->addUnpacker( new HRichUnpackerRaw99(richUnpackers[i]) ); } } if(detectors->Contains("MDC")) { for (Int_t mysamiter=0;mysamiter<24;mysamiter++) { unpackerList[mysamiter] = new HMdcUnpacker(201+mysamiter,mdcDebug,mdcConsistency); if (standalone) unpackerList[mysamiter]->setStandalone(standalone); unpackerList[mysamiter]->setPersistencyRawEventHeader(); if(beamtime->CompareTo("nov01") == 0) { unpackerList[mysamiter]->setDecodeVersion(0); } if(mdcQuiet) unpackerList[mysamiter]->setQuietMode(); //unpackerList[mysamiter]->setUnpackerDebug(); ((HldSource*)firstSource)->addUnpacker(unpackerList[mysamiter]); } } if(detectors->Contains("TOF")) { for(UInt_t i=0; i<(sizeof(tofUnpackers)/sizeof(Int_t)); i++) ((HldSource*)firstSource)->addUnpacker( new HTofUnpacker(tofUnpackers[i])); } if(detectors->Contains("TOFINO")) { for(UInt_t i=0; i<(sizeof(tofinoUnpackers)/sizeof(Int_t)); i++) ((HldSource*)firstSource)->addUnpacker( new HTofinoUnpacker(tofinoUnpackers[i])); } if(detectors->Contains("SHOWER")) { for(UInt_t i=0;i<12;i++) ((HldSource*)firstSource)->addUnpacker(new HShowerUnpacker(showerUnpackers[i])); } if(detectors->Contains("TRIGGER")) { ((HldSource*)firstSource)->addUnpacker( new HMatchUUnpacker(1,kTRUE,0,beamtime->Data())); } return kTRUE; } else return kFALSE; } Bool_t setupOutputName(void) { if(!batchJob) { sprintf(outfile,"%s%s%s%s",outputDir->Data(),"/",outname,".root"); } else { sprintf(outfile,"%s%s",outname,".root"); } return kTRUE; } Bool_t setupOutputGlobal(void) { AsciiIntMap *map; char *name=NULL; if(makeTree) { myHades->setOutputFile(outfile,"RECREATE","unpacker",compLevel); cout << "root output file allocated!" << endl; } HCategory *cat; if(notPersistentCat->Length() > 0) { map = new AsciiIntMap(Categories,CATLISTSIZE); HEvent *event = myHades->getCurrentEvent(); if(notPersistentCat->Contains(",")) { name = strtok((char *)notPersistentCat->Data(),","); cat = ((HCategory *)event->getCategory(map->search(name))); if(cat) cat->setPersistency(kFALSE); do { name = strtok(NULL,","); if(name != NULL) { cat = ((HCategory *)event->getCategory(map->search(name))); if(cat){ cat->setPersistency(kFALSE); } } } while(name!=NULL); } else { cat = ((HCategory *)event->getCategory(map->search(name))); if(cat) cat->setPersistency(kFALSE); } } if(makeTree) { cout << "Creating tree" << endl;; myHades->makeTree(); } return kTRUE; } Bool_t setupDbOutput(void) { if(dbouttype->CompareTo("ASCII")==0) { output = new HParAsciiFileIo(); ((HParAsciiFileIo *)output)->open(((Text_t *)dboutfile->Data()),"out"); } else if(dbouttype->CompareTo("ROOT")==0) { output = new HParRootFileIo(); ((HParRootFileIo*)output)->open(((Text_t *)dboutfile->Data()),"RECREATE"); } if(output) { rtdb->setOutput(output); return kTRUE; } else return kFALSE; }