diff --git a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCalibDigitMaker.h b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCalibDigitMaker.h index 1e110eeb8060ec8eea8b15fbf0fb41d33eb8a504..29bd7d575e7cd2702958fd3e83ee133a42dead45 100644 --- a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCalibDigitMaker.h +++ b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCalibDigitMaker.h @@ -23,6 +23,7 @@ class LArCalibDigitMaker : public AthAlgorithm StatusCode finalize(){return StatusCode::SUCCESS;} private: SG::ReadCondHandleKey<LArCalibLineMapping> m_calibMapKey{this,"CalibMapKey","LArCalibLineMap","SG Key of calib line mapping object"}; + SG::ReadCondHandleKey<LArCalibLineMapping> m_calibMapSCKey{this,"CalibMapSCKey","LArCalibIdMapSC","SG Key of calib line mapping object"}; std::vector<std::string> m_keylist; std::vector<unsigned> m_vPattern; std::vector<unsigned> m_vDAC; @@ -31,6 +32,8 @@ class LArCalibDigitMaker : public AthAlgorithm unsigned m_nTrigger; double m_delayScale; bool m_dontRun; + bool m_isSC; + }; #endif diff --git a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArRampBuilder.h b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArRampBuilder.h index ad0221e3578db63e22607c2b9c339899858a73de..673d7a0a763baca49db68cf96068139a629b817a 100644 --- a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArRampBuilder.h +++ b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArRampBuilder.h @@ -47,8 +47,9 @@ #include "LArCabling/LArOnOffIdMapping.h" #include "StoreGate/ReadCondHandleKey.h" +#include "LArRecConditions/LArCalibLineMapping.h" //#include "LArCalibTriggerAccumulator.h" - +#include "CaloDetDescr/ICaloSuperCellIDTool.h" #include <vector> #include <string> #include <map> @@ -76,6 +77,8 @@ public: private: SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this, "OnOffMap", "LArOnOffIdMap", "SG key for mapping object"}; + SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKeySC{this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}; + //Private member functions // choose reconstruction mode (i.e. OF or Parabola) void chooseRecoMode() ; @@ -100,7 +103,8 @@ private: ToolHandle<LArParabolaPeakRecoTool> m_peakParabolaTool; ToolHandle<LArShapePeakRecoTool> m_peakShapeTool; ToolHandle<LArOFPeakRecoTool> m_peakOFTool; - + ToolHandle<ICaloSuperCellIDTool> m_sc2ccMappingTool; + unsigned m_event_counter; int m_delay; int m_ipassShape; @@ -162,6 +166,14 @@ private: uint16_t m_fatalFebErrorPattern; + // For calib line mapping, only used for SC for now + IntegerProperty m_nPulsedCalibLines; + std::vector<int> m_pulsedCalibLines; + SG::ReadCondHandleKey<LArCalibLineMapping> m_calibMapKey{this,"CalibMapKey","LArCalibLineMap","SG Key of calib line mapping object"}; + SG::ReadCondHandleKey<LArCalibLineMapping> m_calibMapSCKey{this,"CalibMapSCKey","LArCalibIdMapSC","SG Key of calib line mapping object"}; + + + }; #endif diff --git a/LArCalorimeter/LArCalibUtils/src/LArAutoCorrMaker.cxx b/LArCalorimeter/LArCalibUtils/src/LArAutoCorrMaker.cxx index b56db1c4e0e898ed9650b794231773e5ba8b803a..ebe0864264a3f7f6461c8956dee53d28fd11c686 100755 --- a/LArCalorimeter/LArCalibUtils/src/LArAutoCorrMaker.cxx +++ b/LArCalorimeter/LArCalibUtils/src/LArAutoCorrMaker.cxx @@ -49,7 +49,6 @@ LArAutoCorrMaker::LArAutoCorrMaker(const std::string& name, ISvcLocator* pSvcLoc declareProperty("KeyOutput", m_keyoutput="LArAutoCorr"); declareProperty("events_ref", m_nref=50); declareProperty("nsigma", m_rms_cut=5); - declareProperty("Nsamples", m_nsamples=32); declareProperty("normalize", m_normalize=1); declareProperty("physics", m_physics=0); declareProperty("GroupingType", m_groupingType); @@ -139,7 +138,10 @@ StatusCode LArAutoCorrMaker::execute() ATH_MSG_DEBUG("Got LArDigitContainer with key " << *key_it <<", size=" << larDigitContainer->size()); ++m_nEvents; LArDigitContainer::const_iterator it=larDigitContainer->begin(); - LArDigitContainer::const_iterator it_end=larDigitContainer->end(); + LArDigitContainer::const_iterator it_end=larDigitContainer->end(); + m_nsamples = (*larDigitContainer->begin())->nsamples(); + ATH_MSG_DEBUG("NSAMPLES (from digit container) = " << m_nsamples ); + for(;it!=it_end;it++){ const HWIdentifier chid=(*it)->hardwareID(); const CaloGain::CaloGain gain=(*it)->gain(); diff --git a/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx b/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx index 7a4a666a50e156c3daf4e1a090c0ec688a3ece9a..c52a8c8f38632b83510d386852aaac7365423a94 100644 --- a/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx +++ b/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx @@ -33,6 +33,7 @@ LArCalibDigitMaker::LArCalibDigitMaker(const std::string& name, ISvcLocator* pSv declareProperty("BoardIDs",m_vBoardIDs); declareProperty("DelayScale",m_delayScale=(25./240.)*ns); declareProperty("DontRun",m_dontRun=false); //Put only Board configuration in DetectorStore + declareProperty("isSC",m_isSC=false); } LArCalibDigitMaker::~LArCalibDigitMaker() @@ -42,7 +43,18 @@ LArCalibDigitMaker::~LArCalibDigitMaker() StatusCode LArCalibDigitMaker::initialize() { ATH_MSG_DEBUG ( "======== LArCalibDigitMaker Initialize ========" ); - ATH_CHECK( m_calibMapKey.initialize() ); + // bool containsKeySC = false; + for (unsigned int i = 0; i < m_keylist.size(); ++i) { + if (m_keylist.at(i).compare("SC") == 0) { + m_isSC = true; + ATH_MSG_DEBUG ( "======== LArCalibDigitMaker isSC is True ========" ); + } + } + if(m_isSC){ + ATH_CHECK( m_calibMapSCKey.initialize() ); + }else{ + ATH_CHECK( m_calibMapKey.initialize() ); + } // std::cout << "Pattern.size()=" << m_vPattern.size() << std::endl; // std::cout << "DAC.size()=" << m_vDAC.size() << std::endl; @@ -51,6 +63,9 @@ StatusCode LArCalibDigitMaker::initialize() // std::cout << "BoardIDs.size()=" << m_vBoardIDs.size() << std::endl; //Check if calibParams are given consistently: Either all or non + + + if (!((m_vBoardIDs.size()==0 && m_vDAC.size()==0 && m_vDelay.size()==0 && m_vPattern.size()==0 && m_nTrigger==0) || (m_vBoardIDs.size() && m_vDAC.size() && m_vDelay.size() && m_vPattern.size() && m_nTrigger))) { ATH_MSG_ERROR ( "Problem with jobOptions! Please set either ALL calibration parameters" << std:: endl @@ -92,8 +107,18 @@ StatusCode LArCalibDigitMaker::execute() { const EventContext& ctx = Gaudi::Hive::currentContext(); - SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_calibMapKey}; - const LArCalibLineMapping* clcabling{*clHdl}; + + const LArCalibLineMapping *clcabling=0; + if(m_isSC) { + ATH_MSG_DEBUG ( "======== LArCalibDigitMaker: using SC calib line map" ); + SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_calibMapSCKey}; + clcabling=*clHdl; + } else { + SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_calibMapKey}; + clcabling=*clHdl; + } + + if(!clcabling) { ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_calibMapKey.key() ); return StatusCode::FAILURE; diff --git a/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx b/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx index c28511fdd1b70f6c915be1157a87a8ec03c5b757..40177ba1d2ac3e23722ac526391948fdd2738399 100644 --- a/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx +++ b/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx @@ -26,6 +26,7 @@ LArRampBuilder::LArRampBuilder(const std::string& name, ISvcLocator* pSvcLocator m_peakParabolaTool("LArParabolaPeakRecoTool"), m_peakShapeTool("LArShapePeakRecoTool"), m_peakOFTool("LArOFPeakRecoTool"), + m_sc2ccMappingTool("CaloSuperCellIDTool"), m_event_counter(0), m_recoType(OF), m_onlineHelper(), @@ -87,6 +88,7 @@ StatusCode LArRampBuilder::initialize() StatusCode sc; if ( m_isSC ) { + ATH_MSG_DEBUG("==== LArRampBuilder - looking at SuperCells ===="); const LArOnline_SuperCellID* ll; sc = detStore()->retrieve(ll, "LArOnline_SuperCellID"); if (sc.isFailure()) { @@ -111,8 +113,19 @@ StatusCode LArRampBuilder::initialize() } } - + if ( m_isSC ) ATH_CHECK( m_sc2ccMappingTool.retrieve() ); + ATH_CHECK( m_cablingKey.initialize() ); + if ( m_isSC ) ATH_CHECK( m_cablingKeySC.initialize() ); + + // Initialise keys for calib line mapping + if (m_isSC){ + ATH_CHECK( m_calibMapSCKey.initialize() ); + ATH_CHECK( m_calibMapKey.initialize() ); + }else{ + ATH_CHECK( m_calibMapKey.initialize() ); + } + if(m_doBadChannelMask) { sc=m_badChannelMask.retrieve(); @@ -151,6 +164,9 @@ StatusCode LArRampBuilder::initialize() ATH_MSG_INFO( " register callback for HEC map " ); } } + + + return StatusCode::SUCCESS; } @@ -229,6 +245,55 @@ StatusCode LArRampBuilder::execute() if (m_event_counter==1) ATH_MSG_WARNING("No FebErrorSummaryObject found! Feb errors not checked!"); + + + ///* + // calib line mapping for SC + const LArCalibLineMapping *clCont=0; + const LArCalibLineMapping *clContSC=0; + if(m_isSC) { + ATH_MSG_DEBUG( "LArRampBuilder: using SC calib map" ); + SG::ReadCondHandle<LArCalibLineMapping> clHdlSC{m_calibMapSCKey}; + clContSC=*clHdlSC; + + if(!clContSC) { + ATH_MSG_WARNING( "Do not have SC calib line mapping !!!" ); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG( "DONE THE SETUP SC calib line" ); + } + }//} else { + // calib line mapping for main readout + SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_calibMapKey}; + clCont=*clHdl; + //} + if(!clCont) { + ATH_MSG_WARNING( "Do not have calib line mapping !!!" ); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG( "DONE THE SETUP calib line" ); + } + // end of calib line mapping + // */ + + const LArOnOffIdMapping* cabling(0); + if( m_isSC ){ + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKeySC}; + cabling = {*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR("Do not have mapping object " << m_cablingKeySC.key()); + return StatusCode::FAILURE; + } + }else{ + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey}; + cabling = {*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key()); + return StatusCode::FAILURE; + } + } + + std::vector<std::string>::const_iterator key_it=m_keylist.begin(); std::vector<std::string>::const_iterator key_it_e=m_keylist.end(); @@ -301,6 +366,8 @@ StatusCode LArRampBuilder::execute() int DAC = larCaliWave.getDAC(); IdentifierHash chidwave_hash = m_onlineHelper->channel_Hash(itVec.channelId()); + + bool IsBad = false; for(int i=0;i<24*NSamplesKeep;i++){ tempWave[i] = larCaliWave.getSample(i); @@ -371,6 +438,27 @@ StatusCode LArRampBuilder::execute() } } + // HEC Calibration lines + const std::vector<HWIdentifier>& calibLineV = clCont->calibSlotLine(chid); + ATH_MSG_DEBUG( "pulsed lines: "<< calibLineV.size() ); + if(m_isSC){ + const std::vector<HWIdentifier>& calibLineVSC = clContSC->calibSlotLine(chid); + ATH_MSG_DEBUG( "pulsed SC lines: "<< calibLineVSC.size() ); + } + // std::vector<HWIdentifier>::const_iterator calibLineIt = calibLineV.begin(); + // for(calibLineIt = calibLineV.begin(); calibLineIt != calibLineV.end();++calibLineIt) { + // ATH_MSG_DEBUG( "CALIB LINE "<< m_onlineHelper->channel(*calibLineIt) ); + // } + + std::vector<Identifier> ccellIds(0); + if( m_isSC ){ + Identifier myofflineID = cabling->cnvToIdentifier((*it)->hardwareID()) ; + + ccellIds = m_sc2ccMappingTool->superCellToOfflineID( myofflineID ); + ATH_MSG_DEBUG( "Cell: " << myofflineID << " " << (*it)->channelID() << " " << chid << " " << ccellIds.size() << " : " << ccellIds ); + } + + if (m_delay==-1) { //First (pulsed) cell to be processed: m_delay=(*it)->delay(); } @@ -440,16 +528,28 @@ StatusCode LArRampBuilder::execute() // << " mean " << (*it)->mean()[0] << " " << (*it)->mean()[1] << " " << (*it)->mean()[2] << " " << (*it)->mean()[3] // << " " << (*it)->mean()[4] << " " << (*it)->mean()[5] << " " << (*it)->mean()[6] << std::endl; // } - // } + // } + - LArCalibTriggerAccumulator& accpoints=(m_ramps->get(chid,gain))[(*it)->DAC()]; - //rawramp.addAccumulatedEvent( (*it)->mean(),(*it)->RMS(), (*it)->nTriggers() ); - LArCalibTriggerAccumulator::ERRTYPE ec=accpoints.add((*it)->sampleSum(),(*it)->sample2Sum(),(*it)->nTriggers()); - if (ec==LArCalibTriggerAccumulator::WrongNSamples) { - ATH_MSG_ERROR( "Failed to accumulate sub-steps: Inconsistent number of ADC samples"); - } - if (ec==LArCalibTriggerAccumulator::NumericOverflow) { - ATH_MSG_ERROR( "Failed to accumulate sub-steps: Numeric Overflow"); + if (m_isSC){ // Changed here to give DAC value for supercell, rather than DAC for a constituent cell + LArCalibTriggerAccumulator& accpoints=(m_ramps->get(chid,gain))[(*it)->DAC()*ccellIds.size()]; + LArCalibTriggerAccumulator::ERRTYPE ec=accpoints.add((*it)->sampleSum(),(*it)->sample2Sum(),(*it)->nTriggers()); + if (ec==LArCalibTriggerAccumulator::WrongNSamples) { + ATH_MSG_ERROR( "Failed to accumulate sub-steps: Inconsistent number of ADC samples"); + } + if (ec==LArCalibTriggerAccumulator::NumericOverflow) { + ATH_MSG_ERROR( "Failed to accumulate sub-steps: Numeric Overflow"); + } + }else{ + LArCalibTriggerAccumulator& accpoints=(m_ramps->get(chid,gain))[(*it)->DAC()]; + //rawramp.addAccumulatedEvent( (*it)->mean(),(*it)->RMS(), (*it)->nTriggers() ); + LArCalibTriggerAccumulator::ERRTYPE ec=accpoints.add((*it)->sampleSum(),(*it)->sample2Sum(),(*it)->nTriggers()); + if (ec==LArCalibTriggerAccumulator::WrongNSamples) { + ATH_MSG_ERROR( "Failed to accumulate sub-steps: Inconsistent number of ADC samples"); + } + if (ec==LArCalibTriggerAccumulator::NumericOverflow) { + ATH_MSG_ERROR( "Failed to accumulate sub-steps: Numeric Overflow"); + } } }//End loop over all cells } //End loop over all containers @@ -483,13 +583,17 @@ StatusCode LArRampBuilder::stop() else larRampComplete=NULL; + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey}; const LArOnOffIdMapping* cabling{*cablingHdl}; if(!cabling) { - ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key()); - return StatusCode::FAILURE; + ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key()); + return StatusCode::FAILURE; } + + + int containerCounter=0; //Outermost loop goes over all gains (different containers). //for (CaloGain::CaloGain gain=CaloGain::LARHIGHGAIN;gain<CaloGain::LARNGAIN;gain++) { @@ -525,6 +629,9 @@ StatusCode LArRampBuilder::stop() std::vector<float> adc0v; bool isADCsat = false; + + + for (;dac_it!=dac_it_e;dac_it++) { LArRawRamp::RAMPPOINT_t ramppoint;