diff --git a/Reconstruction/RecBackground/RecBackgroundAlgs/RecBackgroundAlgs/BackgroundWordFiller.h b/Reconstruction/RecBackground/RecBackgroundAlgs/RecBackgroundAlgs/BackgroundWordFiller.h index 6a62f6945ff265e8e3072335fc28cb1f3c22ade9..3cacd73aa260b4f37e0a87a53e94ed8080471ba2 100644 --- a/Reconstruction/RecBackground/RecBackgroundAlgs/RecBackgroundAlgs/BackgroundWordFiller.h +++ b/Reconstruction/RecBackground/RecBackgroundAlgs/RecBackgroundAlgs/BackgroundWordFiller.h @@ -13,6 +13,14 @@ Updated Mark Tibbetts 6/3/2012 #include "AthenaBaseComps/AthAlgorithm.h" #include "xAODEventInfo/EventInfo.h" + +#include "RecBackgroundEvent/BeamBackgroundData.h" +#include "LUCID_RawEvent/LUCID_RawDataContainer.h" +#include "BCM_CollisionTime/BcmCollisionTime.h" +#include "TagEvent/RawInfoSummaryForTag.h" +#include "TileEvent/TileContainer.h" +#include "LArRecEvent/LArCollisionTime.h" + #include <array> class BackgroundWordFiller : public AthAlgorithm @@ -29,6 +37,27 @@ class BackgroundWordFiller : public AthAlgorithm private: + /** ReadHandleKey for EventInfo object */ + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "eventInfoKey", "EventInfo", "Key for EventInfo object"}; + + /** ReadHandleKey for BeamBackgroundData */ + SG::ReadHandleKey<BeamBackgroundData> m_beamBackgroundDataKey{this,"BeamBackgroundDataKey","BeamBackgroundData","Key for BeamBackgroundData object"}; + + /** ReadHandleKey for LUCID_RawDataContainer */ + SG::ReadHandleKey<LUCID_RawDataContainer> m_LUCID_rawDataContainerKey{this,"LUCID_rawDataContainerKey","Lucid_RawData","Key for LUCID_RawDataContainer object"}; + + /** ReadHandleKey for BcmCollisionTime */ + SG::ReadHandleKey<BcmCollisionTime> m_bcmCollisionTimeKey{this,"BcmCollisionTimeKey","BcmCollisionTime","Key for BcmCollisionTime"}; + + /** ReadHandleKey for RawInfoSummaryForTag */ + SG::ReadHandleKey<RawInfoSummaryForTag> m_rawIngoSummaryForTagKey{this,"RawInfoSummaryForTagKey","RawInfoSummaryForTag","Key for RawInfoSummaryForTag"}; + + /** ReadHandleKey for TileCellContainer */ + SG::ReadHandleKey<TileCellContainer> m_tileCellContainerKey{this,"TileCellContainerKey","MBTSContainer","Key for TileCellContainer"}; + + /** ReadHandleKey for LArCollisionTime */ + SG::ReadHandleKey<LArCollisionTime> m_lArCollisionTimeKey{this,"LArCollisionTimeKey","LArCollisionTime","Key for LArCollisionTime"}; + int m_HaloNumSegment_Cut; int m_HaloNumClusterShape_Cut; int m_HaloNumOneSidedLoose_Cut; @@ -38,7 +67,6 @@ class BackgroundWordFiller : public AthAlgorithm int m_SCTMultiplicityHuge_Cut; int m_SCTSPNonEmpty_Cut; int m_LUCIDBeamVeto_Cut; - int m_MBTS_SideCut; float m_BCMTimeDiffCol_Cut; float m_BCMTimeDiffHalo_CutLo; int m_BCMHiGainCut; diff --git a/Reconstruction/RecBackground/RecBackgroundAlgs/src/BackgroundWordFiller.cxx b/Reconstruction/RecBackground/RecBackgroundAlgs/src/BackgroundWordFiller.cxx index c2bf5a2bcb5c636b7556eb7d4e497fffeb3a3181..5591e3fcb9952380a7e89976b0c27a38df56942b 100644 --- a/Reconstruction/RecBackground/RecBackgroundAlgs/src/BackgroundWordFiller.cxx +++ b/Reconstruction/RecBackground/RecBackgroundAlgs/src/BackgroundWordFiller.cxx @@ -35,13 +35,7 @@ Mark Tibbetts 6/3/2012 */ #include "RecBackgroundAlgs/BackgroundWordFiller.h" -#include "RecBackgroundEvent/BeamBackgroundData.h" -#include "TagEvent/RawInfoSummaryForTag.h" #include "TileEvent/MBTSCollisionTime.h" -#include "LArRecEvent/LArCollisionTime.h" -#include "TileEvent/TileContainer.h" -#include "LUCID_RawEvent/LUCID_RawDataContainer.h" -#include "BCM_CollisionTime/BcmCollisionTime.h" //---------------------------------------------------------------- @@ -59,7 +53,6 @@ BackgroundWordFiller::BackgroundWordFiller(const std::string& name, m_SCTMultiplicityHuge_Cut(0), m_SCTSPNonEmpty_Cut(0), m_LUCIDBeamVeto_Cut(0), - m_MBTS_SideCut(0), m_BCMTimeDiffCol_Cut(0), m_BCMTimeDiffHalo_CutLo(0), m_BCMHiGainCut(0), @@ -69,7 +62,6 @@ BackgroundWordFiller::BackgroundWordFiller(const std::string& name, m_MBTSBeamVeto_ThresholdCut(0), m_MBTSmask(TileCell::MASK_BADCH | TileCell::MASK_OVER | TileCell::MASK_TIME), m_MBTSpattern(TileCell::MASK_TIME), - m_mbtsContainerName(""), m_LArEC_SideCut(0), m_LArECTimeDiffCol_Cut(0), m_LArECTimeDiffHalo_CutLo(0), @@ -108,8 +100,6 @@ BackgroundWordFiller::BackgroundWordFiller(const std::string& name, // LUCID declareProperty("LUCIDBeamVeto_Cut",m_LUCIDBeamVeto_Cut=0); // >0 - // MBTS - declareProperty("MBTS_SideCut",m_MBTS_SideCut=4); declareProperty("BCMTimeDiffCol_Cut",m_BCMTimeDiffCol_Cut=6.); declareProperty("BCMTimeDiffHalo_CutLo",m_BCMTimeDiffHalo_CutLo=6.); @@ -119,7 +109,6 @@ BackgroundWordFiller::BackgroundWordFiller(const std::string& name, declareProperty("MBTSBeamVeto_MultiplicityCut",m_MBTSBeamVeto_MultiplicityCut=0); // >0 declareProperty("MBTSBeamVeto_TimeCut",m_MBTSBeamVeto_TimeCut=15.); declareProperty("MBTSBeamVeto_ThresholdCut",m_MBTSBeamVeto_ThresholdCut=40.0/222.0); - declareProperty("MBTSContainer",m_mbtsContainerName="MBTSContainer"); // LAr declareProperty("LArEC_SideCut",m_LArEC_SideCut=1); declareProperty("LArECTimeDiffCol_Cut",m_LArECTimeDiffCol_Cut=10.); @@ -142,6 +131,15 @@ BackgroundWordFiller::~BackgroundWordFiller() StatusCode BackgroundWordFiller::initialize() { + //initialise the read handle keys + ATH_CHECK(m_eventInfoKey.initialize()); + ATH_CHECK(m_beamBackgroundDataKey.initialize()); + ATH_CHECK(m_LUCID_rawDataContainerKey.initialize()); + ATH_CHECK(m_bcmCollisionTimeKey.initialize()); + ATH_CHECK(m_rawIngoSummaryForTagKey.initialize()); + ATH_CHECK(m_tileCellContainerKey.initialize()); + ATH_CHECK(m_lArCollisionTimeKey.initialize()); + return StatusCode::SUCCESS; } @@ -149,307 +147,216 @@ StatusCode BackgroundWordFiller::initialize() { StatusCode BackgroundWordFiller::execute() { - ///////////////////////// - // get the EventInfo - ///////////////////////// - const EventInfo * eventInfo_c = 0; - StatusCode sc=evtStore()->retrieve( eventInfo_c ); - - if(sc.isFailure()){ - msg(MSG::ERROR) << "Could not retrieve const EventInfo object" << endmsg; - return StatusCode::FAILURE; - } - EventInfo* eventInfo = const_cast<EventInfo*>(eventInfo_c); - - m_totalcnt++; - - /////////////////////// - // NOW SET THE BITS!! - /////////////////////// - - /////////////////////////////////////////////////// - // Halo Identification - ////////////////////////////////////////////////// - - if( evtStore()->contains<BeamBackgroundData>("BeamBackgroundData") ){ - - const BeamBackgroundData* beamBackgroundData; - - if (evtStore()->retrieve(beamBackgroundData, "BeamBackgroundData").isFailure() ) - msg(MSG::WARNING) << " Could not retrieve BeamBackgroundData." << endmsg; - else { - if( beamBackgroundData->GetNumSegment() > m_HaloNumSegment_Cut ){ - if( eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::HaloMuonSegment)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloMuonSegment] << endmsg; - else - m_bitcntvec[EventInfo::HaloMuonSegment]++; - } - if( beamBackgroundData->GetNumClusterShape() > m_HaloNumClusterShape_Cut ){ - if( eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::HaloClusterShape)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloClusterShape] << endmsg; - else - m_bitcntvec[EventInfo::HaloClusterShape]++; - } - if( beamBackgroundData->GetNumNoTimeLoose() > m_HaloNumOneSidedLoose_Cut ){ - if( eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::HaloMuonOneSided)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloMuonOneSided] << endmsg; - else - m_bitcntvec[EventInfo::HaloMuonOneSided]++; - } - if( beamBackgroundData->GetNumTwoSidedNoTime() > m_HaloNumTwoSided_Cut ){ - if( eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::HaloMuonTwoSided)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloMuonTwoSided] << endmsg; - else - m_bitcntvec[EventInfo::HaloMuonTwoSided]++; - } - }// get BeamBackgroudData - - }// beambackground SG veto - - /////////////////////////////////////////////////// - // LUCID: LUCIDBeamVeto - ////////////////////////////////////////////////// - - if( evtStore()->contains<LUCID_RawDataContainer>("Lucid_RawData") ){ - - const LUCID_RawDataContainer* LUCID_RawDataContainer; - if (evtStore()->retrieve(LUCID_RawDataContainer, "Lucid_RawData").isFailure() ) { - msg(MSG::WARNING) << " Could not retrieve Lucid_RawData" << endmsg; - } - else { - LUCID_RawDataContainer::const_iterator LUCID_RawData_itr = LUCID_RawDataContainer->begin(); - LUCID_RawDataContainer::const_iterator LUCID_RawData_end = LUCID_RawDataContainer->end(); - int LUCIDcounter(0); - for (; LUCID_RawData_itr != LUCID_RawData_end; LUCID_RawData_itr++) { - LUCIDcounter+=(*LUCID_RawData_itr)->getNhitsPMTsideA(); - LUCIDcounter+=(*LUCID_RawData_itr)->getNhitsPMTsideC(); - } - if ( LUCIDcounter>m_LUCIDBeamVeto_Cut ){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::LUCIDBeamVeto)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::LUCIDBeamVeto] << endmsg; - else - m_bitcntvec[EventInfo::LUCIDBeamVeto]++; - } - }// retrieved LUCID stuff - }// LUCID SG veto - - /////////////////////////////////////////////////// - // BCM: BCMTimeDiffHalo, BCMTimeDiffCol, BCMBeamVeto - ////////////////////////////////////////////////// - - if( evtStore()->contains<BcmCollisionTime>("BcmCollisionTime") ){ - - const BcmCollisionTime* BCMct; - if (evtStore()->retrieve(BCMct).isFailure() ) { - msg(MSG::WARNING) << " Could not retrieve BCMCollisionTime" << endmsg; - } - else { - std::vector<float> bcmTDs = BCMct->getDeltaT(); - ATH_MSG_DEBUG( " got BCMCollisionTime object getMultiLG "<<BCMct->getMultiLG()<<" getMultiHG "<<BCMct->getMultiHG()<<" TDs size "<<bcmTDs.size()); - float minTD=999; - float maxTD=0; - for(unsigned int i=0; i < bcmTDs.size(); i++){ - float td = bcmTDs.at(i); - ATH_MSG_DEBUG( " BCMCollisionTime td "<<i<<" "<<td); - if (fabs(td)>fabs(maxTD)) maxTD=td; - if (fabs(td)<fabs(minTD)) minTD=td; - } - ATH_MSG_DEBUG( " BCMCollisionTime minDT "<<minTD<<" maxDT "<<maxTD); - // set time diff bits - if (fabs(minTD)< m_BCMTimeDiffCol_Cut) { - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::BCMTimeDiffCol)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::BCMTimeDiffCol] << endmsg; - else - m_bitcntvec[EventInfo::BCMTimeDiffCol]++; - } - if (fabs(maxTD)>m_BCMTimeDiffHalo_CutLo){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::BCMTimeDiffHalo)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::BCMTimeDiffHalo] << endmsg; - else - m_bitcntvec[EventInfo::BCMTimeDiffHalo]++; - } - if (BCMct->getMultiLG()>m_BCMLowGainCut || BCMct->getMultiHG()>m_BCMHiGainCut){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::BCMBeamVeto)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::BCMBeamVeto] << endmsg; - else - m_bitcntvec[EventInfo::BCMBeamVeto]++; - } - - } - }//BCM SG veto - - - //////////////////////////////////////////////////////////////////////////////// - // ID SP multiplicities from Raw for filling: IDMultiplicityHuge, IDSPNonEmpty - /////////////////////////////////////////////////////////////////////////////// - if( evtStore()->contains<RawInfoSummaryForTag>("RawInfoSummaryForTag") ){ - - - const RawInfoSummaryForTag* rawinfo=0; - - if ( evtStore()->retrieve( rawinfo ).isFailure()) { - msg(MSG::WARNING) << "Cannot get raw summary info from storegate" << endmsg; - } else { - int NSCTsps = rawinfo->getNsctSPs(); - int NPIXsps = rawinfo->getNpixSPs(); - // int NTRTdcs = rawinfo->getNtrtDCs(); - // int NTRTdcsHT = rawinfo->getNtrtHtDCs(); - - // set IDMultiplicityHuge - if ( (NPIXsps)>m_PixMultiplicityHuge_Cut){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::PixMultiplicityHuge)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::PixMultiplicityHuge] << endmsg; - else - m_bitcntvec[EventInfo::PixMultiplicityHuge]++; - } - - // set PixSPNonEmpty - if ( (NPIXsps)>m_PixSPNonEmpty_Cut ){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::PixSPNonEmpty)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::PixSPNonEmpty] << endmsg; - else - m_bitcntvec[EventInfo::PixSPNonEmpty]++; - } - - if ( (NSCTsps)>m_SCTMultiplicityHuge_Cut){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::SCTMultiplicityHuge)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::SCTMultiplicityHuge] << endmsg; - else - m_bitcntvec[EventInfo::SCTMultiplicityHuge]++; - } - - // set SCTSPNonEmpty - if ( (NSCTsps)>m_SCTSPNonEmpty_Cut ){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::SCTSPNonEmpty)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::SCTSPNonEmpty] << endmsg; - else - m_bitcntvec[EventInfo::SCTSPNonEmpty]++; - } - - - } // retrieved RawInfoSummaryForTag object... - }//indet SG veto - - /* - //////////////////////////////////////////////////////////////////////////////////////// - // MBTS Time Diff stuff - for filling: MBTSTimeDiffHalo, MBTSTimeDiffCol, MBTSBeamVeto - //////////////////////////////////////////////////////////////////////////////////////// - const MBTSCollisionTime * mbtsTime; - sc = evtStore()->retrieve(mbtsTime,"MBTSCollisionTime"); - if (!sc.isFailure()) { - if (mbtsTime->ncellA()>m_MBTS_SideCut && mbtsTime->ncellC()>m_MBTS_SideCut){ - if (fabs(mbtsTime->time())<m_MBTSTimeDiffCol_Cut ){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::MBTSTimeDiffCol)==false) { - msg(MSG::WARNING) << "Failed to set EventInfo Background word!" << endmsg; - } - } - if (fabs(mbtsTime->time())<m_MBTSTimeDiffHalo_CutHi && fabs(mbtsTime->time())>m_MBTSTimeDiffHalo_CutLo ){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::MBTSTimeDiffHalo)==false) { - msg(MSG::WARNING) << "Failed to set EventInfo Background word!" << endmsg; - } - } // halo timing - } // enough hits per side - } else { - msg(MSG::WARNING) << "Failed to retrieve MBTSCollisionTime object" << endmsg; - } - */ - //////////////// - // MBTSBeamVeto - - if( evtStore()->contains<TileCellContainer>(m_mbtsContainerName) ){ - - const TileCellContainer *tileCellCnt = 0; - int MBTScount(0); - if (evtStore()->retrieve(tileCellCnt, m_mbtsContainerName).isFailure()) { - msg(MSG::WARNING) << "Error retrieving " << m_mbtsContainerName << endmsg; - } else { - TileCellContainer::const_iterator itr = tileCellCnt->begin(); - TileCellContainer::const_iterator itr_end = tileCellCnt->end(); - for(; itr != itr_end; ++itr) { - if ((*itr)->energy()<m_MBTSBeamVeto_ThresholdCut) continue; - const uint8_t qbit1=(*itr)->qbit1(); - if ((qbit1 & m_MBTSmask) != m_MBTSpattern) { - ATH_MSG_DEBUG("Rejected based on quality bits"); - continue; - } - if (fabs((*itr)->time())<m_MBTSBeamVeto_TimeCut) MBTScount++; - } - if (MBTScount>m_MBTSBeamVeto_MultiplicityCut){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::MBTSBeamVeto)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::MBTSBeamVeto] << endmsg; - else - m_bitcntvec[EventInfo::MBTSBeamVeto]++; - } - } // retrieved MBTS info - }//MBTS SG veto - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// - // LAr EC collision timing stuff (from Guillaume...) - for filling: LArECTimeDiffHalo, LArECTimeDiffCol - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( evtStore()->contains<LArCollisionTime>("LArCollisionTime") ){ - const LArCollisionTime* tps; - if(evtStore()->retrieve(tps,"LArCollisionTime").isFailure()) { - msg(MSG::WARNING) << "Failed to retrieve LArCollisionTime object" << endmsg; - } - else { - if (tps->ncellA() > m_LArEC_SideCut && tps->ncellC() > m_LArEC_SideCut) { - float LArECtimeDiff = tps->timeA()-tps->timeC(); - if (fabs(LArECtimeDiff)<m_LArECTimeDiffCol_Cut){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::LArECTimeDiffCol)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::LArECTimeDiffCol] << endmsg; - else - m_bitcntvec[EventInfo::LArECTimeDiffCol]++; - } - if (fabs(LArECtimeDiff)>m_LArECTimeDiffHalo_CutLo && fabs(LArECtimeDiff)<m_LArECTimeDiffHalo_CutHi){ - if (eventInfo->setEventFlagBit(EventInfo::Background,EventInfo::LArECTimeDiffHalo)==false) - msg(MSG::WARNING) << "Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::LArECTimeDiffHalo] << endmsg; - else - m_bitcntvec[EventInfo::LArECTimeDiffHalo]++; - }// halo timing - } // enough hits per side - } - - } //LAr time SG veto + ///////////////////////// + // get the EventInfo + ///////////////////////// + + SG::ReadHandle<xAOD::EventInfo> eventInfoReadHandle(m_eventInfoKey); - //////////////////////////////////////// - // printout the final background word - /////////////////////////////////////// - if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << "Summary of background word contents:"<< endmsg; - msg(MSG::DEBUG) << "MBTSTimeDiffHalo: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::MBTSTimeDiffHalo)<< endmsg; - msg(MSG::DEBUG) << "MBTSTimeDiffCol: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::MBTSTimeDiffCol)<< endmsg; - msg(MSG::DEBUG) << "MBTSBeamVeto: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::MBTSBeamVeto)<< endmsg; - msg(MSG::DEBUG) << "LArECTimeDiffHalo: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::LArECTimeDiffHalo)<< endmsg; - msg(MSG::DEBUG) << "LArECTimeDiffCol: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::LArECTimeDiffCol)<< endmsg; - msg(MSG::DEBUG) << "PixMultiplicityHuge: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::PixMultiplicityHuge)<< endmsg; - msg(MSG::DEBUG) << "PixSPNonEmpty: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::PixSPNonEmpty)<< endmsg; - msg(MSG::DEBUG) << "SCTMultiplicityHuge: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::SCTMultiplicityHuge)<< endmsg; - msg(MSG::DEBUG) << "SCTSPNonEmpty: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::SCTSPNonEmpty)<< endmsg; - msg(MSG::DEBUG) << "CSCTimeDiffHalo: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::CSCTimeDiffHalo)<< endmsg; - msg(MSG::DEBUG) << "CSCTimeDiffCol: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::CSCTimeDiffCol)<< endmsg; - msg(MSG::DEBUG) << "BCMTimeDiffHalo: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::BCMTimeDiffHalo)<< endmsg; - msg(MSG::DEBUG) << "BCMTimeDiffCol: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::BCMTimeDiffCol)<< endmsg; - msg(MSG::DEBUG) << "BCMBeamVeto: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::BCMBeamVeto)<< endmsg; - msg(MSG::DEBUG) << "MuonTimingCol: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::MuonTimingCol)<< endmsg; - msg(MSG::DEBUG) << "MuonTimingCosmic: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::MuonTimingCosmic)<< endmsg; - msg(MSG::DEBUG) << "LUCIDBeamVeto: "<<eventInfo->isEventFlagBitSet(EventInfo::Background,EventInfo::LUCIDBeamVeto)<< endmsg; - } - return StatusCode::SUCCESS; + m_totalcnt++; + + /////////////////////// + // NOW SET THE BITS!! + /////////////////////// + + /////////////////////////////////////////////////// + // Halo Identification + ////////////////////////////////////////////////// + + SG::ReadHandle<BeamBackgroundData> beamBackgroundDataReadHandle(m_beamBackgroundDataKey); + + if(!beamBackgroundDataReadHandle.isValid()) ATH_MSG_WARNING("Invalid ReadHandle to BeamBackgoundData with name: " << m_beamBackgroundDataKey.key()); + else{ + if( beamBackgroundDataReadHandle->GetNumSegment() > m_HaloNumSegment_Cut ){ + if( eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::HaloMuonSegment)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloMuonSegment]); + else m_bitcntvec[EventInfo::HaloMuonSegment]++; + } + if( beamBackgroundDataReadHandle->GetNumClusterShape() > m_HaloNumClusterShape_Cut ){ + if( eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::HaloClusterShape)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloClusterShape]); + else m_bitcntvec[EventInfo::HaloClusterShape]++; + } + if( beamBackgroundDataReadHandle->GetNumNoTimeLoose() > m_HaloNumOneSidedLoose_Cut ){ + if( eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::HaloMuonOneSided)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloMuonOneSided]); + else m_bitcntvec[EventInfo::HaloMuonOneSided]++; + } + if( beamBackgroundDataReadHandle->GetNumTwoSidedNoTime() > m_HaloNumTwoSided_Cut ){ + if( eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::HaloMuonTwoSided)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::HaloMuonTwoSided]); + else m_bitcntvec[EventInfo::HaloMuonTwoSided]++; + } + } + + /////////////////////////////////////////////////// + // LUCID: LUCIDBeamVeto + ////////////////////////////////////////////////// + + SG::ReadHandle<LUCID_RawDataContainer> LUCID_rawDataContainerReadHandle(m_LUCID_rawDataContainerKey); + + if (!LUCID_rawDataContainerReadHandle.isValid()) ATH_MSG_WARNING("Invalid ReadHandle to LUCID_RawDataContainer with name: " << m_LUCID_rawDataContainerKey.key()); + else{ + int LUCIDcounter(0); + for (auto LUCID_rawData : *LUCID_rawDataContainerReadHandle){ + LUCIDcounter+=LUCID_rawData->getNhitsPMTsideA(); + LUCIDcounter+=LUCID_rawData->getNhitsPMTsideC(); + } + if ( LUCIDcounter>m_LUCIDBeamVeto_Cut ){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::LUCIDBeamVeto)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::LUCIDBeamVeto]); + else m_bitcntvec[EventInfo::LUCIDBeamVeto]++; + } + } + + /////////////////////////////////////////////////// + // BCM: BCMTimeDiffHalo, BCMTimeDiffCol, BCMBeamVeto + ////////////////////////////////////////////////// + + SG::ReadHandle<BcmCollisionTime> bcmCollisionTimeReadHandle(m_bcmCollisionTimeKey); + + if (!bcmCollisionTimeReadHandle.isValid()) ATH_MSG_WARNING("Invalid ReadHandle to BcmCollisionTime with name: " << m_bcmCollisionTimeKey.key()); + else{ + std::vector<float> bcmTDs = bcmCollisionTimeReadHandle->getDeltaT(); + ATH_MSG_DEBUG( " got BCMCollisionTime object getMultiLG "<<bcmCollisionTimeReadHandle->getMultiLG()<<" getMultiHG "<<bcmCollisionTimeReadHandle->getMultiHG()<<" TDs size "<<bcmTDs.size()); + float minTD=999; + float maxTD=0; + + for(unsigned int i=0; i < bcmTDs.size(); i++){ + float td = bcmTDs.at(i); + ATH_MSG_DEBUG( " BCMCollisionTime td "<<i<<" "<<td); + if (fabs(td)>fabs(maxTD)) maxTD=td; + if (fabs(td)<fabs(minTD)) minTD=td; + } + + ATH_MSG_DEBUG(" BCMCollisionTime minDT "<<minTD<<" maxDT "<<maxTD); + + if (fabs(minTD)< m_BCMTimeDiffCol_Cut) { + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::BCMTimeDiffCol)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::BCMTimeDiffCol]); + else m_bitcntvec[EventInfo::BCMTimeDiffCol]++; + } + if (fabs(maxTD)>m_BCMTimeDiffHalo_CutLo){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::BCMTimeDiffHalo)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::BCMTimeDiffHalo]); + else m_bitcntvec[EventInfo::BCMTimeDiffHalo]++; + } + if (bcmCollisionTimeReadHandle->getMultiLG()>m_BCMLowGainCut || bcmCollisionTimeReadHandle->getMultiHG()>m_BCMHiGainCut){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::BCMBeamVeto)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::BCMBeamVeto]); + else m_bitcntvec[EventInfo::BCMBeamVeto]++; + } + } + + //////////////////////////////////////////////////////////////////////////////// + // ID SP multiplicities from Raw for filling: IDMultiplicityHuge, IDSPNonEmpty + /////////////////////////////////////////////////////////////////////////////// + + SG::ReadHandle<RawInfoSummaryForTag> rawInfoSummaryForTagReadHandle(m_rawIngoSummaryForTagKey); + + if (!rawInfoSummaryForTagReadHandle.isValid()) ATH_MSG_WARNING("Invalid ReadHandle to RawInfoSummaryForTag: " << m_rawIngoSummaryForTagKey.key()); + else{ + int NSCTsps = rawInfoSummaryForTagReadHandle->getNsctSPs(); + int NPIXsps = rawInfoSummaryForTagReadHandle->getNpixSPs(); + + // set IDMultiplicityHuge + if ( (NPIXsps)>m_PixMultiplicityHuge_Cut){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::PixMultiplicityHuge)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::PixMultiplicityHuge]); + else m_bitcntvec[EventInfo::PixMultiplicityHuge]++; + } + + // set PixSPNonEmpty + if ( (NPIXsps)>m_PixSPNonEmpty_Cut ){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::PixSPNonEmpty)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::PixSPNonEmpty]); + else m_bitcntvec[EventInfo::PixSPNonEmpty]++; + } + + if ( (NSCTsps)>m_SCTMultiplicityHuge_Cut){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::SCTMultiplicityHuge)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::SCTMultiplicityHuge]); + else m_bitcntvec[EventInfo::SCTMultiplicityHuge]++; + } + + // set SCTSPNonEmpty + if ( (NSCTsps)>m_SCTSPNonEmpty_Cut ){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::SCTSPNonEmpty)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::SCTSPNonEmpty]); + else m_bitcntvec[EventInfo::SCTSPNonEmpty]++; + } + } + + //////////////// + // MBTSBeamVeto + /////////////// + + SG::ReadHandle<TileCellContainer> tileCellContainerReadHandle(m_tileCellContainerKey); + + if (!tileCellContainerReadHandle.isValid()) ATH_MSG_WARNING("Invalid ReadHandle to TileCellContainer: " << m_tileCellContainerKey.key()); + else{ + int MBTScount(0); + + for (auto tileCellContainer : *tileCellContainerReadHandle){ + if (tileCellContainer->energy() < m_MBTSBeamVeto_ThresholdCut) continue; + const uint8_t qbit1 = tileCellContainer->qbit1(); + + if ((qbit1 & m_MBTSmask) != m_MBTSpattern) { + ATH_MSG_DEBUG("Rejected based on quality bits"); + continue; + } + if (fabs(tileCellContainer->time())<m_MBTSBeamVeto_TimeCut) MBTScount++; + }//loop on MBTS containers + + if (MBTScount>m_MBTSBeamVeto_MultiplicityCut){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::MBTSBeamVeto)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::MBTSBeamVeto]); + else m_bitcntvec[EventInfo::MBTSBeamVeto]++; + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + // LAr EC collision timing stuff (from Guillaume...) - for filling: LArECTimeDiffHalo, LArECTimeDiffCol + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + + SG::ReadHandle<LArCollisionTime> lArCollisionTimeReadHandle(m_lArCollisionTimeKey); + + if (!lArCollisionTimeReadHandle.isValid()) ATH_MSG_WARNING("Invalid ReadHandle to LArCollisionTime: " << m_lArCollisionTimeKey.key()); + else{ + if (lArCollisionTimeReadHandle->ncellA() > m_LArEC_SideCut && lArCollisionTimeReadHandle->ncellC() > m_LArEC_SideCut) { + float LArECtimeDiff = lArCollisionTimeReadHandle->timeA()-lArCollisionTimeReadHandle->timeC(); + if (fabs(LArECtimeDiff)<m_LArECTimeDiffCol_Cut){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::LArECTimeDiffCol)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::LArECTimeDiffCol]); + else m_bitcntvec[EventInfo::LArECTimeDiffCol]++; + } + if (fabs(LArECtimeDiff)>m_LArECTimeDiffHalo_CutLo && fabs(LArECtimeDiff)<m_LArECTimeDiffHalo_CutHi){ + if (eventInfoReadHandle->updateEventFlagBit(EventInfo::Background,EventInfo::LArECTimeDiffHalo)==false) ATH_MSG_WARNING("Failed to set EventInfo Background word bit " << m_bitnamevec[EventInfo::LArECTimeDiffHalo]); + else m_bitcntvec[EventInfo::LArECTimeDiffHalo]++; + }// halo timing + } // enough hits per side + } + + //////////////////////////////////////// + // printout the final background word + /////////////////////////////////////// + ATH_MSG_DEBUG("Summary of background word contents:"); + ATH_MSG_DEBUG("MBTSTimeDiffHalo: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::MBTSTimeDiffHalo)); + ATH_MSG_DEBUG("MBTSTimeDiffCol: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::MBTSTimeDiffCol)); + ATH_MSG_DEBUG("MBTSBeamVeto: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::MBTSBeamVeto)); + ATH_MSG_DEBUG("LArECTimeDiffHalo: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::LArECTimeDiffHalo)); + ATH_MSG_DEBUG("LArECTimeDiffCol: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::LArECTimeDiffCol)); + ATH_MSG_DEBUG("PixMultiplicityHuge: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::PixMultiplicityHuge)); + ATH_MSG_DEBUG("PixSPNonEmpty: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::PixSPNonEmpty)); + ATH_MSG_DEBUG("SCTMultiplicityHuge: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::SCTMultiplicityHuge)); + ATH_MSG_DEBUG("SCTSPNonEmpty: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::SCTSPNonEmpty)); + ATH_MSG_DEBUG("CSCTimeDiffHalo: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::CSCTimeDiffHalo)); + ATH_MSG_DEBUG("CSCTimeDiffCol: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::CSCTimeDiffCol)); + ATH_MSG_DEBUG("BCMTimeDiffHalo: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::BCMTimeDiffHalo)); + ATH_MSG_DEBUG("BCMTimeDiffCol: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::BCMTimeDiffCol)); + ATH_MSG_DEBUG("BCMBeamVeto: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::BCMBeamVeto)); + ATH_MSG_DEBUG("MuonTimingCol: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::MuonTimingCol)); + ATH_MSG_DEBUG("MuonTimingCosmic: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::MuonTimingCosmic)); + ATH_MSG_DEBUG("LUCIDBeamVeto: "<<eventInfoReadHandle->isEventFlagBitSet(EventInfo::Background,EventInfo::LUCIDBeamVeto)); + + return StatusCode::SUCCESS; } //---------------------------------------------------------------- StatusCode BackgroundWordFiller::finalize() { - - msg(MSG::INFO) << "In finalize()" << endmsg; + ATH_MSG_INFO("In finalize()"); - msg( MSG::INFO) << "Job Summary for Background Word (NB. MBTS time bits not counted by this alg)" << endmsg; - for(int ibit=0;ibit<EventInfo::NBackgroundWords;++ibit) - msg(MSG::INFO) << " " << m_bitnamevec[ibit] << ": " << m_bitcntvec[ibit] << "/" << m_totalcnt << " events" <<endmsg; + ATH_MSG_INFO("Job Summary for Background Word (NB. MBTS time bits not counted by this alg)"); + for(int ibit=0;ibit<EventInfo::NBackgroundWords;++ibit) ATH_MSG_INFO(" " << m_bitnamevec[ibit] << ": " << m_bitcntvec[ibit] << "/" << m_totalcnt << " events"); return StatusCode::SUCCESS; - }