CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::DiJetAnalyzer Class Reference

#include <DiJetAnalyzer.h>

Inheritance diagram for cms::DiJetAnalyzer:
edm::EDAnalyzer

Public Member Functions

 DiJetAnalyzer (const edm::ParameterSet &)
 
 ~DiJetAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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_
 
HcalRespCorrsoldRespCorrs
 
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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 45 of file DiJetAnalyzer.h.

Constructor & Destructor Documentation

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_.

38 {
39  jets_=iConfig.getParameter<edm::InputTag>("jetsInput");
40  ec_=iConfig.getParameter<edm::InputTag>("ecInput");
41  hbhe_=iConfig.getParameter<edm::InputTag>("hbheInput");
42  ho_=iConfig.getParameter<edm::InputTag>("hoInput");
43  hf_=iConfig.getParameter<edm::InputTag>("hfInput");
44 
45  // get name of output file with histogramms
46  fOutputFileName = iConfig.getUntrackedParameter<std::string>("HistOutFile");
47 
48  allowMissingInputs_ = true;
49 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string fOutputFileName
Definition: DiJetAnalyzer.h:68
edm::InputTag hbhe_
Definition: DiJetAnalyzer.h:61
edm::InputTag ho_
Definition: DiJetAnalyzer.h:62
edm::InputTag ec_
Definition: DiJetAnalyzer.h:60
edm::InputTag hf_
Definition: DiJetAnalyzer.h:63
edm::InputTag jets_
Definition: DiJetAnalyzer.h:59
cms::DiJetAnalyzer::~DiJetAnalyzer ( )

Definition at line 52 of file DiJetAnalyzer.cc.

53 {
54 
55 }

Member Function Documentation

void cms::DiJetAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 64 of file DiJetAnalyzer.cc.

References allowMissingInputs_, HcalDetId::depth(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, 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(), errorMatrix2Lands_multiChannel::id, HcalDetId::ieta(), iEtaHit, HcalDetId::iphi(), iPhiHit, metsig::jet, fwrapper::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.

65 {
66 
67  using namespace std;
68  using namespace edm;
69  using namespace reco;
70 
71  const double pi = 4.*atan(1.);
72 
73  // event number & run number
74  eventNumber = iEvent.id().event();
75  runNumber = iEvent.id().run();
76 
77 
78  // read jets
79  CaloJet jet1, jet2, jet3;
80  try {
82  iEvent.getByLabel(jets_,jets);
83  if(jets->size()>1){
84  jet1 = (*jets)[0];
85  jet2 = (*jets)[1];
86  if(fabs(jet1.eta())>fabs(jet2.eta())){
87  CaloJet jet = jet1;
88  jet1 = jet2;
89  jet2 = jet;
90  }
91  // if(fabs(jet1.eta())>eta_1 || (fabs(jet2.eta())-jet_R) < eta_2){ return;}
92  } else {return;}
93  tagJetP4->SetPxPyPzE(jet1.px(), jet1.py(), jet1.pz(), jet1.energy());
94  probeJetP4->SetPxPyPzE(jet2.px(), jet2.py(), jet2.pz(), jet2.energy());
95  if(jets->size()>2){
96  jet3 = (*jets)[2];
97  etVetoJet = jet3.et();
98  } else { etVetoJet = 0.;}
99  }catch (cms::Exception& e) { // can't find it!
100  if (!allowMissingInputs_) { throw e; }
101  }
102 
103 
104  double dR = 1000.;
106  iSetup.get<CaloGeometryRecord>().get(pG);
107  const CaloGeometry* geo = pG.product();
108  vector<DetId> vid = geo->getValidDetIds();
109  for(vector<DetId>::const_iterator idItr = vid.begin(); idItr != vid.end(); idItr++)
110  {
111  if( (*idItr).det() == DetId::Hcal ) {
112  GlobalPoint pos = geo->getPosition(*idItr);
113  double deta = fabs(jet2.eta() - pos.eta());
114  double dphi = fabs(jet2.phi() - pos.phi());
115  if(dphi>pi){dphi=2*pi-dphi;}
116  double dR_candidate = sqrt(deta*deta + dphi*dphi);
117  int ieta = HcalDetId(*idItr).ieta();
118  int iphi = HcalDetId(*idItr).iphi();
119  int idepth = HcalDetId(*idItr).depth();
120  if(dR_candidate < dR && idepth == 1){
121  dR = dR_candidate;
122  iEtaHit = ieta;
123  iPhiHit = iphi;
124  }
125  }
126  }
127 
128  targetE = jet1.et()/sin(jet2.theta());
129 
130  std::map<DetId,int> mapId;
131  vector<CaloTowerPtr> towers_fw = jet2.getCaloConstituents();
132  vector<CaloTowerPtr>::const_iterator towersItr;
133  for(towersItr = towers_fw.begin(); towersItr != towers_fw.end(); towersItr++){
134  size_t tower_size = (*towersItr)->constituentsSize();
135  for(size_t i=0; i<tower_size; i++){
136  DetId id = (*towersItr)->constituent(i);
137  mapId[id] = 1;
138  }
139  }
140 
141 
142  // probeJetEmFrac = 0.;
143  double emEnergy = 0.;
144  try {
146  iEvent.getByLabel(ec_,ec);
147  for(EcalRecHitCollection::const_iterator ecItr = (*ec).begin();
148  ecItr != (*ec).end(); ++ecItr)
149  {
150  DetId id = ecItr->detid();
151  if(mapId[id]==1){
152  emEnergy += ecItr->energy();
153  }
154  }
155  } catch (cms::Exception& e) { // can't find it!
156  if (!allowMissingInputs_) throw e;
157  }
158 
159  targetE += -emEnergy;
160  probeJetEmFrac = emEnergy/jet2.energy();
161 
162  int nHits = 0;
163  try {
165  iEvent.getByLabel(hbhe_, hbhe);
166  for(HBHERecHitCollection::const_iterator hbheItr=hbhe->begin();
167  hbheItr!=hbhe->end(); hbheItr++)
168  {
169  DetId id = hbheItr->detid();
170  if(mapId[id]==1){
171  TCell* cell = new TCell(id.rawId(),hbheItr->energy());
172  (*cells)[nHits] = cell;
173  nHits++;
174  }
175  }
176  } catch (cms::Exception& e) { // can't find it!
177  if (!allowMissingInputs_) throw e;
178  }
179 
180 
181  try {
183  iEvent.getByLabel(ho_, ho);
184  for(HORecHitCollection::const_iterator hoItr=ho->begin();
185  hoItr!=ho->end(); hoItr++)
186  {
187  DetId id = hoItr->detid();
188  if(mapId[id]==1){
189  TCell* cell = new TCell(id.rawId(),hoItr->energy());
190  (*cells)[nHits] = cell;
191  nHits++;
192  }
193  }
194  } catch (cms::Exception& e) { // can't find it!
195  if (!allowMissingInputs_) throw e;
196  }
197 
198  try {
200  iEvent.getByLabel(hf_, hf);
201  for(HFRecHitCollection::const_iterator hfItr=hf->begin();
202  hfItr!=hf->end(); hfItr++)
203  {
204  DetId id = hfItr->detid();
205  if(mapId[id]==1){
206  TCell* cell = new TCell(id.rawId(),hfItr->energy());
207  (*cells)[nHits] = cell;
208  nHits++;
209  }
210  }
211  } catch (cms::Exception& e) { // can't find it!
212  if (!allowMissingInputs_) throw e;
213  }
214 
215  probeJetEmFrac = emEnergy/jet2.energy();
216 
217 PxTrkHcal = 0;
218 PyTrkHcal = 0;
219 PzTrkHcal = 0;
220 
221  tree->Fill();
222 
223 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:30
TLorentzVector * tagJetP4
Definition: DiJetAnalyzer.h:94
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: TCell.h:15
edm::InputTag hbhe_
Definition: DiJetAnalyzer.h:61
edm::InputTag ho_
Definition: DiJetAnalyzer.h:62
int depth() const
get the tower depth
Definition: HcalDetId.h:42
T sqrt(T t)
Definition: SSEVec.h:46
vector< PseudoJet > jets
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
TLorentzVector * probeJetP4
Definition: DiJetAnalyzer.h:95
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag ec_
Definition: DiJetAnalyzer.h:60
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
T eta() const
Definition: PV3DBase.h:75
edm::EventID id() const
Definition: EventBase.h:56
double pi
edm::InputTag hf_
Definition: DiJetAnalyzer.h:63
edm::InputTag jets_
Definition: DiJetAnalyzer.h:59
void cms::DiJetAnalyzer::beginJob ( void  )
privatevirtual

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.

229 {
230 
231  hOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
232 
233  tree = new TTree("hcalCalibTree", "Tree for IsoTrack Calibration");
234 
235  cells = new TClonesArray("TCell");
236  tagJetP4 = new TLorentzVector();
237  probeJetP4 = new TLorentzVector();
238 
239 
240  tree->Branch("eventNumber", &eventNumber, "eventNumber/i");
241  tree->Branch("runNumber", &runNumber, "runNumber/i");
242  tree->Branch("iEtaHit", &iEtaHit, "iEtaHit/I");
243  tree->Branch("iPhiHit", &iPhiHit, "iPhiHit/i");
244 
245 
246  tree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F");
247  tree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F");
248  tree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F");
249 
250  tree->Branch("PxTrkHcal", &PxTrkHcal, "PxTrkHcal/F");
251  tree->Branch("PyTrkHcal", &PyTrkHcal, "PyTrkHcal/F");
252  tree->Branch("PzTrkHcal", &PzTrkHcal, "PzTrkHcal/F");
253 
254  tree->Branch("cells", &cells, 64000);
255  tree->Branch("emEnergy", &emEnergy, "emEnergy/F");
256  tree->Branch("targetE", &targetE, "targetE/F");
257  tree->Branch("etVetoJet", &etVetoJet, "etVetoJet/F");
258  tree->Branch("tagJetP4", "TLorentzVector", &tagJetP4);
259  tree->Branch("probeJetP4", "TLorentzVector", &probeJetP4);
260  tree->Branch("tagJetEmFrac", &tagJetEmFrac,"tagJetEmFrac/F");
261  tree->Branch("probeJetEmFrac", &probeJetEmFrac,"probeJetEmFrac/F");
262 
263 }
TLorentzVector * tagJetP4
Definition: DiJetAnalyzer.h:94
std::string fOutputFileName
Definition: DiJetAnalyzer.h:68
TLorentzVector * probeJetP4
Definition: DiJetAnalyzer.h:95
TClonesArray * cells
Definition: DiJetAnalyzer.h:88
void cms::DiJetAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 267 of file DiJetAnalyzer.cc.

References hOutputFile, and tree.

267  {
268 
269  hOutputFile->SetCompressionLevel(2);
270  hOutputFile->cd();
271  tree->Write();
272  hOutputFile->Close() ;
273 
274 }

Member Data Documentation

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
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
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().