// -*- mode: c++ -*- // // $Id: TofTimeOffset.C,v 1.8 2004/11/09 12:08:26 ouerdane Exp $ // $Author: ouerdane $ // $Date: 2004/11/09 12:08:26 $ // $Copyright: (C) 2001 BRAHMS Collaboration // #ifndef __CINT__ TofTimeOffset() #endif { #include //__________________________________________________________________ cout << " Configuration script TofTimeOffset_cal.C" << endl; //__________________________________________________________________ BrAppOptionManager* optionManager = BrAppOptionManager::Instance(); BrAppStringOption* outdirOption = new BrAppStringOption('o', "output", "output dir", "/brahms/u/hongyan/brahms_ana/ana/app/calib/tof/timeoffset"); BrAppStringOption* histogramOption = new BrAppStringOption('H', "histogram", "Histogram for adcgap, adcgain, deltadelay, timeoffset", "timeoffset"); BrAppStringOption* parametersOption = new BrAppStringOption('p', "parameters", "Parameters file name", "DetectorParameters.txt"); BrAppIntOption* runOption = new BrAppIntOption('r', "run", "Run number", 8390); BrAppIntOption* seqOption = new BrAppIntOption('s', "sequence", "Sequence number", 0); BrAppIntOption* eventsOption = new BrAppIntOption('e', "events", "Max events", 100000000); BrAppIntOption* verboseOption = new BrAppIntOption('v', "verbose", "Verbosity", 0); BrAppIntOption* prodverOption = new BrAppIntOption('P', "production-version", "Production Version number of gtr file", 1); BrAppIntOption* gtrverOption = new BrAppIntOption('g', "gtr version", "Version number of gtr file", -1); BrAppIntOption* ltrverOption = new BrAppIntOption('l', "ltr version", "Version number of ltr file", -1); BrAppIntOption* debugOption = new BrAppIntOption('d', "debug", "Debug level", 0); BrAppBoolOption* mrsOption = new BrAppBoolOption('\0', "mrs", "Enable/Disable TOFW Cal", kTRUE); BrAppBoolOption* ffsOption = new BrAppBoolOption('\0', "ffs", "Enable/Disable TOF1 Cal", kFALSE); BrAppBoolOption* bfsOption = new BrAppBoolOption('\0', "bfs", "Enable/Disable TOF2 Cal", kFALSE); BrAppStringOption* t1adcgainOption = new BrAppStringOption('a', "adcgain calib.", "tof1 adcgain calib file", ""); BrAppStringOption* t1deltadelayOption = new BrAppStringOption('y', "deltadelay calib", "tof1 deltadelay calib file", ""); BrAppStringOption* t2adcgainOption = new BrAppStringOption('A', "adcgain calib.", "tof2 adcgain calib file", ""); BrAppStringOption* t2deltadelayOption = new BrAppStringOption('Y', "deltadelay calib", "tof2 deltadelay calib file", ""); if (!optionManager->ProcessCommandLine()) { Warning("TofTimeOffset", "Bad command line, try --help option"); return; } //________________________________________________________________ // // Database section // TString userName = "query"; TString serverName = "brahms-db0.rcf.bnl.gov"; TString dbName = "BrahmsMain"; BrMainDb* mainDb = BrMainDb::Instance(); mainDb->SetUserName(userName.Data()); mainDb->SetHostName(serverName.Data()); mainDb->SetDbName(dbName.Data()); if (!mainDb->Connect()) return; BrRunsDb* runsDb = mainDb->ConnectToRun(); if (!runsDb) return; if (!mainDb->ConnectToCalib()) return; if (!mainDb->ConnectToGeom()) return; BrFileCatalogsDb* fileCatalogsDb = mainDb->ConnectToFileCatalog("query"); if(!fileCatalogsDb->Connect()) { printf("Can't connect to file catalog\n"); return; } cout << " connected. " << endl; Int_t runNo = runOption->GetValue(); BrRunInfoManager* runMan = BrRunInfoManager::Instance(); BrFileCatalogManager* fileCatalog = BrFileCatalogManager::Instance(); fileCatalog->Init(); //__________________________________________________________________ // // The main module // // load Flemming's libray -- new Nov 29, 2005 gSystem->Load("/brahms/u/hongyan/work/fv_app/util/libUtil.so"); BrMainModule* mainModule = new BrMainModule("TofTimeOffset", "Tof Time Offset", "Djamel Ouerdane", 0, 1, 0); mainModule->SetMaxEvents(eventsOption->GetValue()); //new Nov 29, 2005 CounterModule* counterModule = new CounterModule("counterModule","List event stat"); mainModule->AddModule(counterModule); //__________________________________________________________________ // // The input module // BrIOModule* inputModule = new BrEventIO("InputFile"); inputModule->SetIOMode(BrIOModule::kBrRunFile | BrIOModule::kBrReadFile); // adding input file(s) to input module TString ext="root"; BrIOModule* inputModule = new BrEventIO("InputFile"); inputModule->SetIOMode(BrIOModule::kBrRunFile | BrIOModule::kBrReadFile); // TString gtrDir; // Int_t gtrVerNo; BrDbRun* dbrun; if(gtrverOption->GetValue() > -1){ inputModule->AddFileSet(runOption->GetValue(),"gtr",prodverOption->GetValue(),gtrverOption->GetValue()); } else{ inputModule->AddFileSet(runNo,"gtr",prodverOption->GetValue()); } runMan->Register(runNo); dbrun = runsDb->GetRun(runNo); if(gtrverOption->GetValue() > -1){ fileCatalog->Update(runNo,"gtr",prodverOption->GetValue(),gtrverOption->GetValue()); } else{ fileCatalog->Update(runNo,"gtr",prodverOption->GetValue()); } // BrFileCatalogInfo* catalogInfo = fileCatalog->GetCurrentRun(); // gtrDir = catalogInfo->GetDirectory(); // gtrVerNo = catalogInfo->GetVersionNo(); Int_t noFiles = inputModule->GetNoFiles(); mainModule->SetMaxRuns(noFiles); mainModule->AddModule(inputModule); cout <<"run period: " << dbrun->GetRunPeriod() <<", colliding species: " << dbrun->GetSpecie() <<" at energy: " << dbrun->GetEnergy() << endl; cout <<" run setting: " << endl; if(mrsOption) cout << dbrun->GetMRSAngle() << dbrun->GetD5Pol() << dbrun->GetD5Set() << endl; if(ffsOption || bfsOption) cout << dbrun->GetFFSAngle() << dbrun->GetD1Pol() << dbrun->GetD1Set() << endl; BrCalibrationManager* parMan = BrCalibrationManager::Instance(); parMan->SetDebugLevel(debugOption->GetValue()); BrParameterDbManager *parameterManager = BrParameterDbManager::Instance(); parameterManager->SetUseRunInfo(); parameterManager->SetDebugLevel(debugOption->GetValue()); BrGeometryDbManager *geometryManager = BrGeometryDbManager::Instance(); geometryManager->SetDbModeMySQL(); geometryManager->SetDebugLevel(debugOption->GetValue()); // this is the way to use the calibration which has not been // committed to the database yet... mainly for testing the calibration BrTofAdcGainCalModule* tof1_adc = new BrTofAdcGainCalModule("TOF1","TOF1 adcgain calibration"); tof1_adc->SetCalibFile(t1adcgainOption->GetValue()); tof1_adc->SetLoadAscii(kTRUE); BrTofDeltaDelayCalModule* tof1_deltadelay = new BrTofDeltaDelayCalModule("TOF1","TOF1 deltadelay calibration"); tof1_deltadelay->SetCalibFile(t1deltadelayOption->GetValue()); tof1_deltadelay->SetLoadAscii(kTRUE); BrTofAdcGainCalModule* tof2_adc = new BrTofAdcGainCalModule("TOF2","TOF2 adcgain calibration"); tof2_adc->SetCalibFile(t2adcgainOption->GetValue()); tof2_adc->SetLoadAscii(kTRUE); BrTofDeltaDelayCalModule* tof2_deltadelay = new BrTofDeltaDelayCalModule("TOF2","TOF2 deltadelay calibration"); tof2_deltadelay->SetCalibFile(t2deltadelayOption->GetValue()); tof2_deltadelay->SetLoadAscii(kTRUE); //__________________________________________________________________ // // Histogram IO module // if (histogramOption->GetValue()[0] == '\0') { cerr << " I need some histogram file!!! " << endl; return; } BrHistIOModule* histModule = new BrHistIOModule("histograms", "Some histograms"); histModule->AddFile(Form("%s/hist_tofw_run%d_%s.%s",outdirOption->GetValue(),runOption->GetValue(),histogramOption->GetValue(),ext.Data())); mainModule->AddModule(histModule); mainModule->SetHistOn(); //__________________________________________________________________ // // Needed modules should go here. // // You can add both BRAT modules, such as BrTileRdoModule, Filters, // Such as BrTriggerFilter, and user defined modules, say MyModule. // User defined modules a used via loading, via TSystem::Load, a // shared library containing that module. // //__________________________________________________________________ // db update module mainModule->AddModule(new BrDbUpdateModule("DB", "DB Update")); //-------------------- // calibration modules //-------------------- BrTriggerFilter* trig = new BrTriggerFilter("Trigger", "Trigger filter"); mainModule->AddModule(trig); if (mrsOption->GetValue()) { trig->AddTrigger(3); // MRS BrTofTimeOffsetCalModule* tofw = new BrTofTimeOffsetCalModule("TOFW", "TOFW Time Offset Calibration"); // BrAppendContainer* swModule3 = new BrAppendContainer("Append1","use out for both in/out"); // mainModule->Add(swModule3); // swModule3->SetVerbose(0); // swModule3->SetDebugLevel(0); BrTMrsFRdoModule* TMrsFRdoModule = new BrTMrsFRdoModule("TMrsF","TMrsF Rdo reduction module"); TMrsFRdoModule -> SetNtuple(kTRUE); TMrsFRdoModule -> SetDebugLevel(0); TMrsFRdoModule -> SetPositionOffset(-4.28); // swModule3 -> AddModule(TMrsFRdoModule); tofw -> SetUseTMrsTime(kTRUE); tofw -> SetUseBbVertex(kFALSE); // for dAu tofw -> SetMaxDY(20000000.); tofw -> SetEnergyThreshold(0.6); tofw -> SetMaxEnergy(1000000.); tofw -> SetSaveAscii(kFALSE); tofw -> SetFillHistoOnly(kTRUE); // tofw -> SetNtuple(kTRUE); // tofw -> SetCalibFile(Form("TofwRun%d.off",runOption->GetData())); tofw -> SetVerbose(11); mainModule -> AddModule(tofw); } if (ffsOption->GetValue()) { trig->AddTrigger(6); // FFS BrTofTimeOffsetCalModule* tof1 = new BrTofTimeOffsetCalModule("TOF1", "TOF1 Time Offset Calibration"); tof1->SetFillHistoOnly(kTRUE); tof1->SetMaxDY(20000000.); tof1->SetMomentumCut(10.); tof1->SetEnergyThreshold(0.6); tof1->SetMaxEnergy(1000000.); mainModule->AddModule(tof1); } if (bfsOption->GetValue()) { trig->AddTrigger(2); // FS BrTofTimeOffsetCalModule* tof2 = new BrTofTimeOffsetCalModule("TOF2", "TOF2 Time Offset Calibration"); tof2->SetFillHistoOnly(kTRUE); // tof2->SetRichMassCut(0.15); // tof2->SetRequireChkv(kFALSE); // tof2->SetRequireAdc(kFALSE); tof2->SetMomentumCut(10.); tof2->SetMaxDY(20000000.); tof2->SetEnergyThreshold(0.6); tof2->SetMaxEnergy(1000000.); mainModule->AddModule(tof2); } //__________________________________________________________________ // // Debug and verbosity mainModule->SetVerbose(verboseOption->GetValue()); mainModule->SetDebugLevel(debugOption->GetValue()); cout << "End of setup" << endl; if(tofw) tofw-> SetVerbose(1); if(tofw) tofw-> SetDebugLevel(1); } //____________________________________________________________________ // // changed a bit for the TOFW calibration Nov 29, 2005 // // $Log: TofTimeOffset.C,v $ // Revision 1.8 2004/11/09 12:08:26 ouerdane // updated scripts // // Revision 1.6 2003/06/11 18:52:22 videbaek // Change all occurences of rcas0005 to brahms-db0 // // Revision 1.5 2003/04/11 20:46:45 videbaek // add the user query to connects // // Revision 1.4 2002/04/16 15:27:43 ouerdane // added connection to geo DB // // Revision 1.3 2002/04/09 01:31:29 ouerdane // corrected small errors // // Revision 1.2 2002/04/08 20:13:18 ouerdane // updated all scripts and added new options to enable or disable a detector, set a comment at commit time and the ascii file as well // //