CMS 3D CMS Logo

Public Member Functions | Private Attributes

CaloTowerAnalyzer Class Reference

#include <CaloTowerAnalyzer.h>

Inheritance diagram for CaloTowerAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 CaloTowerAnalyzer (const edm::ParameterSet &)
virtual void endJob ()

Private Attributes

bool allhist_
edm::InputTag caloTowersLabel_
DQMStoredbe_
bool debug_
double energyThreshold_
bool finebinning_
std::string FolderName_
edm::InputTag HcalNoiseSummaryTag_
MonitorElementhCT_emEt_ieta_iphi
MonitorElementhCT_emEtvsieta
MonitorElementhCT_et_ieta_iphi
MonitorElementhCT_etvsieta
MonitorElementhCT_hadEt_ieta_iphi
MonitorElementhCT_hadEtvsieta
MonitorElementhCT_Maxetvsieta
MonitorElementhCT_METPhivsieta
MonitorElementhCT_METvsieta
MonitorElementhCT_MExvsieta
MonitorElementhCT_MEyvsieta
MonitorElementhCT_Minetvsieta
MonitorElementhCT_Nevents
std::vector< MonitorElement * > hCT_NEvents_HLT
MonitorElementhCT_Occ_ieta_iphi
MonitorElementhCT_Occvsieta
MonitorElementhCT_outerEt_ieta_iphi
MonitorElementhCT_outerEtvsieta
MonitorElementhCT_SETvsieta
std::vector< edm::InputTagHLTBitLabel_
edm::InputTag HLTResultsLabel_
bool hltselection_
int Nevents

Detailed Description

Definition at line 22 of file CaloTowerAnalyzer.h.


Constructor & Destructor Documentation

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

Definition at line 61 of file CaloTowerAnalyzer.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

{

  caloTowersLabel_     = iConfig.getParameter<edm::InputTag>("CaloTowersLabel");
  HLTResultsLabel_     = iConfig.getParameter<edm::InputTag>("HLTResultsLabel");  
  HcalNoiseSummaryTag_ = iConfig.getParameter<edm::InputTag>("HcalNoiseSummary");
  
  if(iConfig.exists("HLTBitLabels"))
    HLTBitLabel_         = iConfig.getParameter<std::vector<edm::InputTag> >("HLTBitLabels");
  
  debug_               = iConfig.getParameter<bool>("Debug");
  finebinning_         = iConfig.getUntrackedParameter<bool>("FineBinning"); 
  allhist_             = iConfig.getUntrackedParameter<bool>("AllHist"); 
  FolderName_          = iConfig.getUntrackedParameter<std::string>("FolderName");

  hltselection_        = iConfig.getUntrackedParameter<bool>("HLTSelection"); 
  
}

Member Function Documentation

void CaloTowerAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 171 of file CaloTowerAnalyzer.cc.

References CaloTower::emEt(), CaloTower::et(), edm::Event::getByLabel(), CaloTower::hadEt(), i, CaloTower::id(), CaloTowerDetId::ieta(), getHLTprescales::index, CaloTowerDetId::iphi(), edm::HandleBase::isValid(), label, LogDebug, CaloTower::outerEt(), reco::LeafCandidate::phi(), colinearityKinematic::Phi, reco::tau::disc::Pt(), findQualityFiles::size, edm::TriggerNames::triggerIndex(), and edm::Event::triggerNames().

{
  // Get HLT Results
  edm::Handle<edm::TriggerResults> TheHLTResults;
  iEvent.getByLabel( HLTResultsLabel_ , TheHLTResults);

  bool EventPasses = true;

  // Make sure handle is valid
  if( TheHLTResults.isValid() && hltselection_ )
    {
      //Get HLT Names
      const edm::TriggerNames & TheTriggerNames = iEvent.triggerNames(*TheHLTResults);
      
      for( unsigned int index = 0 ; index < HLTBitLabel_.size(); index++)
        {
          if( HLTBitLabel_[index].label().size() )
            {
              //Change the default value since HLT requirement has been issued by the user
              if( index == 0 ) EventPasses = false; 
              //Get the HLT bit and check to make sure it is valid
              unsigned int bit = TheTriggerNames.triggerIndex( HLTBitLabel_[index].label().c_str());
              if( bit < TheHLTResults->size() )
                {
                  //If any of the HLT names given by the user accept, then the event passes
                  if( TheHLTResults->accept( bit ) && !TheHLTResults->error( bit ) )
                    {
                      EventPasses = true;
                      hCT_NEvents_HLT[index]->Fill(1);
                    }  
                  else 
                    hCT_NEvents_HLT[index]->Fill(0);
                }
              else
                {
                  edm::LogInfo("OutputInfo") 
                    << "The HLT Trigger Name : " << HLTBitLabel_[index].label() << " is not valid for this trigger table " << std::endl;
                }
            }
        }
    }

  if( !EventPasses && hltselection_ ) 
    return;
  
  //----------GREG & CHRIS' idea---///
  float ETTowerMin = -1; //GeV
  float METRingMin = -2; // GeV
  
  Nevents++;
  hCT_Nevents->Fill(0);

  // ==========================================================
  // Retrieve!
  // ==========================================================

  edm::Handle<edm::View<Candidate> > towers;
  iEvent.getByLabel(caloTowersLabel_, towers);

  if( (!towers.isValid())) {
    edm::LogInfo("")<<"CaloTowers "<< caloTowersLabel_<<" not found!"<<std::endl;
    return;
  }


  edm::Handle<HcalNoiseSummary> HNoiseSummary;
  iEvent.getByLabel(HcalNoiseSummaryTag_,HNoiseSummary);
  if (!HNoiseSummary.isValid()) {
    LogDebug("") << "CaloTowerAnalyzer: Could not find Hcal NoiseSummary product" << std::endl;
  }

  bool bHcalNoiseFilter      = HNoiseSummary->passLooseNoiseFilter();
  if(!bHcalNoiseFilter) return;

  edm::View<Candidate>::const_iterator towerCand = towers->begin();
  
  // ==========================================================
  // Fill Histograms!
  // ==========================================================

  int CTmin_iphi = 99, CTmax_iphi = -99;
  int CTmin_ieta = 99, CTmax_ieta = -99;

  TLorentzVector vMET_EtaRing[83];
  int ActiveRing[83];
  int NActiveTowers[83];
  double SET_EtaRing[83];
  double MinEt_EtaRing[83];
  double MaxEt_EtaRing[83];
  for (int i=0;i<83; i++) 
    {
      ActiveRing[i] = 0;
      NActiveTowers[i] = 0;
      SET_EtaRing[i] = 0;
      MinEt_EtaRing[i] = 0;
      MaxEt_EtaRing[i] = 0;
    }

  //rcr for (calotower = towerCollection->begin(); calotower != towerCollection->end(); calotower++) {
    
  for ( ; towerCand != towers->end(); towerCand++)
    {
      const Candidate* candidate = &(*towerCand);
      if (candidate) 
        {
          const CaloTower* calotower = dynamic_cast<const CaloTower*> (candidate);
          if (calotower){
          //math::RhoEtaPhiVector Momentum = calotower->momentum();
          double Tower_ET = calotower->et();
          //double Tower_Energy  = calotower->energy();
          //      double Tower_Eta = calotower->eta();
          double Tower_Phi = calotower->phi();
          //double Tower_EMEnergy = calotower->emEnergy();
          //double Tower_HadEnergy = calotower->hadEnergy();
          double Tower_OuterEt = calotower->outerEt();
          double Tower_EMEt = calotower->emEt();
          double Tower_HadEt = calotower->hadEt();
          //int Tower_EMLV1 = calotower->emLvl1();
          //int Tower_HadLV1 = calotower->hadLv11();
          int Tower_ieta = calotower->id().ieta();
          int Tower_iphi = calotower->id().iphi();
          int EtaRing = 41+Tower_ieta;
          ActiveRing[EtaRing] = 1;
          NActiveTowers[EtaRing]++;
          SET_EtaRing[EtaRing]+=Tower_ET;
          TLorentzVector v_;
          v_.SetPtEtaPhiE(Tower_ET, 0, Tower_Phi, Tower_ET);
          if (Tower_ET>ETTowerMin)
            vMET_EtaRing[EtaRing]-=v_;
          
          // Fill Histograms
          hCT_Occ_ieta_iphi->Fill(Tower_ieta,Tower_iphi);
          hCT_et_ieta_iphi->Fill(Tower_ieta,Tower_iphi,Tower_ET);
          hCT_emEt_ieta_iphi->Fill(Tower_ieta,Tower_iphi,Tower_EMEt);
          hCT_hadEt_ieta_iphi->Fill(Tower_ieta,Tower_iphi,Tower_HadEt);
          hCT_outerEt_ieta_iphi->Fill(Tower_ieta,Tower_iphi,Tower_OuterEt);

          if (allhist_){
          hCT_etvsieta->Fill(Tower_ieta, Tower_ET);
          hCT_emEtvsieta->Fill(Tower_ieta, Tower_EMEt);
          hCT_hadEtvsieta->Fill(Tower_ieta,Tower_HadEt);
          hCT_outerEtvsieta->Fill(Tower_ieta,Tower_OuterEt);
          }

          if (Tower_ET > MaxEt_EtaRing[EtaRing])
            MaxEt_EtaRing[EtaRing] = Tower_ET;
          if (Tower_ET < MinEt_EtaRing[EtaRing] && Tower_ET>0)
            MinEt_EtaRing[EtaRing] = Tower_ET;
          
          
          if (Tower_ieta < CTmin_ieta) CTmin_ieta = Tower_ieta;
          if (Tower_ieta > CTmax_ieta) CTmax_ieta = Tower_ieta;
          if (Tower_iphi < CTmin_iphi) CTmin_iphi = Tower_iphi;
          if (Tower_iphi > CTmax_iphi) CTmax_iphi = Tower_iphi;
          } //end if (calotower) ..
        } // end if(candidate) ...
      
    } // end loop over towers
  
      // Fill eta-ring MET quantities
  if (allhist_){
  for (int iEtaRing=0; iEtaRing<83; iEtaRing++)
    { 
      hCT_Minetvsieta->Fill(iEtaRing-41, MinEt_EtaRing[iEtaRing]);  
      hCT_Maxetvsieta->Fill(iEtaRing-41, MaxEt_EtaRing[iEtaRing]);  
      
      if (ActiveRing[iEtaRing])
        {
          if (vMET_EtaRing[iEtaRing].Pt()>METRingMin)
            {
              hCT_METPhivsieta->Fill(iEtaRing-41, vMET_EtaRing[iEtaRing].Phi());
              hCT_MExvsieta->Fill(iEtaRing-41, vMET_EtaRing[iEtaRing].Px());
              hCT_MEyvsieta->Fill(iEtaRing-41, vMET_EtaRing[iEtaRing].Py());
              hCT_METvsieta->Fill(iEtaRing-41, vMET_EtaRing[iEtaRing].Pt());
            }
          hCT_SETvsieta->Fill(iEtaRing-41, SET_EtaRing[iEtaRing]);
          hCT_Occvsieta->Fill(iEtaRing-41, NActiveTowers[iEtaRing]);
        }
    } // ietaring
  }   // allhist_
  
  edm::LogInfo("OutputInfo") << "CT ieta range: " << CTmin_ieta << " " << CTmax_ieta;
  edm::LogInfo("OutputInfo") << "CT iphi range: " << CTmin_iphi << " " << CTmax_iphi;
  
}
void CaloTowerAnalyzer::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 81 of file CaloTowerAnalyzer.cc.

References DQMStore::book1D(), DQMStore::book2D(), dbe_, MonitorElement::getTH2F(), i, label, cmsCodeRules::cppFunctionSkipper::operator, and DQMStore::setCurrentFolder().

{
  Nevents = 0;
  // get ahold of back-end interface
  dbe_ = edm::Service<DQMStore>().operator->();

  if (dbe_) {
 
    dbe_->setCurrentFolder(FolderName_); 

    //Store number of events which pass each HLT bit 
    for(unsigned int i = 0 ; i < HLTBitLabel_.size() ; i++ )
      {
        if( HLTBitLabel_[i].label().size() )
          {
            hCT_NEvents_HLT.push_back( dbe_->book1D("METTask_CT_"+HLTBitLabel_[i].label(),HLTBitLabel_[i].label(),2,-0.5,1.5) );
          }
      }
    
    //--Store number of events used
    hCT_Nevents          = dbe_->book1D("METTask_CT_Nevents","",1,0,1);  
    //--Data integrated over all events and stored by CaloTower(ieta,iphi) 
    hCT_et_ieta_iphi          = dbe_->book2D("METTask_CT_et_ieta_iphi","",83,-41,42, 72,1,73);  
    hCT_et_ieta_iphi->getTH2F()->SetOption("colz");
    hCT_et_ieta_iphi->setAxisTitle("ieta",1);
    hCT_et_ieta_iphi->setAxisTitle("ephi",2);

    hCT_emEt_ieta_iphi        = dbe_->book2D("METTask_CT_emEt_ieta_iphi","",83,-41,42, 72,1,73);  
    hCT_emEt_ieta_iphi->getTH2F()->SetOption("colz");
    hCT_emEt_ieta_iphi->setAxisTitle("ieta",1);
    hCT_emEt_ieta_iphi->setAxisTitle("ephi",2);
    hCT_hadEt_ieta_iphi       = dbe_->book2D("METTask_CT_hadEt_ieta_iphi","",83,-41,42, 72,1,73);  
    hCT_hadEt_ieta_iphi->getTH2F()->SetOption("colz");
    hCT_hadEt_ieta_iphi->setAxisTitle("ieta",1);
    hCT_hadEt_ieta_iphi->setAxisTitle("ephi",2);
    hCT_outerEt_ieta_iphi = dbe_->book2D("METTask_CT_outerEt_ieta_iphi","",83,-41,42, 72,1,73);  
    hCT_outerEt_ieta_iphi->getTH2F()->SetOption("colz");
    hCT_outerEt_ieta_iphi->setAxisTitle("ieta",1);
    hCT_outerEt_ieta_iphi->setAxisTitle("ephi",2);
    hCT_Occ_ieta_iphi         = dbe_->book2D("METTask_CT_Occ_ieta_iphi","",83,-41,42, 72,1,73);  
    hCT_Occ_ieta_iphi->getTH2F()->SetOption("colz");
    hCT_Occ_ieta_iphi->setAxisTitle("ieta",1);
    hCT_Occ_ieta_iphi->setAxisTitle("ephi",2);
    //--Data over eta-rings

    // CaloTower values
    if(allhist_){
    if(finebinning_)
      {

        hCT_etvsieta          = dbe_->book2D("METTask_CT_etvsieta","", 83,-41,42, 10001,0,1001);  
        hCT_Minetvsieta       = dbe_->book2D("METTask_CT_Minetvsieta","", 83,-41,42, 10001,0,1001);  
        hCT_Maxetvsieta       = dbe_->book2D("METTask_CT_Maxetvsieta","", 83,-41,42, 10001,0,1001);  
        hCT_emEtvsieta        = dbe_->book2D("METTask_CT_emEtvsieta","",83,-41,42, 10001,0,1001);  
        hCT_hadEtvsieta       = dbe_->book2D("METTask_CT_hadEtvsieta","",83,-41,42, 10001,0,1001);  
        hCT_outerEtvsieta = dbe_->book2D("METTask_CT_outerEtvsieta","",83,-41,42, 10001,0,1001);  
        // Integrated over phi

        hCT_Occvsieta         = dbe_->book2D("METTask_CT_Occvsieta","",83,-41,42, 84,0,84);  
        hCT_SETvsieta         = dbe_->book2D("METTask_CT_SETvsieta","",83,-41,42, 20001,0,2001);  
        hCT_METvsieta         = dbe_->book2D("METTask_CT_METvsieta","",83,-41,42, 20001,0,2001);  
        hCT_METPhivsieta      = dbe_->book2D("METTask_CT_METPhivsieta","",83,-41,42, 80,-4,4);  
        hCT_MExvsieta         = dbe_->book2D("METTask_CT_MExvsieta","",83,-41,42, 10001,-500,501);  
        hCT_MEyvsieta         = dbe_->book2D("METTask_CT_MEyvsieta","",83,-41,42, 10001,-500,501);  
      }
    else 
      {
        
        if(allhist_){
        hCT_etvsieta          = dbe_->book2D("METTask_CT_etvsieta","", 83,-41,42, 200,-0.5,999.5);
        hCT_Minetvsieta       = dbe_->book2D("METTask_CT_Minetvsieta","", 83,-41,42, 200,-0.5,999.5);
        hCT_Maxetvsieta       = dbe_->book2D("METTask_CT_Maxetvsieta","", 83,-41,42, 200,-0.5,999.5);
        hCT_emEtvsieta        = dbe_->book2D("METTask_CT_emEtvsieta","",83,-41,42, 200,-0.5,999.5);
        hCT_hadEtvsieta       = dbe_->book2D("METTask_CT_hadEtvsieta","",83,-41,42, 200,-0.5,999.5);
        hCT_outerEtvsieta = dbe_->book2D("METTask_CT_outerEtvsieta","",83,-41,42, 80,-0.5,399.5);
        // Integrated over phi
        }

        hCT_Occvsieta         = dbe_->book2D("METTask_CT_Occvsieta","",83,-41,42, 73,-0.5,72.5);
        hCT_SETvsieta         = dbe_->book2D("METTask_CT_SETvsieta","",83,-41,42, 200,-0.5,1999.5);
        hCT_METvsieta         = dbe_->book2D("METTask_CT_METvsieta","",83,-41,42, 200,-0.5,1999.5);
        hCT_METPhivsieta      = dbe_->book2D("METTask_CT_METPhivsieta","",83,-41,42, 80,-4,4);
        hCT_MExvsieta         = dbe_->book2D("METTask_CT_MExvsieta","",83,-41,42, 100,-499.5,499.5);
        hCT_MEyvsieta         = dbe_->book2D("METTask_CT_MEyvsieta","",83,-41,42, 100,-499.5,499.5);
        
      }
    } // allhist
  }
}
void CaloTowerAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 357 of file CaloTowerAnalyzer.cc.

{
} 

Member Data Documentation

Definition at line 44 of file CaloTowerAnalyzer.h.

Definition at line 38 of file CaloTowerAnalyzer.h.

Definition at line 35 of file CaloTowerAnalyzer.h.

bool CaloTowerAnalyzer::debug_ [private]

Definition at line 42 of file CaloTowerAnalyzer.h.

Definition at line 43 of file CaloTowerAnalyzer.h.

Definition at line 45 of file CaloTowerAnalyzer.h.

std::string CaloTowerAnalyzer::FolderName_ [private]

Definition at line 47 of file CaloTowerAnalyzer.h.

Definition at line 41 of file CaloTowerAnalyzer.h.

Definition at line 53 of file CaloTowerAnalyzer.h.

Definition at line 60 of file CaloTowerAnalyzer.h.

Definition at line 52 of file CaloTowerAnalyzer.h.

Definition at line 57 of file CaloTowerAnalyzer.h.

Definition at line 54 of file CaloTowerAnalyzer.h.

Definition at line 61 of file CaloTowerAnalyzer.h.

Definition at line 59 of file CaloTowerAnalyzer.h.

Definition at line 66 of file CaloTowerAnalyzer.h.

Definition at line 65 of file CaloTowerAnalyzer.h.

Definition at line 67 of file CaloTowerAnalyzer.h.

Definition at line 68 of file CaloTowerAnalyzer.h.

Definition at line 58 of file CaloTowerAnalyzer.h.

Definition at line 51 of file CaloTowerAnalyzer.h.

Definition at line 69 of file CaloTowerAnalyzer.h.

Definition at line 56 of file CaloTowerAnalyzer.h.

Definition at line 63 of file CaloTowerAnalyzer.h.

Definition at line 55 of file CaloTowerAnalyzer.h.

Definition at line 62 of file CaloTowerAnalyzer.h.

Definition at line 64 of file CaloTowerAnalyzer.h.

Definition at line 39 of file CaloTowerAnalyzer.h.

Definition at line 40 of file CaloTowerAnalyzer.h.

Definition at line 46 of file CaloTowerAnalyzer.h.

Definition at line 48 of file CaloTowerAnalyzer.h.