CMS 3D CMS Logo

Public Member Functions | Private Attributes

EwkDQM Class Reference

#include <EwkDQM.h>

Inheritance diagram for EwkDQM:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Get the analysis.
void beginJob ()
 Inizialize parameters for histo binning.
void beginRun (const edm::Run &, const edm::EventSetup &)
double calcDeltaPhi (double phi1, double phi2)
void endJob (void)
 Save the histos.
 EwkDQM (const edm::ParameterSet &)
 Constructor.
virtual ~EwkDQM ()
 Destructor.

Private Attributes

MonitorElementh_e1_et
MonitorElementh_e1_eta
MonitorElementh_e1_phi
MonitorElementh_e2_et
MonitorElementh_e2_eta
MonitorElementh_e2_phi
MonitorElementh_e_invWMass
MonitorElementh_ee_invMass
MonitorElementh_jet2_et
MonitorElementh_jet_count
MonitorElementh_jet_et
MonitorElementh_m1_eta
MonitorElementh_m1_phi
MonitorElementh_m1_pt
MonitorElementh_m2_eta
MonitorElementh_m2_phi
MonitorElementh_m2_pt
MonitorElementh_m_invWMass
MonitorElementh_met
MonitorElementh_met_phi
MonitorElementh_mumu_invMass
MonitorElementh_t1_et
MonitorElementh_t1_eta
MonitorElementh_t1_phi
MonitorElementh_vertex_chi2
MonitorElementh_vertex_d0
MonitorElementh_vertex_number
MonitorElementh_vertex_numTrks
MonitorElementh_vertex_sumTrks
HLTConfigProvider hltConfigProvider_
bool isValidHltConfig_
std::string logTraceName
edm::InputTag theCaloJetCollectionLabel
edm::InputTag theCaloMETCollectionLabel
DQMStoretheDbe
std::string theElecTriggerPathToPass
edm::InputTag theElectronCollectionLabel
edm::InputTag theMuonCollectionLabel
std::string theMuonTriggerPathToPass
edm::InputTag theTriggerResultsCollection

Detailed Description

DQM offline for QCD-Photons

Date:
2010/03/12 10:25:45
Revision:
1.9
Author:
Michael B. Anderson, University of Wisconsin Madison

Definition at line 27 of file EwkDQM.h.


Constructor & Destructor Documentation

EwkDQM::EwkDQM ( const edm::ParameterSet parameters)

Constructor.

Definition at line 52 of file EwkDQM.cc.

References edm::ParameterSet::getParameter().

                                             {
  // Get parameters from configuration file
  theElecTriggerPathToPass    = parameters.getParameter<string>("elecTriggerPathToPass");
  theMuonTriggerPathToPass    = parameters.getParameter<string>("muonTriggerPathToPass");
  theTriggerResultsCollection = parameters.getParameter<InputTag>("triggerResultsCollection");
  theMuonCollectionLabel      = parameters.getParameter<InputTag>("muonCollection");
  theElectronCollectionLabel  = parameters.getParameter<InputTag>("electronCollection");
  theCaloJetCollectionLabel   = parameters.getParameter<InputTag>("caloJetCollection");
  theCaloMETCollectionLabel   = parameters.getParameter<InputTag>("caloMETCollection");
  
  // just to initialize
  isValidHltConfig_ = false;

}
EwkDQM::~EwkDQM ( ) [virtual]

Destructor.

Definition at line 67 of file EwkDQM.cc.

                { 
}

Member Function Documentation

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

Get the analysis.

Implements edm::EDAnalyzer.

Definition at line 130 of file EwkDQM.cc.

References calcDeltaPhi(), funct::cos(), edm::Event::getByLabel(), edm::HandleBase::isValid(), LogTrace, edm::Handle< T >::product(), mathSSE::sqrt(), v, and GoodVertex_cfg::vertexCollection.

                                                                  {

  // short-circuit if hlt problems
  if( ! isValidHltConfig_ ) return;


  LogTrace(logTraceName)<<"Analysis of event # ";
  // Did it pass certain HLT path?
  Handle<TriggerResults> HLTresults;
  iEvent.getByLabel(theTriggerResultsCollection, HLTresults); 
  if ( !HLTresults.isValid() ) return;

  //unsigned int triggerIndex_elec = hltConfig.triggerIndex(theElecTriggerPathToPass);
  //unsigned int triggerIndex_muon = hltConfig.triggerIndex(theMuonTriggerPathToPass);
  bool passed_electron_HLT = true;
  bool passed_muon_HLT     = true;
  //if (triggerIndex_elec < HLTresults->size()) passed_electron_HLT = HLTresults->accept(triggerIndex_elec);
  //if (triggerIndex_muon < HLTresults->size()) passed_muon_HLT     = HLTresults->accept(triggerIndex_muon);
  //if ( !(passed_electron_HLT || passed_muon_HLT) ) return;

  //Vertex information
  Handle<VertexCollection> vertexHandle;
  iEvent.getByLabel("offlinePrimaryVertices", vertexHandle);
  if ( !vertexHandle.isValid() ) return;
  VertexCollection vertexCollection = *(vertexHandle.product());
  int vertex_number     = vertexCollection.size();
  VertexCollection::const_iterator v = vertexCollection.begin();
  double vertex_chi2    = v->normalizedChi2(); //v->chi2();
  double vertex_d0      = sqrt(v->x()*v->x()+v->y()*v->y());
  //double vertex_ndof    = v->ndof();cout << "ndof="<<vertex_ndof<<endl;
  double vertex_numTrks = v->tracksSize();
  double vertex_sumTrks = 0.0;
  for (Vertex::trackRef_iterator vertex_curTrack = v->tracks_begin(); vertex_curTrack!=v->tracks_end(); vertex_curTrack++) {
    vertex_sumTrks += (*vertex_curTrack)->pt();
  }

  //Missing ET
  Handle<CaloMETCollection> caloMETCollection;
  iEvent.getByLabel(theCaloMETCollectionLabel, caloMETCollection);
  if ( !caloMETCollection.isValid() ) return;
  float missing_et = caloMETCollection->begin()->et();
  float met_phi    = caloMETCollection->begin()->phi();


  // grab "gaussian sum fitting" electrons
  Handle<GsfElectronCollection> electronCollection;
  iEvent.getByLabel(theElectronCollectionLabel, electronCollection);
  if ( !electronCollection.isValid() ) return;

  // Find the highest and 2nd highest electron
  float electron_et   = -8.0;
  float electron_eta  = -8.0;
  float electron_phi  = -8.0;
  float electron2_et  = -9.0;
  float electron2_eta = -9.0;
  float electron2_phi = -9.0;
  float ee_invMass    = -9.0;
  TLorentzVector e1, e2;

  // If it passed electron HLT and the collection was found, find electrons near Z mass
  if( passed_electron_HLT ) {

    for (reco::GsfElectronCollection::const_iterator recoElectron=electronCollection->begin(); recoElectron!=electronCollection->end(); recoElectron++){

      // Require electron to pass some basic cuts
      if ( recoElectron->et() < 20 || fabs(recoElectron->eta())>2.5 ) continue;

      // Tighter electron cuts
      if ( recoElectron->deltaPhiSuperClusterTrackAtVtx() > 0.58 || 
           recoElectron->deltaEtaSuperClusterTrackAtVtx() > 0.01 || 
           recoElectron->sigmaIetaIeta() > 0.027 ) continue;

      if (recoElectron->et() > electron_et){
        electron2_et  = electron_et;  // 2nd highest gets values from current highest
        electron2_eta = electron_eta;
        electron2_phi = electron_phi;
        electron_et   = recoElectron->et();  // 1st highest gets values from new highest
        electron_eta  = recoElectron->eta();
        electron_phi  = recoElectron->phi();
        e1 = TLorentzVector(recoElectron->momentum().x(),recoElectron->momentum().y(),recoElectron->momentum().z(),recoElectron->p());
      } else if (recoElectron->et() > electron2_et) {
        electron2_et  = recoElectron->et();
        electron2_eta = recoElectron->eta();
        electron2_phi = recoElectron->phi();
        e2 = TLorentzVector(recoElectron->momentum().x(),recoElectron->momentum().y(),recoElectron->momentum().z(),recoElectron->p());
      }
    } // end of loop over electrons
    if (electron2_et>0.0) {
      TLorentzVector pair=e1+e2;
      ee_invMass = pair.M();
    }
  } // end of "are electrons valid"



  // Take the STA muon container
  Handle<MuonCollection> muonCollection;
  iEvent.getByLabel(theMuonCollectionLabel,muonCollection);
  if ( !muonCollection.isValid() ) return;

  // Find the highest pt muons
  float mm_invMass = -9.0;
  float muon_pt   = -9.0;
  float muon_eta  = -9.0;
  float muon_phi  = -9.0;
  float muon2_pt  = -9.0;
  float muon2_eta = -9.0;
  float muon2_phi = -9.0;
  TLorentzVector m1, m2;

  if( passed_muon_HLT ) {
    for (reco::MuonCollection::const_iterator recoMuon=muonCollection->begin(); recoMuon!=muonCollection->end(); recoMuon++){

      // Require muon to pass some basic cuts
      if ( recoMuon->pt() < 20 || !recoMuon->isGlobalMuon() ) continue;
      // Some tighter muon cuts
      if ( recoMuon->globalTrack()->normalizedChi2() > 10 ) continue;

      if (recoMuon->pt() > muon_pt){
        muon2_pt  = muon_pt;  // 2nd highest gets values from current highest    
        muon2_eta = muon_eta;
        muon2_phi = muon_phi;
        muon_pt   = recoMuon->pt();  // 1st highest gets values from new highest
        muon_eta  = recoMuon->eta();
        muon_phi  = recoMuon->phi();
        m1 = TLorentzVector(recoMuon->momentum().x(),recoMuon->momentum().y(),recoMuon->momentum().z(),recoMuon->p());
      } else if (recoMuon->pt() > muon2_pt) {
        muon2_pt  = recoMuon->pt();
        muon2_eta = recoMuon->eta();
        muon2_phi = recoMuon->phi();
        m2 = TLorentzVector(recoMuon->momentum().x(),recoMuon->momentum().y(),recoMuon->momentum().z(),recoMuon->p());
      }
    }
  }
  if (muon2_pt>0.0) {
    TLorentzVector pair=m1+m2;
    mm_invMass = pair.M();
  }


  // Find the highest et jet
  Handle<CaloJetCollection> caloJetCollection;
  iEvent.getByLabel (theCaloJetCollectionLabel,caloJetCollection);
  if ( !caloJetCollection.isValid() ) return;

  float jet_et    = -8.0;
  float jet_eta   = -8.0;
  float jet_phi   = -8.0;
  int   jet_count = 0;
  float jet2_et   = -9.0;
  float jet2_eta  = -9.0;
  float jet2_phi  = -9.0;
  for (CaloJetCollection::const_iterator i_calojet = caloJetCollection->begin(); i_calojet != caloJetCollection->end(); i_calojet++) {

    float jet_current_et = i_calojet->et();

    // if it overlaps with electron, it is not a jet
    if ( electron_et>0.0 && fabs(i_calojet->eta()-electron_eta ) < 0.2 && calcDeltaPhi(i_calojet->phi(), electron_phi ) < 0.2) continue;
    if ( electron2_et>0.0&& fabs(i_calojet->eta()-electron2_eta) < 0.2 && calcDeltaPhi(i_calojet->phi(), electron2_phi) < 0.2) continue;

    // if it has too low Et, throw away
    if (jet_current_et < 15) continue;

    jet_count++;
    if (jet_current_et > jet_et) {
      jet2_et  = jet_et;  // 2nd highest jet get's et from current highest
      jet2_eta = jet_eta;
      jet2_phi = jet_phi;
      jet_et   = i_calojet->et(); // current highest jet gets et from the new highest
      jet_eta  = i_calojet->eta();
      jet_phi  = i_calojet->phi();
    } else if (jet_current_et > jet2_et) {
      jet2_et  = i_calojet->et();
      jet2_eta = i_calojet->eta();
      jet2_phi = i_calojet->phi();
    }
  }



  //                 Fill Histograms                                            //

  bool fill_e1  = false;
  bool fill_e2  = false;
  bool fill_m1  = false;
  bool fill_m2  = false;
  bool fill_met = false;

  // Was Z->ee found?
  if (ee_invMass>0.0) {
    h_ee_invMass ->Fill(ee_invMass);
    fill_e1 = true;
    fill_e2 = true;
  }

  // Was Z->mu mu found?
  if (mm_invMass > 0.0) {
    h_mumu_invMass->Fill(mm_invMass);
    fill_m1 = true;
    fill_m2 = true;
  }

  // Was W->e nu found?
  if (electron_et>0.0&&missing_et>20.0) {
    float dphiW = fabs(met_phi-electron_phi);
    float W_mt_e = sqrt(2*missing_et*electron_et*(1-cos(dphiW)));
    h_e_invWMass ->Fill(W_mt_e);
    fill_e1  = true;
    fill_met = true;
  }

  // Was W->mu nu found?
  if (muon_pt>0.0&&missing_et>20.0) {
    float dphiW = fabs(met_phi-muon_phi);
    float W_mt_m = sqrt(2*missing_et*muon_pt*(1-cos(dphiW)));
    h_m_invWMass ->Fill(W_mt_m);
    fill_m1  = true;
    fill_met = true;
  }

  if (jet_et>0.0) {
    h_jet_et   ->Fill(jet_et);
    h_jet_count->Fill(jet_count);
  }

  if (fill_e1 || fill_m1) {
    h_vertex_number->Fill(vertex_number);
    h_vertex_chi2->Fill(vertex_chi2);
    h_vertex_d0  ->Fill(vertex_d0);
    h_vertex_numTrks->Fill(vertex_numTrks);
    h_vertex_sumTrks->Fill(vertex_sumTrks);
  }

  if (fill_e1) {
    h_e1_et      ->Fill(electron_et);
    h_e1_eta     ->Fill(electron_eta);
    h_e1_phi     ->Fill(electron_phi);
  }
  if (fill_e2) {
    h_e2_et      ->Fill(electron2_et);
    h_e2_eta     ->Fill(electron2_eta);
    h_e2_phi     ->Fill(electron2_phi);
  }
  if (fill_m1) {
    h_m1_pt      ->Fill(muon_pt);
    h_m1_eta     ->Fill(muon_eta);
    h_m1_phi     ->Fill(muon_phi);
  }
  if (fill_m2) {
    h_m2_pt      ->Fill(muon2_pt);
    h_m2_eta     ->Fill(muon2_eta);
    h_m2_phi     ->Fill(muon2_phi);
  }
  if (fill_met) {
    h_met        ->Fill(missing_et);
    h_met_phi    ->Fill(met_phi);
  }
}
void EwkDQM::beginJob ( void  ) [virtual]

Inizialize parameters for histo binning.

Reimplemented from edm::EDAnalyzer.

Definition at line 71 of file EwkDQM.cc.

References LogTrace, cmsCodeRules::cppFunctionSkipper::operator, and pi.

                      {

  logTraceName = "EwkAnalyzer";

  LogTrace(logTraceName)<<"Parameters initialization";
  theDbe = Service<DQMStore>().operator->();
  theDbe->setCurrentFolder("Physics/EwkDQM");  // Use folder with name of PAG

  const float pi = 3.14159265;

  // Keep the number of plots and number of bins to a minimum!
  h_vertex_number = theDbe->book1D("h_vertex_number", "Number of event vertices in collection", 10,-0.5,   9.5 );
  h_vertex_chi2  = theDbe->book1D("h_vertex_chi2" , "Event Vertex #chi^{2}/n.d.o.f."          , 20, 0.0,   2.0 );
  h_vertex_numTrks = theDbe->book1D("h_vertex_numTrks", "Event Vertex, number of tracks"     , 20, -0.5,  59.5 );
  h_vertex_sumTrks = theDbe->book1D("h_vertex_sumTrks", "Event Vertex, sum of track pt"      , 20,  0.0, 100.0 );
  h_vertex_d0    = theDbe->book1D("h_vertex_d0"   , "Event Vertex d0"                        , 20,  0.0,   0.05);
  h_mumu_invMass = theDbe->book1D("h_mumu_invMass", "#mu#mu Invariant Mass;InvMass (GeV)"    , 20, 40.0, 140.0 );
  h_ee_invMass   = theDbe->book1D("h_ee_invMass",   "ee Invariant Mass;InvMass (Gev)"        , 20, 40.0, 140.0 );
  h_jet_et       = theDbe->book1D("h_jet_et",       "Jet with highest E_{T} (from "+theCaloJetCollectionLabel.label()+");E_{T}(1^{st} jet) (GeV)",    20, 0., 200.0);
  h_jet2_et      = theDbe->book1D("h_jet2_et",      "Jet with 2^{nd} highest E_{T} (from "+theCaloJetCollectionLabel.label()+");E_{T}(2^{nd} jet) (GeV)",    20, 0., 200.0);
  h_jet_count    = theDbe->book1D("h_jet_count",    "Number of "+theCaloJetCollectionLabel.label()+" (E_{T} > 15 GeV);Number of Jets", 8, -0.5, 7.5);
  h_e1_et        = theDbe->book1D("h_e1_et",  "E_{T} of Leading Electron;E_{T} (GeV)"        , 20,  0.0 , 100.0);
  h_e2_et        = theDbe->book1D("h_e2_et",  "E_{T} of Second Electron;E_{T} (GeV)"         , 20,  0.0 , 100.0);
  h_e1_eta       = theDbe->book1D("h_e1_eta", "#eta of Leading Electron;#eta"                , 20, -4.0 , 4.0);
  h_e2_eta       = theDbe->book1D("h_e2_eta", "#eta of Second Electron;#eta"                 , 20, -4.0 , 4.0);
  h_e1_phi       = theDbe->book1D("h_e1_phi", "#phi of Leading Electron;#phi"                , 22, (-1.-1./10.)*pi, (1.+1./10.)*pi );
  h_e2_phi       = theDbe->book1D("h_e2_phi", "#phi of Second Electron;#phi"                 , 22, (-1.-1./10.)*pi, (1.+1./10.)*pi );
  h_m1_pt        = theDbe->book1D("h_m1_pt",  "p_{T} of Leading Muon;p_{T}(1^{st} #mu) (GeV)", 20,  0.0 , 100.0);
  h_m2_pt        = theDbe->book1D("h_m2_pt",  "p_{T} of Second Muon;p_{T}(2^{nd} #mu) (GeV)" , 20,  0.0 , 100.0);
  h_m1_eta       = theDbe->book1D("h_m1_eta", "#eta of Leading Muon;#eta(1^{st} #mu)"        , 20, -4.0 , 4.0);
  h_m2_eta       = theDbe->book1D("h_m2_eta", "#eta of Second Muon;#eta(2^{nd} #mu)"         , 20, -4.0 , 4.0);
  h_m1_phi       = theDbe->book1D("h_m1_phi", "#phi of Leading Muon;#phi(1^{st} #mu)"        , 20, (-1.-1./10.)*pi, (1.+1./10.)*pi);
  h_m2_phi       = theDbe->book1D("h_m2_phi", "#phi of Second Muon;#phi(2^{nd} #mu)"         , 20, (-1.-1./10.)*pi, (1.+1./10.)*pi);
//  h_t1_et          = theDbe->book1D("h_t1_et",           "E_{T} of Leading Tau;E_{T} (GeV)" , 20, 0.0 , 100.0);
//  h_t1_eta         = theDbe->book1D("h_t1_eta",          "#eta of Leading Tau;#eta"               , 20, -4.0, 4.0);
//  h_t1_phi         = theDbe->book1D("h_t1_phi",          "#phi of Leading Tau;#phi"               , 20, -4.0, 4.0);
  h_met          = theDbe->book1D("h_met",        "Missing E_{T}; GeV"                       , 20,  0.0 , 100);
  h_met_phi      = theDbe->book1D("h_met_phi",    "Missing E_{T} #phi;#phi(MET)"             , 22, (-1.-1./10.)*pi, (1.+1./10.)*pi );
  h_e_invWMass   = theDbe->book1D("h_e_invWMass", "W-> e #nu Transverse Mass;M_{T} (GeV)"    , 20,  0.0, 140.0); 
  h_m_invWMass   = theDbe->book1D("h_m_invWMass", "W-> #mu #nu Transverse Mass;M_{T} (GeV)"  , 20,  0.0, 140.0); 
}
void EwkDQM::beginRun ( const edm::Run theRun,
const edm::EventSetup theSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 118 of file EwkDQM.cc.

                                                                           {
  
  // passed as parameter to HLTConfigProvider::init(), not yet used
  bool isConfigChanged = false;
  
  // isValidHltConfig_ used to short-circuit analyze() in case of problems
  const std::string hltProcessName( theTriggerResultsCollection.process() );
  isValidHltConfig_ = hltConfigProvider_.init( theRun, theSetup, hltProcessName, isConfigChanged );

}
double EwkDQM::calcDeltaPhi ( double  phi1,
double  phi2 
)

Definition at line 405 of file EwkDQM.cc.

References Geom::deltaPhi().

                                                    {

  double deltaPhi = phi1 - phi2;

  if (deltaPhi < 0) deltaPhi = -deltaPhi;

  if (deltaPhi > 3.1415926) {
    deltaPhi = 2 * 3.1415926 - deltaPhi;
  }

  return deltaPhi;
}
void EwkDQM::endJob ( void  ) [virtual]

Save the histos.

Reimplemented from edm::EDAnalyzer.

Definition at line 401 of file EwkDQM.cc.

{}

Member Data Documentation

Definition at line 83 of file EwkDQM.h.

Definition at line 85 of file EwkDQM.h.

Definition at line 87 of file EwkDQM.h.

Definition at line 84 of file EwkDQM.h.

Definition at line 86 of file EwkDQM.h.

Definition at line 88 of file EwkDQM.h.

Definition at line 100 of file EwkDQM.h.

Definition at line 78 of file EwkDQM.h.

Definition at line 80 of file EwkDQM.h.

Definition at line 81 of file EwkDQM.h.

Definition at line 79 of file EwkDQM.h.

Definition at line 91 of file EwkDQM.h.

Definition at line 93 of file EwkDQM.h.

Definition at line 89 of file EwkDQM.h.

Definition at line 92 of file EwkDQM.h.

Definition at line 94 of file EwkDQM.h.

Definition at line 90 of file EwkDQM.h.

Definition at line 101 of file EwkDQM.h.

Definition at line 98 of file EwkDQM.h.

Definition at line 99 of file EwkDQM.h.

Definition at line 77 of file EwkDQM.h.

Definition at line 95 of file EwkDQM.h.

Definition at line 96 of file EwkDQM.h.

Definition at line 97 of file EwkDQM.h.

Definition at line 73 of file EwkDQM.h.

Definition at line 74 of file EwkDQM.h.

Definition at line 72 of file EwkDQM.h.

Definition at line 75 of file EwkDQM.h.

Definition at line 76 of file EwkDQM.h.

Definition at line 58 of file EwkDQM.h.

bool EwkDQM::isValidHltConfig_ [private]

Definition at line 59 of file EwkDQM.h.

std::string EwkDQM::logTraceName [private]

Definition at line 56 of file EwkDQM.h.

Definition at line 68 of file EwkDQM.h.

Definition at line 69 of file EwkDQM.h.

Definition at line 54 of file EwkDQM.h.

std::string EwkDQM::theElecTriggerPathToPass [private]

Definition at line 63 of file EwkDQM.h.

Definition at line 67 of file EwkDQM.h.

Definition at line 66 of file EwkDQM.h.

std::string EwkDQM::theMuonTriggerPathToPass [private]

Definition at line 64 of file EwkDQM.h.

Definition at line 65 of file EwkDQM.h.