//////////////////////////////////////////////////////////////////////////////////////////////////////// // // Component: TowerCorrMaker.cc // Purpose: Implementation of TowerCorrMaker class. // // Created: 15/04/99 Pierre Savard (adapted from J. Lamoureux's // CalBankMaker) // History: // 06/21/02 Beate Heinmann: make not only TowerCorr but also TowerCorrectionColl // TowerCorrectionsColl contains the values of the offline LERs // since those values are now applied to TowerCorr directly // these offline LERs are taken out when the raw data banks // are recreated // It is written to the RunRecord // 06/16/03 Beate Heinemann: now have one collection per detector to hold the tower-by // tower calibration constants // 06/30/03 Willis Sakumoto: write all LERs from the database to the begin run TowerCorr // collection; streamline code and update comments // 29/09/04 Angela Wyatt: Add a TowerCorrColl for MiniPlug //////////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include "inc/bcs.h" #include "BaBar/Cdf.hh" #include "ErrorLogger_i/gERRLOG.hh" #include "CalorGeometry/CalorKey.hh" #include "CalorGeometry/CalConstants.hh" #include "Edm/Handle.hh" #include "AbsEnv/AbsEnv.hh" // Geometry headers #include "GeometryBase/CdfDetector.hh" #include "CalorGeometry/AbsCalorDetectorNode.hh" #include "CalorGeometry/HWCalorDetectorNode.hh" // Calorimetry class headers #include "CalorObjects/TowerCorr.hh" #include "CalorObjects/TowerType.hh" #include "Calor/TowerCorrMaker.hh" using namespace std; // namespace calor { // // Memory management // TowerCorrMaker::TowerCorrMaker(){ _CEMtowerCorr = 0; _CHAtowerCorr = 0; _WHAtowerCorr = 0; _PEMtowerCorr = 0; _PHAtowerCorr = 0; _PPRtowerCorr = 0; _MPAtowerCorr = 0; } //------------------------------------------------------------------- // // Destructor // //------------------------------------------------------------------- TowerCorrMaker::~TowerCorrMaker() { } void TowerCorrMaker::initJob() { } void TowerCorrMaker::initRun() { initRun(false,true); } void TowerCorrMaker::initRun(bool verbose) { initRun(verbose,true); } void TowerCorrMaker::initRun(bool verbose, bool accDB) { initRun(verbose,accDB,false); } void TowerCorrMaker::initRun(bool verbose, bool accDB, bool makeMPA) { _dbInitialized = false; if (accDB) { if (verbose) cout << "TowerCorrMaker: read DB values for offline LERs"<monteFlag() ) ERRLOG(ELabort,"TowerCorrMaker: ") << "Error initialising DB!" << endmsg; if(_dbInitialized && !gblEnv->monteFlag()){ bool result = _calib.loadCalibConsts(); if(!result) ERRLOG(ELabort,"TowerCorrMaker: ") << "Error fetching calibration constants from DB!" << endmsg; } } else { // load fake constants if only running for test purposes _calib.loadFakeConsts(); ERRLOG(ELwarning,"TowerCorrMaker: ") << "Not applying offline LER values!" << endmsg; } if(gblEnv->monteFlag()){ _calib.loadMCConsts(); } if(verbose) _calib.print(std::cout); // if(verbose) _calib.printLers(std::cout); _CEMtowerCorr = new CEMTowerCorrColl(); _CHAtowerCorr = new CHATowerCorrColl(); _PEMtowerCorr = new PEMTowerCorrColl(); _PHAtowerCorr = new PHATowerCorrColl(); _WHAtowerCorr = new WHATowerCorrColl(); _PPRtowerCorr = new PPRTowerCorrColl(); _MPAtowerCorr = new MPATowerCorrColl(); makeTowerCorr(verbose,makeMPA); if (AbsEnv::theRunRecord()) { AbsEnv::theRunRecord()->append(_CEMtowerCorr); AbsEnv::theRunRecord()->append(_CHAtowerCorr); AbsEnv::theRunRecord()->append(_WHAtowerCorr); AbsEnv::theRunRecord()->append(_PEMtowerCorr); AbsEnv::theRunRecord()->append(_PHAtowerCorr); AbsEnv::theRunRecord()->append(_PPRtowerCorr); if (makeMPA) AbsEnv::theRunRecord()->append(_MPAtowerCorr); } else { ERRLOG(ELwarning,"TowerCorrMaker: ") << "No RunRecord: cannot append the offline LER collection (TowerCollectionColl) and thereby not apply the tower-by-tower calibrations!" << endmsg; } } // presently there is no event by event correction void TowerCorrMaker::initEvent(AbsEvent* anEvent){ } void TowerCorrMaker::endEvent(AbsEvent* anEvent, bool verbose){ } int TowerCorrMaker::writeTowerCorr(AbsEvent* anEvent,bool verbose){ return 1; } //------------------------------------------------------------------- // Make TowerCorrectionColl //------------------------------------------------------------------- int TowerCorrMaker::makeTowerCorr(bool verbose, bool makeMPA){ if (verbose) std::cout << "TowerCorrMaker: apply offline LER values"<=34 && ie<=35) ) ) ++nZero; if ( chaLer<0.01 && !( ip==11 && (ie>=30 && ie<=33) ) ) ++nZero; if ( whaLer<0.01 ) ++nZero; // Write out all LERs from the database as is: no cuts. Contents of // CEM,CHA,WHA,PEM,PPR,PHATowerCollCorr validated. WKS:26Jun03 TowerCorr cemt = TowerCorr('c',ie,ip,cemLer); _CEMtowerCorr->contents().push_back(cemt); TowerCorr chat = TowerCorr('c',ie,ip,chaLer); _CHAtowerCorr->contents().push_back(chat); TowerCorr what = TowerCorr('c',ie,ip,whaLer); _WHAtowerCorr->contents().push_back(what); TowerCorr pprt = TowerCorr('c',ie,ip,pprLer); _PPRtowerCorr->contents().push_back(pprt); TowerCorr pemt = TowerCorr('c',ie,ip,pemLer); _PEMtowerCorr->contents().push_back(pemt); TowerCorr phat = TowerCorr('c',ie,ip,phaLer); _PHAtowerCorr->contents().push_back(phat); } } if ( nZero != 0 ) { ERRLOG(ELwarning,"TowerCorrMaker: ") << "Error in tower-by-tower corrections (offline LERs): LER is 0 for some towers" << endmsg; } if (verbose) std::cout << "TowerCorrMaker: makeMPA: " << makeMPA << std::endl; if (makeMPA) { for (size_t is=0;iscontents().push_back(mpat); TowerCorr mpat2 = TowerCorr('c',is+2,it,mpaSlope); _MPAtowerCorr->contents().push_back(mpat2); } } } if (verbose) std::cout << "done with makeTowerCorr"<