#include <DiJetAnalyzer.h>
Public Member Functions | |
DiJetAnalyzer (const edm::ParameterSet &) | |
~DiJetAnalyzer () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
Private Attributes | |
bool | allowMissingInputs_ |
TClonesArray * | cells |
edm::InputTag | ec_ |
Float_t | emEnergy |
Float_t | etVetoJet |
UInt_t | eventNumber |
std::string | fOutputFileName |
edm::InputTag | hbhe_ |
edm::InputTag | hf_ |
edm::InputTag | ho_ |
TFile * | hOutputFile |
Int_t | iEtaHit |
UInt_t | iPhiHit |
edm::InputTag | jets_ |
HcalRespCorrs * | oldRespCorrs |
Float_t | probeJetEmFrac |
TLorentzVector * | probeJetP4 |
Float_t | PxTrkHcal |
Float_t | PyTrkHcal |
Float_t | PzTrkHcal |
UInt_t | runNumber |
Float_t | tagJetEmFrac |
TLorentzVector * | tagJetP4 |
Float_t | targetE |
TTree * | tree |
Float_t | xTrkHcal |
Float_t | yTrkHcal |
Float_t | zTrkHcal |
Definition at line 45 of file DiJetAnalyzer.h.
cms::DiJetAnalyzer::DiJetAnalyzer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 37 of file DiJetAnalyzer.cc.
References allowMissingInputs_, ec_, fOutputFileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hbhe_, hf_, ho_, and jets_.
{ jets_=iConfig.getParameter<edm::InputTag>("jetsInput"); ec_=iConfig.getParameter<edm::InputTag>("ecInput"); hbhe_=iConfig.getParameter<edm::InputTag>("hbheInput"); ho_=iConfig.getParameter<edm::InputTag>("hoInput"); hf_=iConfig.getParameter<edm::InputTag>("hfInput"); // get name of output file with histogramms fOutputFileName = iConfig.getUntrackedParameter<std::string>("HistOutFile"); allowMissingInputs_ = true; }
cms::DiJetAnalyzer::~DiJetAnalyzer | ( | ) |
Definition at line 52 of file DiJetAnalyzer.cc.
{ }
void cms::DiJetAnalyzer::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 64 of file DiJetAnalyzer.cc.
References allowMissingInputs_, HcalDetId::depth(), alignCSCRings::e, ec_, emEnergy, PV3DBase< T, PVType, FrameType >::eta(), etVetoJet, edm::EventID::event(), eventNumber, edm::EventSetup::get(), edm::Event::getByLabel(), CaloGeometry::getValidDetIds(), hbhe_, DetId::Hcal, hf_, ho_, i, edm::EventBase::id(), HcalDetId::ieta(), iEtaHit, HcalDetId::iphi(), iPhiHit, metsig::jet, analyzePatCleaning_cfg::jets, jets_, PV3DBase< T, PVType, FrameType >::phi(), pi, pos, probeJetEmFrac, probeJetP4, PxTrkHcal, PyTrkHcal, PzTrkHcal, dt_dqm_sourceclient_common_cff::reco, edm::EventID::run(), runNumber, funct::sin(), mathSSE::sqrt(), tagJetP4, targetE, and tree.
{ using namespace std; using namespace edm; using namespace reco; const double pi = 4.*atan(1.); // event number & run number eventNumber = iEvent.id().event(); runNumber = iEvent.id().run(); // read jets CaloJet jet1, jet2, jet3; try { edm::Handle<CaloJetCollection> jets; iEvent.getByLabel(jets_,jets); if(jets->size()>1){ jet1 = (*jets)[0]; jet2 = (*jets)[1]; if(fabs(jet1.eta())>fabs(jet2.eta())){ CaloJet jet = jet1; jet1 = jet2; jet2 = jet; } // if(fabs(jet1.eta())>eta_1 || (fabs(jet2.eta())-jet_R) < eta_2){ return;} } else {return;} tagJetP4->SetPxPyPzE(jet1.px(), jet1.py(), jet1.pz(), jet1.energy()); probeJetP4->SetPxPyPzE(jet2.px(), jet2.py(), jet2.pz(), jet2.energy()); if(jets->size()>2){ jet3 = (*jets)[2]; etVetoJet = jet3.et(); } else { etVetoJet = 0.;} }catch (cms::Exception& e) { // can't find it! if (!allowMissingInputs_) { throw e; } } double dR = 1000.; edm::ESHandle<CaloGeometry> pG; iSetup.get<CaloGeometryRecord>().get(pG); const CaloGeometry* geo = pG.product(); vector<DetId> vid = geo->getValidDetIds(); for(vector<DetId>::const_iterator idItr = vid.begin(); idItr != vid.end(); idItr++) { if( (*idItr).det() == DetId::Hcal ) { GlobalPoint pos = geo->getPosition(*idItr); double deta = fabs(jet2.eta() - pos.eta()); double dphi = fabs(jet2.phi() - pos.phi()); if(dphi>pi){dphi=2*pi-dphi;} double dR_candidate = sqrt(deta*deta + dphi*dphi); int ieta = HcalDetId(*idItr).ieta(); int iphi = HcalDetId(*idItr).iphi(); int idepth = HcalDetId(*idItr).depth(); if(dR_candidate < dR && idepth == 1){ dR = dR_candidate; iEtaHit = ieta; iPhiHit = iphi; } } } targetE = jet1.et()/sin(jet2.theta()); std::map<DetId,int> mapId; vector<CaloTowerPtr> towers_fw = jet2.getCaloConstituents(); vector<CaloTowerPtr>::const_iterator towersItr; for(towersItr = towers_fw.begin(); towersItr != towers_fw.end(); towersItr++){ size_t tower_size = (*towersItr)->constituentsSize(); for(size_t i=0; i<tower_size; i++){ DetId id = (*towersItr)->constituent(i); mapId[id] = 1; } } // probeJetEmFrac = 0.; double emEnergy = 0.; try { Handle<EcalRecHitCollection> ec; iEvent.getByLabel(ec_,ec); for(EcalRecHitCollection::const_iterator ecItr = (*ec).begin(); ecItr != (*ec).end(); ++ecItr) { DetId id = ecItr->detid(); if(mapId[id]==1){ emEnergy += ecItr->energy(); } } } catch (cms::Exception& e) { // can't find it! if (!allowMissingInputs_) throw e; } targetE += -emEnergy; probeJetEmFrac = emEnergy/jet2.energy(); int nHits = 0; try { Handle<HBHERecHitCollection> hbhe; iEvent.getByLabel(hbhe_, hbhe); for(HBHERecHitCollection::const_iterator hbheItr=hbhe->begin(); hbheItr!=hbhe->end(); hbheItr++) { DetId id = hbheItr->detid(); if(mapId[id]==1){ TCell* cell = new TCell(id.rawId(),hbheItr->energy()); (*cells)[nHits] = cell; nHits++; } } } catch (cms::Exception& e) { // can't find it! if (!allowMissingInputs_) throw e; } try { Handle<HORecHitCollection> ho; iEvent.getByLabel(ho_, ho); for(HORecHitCollection::const_iterator hoItr=ho->begin(); hoItr!=ho->end(); hoItr++) { DetId id = hoItr->detid(); if(mapId[id]==1){ TCell* cell = new TCell(id.rawId(),hoItr->energy()); (*cells)[nHits] = cell; nHits++; } } } catch (cms::Exception& e) { // can't find it! if (!allowMissingInputs_) throw e; } try { Handle<HFRecHitCollection> hf; iEvent.getByLabel(hf_, hf); for(HFRecHitCollection::const_iterator hfItr=hf->begin(); hfItr!=hf->end(); hfItr++) { DetId id = hfItr->detid(); if(mapId[id]==1){ TCell* cell = new TCell(id.rawId(),hfItr->energy()); (*cells)[nHits] = cell; nHits++; } } } catch (cms::Exception& e) { // can't find it! if (!allowMissingInputs_) throw e; } probeJetEmFrac = emEnergy/jet2.energy(); PxTrkHcal = 0; PyTrkHcal = 0; PzTrkHcal = 0; tree->Fill(); }
void cms::DiJetAnalyzer::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 228 of file DiJetAnalyzer.cc.
References cells, emEnergy, etVetoJet, eventNumber, fOutputFileName, hOutputFile, iEtaHit, iPhiHit, probeJetEmFrac, probeJetP4, PxTrkHcal, PyTrkHcal, PzTrkHcal, runNumber, tagJetEmFrac, tagJetP4, targetE, tree, xTrkHcal, yTrkHcal, and zTrkHcal.
{ hOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ; tree = new TTree("hcalCalibTree", "Tree for IsoTrack Calibration"); cells = new TClonesArray("TCell"); tagJetP4 = new TLorentzVector(); probeJetP4 = new TLorentzVector(); tree->Branch("eventNumber", &eventNumber, "eventNumber/i"); tree->Branch("runNumber", &runNumber, "runNumber/i"); tree->Branch("iEtaHit", &iEtaHit, "iEtaHit/I"); tree->Branch("iPhiHit", &iPhiHit, "iPhiHit/i"); tree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F"); tree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F"); tree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F"); tree->Branch("PxTrkHcal", &PxTrkHcal, "PxTrkHcal/F"); tree->Branch("PyTrkHcal", &PyTrkHcal, "PyTrkHcal/F"); tree->Branch("PzTrkHcal", &PzTrkHcal, "PzTrkHcal/F"); tree->Branch("cells", &cells, 64000); tree->Branch("emEnergy", &emEnergy, "emEnergy/F"); tree->Branch("targetE", &targetE, "targetE/F"); tree->Branch("etVetoJet", &etVetoJet, "etVetoJet/F"); tree->Branch("tagJetP4", "TLorentzVector", &tagJetP4); tree->Branch("probeJetP4", "TLorentzVector", &probeJetP4); tree->Branch("tagJetEmFrac", &tagJetEmFrac,"tagJetEmFrac/F"); tree->Branch("probeJetEmFrac", &probeJetEmFrac,"probeJetEmFrac/F"); }
void cms::DiJetAnalyzer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 267 of file DiJetAnalyzer.cc.
References hOutputFile, and tree.
{ hOutputFile->SetCompressionLevel(2); hOutputFile->cd(); tree->Write(); hOutputFile->Close() ; }
bool cms::DiJetAnalyzer::allowMissingInputs_ [private] |
Definition at line 100 of file DiJetAnalyzer.h.
Referenced by analyze(), and DiJetAnalyzer().
TClonesArray* cms::DiJetAnalyzer::cells [private] |
Definition at line 88 of file DiJetAnalyzer.h.
Referenced by beginJob().
edm::InputTag cms::DiJetAnalyzer::ec_ [private] |
Definition at line 60 of file DiJetAnalyzer.h.
Referenced by analyze(), and DiJetAnalyzer().
Float_t cms::DiJetAnalyzer::emEnergy [private] |
Definition at line 90 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
Float_t cms::DiJetAnalyzer::etVetoJet [private] |
Definition at line 93 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
UInt_t cms::DiJetAnalyzer::eventNumber [private] |
Definition at line 75 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
std::string cms::DiJetAnalyzer::fOutputFileName [private] |
Definition at line 68 of file DiJetAnalyzer.h.
Referenced by beginJob(), and DiJetAnalyzer().
edm::InputTag cms::DiJetAnalyzer::hbhe_ [private] |
Definition at line 61 of file DiJetAnalyzer.h.
Referenced by analyze(), and DiJetAnalyzer().
edm::InputTag cms::DiJetAnalyzer::hf_ [private] |
Definition at line 63 of file DiJetAnalyzer.h.
Referenced by analyze(), and DiJetAnalyzer().
edm::InputTag cms::DiJetAnalyzer::ho_ [private] |
Definition at line 62 of file DiJetAnalyzer.h.
Referenced by analyze(), and DiJetAnalyzer().
TFile* cms::DiJetAnalyzer::hOutputFile [private] |
Definition at line 71 of file DiJetAnalyzer.h.
Referenced by beginJob(), and endJob().
Int_t cms::DiJetAnalyzer::iEtaHit [private] |
Definition at line 77 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
UInt_t cms::DiJetAnalyzer::iPhiHit [private] |
Definition at line 78 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
edm::InputTag cms::DiJetAnalyzer::jets_ [private] |
Definition at line 59 of file DiJetAnalyzer.h.
Referenced by analyze(), and DiJetAnalyzer().
HcalRespCorrs* cms::DiJetAnalyzer::oldRespCorrs [private] |
Definition at line 102 of file DiJetAnalyzer.h.
Float_t cms::DiJetAnalyzer::probeJetEmFrac [private] |
Definition at line 97 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
TLorentzVector* cms::DiJetAnalyzer::probeJetP4 [private] |
Definition at line 95 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
Float_t cms::DiJetAnalyzer::PxTrkHcal [private] |
Definition at line 84 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
Float_t cms::DiJetAnalyzer::PyTrkHcal [private] |
Definition at line 85 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
Float_t cms::DiJetAnalyzer::PzTrkHcal [private] |
Definition at line 86 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
UInt_t cms::DiJetAnalyzer::runNumber [private] |
Definition at line 76 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
Float_t cms::DiJetAnalyzer::tagJetEmFrac [private] |
Definition at line 96 of file DiJetAnalyzer.h.
Referenced by beginJob().
TLorentzVector* cms::DiJetAnalyzer::tagJetP4 [private] |
Definition at line 94 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
Float_t cms::DiJetAnalyzer::targetE [private] |
Definition at line 91 of file DiJetAnalyzer.h.
Referenced by analyze(), and beginJob().
TTree* cms::DiJetAnalyzer::tree [private] |
Definition at line 73 of file DiJetAnalyzer.h.
Referenced by analyze(), beginJob(), and endJob().
Float_t cms::DiJetAnalyzer::xTrkHcal [private] |
Definition at line 80 of file DiJetAnalyzer.h.
Referenced by beginJob().
Float_t cms::DiJetAnalyzer::yTrkHcal [private] |
Definition at line 81 of file DiJetAnalyzer.h.
Referenced by beginJob().
Float_t cms::DiJetAnalyzer::zTrkHcal [private] |
Definition at line 82 of file DiJetAnalyzer.h.
Referenced by beginJob().