#ifdef USE_CDFEDM2 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Component: Calib.cc // Purpose: This class contains the offline calorimeter calibration // constants. The loadCalibConsts loads the constants from // the database // // Created: 1998 Jodi Lamoureux // // History: 16/11/99 Pierre Savard: Add database access // 27/07/00 Pierre Savard: Change defaults calibrations to // corrspond to note 4781 for // CEM,CHA,WHA,PEM,PHA // 05/12/00 Pierre Savard: add Monte Carlo flag check (monteFlag) // 04/12/01 Bob Wagner: Change default CES gain constants to be // in GeV/ADC instead of ADC/GeV // 06/25/01 Beate Heinemann: use new database tables CALDigiToGeV3 // and CALL1Peds3 // 05/06/01 Beate Heinemann: read calibration and pedestal tables for MiniPlug // (FWDDigiToGeV3 and FWDL1Peds3) // 06/25/03 Willis Sakumoto: standardize offline LERs for CEM,CHA, // WHA,PEM,PHA and PPR; add PEM,PHA badChannels // 29/10/03 Angela Wyatt: Use BadChannels in preference to DeadChannels. // 17/09/04 Angela Wyatt: Add new MiniPlug offline calibration constants. // 03/03/05 Bob Wagner: Comment out lines 865 and 880 which cause run to abort // if no LERs found for CPR2 or CCR. There are still runs for which // these are not available. This was done to allow 6.1.0 to get into // production. // 09/03/05 Else Lytken: All DB abort lines are now uncommented // 14/04/05 Emily Nurse: Add fudge factor for runs 193800 to 196000 // 17/05/05 Emily Nurse: Add fudge factor for runs 196000 to 197400 // 29/06/05 Emily Nurse: Add fudge factor for runs 197400 to 199300 // 26/07/05 Emily Nurse: Add fudge factor for runs up to 201350 // 25/08/05 Emily Nurse: Add fudge factor for runs up to 202604 // 07/09/05 Emily Nurse: Add fudge factor for runs up to 203800 // 18/11/05 Emily Nurse: Add fudge factor for runs up to 206989 // 05/12/05 Emily Nurse: Add fudge factor for runs up to 208000 // 30/01/06 Emily Nurse: Add fudge factor for runs up to 210020 // 10/03/06 Emily Nurse: Add fudge factor for runs up to 213000 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #include "inc/bcs.h" #include "ErrorLogger_i/gERRLOG.hh" #include "CalorObjects/Calib.hh" #include "CalorObjects/CalDataCalib.hh" #include "CalorGeometry/CalorComponent.h" #include "AbsEnv/AbsEnv.hh" #include "CalorObjects/TdcKey.hh" #include "CalorGeometry/CalorKey.hh" #include "CalorGeometry/CellKey.hh" #include "CalibDB/KeyDatabase.hh" #include "RawDataBanks/RawQieStorableBank.hh" // namespace calor{ //----------------------------------------------------------------------------- // Dec 21 2002 P.Murat: best Larry's (ljn@fnal.gov) run-dependent scale // corrections for CEM // 1.022 is consistent with what has been put into DB, // Larry recommends to use 1.03 which puts Z->ee peak // to the right place //----------------------------------------------------------------------------- float larry_cem_scale(int Run) { float fudge=1.0; float scale=1.03; if (Run > 10) { if (Run < 141544) fudge = scale/(1.0220 - .000000224*(Run-140000)); else if (Run < 143500) fudge = scale/(1.0211 + .000000514*(Run-142500)); else if (Run < 146000) fudge = scale/(1.016 - .0000036 *(Run-144300)); else if (Run < 152400) fudge = scale/(1.009 - .0000045 *(Run-148000)); //scl bump by 3% else if (Run < 155000) fudge = scale/(1.014 - .0000022 *(Run-153600)); else if (Run < 158000) fudge = scale/(1.005 - .000005 *(Run-155700)); else if (Run < 160200) fudge = scale/1.0017; else if (Run < 160800) fudge = scale/(.9977 - .0000045 *(Run-160500)); else if (Run < 163800) { fudge = scale/(.991 - .0000020 *(Run-161750)); // scl bump by 3% if (Run > 162697) fudge *=.975; } else if(Run<166200) { fudge = scale/(1.018 - .0000066 * (Run-164750)); if(Run>165700) fudge=.996*fudge; } else if(Run<166900) fudge = scale/(1.012 - .0000190*(Run-166600)); else if(Run<170000) fudge = scale/1.011; else if(Run<177000) fudge = scale/(1.0198+.0000017*(Run-175800)); else if(Run<177600) fudge = scale/1.0173; else if(Run<180000) fudge = scale/(1.016 - .000009*(Run-178100)); else if(Run<182100) fudge= scale/(1.007 + .0000020*(Run-181500)); else if(Run<185549) fudge= scale/(1.007-.0000054*(Run-182350)); else if(Run<188000) fudge= scale/(1.037-.0000054*(Run-182350)); else if(Run<193800) fudge= scale/(1.0188 - .0000037*(Run-191800)); else if(Run<196000) { fudge=scale/(1.0078 - .0000059*(Run-194200)); if(Run>195437) fudge=fudge/1.03; } else if(Run<197500) fudge= scale/(1.0264 - .0000040*(Run-196700)); else if(Run<200400) fudge= scale/(1.0298 - .0000040*(Run-196700)); else if(Run<201300) fudge= scale/(1.0176 - .0000045*(Run-200900)); else if(Run<202604) fudge= scale/(1.0231 - .0000045*(Run-200900)); else if(Run<203800) fudge= scale/(1.0246 - .0000045*(Run-200900)); else if(Run<208000) { fudge=scale/(1.0256 - .0000045*(Run-200900)); if(Run>207100) fudge=fudge/1.03; if(Run>207400) fudge=fudge/1.0046; } else if(Run<209051) fudge= scale/(.978 + .00037*(Run-208900)); else if(Run<210012) fudge= scale/(1.029 - .000007*(Run-209300)); else if(Run<213000) fudge= scale/(1.0375 - .000007*(Run-209300)); } return fudge; } Calib::Calib(): _calibCem(0.0), _calibCha(0.0), _calibWha(0.0), _calibPem(0.0), _calibPha(0.0), _calibPpr(0.0), _calibMpa(0.0),_calibCpr(0.0),_calibCesStrip(0.0), _calibCesWire(0.0), _pedCem(50), _pedCha(50), _pedWha(50), _pedPem(50), _pedPha(50), _pedPpr(12), _pedMpa(50),_pedCpr(50),_pedCes(48), _sclCEM(1.0),_sclCHA(1.0),_sclWHA(1.0), _sclPEM(1.0),_sclPHA(1.0) { // initialise slewing corrections and LERs memset(_slewTdcCHA,0,TENETA*TENPHI*sizeof(float)); memset(_slewTdcWHA,0,TENETA*TENPHI*sizeof(float)); memset(_slewTdcPHA,0,TENETA*TENPHI*sizeof(float)); memset(_t0TdcCHA,0,TENETA*TENPHI*sizeof(float)); memset(_t0TdcWHA,0,TENETA*TENPHI*sizeof(float)); memset(_t0TdcPHA,0,TENETA*TENPHI*sizeof(float)); memset(_lerPPR,0,TENETA*TENPHI*sizeof(float)); memset(_lerCEM,0,TENETA*TENPHI*sizeof(float)); memset(_lerCHA,0,TENETA*TENPHI*sizeof(float)); memset(_lerWHA,0,TENETA*TENPHI*sizeof(float)); memset(_lerPEM,0,TENETA*TENPHI*sizeof(float)); memset(_lerPHA,0,TENETA*TENPHI*sizeof(float)); // +++++++ added for cpr calibration +++++++ memset(_lerCP2,0,NCP2_SIDES*NCP2_WEDGES*NCP2_PADS*sizeof(float)); memset(_lerCCR,0,NCP2_SIDES*NCP2_WEDGES*NCCR_CELLS*sizeof(float)); //added initialization 8/18/03 Ben W memset(_efficTdcCHA,0,TENETA*TENPHI*sizeof(float)); memset(_efficTdcWHA,0,TENETA*TENPHI*sizeof(float)); memset(_efficTdcPHA,0,TENETA*TENPHI*sizeof(float)); //initialise bad chnls memset( _badChannelsCEM,0,TENETA*TENPHI*sizeof(long)); memset( _badChannelsCHA,0,TENETA*TENPHI*sizeof(long)); memset( _badChannelsWHA,0,TENETA*TENPHI*sizeof(long)); memset( _badChannelsPEM,0,TENETA*TENPHI*sizeof(long)); memset( _badChannelsPHA,0,TENETA*TENPHI*sizeof(long)); numDeadDB = 0; numBadDB = 0; memset(_mpaOffset,0,2*84*sizeof(float)); memset(_mpaSlope ,0,2*84*sizeof(float)); } Calib::~Calib() {} bool Calib::initializeDB(){ // Connect to ALL of the required calibration tables via the DB // manager. If any calibration table is not found, return false // (initOK = false). This method tests all calibrations. bool initOK( true ); //calibration: ADC->GeV and pedestals calDB_mgr = CALDigiToGeV3_mgr("CALDigiToGeV3"); pedDB_mgr = CALL1Peds3_mgr("CALL1Peds3"); // fwdDB_mgr = FWDDigiToGeV3_mgr("FWDDigiToGeV3"); // fwdpedDB_mgr = FWDL1Peds3_mgr("FWDL1Peds3"); // slewing corrections chaSlDB_mgr = CHASlewing_mgr("CHASlewing"); phaSlDB_mgr = PHASlewing_mgr("PHASlewing"); whaSlDB_mgr = WHASlewing_mgr("WHASlewing"); // efficiency corrections chaEfDB_mgr = CHAEfficiency_mgr("CHAEfficiency"); phaEfDB_mgr = PHAEfficiency_mgr("PHAEfficiency"); whaEfDB_mgr = WHAEfficiency_mgr("WHAEfficiency"); // LER's pprLER_mgr = PPRLinEResponse_mgr("PPRLinEResponse"); cemLER_mgr = CEMOffLER_mgr("CEMOffLER"); chaLER_mgr = CHAOffLER_mgr("CHAOffLER"); whaLER_mgr = WHAOffLER_mgr("WHAOffLER"); pemLER_mgr = PEMOffLER_mgr("PEMOffLER"); phaLER_mgr = PHAOffLER_mgr("PHAOffLER"); cp2LER_mgr = CP2OffLER_mgr("CP2OffLER"); ccrLER_mgr = CCROffLER_mgr("CCROffLER"); //SCL offScl_mgr = OffSCL_mgr("OffSCL"); // old DB dead channels cemDeadDB_mgr = CEMPMTDeadChannels_mgr("CEMPMTDeadChannels"); chaDeadDB_mgr = CHAPMTDeadChannels_mgr("CHAPMTDeadChannels"); whaDeadDB_mgr = WHAPMTDeadChannels_mgr("WHAPMTDeadChannels"); // bad channels cemBadDB_mgr = CEMBadChannels_mgr("CEMBadChannels"); chaBadDB_mgr = CHABadChannels_mgr("CHABadChannels"); whaBadDB_mgr = WHABadChannels_mgr("WHABadChannels"); pemBadDB_mgr = PEMBadChannels_mgr("PEMBadChannels"); phaBadDB_mgr = PHABadChannels_mgr("PHABadChannels"); //MP Cals mpaCalDB_mgr = MPAOffLumiCalib_mgr("MPAOffLumiCalib"); Result rccal; Result rcped; Result rcchaSl; Result rcphaSl; Result rcwhaSl; Result rcchaEf; Result rcphaEf; Result rcwhaEf; Result rcppr; Result rccem; Result rccha; Result rcwha; Result rcpem; Result rcpha; Result rccp2; Result rcccr; Result rcscl; Result rcfwd; Result rcfwdped; Result rccemDead; Result rcchaDead; Result rcwhaDead; Result rccemBad; Result rcchaBad; Result rcwhaBad; Result rcpemBad; Result rcphaBad; Result rcmpa; if(calDB_mgr.isValid() == true){ // Use the default key setup by the CalibrationManager rccal = calDB_mgr.get(calDB_data); } if(pedDB_mgr.isValid() == true){ // Use the default key setup by the CalibrationManager rcped = pedDB_mgr.get(pedDB_data); } // slewign corrections if(chaSlDB_mgr.isValid() == true){ rcchaSl = chaSlDB_mgr.get(chaSlDB_data); } if(phaSlDB_mgr.isValid() == true){ rcphaSl = phaSlDB_mgr.get(phaSlDB_data); } if(whaSlDB_mgr.isValid() == true){ rcwhaSl = whaSlDB_mgr.get(whaSlDB_data); } // TDC efficiencies if(chaEfDB_mgr.isValid() == true){ rcchaEf = chaEfDB_mgr.get(chaEfDB_data); } if(phaEfDB_mgr.isValid() == true){ rcphaEf = phaEfDB_mgr.get(phaEfDB_data); } if(whaEfDB_mgr.isValid() == true){ rcwhaEf = whaEfDB_mgr.get(whaEfDB_data); } //offline LERs if (pprLER_mgr.isValid() == true) { rcppr = pprLER_mgr.get(pprLER_data); } if (cemLER_mgr.isValid() == true) { rccem = cemLER_mgr.get(cemLER_data); } if (chaLER_mgr.isValid() == true) { rccha = chaLER_mgr.get(chaLER_data); } if (whaLER_mgr.isValid() == true) { rcwha = whaLER_mgr.get(whaLER_data); } if (pemLER_mgr.isValid() == true) { rcpem = pemLER_mgr.get(pemLER_data); } if (phaLER_mgr.isValid() == true) { rcpha = phaLER_mgr.get(phaLER_data); } if (cp2LER_mgr.isValid() == true) { rccp2 = cp2LER_mgr.get(cp2LER_data); } if (ccrLER_mgr.isValid() == true) { rcccr = ccrLER_mgr.get(ccrLER_data); } // offline SCL if (offScl_mgr.isValid() == true) { rcscl = offScl_mgr.get(offScl_data); } // Dead+bad channels: defined table with no run list // entry still gives Result::success numDeadDB = 0; numBadDB = 0; bool badDBabort( false ); if ( cemDeadDB_mgr.isValid() == true) { rccemDead = cemDeadDB_mgr.get(cemDeadDB_data); if ( !cemDeadDB_data.isStale() ) ++numDeadDB; } if ( chaDeadDB_mgr.isValid() == true) { rcchaDead = chaDeadDB_mgr.get(chaDeadDB_data); if ( !chaDeadDB_data.isStale() ) ++numDeadDB; } if ( whaDeadDB_mgr.isValid() == true) { rcwhaDead = whaDeadDB_mgr.get(whaDeadDB_data); if ( !whaDeadDB_data.isStale() ) ++numDeadDB; } if ( cemBadDB_mgr.isValid() == true) { rccemBad = cemBadDB_mgr.get(cemBadDB_data); if ( !cemBadDB_data.isStale() ) ++numBadDB; } if ( chaBadDB_mgr.isValid() == true) { rcchaBad = chaBadDB_mgr.get(chaBadDB_data); if ( !chaBadDB_data.isStale() ) ++numBadDB; } if ( whaBadDB_mgr.isValid() == true) { rcwhaBad = whaBadDB_mgr.get(whaBadDB_data); if ( !whaBadDB_data.isStale() ) ++numBadDB; } if ( pemBadDB_mgr.isValid() == true) { rcpemBad = pemBadDB_mgr.get(pemBadDB_data); if ( !pemBadDB_data.isStale() ) ++numBadDB; } if ( phaBadDB_mgr.isValid() == true) { rcphaBad = phaBadDB_mgr.get(phaBadDB_data); if ( !phaBadDB_data.isStale() ) ++numBadDB; } //code aborts if numBadDB = numDeadDB = 0 if ( numBadDB ) { if ( numBadDB != 5 ) { numBadDB = 0; numDeadDB = 0; badDBabort = true; } } else { if ( numDeadDB ) { if ( numDeadDB != 3 ) { numDeadDB = 0; badDBabort = true; } } else { numBadDB = numDeadDB = 0; badDBabort = true; } } if ( badDBabort ) { // no DB found abort initOK = false; ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB for Bad Channels Failed" << endmsg; } if (mpaCalDB_mgr.isValid() == true) { rcmpa = mpaCalDB_mgr.get(mpaCalDB_data); } if (rcmpa!=Result::success) ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of Miniplug DB Managers Failed - using old calibrations" << endmsg; // if(fwdDB_mgr.isValid() == true){ // // Use the default key setup by the CalibrationManager // rcfwd = fwdDB_mgr.get(fwdDB_data); // } // if(fwdpedDB_mgr.isValid() == true){ // // Use the default key setup by the CalibrationManager // rcfwdped = fwdpedDB_mgr.get(fwdpedDB_data); // } // Check if DB connnection worked: bail out on "hardware" calib problems if (rccal!=Result::success || rcped!=Result::success || rcchaSl !=Result::success|| rcwhaSl !=Result::success|| rcphaSl !=Result::success || rcchaEf!=Result::success|| rcwhaEf!=Result::success || rcphaEf!=Result::success || rcppr !=Result::success){ // || rcfwd!=Result::success|| rcfwdped!=Result::success){ if (rccal!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB Managers Failed - using default calibration constants or will use MC constants (if file is MC)" << endmsg; ERRLOG(ELwarning,"calor::Calib: ") << calDB_mgr.lastResult(); } if (rcped!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB Managers Failed - using default pedastals or will use MC constants (if file is MC)" << endmsg; ERRLOG(ELwarning,"calor::Calib: ") << pedDB_mgr.lastResult(); } if (rcchaSl!=Result::success|| rcwhaSl!=Result::success || rcphaSl!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB Managers (Slewing) Failed " << endmsg; ERRLOG(ELwarning,"calor::Calib: ") << chaSlDB_mgr.lastResult(); ERRLOG(ELwarning,"calor::Calib: ") << whaSlDB_mgr.lastResult(); ERRLOG(ELwarning,"calor::Calib: ") << phaSlDB_mgr.lastResult(); } if (rcchaEf!=Result::success|| rcwhaEf!=Result::success || rcphaEf!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB Managers (Efficiency) Failed " << endmsg; ERRLOG(ELwarning,"calor::Calib: ") << chaEfDB_mgr.lastResult(); ERRLOG(ELwarning,"calor::Calib: ") << whaEfDB_mgr.lastResult(); ERRLOG(ELwarning,"calor::Calib: ") << phaEfDB_mgr.lastResult(); } if (rcppr!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB Managers (PPRLer) Failed " << endmsg; ERRLOG(ELwarning,"calor::Calib: ") << pprLER_mgr.lastResult(); } // if (rcfwd!=Result::success|| rcfwdped!=Result::success) { // ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of DB Managers for MiniPlug Failed - using default pedastals or will use MC constants (if file is MC)" << endmsg; // ERRLOG(ELwarning,"calor::Calib: ") << fwdDB_mgr.lastResult(); // ERRLOG(ELwarning,"calor::Calib: ") << fwdpedDB_mgr.lastResult(); // } initOK = false; } else { if (rccem!=Result::success || rccha!=Result::success|| rcwha!=Result::success || rcpem!=Result::success || rcpha!=Result::success || rccp2!=Result::success || rcccr!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << "Initialisation of offLER DB Managers Failed - using LER=1" << endmsg; if (rccem!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << cemLER_mgr.lastResult(); } if (rccha!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << chaLER_mgr.lastResult(); } if (rcwha!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << whaLER_mgr.lastResult(); } if (rcpem!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << pemLER_mgr.lastResult(); } if (rcpha!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << phaLER_mgr.lastResult(); } if (rccp2!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << cp2LER_mgr.lastResult(); } if (rcccr!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << ccrLER_mgr.lastResult(); } if (rcscl!=Result::success) { ERRLOG(ELwarning,"calor::Calib: ") << offScl_mgr.lastResult(); } } } return initOK; } bool Calib::loadCalibConsts() { return loadCalibConsts(false); } bool Calib::loadCalibConsts(bool applyOffScl) { if(calDB_data ->size() == 0) return false; if(pedDB_data ->size() == 0) return false; bool loadOK( true ); // Calibration go/no-go flag _calibCem = (calDB_data->at(CalorComponent::CEM)).calib(); _calibCha = (calDB_data->at(CalorComponent::CHA)).calib(); _calibWha = (calDB_data->at(CalorComponent::WHA)).calib(); _calibPem = (calDB_data->at(CalorComponent::PEM)).calib(); _calibPha = (calDB_data->at(CalorComponent::PHA)).calib(); _calibPpr = (calDB_data->at(CalorComponent::PPR)).calib(); // _calibMpa = (fwdDB_data->at(CalorComponent::MPA)).calib(); _calibMpa = 0.001; _calibCpr = (calDB_data->at(CalorComponent::CPR)).calib(); _calibCesStrip = (calDB_data->at(CalorComponent::CES_STRIPS)).calib(); _calibCesWire = (calDB_data->at(CalorComponent::CES_WIRES)).calib(); // the pedestals for CEM,CHA,PEM,PHA and WHA are all taken from the individual components _pedCem = (pedDB_data->at(CalorComponent::CEM)).ped(); _pedCha = (pedDB_data->at(CalorComponent::CHA)).ped(); _pedWha = (pedDB_data->at(CalorComponent::WHA)).ped(); _pedPem = (pedDB_data->at(CalorComponent::PEM)).ped(); _pedPha = (pedDB_data->at(CalorComponent::PHA)).ped(); _pedPpr = (pedDB_data->at(CalorComponent::PPR)).ped(); _pedMpa = 200; // _pedMpa = (fwdpedDB_data->at(CalorComponent::MPA)).ped(); _pedCpr = (pedDB_data->at(CalorComponent::CPR)).ped(); _pedCes = (pedDB_data->at(CalorComponent::CES_STRIPS)).ped(); // peds for strips and wires are the same // _pedCes = (pedDB_data->at(CalorComponent::CES_WIRES)).ped(); for (int ie=0;iebegin(); chait< chaSlDB_data->end();chait++) { // first work out software indices for this tower int side=(chait->geomid() & 0x00000800) >> 11; int wedge=(chait->geomid() & 0x000007C0) >> 6; int rapidity = (chait->geomid() & 0x0000003E) >> 1; int depth_or_tile=chait->geomid() & 0x00000001; TdcKey tdccha(side, wedge, rapidity, depth_or_tile); int ieta=tdccha.ixEta(); int iphi=tdccha.ixPhi(); // make sure this is in allowed range for CHA if ( ieta>=MinEtaCHAW && ieta<=MaxEtaCHAE && iphi>=0 && iphislew()*sqrt(_calibCha); _t0TdcCHA[ieta][iphi]=chait->t0(); } else { ERRLOG(ELerror,"calor::Calib: ") << "CHA Slewing corrections not correct" << endmsg; } } WHASlewingContainer::iterator whait = whaSlDB_data->begin(); while (whait!=whaSlDB_data->end()) { int side=(whait->geomid() & 0x00000800) >> 11; int wedge=(whait->geomid() & 0x000007C0) >> 6; int rapidity = (whait->geomid() & 0x0000003E) >> 1; int depth_or_tile=whait->geomid() & 0x00000001; TdcKey tdcwha(side, wedge, rapidity, depth_or_tile); int ieta=tdcwha.ixEta(); int iphi=tdcwha.ixPhi(); // make sure this is in allowed range for WHA if ( ( (ieta <= MaxEtaWHAE && ieta >= MinEtaWHAE)|| (ieta >= MinEtaWHAW && ieta <= MaxEtaWHAW) ) && iphi>=0 && iphislew()*sqrt(_calibWha); _t0TdcWHA[ieta][iphi]=whait->t0(); } else { ERRLOG(ELerror,"calor::Calib: ") << "WHA Slewing corrections not correct" << endmsg; } whait++; } PHASlewingContainer::iterator phait = phaSlDB_data->begin(); while (phait!=phaSlDB_data->end()) { int side=(phait->geomid() & 0x00000800) >> 11; int wedge=(phait->geomid() & 0x000007C0) >> 6; int rapidity = (phait->geomid() & 0x0000003E) >> 1; int depth_or_tile=phait->geomid() & 0x00000001; TdcKey tdcpha(side, wedge, rapidity, depth_or_tile); int ieta=tdcpha.ixEta(); int iphi=tdcpha.ixPhi(); // make sure this is in allowed range if ( ( ieta<=MaxEtaPHAW || ieta>=MinEtaPHAE ) && ieta>=MinEtaPHAW && ieta<=MaxEtaPHAE && iphi>=0 && iphislew()*sqrt(_calibPha); _t0TdcPHA[ieta][iphi]=phait->t0(); } else { ERRLOG(ELerror,"calor::Calib: ") << "PHA Slewing corrections not correct" << endmsg; } phait++; } // store the chi2 from the efficiency as the effic for (CHAEfficiencyContainer::iterator chait= chaEfDB_data->begin(); chait< chaEfDB_data->end();chait++) { // first work out software indices for this tower int side=(chait->geomid() & 0x00000800) >> 11; int wedge=(chait->geomid() & 0x000007C0) >> 6; int rapidity = (chait->geomid() & 0x0000003E) >> 1; int depth_or_tile=chait->geomid() & 0x00000001; TdcKey tdccha(side, wedge, rapidity, depth_or_tile); int ieta=tdccha.ixEta(); int iphi=tdccha.ixPhi(); // make sure this is in allowed range for CHA if ( ieta>=MinEtaCHAW && ieta<=MaxEtaCHAE && iphi>=0 && iphichi2(); } else { ERRLOG(ELerror,"calor::Calib: ") << "CHA Efficiency corrections not correct" << endmsg; } } WHAEfficiencyContainer::iterator whaEf_it = whaEfDB_data->begin(); while (whaEf_it!=whaEfDB_data->end()) { int side=(whaEf_it->geomid() & 0x00000800) >> 11; int wedge=(whaEf_it->geomid() & 0x000007C0) >> 6; int rapidity = (whaEf_it->geomid() & 0x0000003E) >> 1; int depth_or_tile=whaEf_it->geomid() & 0x00000001; TdcKey tdcwha(side, wedge, rapidity, depth_or_tile); int ieta=tdcwha.ixEta(); int iphi=tdcwha.ixPhi(); // make sure this is in allowed range for WHA if ( ( (ieta <= MaxEtaWHAE && ieta >= MinEtaWHAE)|| (ieta >= MinEtaWHAW && ieta <= MaxEtaWHAW) ) && iphi>=0 && iphichi2(); } else { ERRLOG(ELerror,"calor::Calib: ") << "WHA Efficiency corrections not correct" << endmsg; } whaEf_it++; } PHAEfficiencyContainer::iterator phaEf_it = phaEfDB_data->begin(); while (phaEf_it!=phaEfDB_data->end()) { int side=(phaEf_it->geomid() & 0x00000800) >> 11; int wedge=(phaEf_it->geomid() & 0x000007C0) >> 6; int rapidity = (phaEf_it->geomid() & 0x0000003E) >> 1; int depth_or_tile=phaEf_it->geomid() & 0x00000001; TdcKey tdcpha(side, wedge, rapidity, depth_or_tile); int ieta=tdcpha.ixEta(); int iphi=tdcpha.ixPhi(); // make sure this is in allowed range if ( ( ieta<=MaxEtaPHAW || ieta>=MinEtaPHAE ) && ieta>=MinEtaPHAW && ieta<=MaxEtaPHAE && iphi>=0 && iphichi2(); } else { ERRLOG(ELerror,"calor::Calib: ") << "PHA Efficiency corrections not correct" << endmsg; } phaEf_it++; } if (!mpaCalDB_data.isStale()) { for (MPAOffLumiCalibContainer::iterator mp_iter = mpaCalDB_data->begin(); mp_iter != mpaCalDB_data->end(); mp_iter++ ) { int iSide = mp_iter->side(); int iTower = mp_iter->tower(); _mpaOffset[iSide][iTower] = mp_iter->offset(); _mpaSlope[iSide][iTower] = mp_iter->slope(); } } else _mpaOffset[0][0] = -9999; // Initialise the badChannels to zero (good) for (int ieta=0;ietasize() != 0) ) { for ( CEMBadChannelsContainer::iterator iter = cemBadDB_data->begin(); iter != cemBadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphibadCode(); } } if ( !chaBadDB_data.isStale() && (chaBadDB_data->size() != 0) ) { for ( CHABadChannelsContainer::iterator iter = chaBadDB_data->begin(); iter != chaBadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphibadCode(); } } if ( !whaBadDB_data.isStale() && (whaBadDB_data->size() != 0) ) { for ( WHABadChannelsContainer::iterator iter = whaBadDB_data->begin(); iter != whaBadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphibadCode(); } } } else { if (numDeadDB) { if ( !cemDeadDB_data.isStale() && (cemDeadDB_data->size() != 0) ) { for ( CEMPMTDeadChannelsContainer::iterator iter = cemDeadDB_data->begin(); iter != cemDeadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphisize() != 0) ) { for ( CHAPMTDeadChannelsContainer::iterator iter = chaDeadDB_data->begin(); iter != chaDeadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphisize() != 0) ) { for ( WHAPMTDeadChannelsContainer::iterator iter = whaDeadDB_data->begin(); iter != whaDeadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphisize() != 0) ) { for ( PEMBadChannelsContainer::iterator iter = pemBadDB_data->begin(); iter != pemBadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphibadCode(); } } if ( !phaBadDB_data.isStale() && (phaBadDB_data->size() != 0) ) { for ( PHABadChannelsContainer::iterator iter = phaBadDB_data->begin(); iter != phaBadDB_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channelID(), ieta, iphi ); if (iphibadCode(); } } // Initialise the offline LERs all to 1 for the CEM,CHA,WHA,PEM, // PHA, and PPR. The LER usage for all is identical: // ieta = TOWE detector eta index // iphi = 2*wedge + ipmt (or tile) // The online and offline LER tables are identical in format and // use the same geomID. The geomid encodes ew, rapidity tower, // wedge, and pmt/tile, as per CDF4152. WKS:25Jun03 for (int ieta=0;ietasize() != 0 ) { for ( PPRLinEResponseContainer::iterator iter = pprLER_data->begin(); iter != pprLER_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->geomid(), ieta, iphi ); if (iphiresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "PPR Calibration table corrupted" << endmsg; } } else noDBentry += "PPR "; if (cemLER_data->size() != 0) { for ( CEMOffLERContainer::iterator iter = cemLER_data->begin(); iter != cemLER_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->geomid(), ieta, iphi ); if (iphiresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "CEM Calibration table corrupted" << endmsg; } } else noDBentry += "CEM "; if (chaLER_data->size() != 0) { for ( CHAOffLERContainer::iterator iter = chaLER_data->begin(); iter != chaLER_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->geomid(), ieta, iphi ); if (iphiresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "CHA Calibration table corrupted" << endmsg; } } else noDBentry += "CHA "; if (whaLER_data->size() != 0) { for ( WHAOffLERContainer::iterator iter = whaLER_data->begin(); iter != whaLER_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->geomid(), ieta, iphi ); if (iphiresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "WHA Calibration table corrupted" << endmsg; } } else noDBentry += "WHA "; if (pemLER_data->size() != 0) { for ( PEMOffLERContainer::iterator iter = pemLER_data->begin(); iter != pemLER_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->geomid(), ieta, iphi ); if (iphiresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "PEM Calibration table corrupted" << endmsg; } } else noDBentry += "PEM "; if (phaLER_data->size() != 0) { for ( PHAOffLERContainer::iterator iter = phaLER_data->begin(); iter != phaLER_data->end(); iter++ ) { int ieta, iphi; getLERindices( iter->channel(), ieta, iphi ); // channel==geomid if (iphiresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "PHA Calibration table corrupted" << endmsg; } } else noDBentry += "PHA "; // +++++++ added for cp2 calibration +++++++ int run_num = AbsEnv::instance()->runNumber(); //only look for calibrations for new data: if(run_num>190000){ if ( cp2LER_data->size() != 0 ) { for ( CP2OffLERContainer::iterator iter = cp2LER_data->begin(); iter != cp2LER_data->end(); iter++ ) { int iside, imodule, ipad; getCP2LERindices( iter->geomid(), iside, imodule, ipad ); if (isideresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "CP2 Calibration table corrupted" << endmsg; } } else noDBentry += "CP2 "; //same for CCR if ( ccrLER_data->size() != 0 ) { for ( CCROffLERContainer::iterator iter = ccrLER_data->begin(); iter != ccrLER_data->end(); iter++ ) { int iside, imodule, icell; getCCRLERindices( iter->geomid(), iside, imodule, icell ); if (isideresponse(); else ERRLOG(ELerror,"calor::Calib: ") << "CCR Calibration table corrupted" << endmsg; } } else noDBentry += "CCR "; } // end of new Cp2/Ccr calibrations if ( noDBentry != " " ) { ERRLOG(ELerror,"calor::Calib: ") << "no DB LERs found for " << noDBentry << endmsg; loadOK = false; // Abort signal } if(offScl_data ->size() != 0) { //----------------------------------------------------------------------------- // Dec 22 2002 P.Murat: use Larry's corrections for CEM as defined by the // primary source - code above, do not take them from DB // in Oct'2002 online scales were changed to account for // observed 4% shift in CHA scales (MIP position), // for runs > 152400 they should be equal to 1 // during the Jun'2002 shutdown the online CEM LER's // (tower-to-tower corrections) were changed to equalize // responses of different towers as seen by the offline // (the corrections were derived by Eva) // So for runs>=146805 offline LER's are set to 1 for all // the channels //----------------------------------------------------------------------------- int run_num = AbsEnv::instance()->runNumber(); // _sclCEM = (offScl_data->at(CalorComponent::CEM)).calib(); _sclCEM = larry_cem_scale(run_num); _sclCHA = (offScl_data->at(CalorComponent::CHA)).calib(); _sclWHA = (offScl_data->at(CalorComponent::WHA)).calib(); _sclPEM = (offScl_data->at(CalorComponent::PEM)).calib(); _sclPHA = (offScl_data->at(CalorComponent::PHA)).calib(); // now we multiply the offline and online SCLs to get the final one _calibCem=_calibCem*_sclCEM; _calibCha=_calibCha*_sclCHA; _calibWha=_calibWha*_sclWHA; _calibPem=_calibPem*_sclPEM; _calibPha=_calibPha*_sclPHA; } ERRLOG(ELinfo,"calor::Calib: ") << "calorimeter calibration constants loaded" << endmsg; return loadOK; } bool Calib::loadMCConsts() { // Monte Carlo Constants: // The big calorimeters use the default values defined in the constructor _calibCem = 0.003; _calibCha = 0.003; _calibWha = 0.003; _calibPem = 0.004; _calibPha = 0.005; _calibPpr = 0.0004; _calibMpa = 0.001; // For CPR _calibCpr = 1.14444; _pedCpr = 0; // For CES (strips and wires) _calibCesStrip = 1.0 / 120.0480; _calibCesWire = 1.0 / 240.3846; _pedCes = 48; for (int ieta=0;ietacalibCem(); _calibCha = Calibrations->calibCha(); _calibWha = Calibrations->calibWha(); _calibPem = Calibrations->calibPem(); _calibPha = Calibrations->calibPha(); _calibPpr = Calibrations->calibPpr(); _calibMpa = Calibrations->calibMpa(); // ............................ this is a question, but not necessary _calibCpr = 1.67; _calibCesStrip = 0.00833; _calibCesWire = 0.00416; _pedCem = Calibrations->pedCem(); _pedCha = Calibrations->pedCha(); _pedWha = Calibrations->pedWha(); _pedPem = Calibrations->pedPem(); _pedPha = Calibrations->pedPha(); _pedPpr = Calibrations->pedPpr(); // _pedCpr = Calibrations->pedCpr(); // _pedCes = Calibrations->pedCes(); _pedMpa = Calibrations->pedMpa(); // +++++++ added for cpr calibration +++++++ //ShMax LER initialized to 1 for (int iside=0;iside 17) && ( (it%2) == 1 ) ) continue; // 15 degree phi towers int ieta( (is == 0) ? 25 - ir : 26 + ir ); int iphi( 2*iw + it ); float cler( (id == 0) ? _lerPEM[ieta][iphi] : ((id == 1) ? _lerPHA[ieta][iphi] : _lerPPR[ieta][iphi]) ); os << "LER:" << pDET[id] << "(" << std::setw(2) << ieta << "," << std::setw(2) << iphi << ":" << std::setw(1) << is << "," << std::setw(2) << ir << "," << std::setw(2) << iw << "," << std::setw(1) << it << ")" << std::setw(6) << geomID[ieta][iphi] << " = " << cler << std::endl; } } } } os << std::endl; } // return os; } void Calib::printEffic(std::ostream& os) const{ os << "CHAEfficiency table: " << std::endl; for (int ieta=MinEtaCHAW;ieta<=MaxEtaCHAE;ieta++) { for (int iphi=0;iphi 31) { for (int iphi=0;iphi 37) { int endphi = TENPHI; if (ieta < 8 || ieta > 43) endphi = TENPHI/2; for (int iphi=0;iphi