CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HBHEIsolatedNoiseReflagger Class Reference

#include <HBHEIsolatedNoiseReflagger.h>

Inheritance diagram for HBHEIsolatedNoiseReflagger:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 HBHEIsolatedNoiseReflagger (const edm::ParameterSet &)
 ~HBHEIsolatedNoiseReflagger ()

Private Member Functions

void DumpHBHEHitMap (std::vector< HBHEHitMap > &i) const
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

bool debug_
edm::InputTag ebLabel_
edm::InputTag eeLabel_
edm::InputTag hbheLabel_
double LooseDiHitEne_
double LooseEcalIsol_
double LooseHcalIsol_
double LooseHPDEne1_
double LooseHPDEne2_
int LooseHPDHits1_
int LooseHPDHits2_
double LooseMonoHitEne_
double LooseRBXEne1_
double LooseRBXEne2_
int LooseRBXHits1_
int LooseRBXHits2_
double LooseTrackIsol_
ObjectValidator objvalidator_
double TightDiHitEne_
double TightEcalIsol_
double TightHcalIsol_
double TightHPDEne1_
double TightHPDEne2_
int TightHPDHits1_
int TightHPDHits2_
double TightMonoHitEne_
double TightRBXEne1_
double TightRBXEne2_
int TightRBXHits1_
int TightRBXHits2_
double TightTrackIsol_
edm::InputTag trackExtrapolationLabel_

Detailed Description

Definition at line 18 of file HBHEIsolatedNoiseReflagger.h.


Constructor & Destructor Documentation

HBHEIsolatedNoiseReflagger::HBHEIsolatedNoiseReflagger ( const edm::ParameterSet iConfig) [explicit]

Definition at line 23 of file HBHEIsolatedNoiseReflagger.cc.

                                                                                     :
  hbheLabel_(iConfig.getParameter<edm::InputTag>("hbheInput")),
  ebLabel_(iConfig.getParameter<edm::InputTag>("ebInput")),
  eeLabel_(iConfig.getParameter<edm::InputTag>("eeInput")),
  trackExtrapolationLabel_(iConfig.getParameter<edm::InputTag>("trackExtrapolationInput")),
  
  LooseHcalIsol_(iConfig.getParameter<double>("LooseHcalIsol")),
  LooseEcalIsol_(iConfig.getParameter<double>("LooseEcalIsol")),
  LooseTrackIsol_(iConfig.getParameter<double>("LooseTrackIsol")),
  TightHcalIsol_(iConfig.getParameter<double>("TightHcalIsol")),
  TightEcalIsol_(iConfig.getParameter<double>("TightEcalIsol")),
  TightTrackIsol_(iConfig.getParameter<double>("TightTrackIsol")),

  LooseRBXEne1_(iConfig.getParameter<double>("LooseRBXEne1")),
  LooseRBXEne2_(iConfig.getParameter<double>("LooseRBXEne2")),
  LooseRBXHits1_(iConfig.getParameter<int>("LooseRBXHits1")),
  LooseRBXHits2_(iConfig.getParameter<int>("LooseRBXHits2")),
  TightRBXEne1_(iConfig.getParameter<double>("TightRBXEne1")),
  TightRBXEne2_(iConfig.getParameter<double>("TightRBXEne2")),
  TightRBXHits1_(iConfig.getParameter<int>("TightRBXHits1")),
  TightRBXHits2_(iConfig.getParameter<int>("TightRBXHits2")),

  LooseHPDEne1_(iConfig.getParameter<double>("LooseHPDEne1")),
  LooseHPDEne2_(iConfig.getParameter<double>("LooseHPDEne2")),
  LooseHPDHits1_(iConfig.getParameter<int>("LooseHPDHits1")),
  LooseHPDHits2_(iConfig.getParameter<int>("LooseHPDHits2")),
  TightHPDEne1_(iConfig.getParameter<double>("TightHPDEne1")),
  TightHPDEne2_(iConfig.getParameter<double>("TightHPDEne2")),
  TightHPDHits1_(iConfig.getParameter<int>("TightHPDHits1")),
  TightHPDHits2_(iConfig.getParameter<int>("TightHPDHits2")),

  LooseDiHitEne_(iConfig.getParameter<double>("LooseDiHitEne")),
  TightDiHitEne_(iConfig.getParameter<double>("TightDiHitEne")),
  LooseMonoHitEne_(iConfig.getParameter<double>("LooseMonoHitEne")),
  TightMonoHitEne_(iConfig.getParameter<double>("TightMonoHitEne")),
  
  debug_(iConfig.getUntrackedParameter<bool>("debug",true)),
  objvalidator_(iConfig)
{
  produces<HBHERecHitCollection>();
}
HBHEIsolatedNoiseReflagger::~HBHEIsolatedNoiseReflagger ( )

Definition at line 65 of file HBHEIsolatedNoiseReflagger.cc.

{
}

Member Function Documentation

void HBHEIsolatedNoiseReflagger::DumpHBHEHitMap ( std::vector< HBHEHitMap > &  i) const [private]

Definition at line 223 of file HBHEIsolatedNoiseReflagger.cc.

References HBHERecHit::id(), HcalHPDRBXMap::indexHPD(), and HcalHPDRBXMap::indexRBX().

Referenced by produce().

{
  for(std::vector<HBHEHitMap>::const_iterator it=i.begin(); it!=i.end(); ++it) {
    edm::LogInfo("HBHEIsolatedNoiseReflagger") << "hit energy=" << it->hitEnergy()
              << "; # hits=" << it->nHits()
              << "; hcal energy same=" << it->hcalEnergySameTowers()
                    << "; ecal energy same=" << it->ecalEnergySameTowers()
                  << "; track energy same=" << it->trackEnergySameTowers()
                  << "; neighbor hcal energy=" << it->hcalEnergyNeighborTowers() << std::endl;
        edm::LogInfo("HBHEIsolatedNoiseReflagger") << "hits:" << std::endl;
        for(HBHEHitMap::hitmap_const_iterator it2=it->beginHits(); it2!=it->endHits(); ++it2) {
          const HBHERecHit *hit=it2->first;
            edm::LogInfo("HBHEIsolatedNoiseReflagger") << "RBX #=" << HcalHPDRBXMap::indexRBX(hit->id())
                      << "; HPD #=" << HcalHPDRBXMap::indexHPD(hit->id())
                      << "; " << (*hit) << std::endl;
        }
  }
  return;
}
void HBHEIsolatedNoiseReflagger::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 71 of file HBHEIsolatedNoiseReflagger.cc.

References debug_, DumpHBHEHitMap(), ebLabel_, eeLabel_, edm::EventSetup::get(), edm::Event::getByLabel(), HBHEHitMapOrganizer::getDiHits(), HBHEHitMapOrganizer::getHPDs(), HBHEHitMapOrganizer::getMonoHits(), HBHEHitMapOrganizer::getRBXs(), HcalCaloFlagLabels::HBHEIsolatedNoise, hbheLabel_, i, LooseDiHitEne_, LooseEcalIsol_, LooseHcalIsol_, LooseHPDEne1_, LooseHPDEne2_, LooseHPDHits1_, LooseHPDHits2_, LooseMonoHitEne_, LooseRBXEne1_, LooseRBXEne2_, LooseRBXHits1_, LooseRBXHits2_, LooseTrackIsol_, objvalidator_, edm::ESHandle< T >::product(), edm::Event::put(), ObjectValidator::setEBRecHitCollection(), ObjectValidator::setEcalChannelStatus(), ObjectValidator::setEcalSeverityLevelAlgo(), ObjectValidator::setEERecHitCollection(), CaloRecHit::setFlagField(), ObjectValidator::setHcalChannelQuality(), ObjectValidator::setHcalSeverityLevelComputer(), TightDiHitEne_, TightEcalIsol_, TightHcalIsol_, TightHPDEne1_, TightHPDEne2_, TightHPDHits1_, TightHPDHits2_, TightMonoHitEne_, TightRBXEne1_, TightRBXEne2_, TightRBXHits1_, TightRBXHits2_, TightTrackIsol_, and trackExtrapolationLabel_.

{
  // get the ECAL channel status map
  edm::ESHandle<EcalChannelStatus> ecalChStatus;
  evSetup.get<EcalChannelStatusRcd>().get( ecalChStatus );
  const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();

  // get the HCAL channel status map
  edm::ESHandle<HcalChannelQuality> hcalChStatus;    
  evSetup.get<HcalChannelQualityRcd>().get( hcalChStatus );
  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();

  // get the severity level computers
  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
  evSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();

  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
  evSetup.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
  const EcalSeverityLevelAlgo* ecalSevLvlAlgo = ecalSevLvlAlgoHndl.product();

  // get the calotower mappings
  edm::ESHandle<CaloTowerConstituentsMap> ctcm;
  evSetup.get<IdealGeometryRecord>().get(ctcm);
  
  // get the HB/HE hits
  edm::Handle<HBHERecHitCollection> hbhehits_h;
  iEvent.getByLabel(hbheLabel_, hbhehits_h);

  // get the ECAL hits
  edm::Handle<EcalRecHitCollection> ebhits_h;
  iEvent.getByLabel(ebLabel_, ebhits_h);
  edm::Handle<EcalRecHitCollection> eehits_h;
  iEvent.getByLabel(eeLabel_, eehits_h);

  // get the tracks
  edm::Handle<std::vector<reco::TrackExtrapolation> > trackextraps_h;
  iEvent.getByLabel(trackExtrapolationLabel_, trackextraps_h);

  // set the status maps and severity level computers for the hit validator
  objvalidator_.setHcalChannelQuality(dbHcalChStatus);
  objvalidator_.setEcalChannelStatus(dbEcalChStatus);
  objvalidator_.setHcalSeverityLevelComputer(hcalSevLvlComputer);
  objvalidator_.setEcalSeverityLevelAlgo(ecalSevLvlAlgo);
  objvalidator_.setEBRecHitCollection(&(*ebhits_h));
  objvalidator_.setEERecHitCollection(&(*eehits_h));

  // organizer the hits
  PhysicsTowerOrganizer pto(iEvent, evSetup, hbhehits_h, ebhits_h, eehits_h, trackextraps_h, objvalidator_, *(ctcm.product()));
  HBHEHitMapOrganizer organizer(hbhehits_h, objvalidator_, pto);

  // get the rbxs, hpds, dihits, and monohits
  std::vector<HBHEHitMap> rbxs;
  std::vector<HBHEHitMap> hpds;
  std::vector<HBHEHitMap> dihits;
  std::vector<HBHEHitMap> monohits;
  organizer.getRBXs(rbxs, LooseRBXEne1_<TightRBXEne1_ ? LooseRBXEne1_ : TightRBXEne1_);
  organizer.getHPDs(hpds, LooseHPDEne1_<TightHPDEne1_ ? LooseHPDEne1_ : TightHPDEne1_);
  organizer.getDiHits(dihits, LooseDiHitEne_<TightDiHitEne_ ? LooseDiHitEne_ : TightDiHitEne_);
  organizer.getMonoHits(monohits, LooseMonoHitEne_<TightMonoHitEne_ ? LooseMonoHitEne_ : TightMonoHitEne_);

  if(debug_ && (rbxs.size()>0 || hpds.size()>0 || dihits.size()>0 || monohits.size()>0)) {
    edm::LogInfo("HBHEIsolatedNoiseReflagger") << "RBXs:" << std::endl;
    DumpHBHEHitMap(rbxs);
    edm::LogInfo("HBHEIsolatedNoiseReflagger") << "\nHPDs:" << std::endl;
    DumpHBHEHitMap(hpds);
    edm::LogInfo("HBHEIsolatedNoiseReflagger") << "\nDiHits:" << std::endl;
    DumpHBHEHitMap(dihits);
    edm::LogInfo("HBHEIsolatedNoiseReflagger") << "\nMonoHits:" << std::endl;
    DumpHBHEHitMap(monohits);
  }

  //  bool result=true;

  // determine which hits are noisy
  std::set<const HBHERecHit*> noisehits;
  for(int i=0; i<static_cast<int>(rbxs.size()); i++) {
    int nhits=rbxs[i].nHits();
    double ene=rbxs[i].hitEnergy();
    double trkfide=rbxs[i].hitEnergyTrackFiducial();
    double isolhcale=rbxs[i].hcalEnergySameTowers()+rbxs[i].hcalEnergyNeighborTowers();
    double isolecale=rbxs[i].ecalEnergySameTowers();
    double isoltrke=rbxs[i].trackEnergySameTowers()+rbxs[i].trackEnergyNeighborTowers();
    if((isolhcale/ene<LooseHcalIsol_ && isolecale/ene<LooseEcalIsol_ && isoltrke/ene<LooseTrackIsol_ && ((trkfide>LooseRBXEne1_ && nhits>=LooseRBXHits1_) || (trkfide>LooseRBXEne2_ && nhits>=LooseRBXHits2_))) ||
       (isolhcale/ene<TightHcalIsol_ && isolecale/ene<TightEcalIsol_ && isoltrke/ene<TightTrackIsol_ && ((trkfide>TightRBXEne1_ && nhits>=TightRBXHits1_) || (trkfide>TightRBXEne2_ && nhits>=TightRBXHits2_)))) {
      for(HBHEHitMap::hitmap_const_iterator it=rbxs[i].beginHits(); it!=rbxs[i].endHits(); ++it)
        noisehits.insert(it->first);
      //      result=false;
    }
  }

  for(int i=0; i<static_cast<int>(hpds.size()); i++) {
    int nhits=hpds[i].nHits();
    double ene=hpds[i].hitEnergy();
    double trkfide=hpds[i].hitEnergyTrackFiducial();
    double isolhcale=hpds[i].hcalEnergySameTowers()+hpds[i].hcalEnergyNeighborTowers();
    double isolecale=hpds[i].ecalEnergySameTowers();
    double isoltrke=hpds[i].trackEnergySameTowers()+hpds[i].trackEnergyNeighborTowers();
    if((isolhcale/ene<LooseHcalIsol_ && isolecale/ene<LooseEcalIsol_ && isoltrke/ene<LooseTrackIsol_ && ((trkfide>LooseHPDEne1_ && nhits>=LooseHPDHits1_) || (trkfide>LooseHPDEne2_ && nhits>=LooseHPDHits2_))) ||
       (isolhcale/ene<TightHcalIsol_ && isolecale/ene<TightEcalIsol_ && isoltrke/ene<TightTrackIsol_ && ((trkfide>TightHPDEne1_ && nhits>=TightHPDHits1_) || (trkfide>TightHPDEne2_ && nhits>=TightHPDHits2_)))) {
      for(HBHEHitMap::hitmap_const_iterator it=hpds[i].beginHits(); it!=hpds[i].endHits(); ++it)
        noisehits.insert(it->first);
      //      result=false;
    }
  }

  for(int i=0; i<static_cast<int>(dihits.size()); i++) {
    double ene=dihits[i].hitEnergy();
    double trkfide=dihits[i].hitEnergyTrackFiducial();
    double isolhcale=dihits[i].hcalEnergySameTowers()+dihits[i].hcalEnergyNeighborTowers();
    double isolecale=dihits[i].ecalEnergySameTowers();
    double isoltrke=dihits[i].trackEnergySameTowers()+dihits[i].trackEnergyNeighborTowers();
    if((isolhcale/ene<LooseHcalIsol_ && isolecale/ene<LooseEcalIsol_ && isoltrke/ene<LooseTrackIsol_ && trkfide>0.99*ene && trkfide>LooseDiHitEne_) ||
       (isolhcale/ene<TightHcalIsol_ && isolecale/ene<TightEcalIsol_ && isoltrke/ene<TightTrackIsol_ && ene>TightDiHitEne_)) {
      for(HBHEHitMap::hitmap_const_iterator it=dihits[i].beginHits(); it!=dihits[i].endHits(); ++it)
        noisehits.insert(it->first);
      //      result=false;
    }
  }
  
  for(int i=0; i<static_cast<int>(monohits.size()); i++) {
    double ene=monohits[i].hitEnergy();
    double trkfide=monohits[i].hitEnergyTrackFiducial();
    double isolhcale=monohits[i].hcalEnergySameTowers()+monohits[i].hcalEnergyNeighborTowers();
    double isolecale=monohits[i].ecalEnergySameTowers();
    double isoltrke=monohits[i].trackEnergySameTowers()+monohits[i].trackEnergyNeighborTowers();
    if((isolhcale/ene<LooseHcalIsol_ && isolecale/ene<LooseEcalIsol_ && isoltrke/ene<LooseTrackIsol_ && trkfide>0.99*ene && trkfide>LooseMonoHitEne_) ||
       (isolhcale/ene<TightHcalIsol_ && isolecale/ene<TightEcalIsol_ && isoltrke/ene<TightTrackIsol_ && ene>TightMonoHitEne_)) {
      for(HBHEHitMap::hitmap_const_iterator it=monohits[i].beginHits(); it!=monohits[i].endHits(); ++it)
        noisehits.insert(it->first);
      //      result=false;
    }
  }

  // prepare the output HBHE RecHit collection
  std::auto_ptr<HBHERecHitCollection> pOut(new HBHERecHitCollection());
  // loop over rechits, and set the new bit you wish to use
  for(HBHERecHitCollection::const_iterator it=hbhehits_h->begin(); it!=hbhehits_h->end(); ++it) {
    const HBHERecHit* hit=&(*it);
    HBHERecHit newhit(*hit);
    if(noisehits.end()!=noisehits.find(hit)) {
      newhit.setFlagField(1, HcalCaloFlagLabels::HBHEIsolatedNoise);
    }
    pOut->push_back(newhit);
  }

  iEvent.put(pOut);

  return;  
}

Member Data Documentation

Definition at line 54 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 31 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 31 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 30 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 49 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 35 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 34 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 45 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 45 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 46 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 46 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 51 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 41 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 41 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 42 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 42 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 36 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 57 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 50 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 38 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 37 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 47 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 47 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 48 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 48 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 52 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 43 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 43 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 44 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 44 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 39 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().

Definition at line 32 of file HBHEIsolatedNoiseReflagger.h.

Referenced by produce().