#include "analysisDST.h" #include "TSystem.h" // #include "helpers.h" #include "Emc.C" #include "DabcHydra.h" Int_t analysisDST(TString inFile = "file.hld", Int_t nEvents=1, Int_t startEvt=0) { cout << " line " << __LINE__ << endl; Hades *myHades=NULL; TStopwatch timer; Int_t evN=nEvents; myHades=new Hades; myHades->setTreeBufferSize(8000); printf("Setting configuration...+++\n"); cout << " line " << __LINE__ << endl; //Int_t refId = 113152567; Int_t refId = 1; //-------------- Default Settings for the File names ----------------- // Put here the OUTPUT directory: outDir !!!!! // TString outDir = "/misc/linev/abc/"; TString outFileSuffix = "_dst.root"; // Parameter input (here from ASCII) TString asciiParFile = "./emc_params.txt"; TString rootParFile = ""; //------------- Operations on the filenames -------------------------- TString outFile = ""; // if(gSystem->AccessPathName(outDir.Data()) != 0) { // cout<<"Creating output dir :"<Exec(Form("mkdir -p %s",outDir.Data())); // } //------Short-List-Of-Categories-which-are-notneeded-in-this-DST-production------// Cat_t notPersistentCat[] = { }; //------- Detector setup Int_t emcMods[1] = {1}; HSpectrometer* spec = gHades->getSetup(); spec->addDetector(new HEmcDetector); spec->getDetector("Emc")->setModules(0,emcMods); // only sector 0 //------- Parameters HRuntimeDb *rtdb = myHades -> getRuntimeDb(); if (!asciiParFile.IsNull()) { HParAsciiFileIo *input1=new HParAsciiFileIo; input1->open((Text_t*)asciiParFile.Data(),"in"); rtdb->setFirstInput(input1); } if (!rootParFile.IsNull()) { HParRootFileIo *input2=new HParRootFileIo; input2->open((Text_t*)rootParFile.Data(),"READ"); rtdb->setSecondInput(input2); } //rtdb->print(); //------- Data source // printf ("Search for dabc:// = %d\n", inFile.Index("dabc://")); if (inFile.Index("dabc://")==0) { printf("Create stream source %s\n", inFile.Data() + 7); HldStreamSource *source = new HldStreamSource(inFile.Data() + 7); source->setRefId(refId); myHades->setDataSource(source); // generate output file name from stream outFile = outDir + "Stream" + outFileSuffix; } else { printf("Create file source \n"); HldFileSource* source = new HldFileSource; source->setDirectory(""); source->addFile((Text_t*)inFile.Data(), refId); myHades->setDataSource(source); // generate output file name from input file name TString hldSuffix =".hld"; TString hldFile = gSystem->BaseName(inFile.Data()); if (hldFile.EndsWith(hldSuffix)) hldFile.ReplaceAll(hldSuffix,""); TString hld = hldFile+hldSuffix; outFile = outDir+hld+outFileSuffix; outFile.ReplaceAll("//", "/"); } HldSource* source = dynamic_cast (myHades->getDataSource()); //------- Unpackers ... Int_t emcUnpackers [1] = { 0x88f0 }; // subevent id //------- Unpackers for(UInt_t i=0; i<(sizeof(emcUnpackers)/sizeof(Int_t)); i++){ HEmcTrb3Unpacker *emcUnp = new HEmcTrb3Unpacker(emcUnpackers[i]); emcUnp->setDebugFlag(0); emcUnp->setQuietMode(); emcUnp->setHUBId(0x9000); emcUnp->setCTSId(0x8000); // this is min/max values, used for simple linear calibrations HTrb3TdcMessage::setFineLimits(31, 421); // create 4 TDC with correspondent ID numbers emcUnp->createTDC(0x50f0, 0x50f1, 0x50f2, 0x50f3); // emcUnp->loadCalibrations("/misc/linev/cal2011/test"); // if (gEmcUnpacker==0) gEmcUnpacker = emcUnp; source->addUnpacker(emcUnp); } // ----------- Build TASK SETS (using H***TaskSet::make) ------------- HEmcTaskSet *emcTaskSet = new HEmcTaskSet(); HTask *emcTasks = emcTaskSet->make("real",""); //------------------------ Master task set --------------------------- HTaskSet *masterTaskSet = gHades->getTaskSet("all"); masterTaskSet->add(emcTasks); myHades->makeCounter(10000); if (!myHades->init()){ Error("init()","Hades did not initialize ... once again"); exit(1); } //----------------- Set not persistent categories -------------------- HEvent *event = myHades->getCurrentEvent(); for(UInt_t i=0;igetCategory(notPersistentCat[i])); if(cat)cat->setPersistency(kFALSE); } // output file myHades->setOutputFile((Text_t*)outFile.Data(),"RECREATE","Test",2); myHades->makeTree(); // mapHolder::getMapHolder(); // create mapHolder object (helpers.h) // TList histpool; // list of all histograms std::vector < DabcFillFunction > fillfunctions; fillfunctions.push_back(&fillHistEmc); DabcHydra::StartServers(); createHistEmc(); // DabcHydra::RegisterHist(histpool); DabcHydra::RegisterExtra(event); myHades->setQuietMode(2); myHades->makeCounter(1); Int_t nProcessed = DabcHydra::EventLoop(fillfunctions, nEvents); // Int_t nProcessed = myHades->eventLoop(nEvents,startEvt); printf("Events processed: %i\n",nProcessed); cout<<"--Input HLD file: "<DirName(argv[0])); return EXIT_SUCCESS; } return usage(TString(argv[0])); } break; case 4: if ((atoi(argv[2])!=0) && (atoi(argv[3])!=0)) { return analysisDST(TString(argv[1]),atoi(argv[2]),atoi(argv[3])); } else { return usage(TString(argv[0])); } break; default: usage(TString(argv[0])); return EXIT_SUCCESS; } } #endif