CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GammaJetAnalysis.cc
Go to the documentation of this file.
1 //
15 #include "TTree.h"
16 #include "TFile.h"
17 #include "TClonesArray.h"
18 #include <iostream>
19 #include <vector>
20 #include <set>
21 #include <map>
22 #include <boost/regex.hpp>
23 
24 inline void HERE(const char *msg) {
25  if (0 && msg) edm::LogWarning("GammaJetAnalysis") << msg;
26 }
27 
28 double getNeutralPVCorr(double eta, int intNPV, double area, bool isMC_) {
29  double NPV = static_cast<double>(intNPV);
30  double etaArray[101] = {-5, -4.9, -4.8, -4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4, -3.9, -3.8, -3.7, -3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9, -2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5};
31  int ind = -1;
32  for(int i=0; i<100; ++i){
33  if(eta > etaArray[i] && eta < etaArray[i+1]){
34  ind = i;
35  break;
36  }
37  }
38  if(ind < 0) return 0;
39  double pt_density;
40  if(isMC_){
41  double p0[100] = {0.08187, 0.096718, 0.11565, 0.12115, 0.12511, 0.12554, 0.13858, 0.14282, 0.14302, 0.15054, 0.14136, 0.14992, 0.13812, 0.13771, 0.13165, 0.12609, 0.12446, 0.11311, 0.13771, 0.16401, 0.20454, 0.27899, 0.34242, 0.43096, 0.50742, 0.59683, 0.66877, 0.68664, 0.69541, 0.66873, 0.64175, 0.61097, 0.58524, 0.5712, 0.55752, 0.54869, 0.31073, 0.22667, 0.55614, 0.55962, 0.54348, 0.53206, 0.51594, 0.49928, 0.49139, 0.48766, 0.49157, 0.49587, 0.50109, 0.5058, 0.51279, 0.51515, 0.51849, 0.52607, 0.52362, 0.52169, 0.53579, 0.54821, 0.56262, 0.58355, 0.58809, 0.57525, 0.52539, 0.53505, 0.52307, 0.52616, 0.52678, 0.53536, 0.55141, 0.58107, 0.60556, 0.62601, 0.60897, 0.59018, 0.49593, 0.40462, 0.32052, 0.24436, 0.18867, 0.12591, 0.095421, 0.090578, 0.078767, 0.11797, 0.14057, 0.14614, 0.15232, 0.14742, 0.15647, 0.14947, 0.15805, 0.14467, 0.14526, 0.14081, 0.1262, 0.12429, 0.11951, 0.11146, 0.095677, 0.083126};
42  double p1[100] = {0.26831, 0.30901, 0.37017, 0.38747, 0.41547, 0.45237, 0.49963, 0.54074, 0.54949, 0.5937, 0.56904, 0.60766, 0.58042, 0.59823, 0.58535, 0.54594, 0.58403, 0.601, 0.65401, 0.65049, 0.65264, 0.6387, 0.60646, 0.59669, 0.55561, 0.5053, 0.42889, 0.37264, 0.36456, 0.36088, 0.36728, 0.37439, 0.38779, 0.40133, 0.40989, 0.41722, 0.47539, 0.49848, 0.42642, 0.42431, 0.42113, 0.41285, 0.41003, 0.41116, 0.41231, 0.41634, 0.41795, 0.41806, 0.41786, 0.41765, 0.41779, 0.41961, 0.42144, 0.42192, 0.4209, 0.41885, 0.4163, 0.4153, 0.41864, 0.4257, 0.43018, 0.43218, 0.43798, 0.42723, 0.42185, 0.41349, 0.40553, 0.39132, 0.3779, 0.37055, 0.36522, 0.37057, 0.38058, 0.43259, 0.51052, 0.55918, 0.60178, 0.60995, 0.64087, 0.65554, 0.65308, 0.65654, 0.60466, 0.58678, 0.54392, 0.58277, 0.59651, 0.57916, 0.60744, 0.56882, 0.59323, 0.5499, 0.54003, 0.49938, 0.4511, 0.41499, 0.38676, 0.36955, 0.30803, 0.26659};
43  double p2[100] = {0.00080918, 0.00083447, 0.0011378, 0.0011221, 0.0013613, 0.0016362, 0.0015854, 0.0019131, 0.0017474, 0.0020078, 0.001856, 0.0020331, 0.0020823, 0.001898, 0.0020096, 0.0016464, 0.0032413, 0.0045615, 0.0054495, 0.0057584, 0.0058982, 0.0058956, 0.0055109, 0.0051433, 0.0042098, 0.0032096, 0.00044089, -0.0003884, -0.0007059, -0.00092769, -0.001116, -0.0010437, -0.00080318, -0.00044142, 6.7232e-05, 0.00055265, -0.0014486, -0.0020432, 0.0015121, 0.0016343, 0.0015638, 0.0015707, 0.0014403, 0.0012886, 0.0011684, 0.00099089, 0.00091497, 0.00087915, 0.00084703, 0.00084542, 0.00087419, 0.00088013, 0.00090493, 0.00095853, 0.0010389, 0.0011191, 0.0012643, 0.0013833, 0.001474, 0.0015401, 0.0015582, 0.0014265, 0.00087453, 0.00086639, 0.00042986, -5.0257e-06, -0.00053124, -0.00086417, -0.0011228, -0.0011749, -0.0010068, -0.00083012, -0.00062906, 0.00021515, 0.0028714, 0.0038835, 0.0047212, 0.0051427, 0.0055762, 0.0055872, 0.0054989, 0.0053033, 0.0044519, 0.0032223, 0.0017641, 0.0021165, 0.0019909, 0.0021061, 0.0020322, 0.0018357, 0.0019829, 0.001683, 0.0018553, 0.0015304, 0.0015822, 0.0013119, 0.0010745, 0.0010808, 0.00080678, 0.00079756};
44  pt_density = p0[ind] + p1[ind]*(NPV - 1) + p2[ind]*(NPV - 1)*(NPV - 1);
45  }
46  else{
47  double p0[100] = {0.12523, 0.14896, 0.17696, 0.19376, 0.20038, 0.21353, 0.25069, 0.27089, 0.29124, 0.31947, 0.31781, 0.35453, 0.35424, 0.38159, 0.39453, 0.4003, 0.34798, 0.26303, 0.24824, 0.22857, 0.22609, 0.26793, 0.30096, 0.37637, 0.44461, 0.55692, 0.70328, 0.72458, 0.75065, 0.73569, 0.72485, 0.69933, 0.69804, 0.70775, 0.70965, 0.71439, 0.72189, 0.73691, 0.74847, 0.74968, 0.73467, 0.70115, 0.6732, 0.65971, 0.65724, 0.67751, 0.69569, 0.70905, 0.71815, 0.72119, 0.72128, 0.71645, 0.70588, 0.68958, 0.66978, 0.65959, 0.66889, 0.68713, 0.71063, 0.74283, 0.75153, 0.74733, 0.73335, 0.71346, 0.70168, 0.69445, 0.68841, 0.67761, 0.67654, 0.6957, 0.70276, 0.71057, 0.68176, 0.64651, 0.49156, 0.38366, 0.31375, 0.24127, 0.21395, 0.17783, 0.19026, 0.21486, 0.24689, 0.3434, 0.40184, 0.39876, 0.3873, 0.36462, 0.36337, 0.32777, 0.328, 0.29868, 0.28087, 0.25713, 0.22466, 0.20784, 0.19798, 0.18054, 0.15022, 0.12811};
48  double p1[100] = {0.26829, 0.30825, 0.37034, 0.38736, 0.41645, 0.45985, 0.51433, 0.56215, 0.5805, 0.63926, 0.62007, 0.67895, 0.66015, 0.68817, 0.67975, 0.64161, 0.70887, 0.74454, 0.80197, 0.78873, 0.77892, 0.74943, 0.70034, 0.6735, 0.60774, 0.53312, 0.42132, 0.36279, 0.3547, 0.35014, 0.35655, 0.3646, 0.37809, 0.38922, 0.39599, 0.40116, 0.40468, 0.40645, 0.40569, 0.4036, 0.39874, 0.39326, 0.39352, 0.39761, 0.40232, 0.40729, 0.41091, 0.41247, 0.413, 0.41283, 0.41289, 0.4134, 0.41322, 0.41185, 0.40769, 0.40193, 0.39707, 0.39254, 0.39274, 0.3989, 0.40474, 0.40758, 0.40788, 0.40667, 0.40433, 0.40013, 0.39371, 0.38154, 0.36723, 0.3583, 0.35148, 0.35556, 0.36172, 0.41073, 0.50629, 0.57068, 0.62972, 0.65188, 0.69954, 0.72967, 0.74333, 0.76148, 0.71418, 0.69062, 0.63065, 0.67117, 0.68278, 0.66028, 0.68147, 0.62494, 0.64452, 0.58685, 0.57076, 0.52387, 0.47132, 0.42637, 0.39554, 0.37989, 0.31825, 0.27969};
49  double p2[100] = {-0.0014595, -0.0014618, -0.0011988, -0.00095404, -5.3893e-05, 0.00018901, 0.00012553, 0.0004172, 0.00020229, 0.00051942, 0.00052088, 0.00076727, 0.0010407, 0.0010184, 0.0013442, 0.0011271, 0.0032841, 0.0045259, 0.0051803, 0.0054477, 0.0055691, 0.0056668, 0.0053084, 0.0050978, 0.0042061, 0.003321, 0.00045155, 0.00021376, 0.0001178, -2.6836e-05, -0.00017689, -0.00014723, 0.00016887, 0.00067322, 0.0012952, 0.0019229, 0.0024702, 0.0028854, 0.0031576, 0.003284, 0.0032643, 0.0031061, 0.0028377, 0.0025386, 0.0022583, 0.0020448, 0.001888, 0.0017968, 0.0017286, 0.0016989, 0.0017014, 0.0017302, 0.0017958, 0.0018891, 0.0020609, 0.0022876, 0.0025391, 0.0028109, 0.0030294, 0.0031867, 0.0032068, 0.0030755, 0.0028181, 0.0023893, 0.0018359, 0.0012192, 0.00061654, 0.00016088, -0.00015204, -0.00019503, -3.7236e-05, 0.00016663, 0.00033833, 0.00082988, 0.0034005, 0.0042941, 0.0050884, 0.0052612, 0.0055901, 0.0054357, 0.0052671, 0.0049174, 0.0042236, 0.0031138, 0.0011733, 0.0014057, 0.0010843, 0.0010992, 0.0007966, 0.00052196, 0.00053029, 0.00021273, 0.00041664, 0.00010455, 0.00015173, -9.7827e-05, -0.0010859, -0.0013748, -0.0016641, -0.0016887};
50  pt_density = p0[ind] + p1[ind]*(NPV - 1) + p2[ind]*(NPV - 1)*(NPV - 1);
51  }
52  double ECorr = pt_density*area*cosh(eta);
53  return ECorr;
54 }
55 
56 // -------------------------------------------------
57 
58 inline
59 unsigned int helper_findTrigger(const std::vector<std::string>& list,
60  const std::string& name)
61 {
62  boost::regex re(std::string("^(")+name+"|"+name+"_v\\d*)$");
63  for (unsigned int i = 0,n = list.size() ; i < n ; ++i) {
64  if(boost::regex_match(list[i],re)) return i;
65  }
66  return list.size();
67 }
68 
69 // -------------------------------------------------
70 
72  // set parameters
73  debug_ = iConfig.getUntrackedParameter<int>("debug", 0);
74  debugHLTTrigNames = iConfig.getUntrackedParameter<int>("debugHLTTrigNames",1);
75  debugEvent = iConfig.getUntrackedParameter<unsigned int>("debugEvent",0);
76  pfMETColl = iConfig.getParameter<edm::InputTag>("PFMETColl");
77  pfType1METColl = iConfig.getParameter<edm::InputTag>("PFMETTYPE1Coll");
78  rhoCollection_ = iConfig.getParameter<edm::InputTag>("rhoColl");
79  photonCollName_ = iConfig.getParameter<std::string>("photonCollName");
80  pfJetCollName_ = iConfig.getParameter<std::string>("pfJetCollName");
81  pfJetCorrName_ = iConfig.getParameter<std::string>("pfJetCorrName");
82  genJetCollName_ = iConfig.getParameter<std::string>("genJetCollName");
83  genParticleCollName_ = iConfig.getParameter<std::string>("genParticleCollName");
84  genEventInfoName_ = iConfig.getParameter<std::string>("genEventInfoName");
85  hbheRecHitName_ = iConfig.getParameter<std::string>("hbheRecHitName");
86  hfRecHitName_ = iConfig.getParameter<std::string>("hfRecHitName");
87  hoRecHitName_ = iConfig.getParameter<std::string>("hoRecHitName");
88  rootHistFilename_ = iConfig.getParameter<std::string>("rootHistFilename");
89  pvCollName_ = iConfig.getParameter<std::string>("pvCollName");
90  prodProcess_ = "MYGAMMA";
91  if (iConfig.exists("prodProcess"))
92  prodProcess_ = iConfig.getUntrackedParameter<std::string>("prodProcess");
93 
94  allowNoPhoton_ = iConfig.getParameter<bool>("allowNoPhoton");
95  photonPtMin_ = iConfig.getParameter<double>("photonPtMin");
96  photonJetDPhiMin_ = iConfig.getParameter<double>("photonJetDPhiMin");
97  jetEtMin_ = iConfig.getParameter<double>("jetEtMin");
98  jet2EtMax_ = iConfig.getParameter<double>("jet2EtMax");
99  jet3EtMax_ = iConfig.getParameter<double>("jet3EtMax");
100  photonTrigNamesV_ = iConfig.getParameter<std::vector<std::string>>("photonTriggers");
101  jetTrigNamesV_ = iConfig.getParameter<std::vector<std::string>>("jetTriggers");
102  writeTriggerPrescale_= iConfig.getParameter<bool>("writeTriggerPrescale");
103  doPFJets_ = iConfig.getParameter<bool>("doPFJets");
104  doGenJets_ = iConfig.getParameter<bool>("doGenJets");
105  workOnAOD_ = iConfig.getParameter<int>("workOnAOD");
106  ignoreHLT_ = iConfig.getUntrackedParameter<bool>("ignoreHLT",false);
107 
108  eventWeight_ = 1.0;
109  eventPtHat_ = 0.;
110  nProcessed_ = 0;
111 
112  //Get the tokens
113  // FAST FIX
114  if (workOnAOD_ < 2) { // origin data file
115  tok_Photon_ = consumes<reco::PhotonCollection>(photonCollName_);
116  tok_PFJet_ = consumes<reco::PFJetCollection>(pfJetCollName_);
117  tok_GenJet_ = consumes<std::vector<reco::GenJet> >(genJetCollName_);
118  tok_GenPart_ = consumes<std::vector<reco::GenParticle> >(genParticleCollName_);
119  tok_GenEvInfo_ = consumes<GenEventInfoProduct>(genEventInfoName_);
120  tok_HBHE_ = consumes<edm::SortedCollection<HBHERecHit,edm::StrictWeakOrdering<HBHERecHit> > >(hbheRecHitName_);
121  tok_HF_ = consumes<edm::SortedCollection<HFRecHit,edm::StrictWeakOrdering<HFRecHit> > >(hfRecHitName_);
122  tok_HO_ = consumes<edm::SortedCollection<HORecHit,edm::StrictWeakOrdering<HORecHit> > >(hoRecHitName_);
123  tok_loosePhoton_ = consumes<edm::ValueMap<Bool_t> >(edm::InputTag("PhotonIDProdGED","PhotonCutBasedIDLoose"));
124  tok_tightPhoton_ = consumes<edm::ValueMap<Bool_t> >(edm::InputTag("PhotonIDProdGED:PhotonCutBasedIDTight"));
125  tok_PFCand_ = consumes<reco::PFCandidateCollection>(edm::InputTag("particleFlow"));
126  tok_Vertex_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
127  tok_GsfElec_ = consumes<reco::GsfElectronCollection>(edm::InputTag("gsfElectrons"));
128  tok_Rho_ = consumes<double>(rhoCollection_);
129  tok_Conv_ = consumes<reco::ConversionCollection>(edm::InputTag("allConversions"));
130  tok_BS_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
131  tok_PV_ = consumes<std::vector<reco::Vertex> >(pvCollName_);
132  tok_PFMET_ = consumes<reco::PFMETCollection>(pfMETColl);
133  tok_PFType1MET_ = consumes<reco::PFMETCollection>(pfType1METColl);
134  tok_TrigRes_ = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults::HLT"));
135 
136  } else {
137  // FAST FIX
138  const char* prod= "GammaJetProd";
139  if (prodProcess_.size()==0) {
140  edm::LogError("GammaJetAnalysis") << "prodProcess needs to be defined";
142  }
143  const char* an= prodProcess_.c_str();
144  edm::LogWarning("GammaJetAnalysis") << "FAST FIX: changing " << photonCollName_
145  << " to" << edm::InputTag(prod,photonCollName_,an);
146  tok_Photon_ = consumes<reco::PhotonCollection>(edm::InputTag(prod,photonCollName_,an));
147  tok_PFJet_ = consumes<reco::PFJetCollection>(edm::InputTag(prod,pfJetCollName_,an));
148  tok_GenJet_ = consumes<std::vector<reco::GenJet> >(edm::InputTag(prod,genJetCollName_,an));
149  tok_GenPart_ = consumes<std::vector<reco::GenParticle> >(edm::InputTag(prod,genParticleCollName_,an));
150  tok_GenEvInfo_ = consumes<GenEventInfoProduct>(edm::InputTag(prod,genEventInfoName_,an));
151  tok_HBHE_ = consumes<edm::SortedCollection<HBHERecHit,edm::StrictWeakOrdering<HBHERecHit> > >(edm::InputTag(prod,hbheRecHitName_,an));
152  tok_HF_ = consumes<edm::SortedCollection<HFRecHit,edm::StrictWeakOrdering<HFRecHit> > >(edm::InputTag(prod,hfRecHitName_,an));
153  tok_HO_ = consumes<edm::SortedCollection<HORecHit,edm::StrictWeakOrdering<HORecHit> > >(edm::InputTag(prod,hoRecHitName_,an));
154  //tok_loosePhoton_ = consumes<edm::ValueMap<Bool_t> >(edm::InputTag("PhotonIDProdGED","PhotonCutBasedIDLoose"));
155  //tok_tightPhoton_ = consumes<edm::ValueMap<Bool_t> >(edm::InputTag("PhotonIDProdGED:PhotonCutBasedIDTight"));
156  tok_loosePhotonV_ = consumes<std::vector<Bool_t> >(edm::InputTag(prod,"PhotonIDProdGED:PhotonCutBasedIDLoose",an));
157  tok_tightPhotonV_ = consumes<std::vector<Bool_t> >(edm::InputTag(prod,"PhotonIDProdGED:PhotonCutBasedIDTight",an));
158  tok_PFCand_ = consumes<reco::PFCandidateCollection>(edm::InputTag(prod,"particleFlow",an));
159  tok_Vertex_ = consumes<reco::VertexCollection>(edm::InputTag(prod,"offlinePrimaryVertices",an));
160  tok_GsfElec_ = consumes<reco::GsfElectronCollection>(edm::InputTag(prod,"gedGsfElectrons",an));
161  tok_Rho_ = consumes<double>(edm::InputTag(prod,rhoCollection_.label(),an));
162  tok_Conv_ = consumes<reco::ConversionCollection>(edm::InputTag(prod,"allConversions",an));
163  tok_BS_ = consumes<reco::BeamSpot>(edm::InputTag(prod,"offlineBeamSpot",an));
164  tok_PV_ = consumes<std::vector<reco::Vertex> >(edm::InputTag(prod,pvCollName_,an));
165  tok_PFMET_ = consumes<reco::PFMETCollection>(edm::InputTag(prod,pfMETColl.label(),an));
166  tok_PFType1MET_ = consumes<reco::PFMETCollection>(edm::InputTag(prod,pfType1METColl.label(),an));
167  TString HLTlabel = "TriggerResults::HLT";
168  if (prodProcess_.find("reRECO")!=std::string::npos)
169  HLTlabel.ReplaceAll("HLT","reHLT");
170  tok_TrigRes_ = consumes<edm::TriggerResults>(edm::InputTag(prod,HLTlabel.Data(),an));
171  }
172 }
173 
175 
176 //
177 // member functions
178 //
179 
180 // ------------ method called to for each event ------------
182  nProcessed_++;
183 
184  edm::LogInfo("GammaJetAnalysis") << "nProcessed=" << nProcessed_ << "\n";
185 
186  // 1st. Get Photons //
188  iEvent.getByToken(tok_Photon_, photons);
189  if(!photons.isValid()) {
190  edm::LogWarning("GammaJetAnalysis") << "Could not find PhotonCollection named "
191  << photonCollName_;
192  return;
193  }
194 
195  if ((photons->size()==0) && !allowNoPhoton_) {
196  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "No photons in the event";
197  return;
198  }
199 
200  nPhotons_= photons->size();
201  edm::LogInfo("GammaJetAnalysis") << "nPhotons_=" << nPhotons_;
202 
203  // Get photon quality flags
204  edm::Handle<edm::ValueMap<Bool_t> > loosePhotonQual, tightPhotonQual;
205  edm::Handle<std::vector<Bool_t> > loosePhotonQual_Vec, tightPhotonQual_Vec;
206  if (workOnAOD_ < 2) {
207  iEvent.getByToken(tok_loosePhoton_, loosePhotonQual);
208  iEvent.getByToken(tok_tightPhoton_, tightPhotonQual);
209  if (!loosePhotonQual.isValid() || !tightPhotonQual.isValid()) {
210  edm::LogWarning("GammaJetAnalysis") << "Failed to get photon quality flags";
211  return;
212  }
213  }
214  else {
215  iEvent.getByToken(tok_loosePhotonV_, loosePhotonQual_Vec);
216  iEvent.getByToken(tok_tightPhotonV_, tightPhotonQual_Vec);
217  if (!loosePhotonQual_Vec.isValid() || !tightPhotonQual_Vec.isValid()) {
218  edm::LogWarning("GammaJetAnalysis") << "Failed to get photon quality flags (vec)";
219  return;
220  }
221  }
222 
223  // sort photons by Et //
224  // counter is needed later to get the reference to the ptr
225  std::set<PhotonPair, PhotonPairComp> photonpairset;
226  int counter=0;
227  for(reco::PhotonCollection::const_iterator it=photons->begin(); it!=photons->end(); ++it) {
228  //HERE(Form("photon counter=%d",counter));
229  const reco::Photon* photon=&(*it);
230  //if(loosePhotonQual.isValid()){
231  photonpairset.insert( PhotonPair(photon, photon->pt(), counter) );
232  counter++;
233  //}
234  }
235 
236  HERE(Form("photonpairset.size=%d",int(photonpairset.size())));
237 
238  if ((photonpairset.size()==0) && !allowNoPhoton_) {
239  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "No good quality photons in the event";
240  return;
241  }
242 
244  // TAG = Highest Et photon
246 
247  // find highest Et photon //
248  PhotonPair photon_tag;
249  PhotonPair photon_2nd;
250  counter=0;
251  for(std::set<PhotonPair, PhotonPairComp>::const_iterator it=photonpairset.begin(); it!=photonpairset.end(); ++it) {
252  PhotonPair photon=(*it);
253  ++counter;
254  if(counter==1) photon_tag = photon;
255  else if (counter==2) photon_2nd = photon;
256  else break;
257  }
258 
259  if (counter==0) {
260  edm::LogWarning("GammaJetAnalysis") << "Code bug";
261  return;
262  }
263 
264  HERE(Form("counter=%d",counter));
265 
266  // cut on photon pt
267  if (photon_tag.isValid() && ( photon_tag.pt() < photonPtMin_ )) {
268  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "largest photonPt=" << photon_tag.pt();
269  return;
270  }
271 
272  HERE("aa");
273 
274  // 2nd. Get Jets
276  nPFJets_=0;
277  nGenJets_=0;
278 
279  unsigned int anyJetCount=0;
280 
281  if (doPFJets_) {
282  iEvent.getByToken(tok_PFJet_,pfjets);
283  if(!pfjets.isValid()) {
284  edm::LogWarning("GammaJetAnalysis") << "Could not find PFJetCollection named " << pfJetCollName_;
285  return;
286  }
287  anyJetCount+= pfjets->size();
288  nPFJets_ = pfjets->size();
289  }
290 
291  HERE(Form("anyJetCount=%d",anyJetCount));
292 
293  if (anyJetCount==0) {
294  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "Event contains no jets";
295  return;
296  }
297  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "nPhotons=" << nPhotons_
298  << ", nPFJets=" << nPFJets_;
299 
300  HERE(Form("nPhotons_=%d, nPFJets_=%d",nPhotons_,nPFJets_));
301 
302  // 3rd. Check the trigger
303  photonTrigFired_.clear();
304  photonTrigPrescale_.clear();
305  jetTrigFired_.clear();
306  jetTrigPrescale_.clear();
307 
308  HERE("trigger");
309 
310  // HLT Trigger
311  // assign "trig fired" if no triggers are specified
312  bool photonTrigFlag= (photonTrigNamesV_.size()==0) ? true : false;
313  bool jetTrigFlag= (jetTrigNamesV_.size()==0) ? true : false;
314  if ((photonTrigNamesV_.size()==1) &&
315  (photonTrigNamesV_[0].length()==0)) photonTrigFlag=true;
316  if ((jetTrigNamesV_.size()==1) &&
317  (jetTrigNamesV_[0].length()==0)) jetTrigFlag=true;
318 
319  // If needed, process trigger information
320  if (!photonTrigFlag || !jetTrigFlag) {
321  // check the triggers
323  if( !iEvent.getByToken(tok_TrigRes_,triggerResults) ) {
324  edm::LogWarning("GammaJetAnalysis") << "Could not find TriggerResults::HLT";
325  return;
326  }
327  const edm::TriggerNames &evTrigNames =iEvent.triggerNames(*triggerResults);
328 
329  if (debugHLTTrigNames>0) {
330  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "debugHLTTrigNames is on";
331  const std::vector<std::string> *trNames= & evTrigNames.triggerNames();
332  for (size_t i=0; i<trNames->size(); ++i) {
333  if (trNames->at(i).find("_Photon")!=std::string::npos) {
334  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << " - " << trNames->at(i);
335  }
336  }
337  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << " ";
339  }
340 
341  size_t id = 0;
342  for (size_t i=0; i<photonTrigNamesV_.size(); ++i) {
343  const std::string trigName=photonTrigNamesV_.at(i);
344  id= helper_findTrigger(evTrigNames.triggerNames(),trigName);
345  if (id==evTrigNames.size()) {
346  photonTrigFired_.push_back(0);
347  photonTrigPrescale_.push_back(-1);
348  continue;
349  }
350  int fired= triggerResults->accept(id);
351  if (fired) photonTrigFlag=true;
352  photonTrigFired_.push_back(fired);
353  if (!writeTriggerPrescale_) photonTrigPrescale_.push_back(-1);
354  else {
355  // for triggers with two L1 seeds this fails
356  std::pair<int,int> prescaleVals= hltConfig_.prescaleValues(iEvent,evSetup, evTrigNames.triggerName(id));
357  photonTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second);
358  }
359  }
360  for (size_t i=0; i<jetTrigNamesV_.size(); ++i) {
361  const std::string trigName=jetTrigNamesV_.at(i);
362  id= helper_findTrigger(evTrigNames.triggerNames(),trigName);
363  if (id==evTrigNames.size()) {
364  jetTrigFired_.push_back(0);
365  jetTrigPrescale_.push_back(-1);
366  continue;
367  }
368  int fired= triggerResults->accept(id);
369  if (fired) jetTrigFlag=true;
370  jetTrigFired_.push_back(fired);
371  std::pair<int,int> prescaleVals= hltConfig_.prescaleValues(iEvent,evSetup,evTrigNames.triggerName(id));
372  jetTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second);
373  }
374  }
375 
376  if (!photonTrigFlag && !jetTrigFlag) {
377  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "no trigger fired";
378  return;
379  }
380 
381  HERE("start isolation");
382 
383  tagPho_pfiso_mycharged03.clear();
384 
388  iEvent.getByToken(tok_PFCand_, pfHandle);
389 
391  iEvent.getByToken(tok_Vertex_, vtxHandle);
392 
394  iEvent.getByToken(tok_GsfElec_, gsfElectronHandle);
395  edm::Handle<double> rhoHandle_2012;
396  iEvent.getByToken(tok_Rho_, rhoHandle_2012);
397  rho2012_ = *(rhoHandle_2012.product());
398  //rho2012_ = -1e6;
399 
401  iEvent.getByToken(tok_Conv_, convH);
402  edm::Handle<reco::BeamSpot> beamSpotHandle;
403  iEvent.getByToken(tok_BS_, beamSpotHandle);
404 
405  HERE("doGenJets");
406 
407  if(doGenJets_){
408  // Get GenJets
409  iEvent.getByToken(tok_GenJet_,genjets);
410  if(!genjets.isValid()) {
411  edm::LogWarning("GammaJetAnalysis") << "Could not find GenJet vector named "
412  << genJetCollName_;
413  return;
414  }
415  nGenJets_= genjets->size();
416 
417  // Get GenParticles
418  iEvent.getByToken(tok_GenPart_,genparticles);
419  if(!genparticles.isValid()) {
420  edm::LogWarning("GammaJetAnalysis") << "Could not find GenParticle vector named " << genParticleCollName_;
421  return;
422  }
423 
424  // Get weights
425  edm::Handle<GenEventInfoProduct> genEventInfoProduct;
426  iEvent.getByToken(tok_GenEvInfo_, genEventInfoProduct);
427  if(!genEventInfoProduct.isValid()){
428  edm::LogWarning("GammaJetAnalysis") << "Could not find GenEventInfoProduct named " << genEventInfoName_;
429  return;
430  }
431  eventWeight_ = genEventInfoProduct->weight();
432  eventPtHat_ = 0.;
433  if (genEventInfoProduct->hasBinningValues()) {
434  eventPtHat_ = genEventInfoProduct->binningValues()[0];
435  }
436  }
437 
438  runNumber_ = iEvent.id().run();
439  lumiBlock_ = iEvent.id().luminosityBlock();
440  eventNumber_ = iEvent.id().event();
441 
442  HERE(Form("runNumber=%d, eventNumber=%d",runNumber_,eventNumber_));
443 
444  // fill tag photon variables
445  if (!photon_tag.isValid()) {
446  tagPho_pt_=-1;
447  pho_2nd_pt_=-1;
448  tagPho_energy_=-1;
449  tagPho_eta_=0;
450  tagPho_phi_=0;
451  tagPho_sieie_=0;
452  tagPho_HoE_=0;
453  tagPho_r9_=0;
460  tagPho_pfiso_mycharged03.clear();
463  tagPho_idTight_=0;
464  tagPho_idLoose_=0;
465  tagPho_genPt_=0;
467  tagPho_genEta_=0;
468  tagPho_genPhi_=0;
470  }
471  else {
472  HERE("bb");
473 
474  tagPho_pt_ = photon_tag.photon()->pt();
475  pho_2nd_pt_ = (photon_2nd.photon()) ? photon_2nd.photon()->pt() : -1.;
476  tagPho_energy_ = photon_tag.photon()->energy();
477  tagPho_eta_ = photon_tag.photon()->eta();
478  tagPho_phi_ = photon_tag.photon()->phi();
479  tagPho_sieie_ = photon_tag.photon()->sigmaIetaIeta();
480  tagPho_HoE_ = photon_tag.photon()->hadTowOverEm();
481  tagPho_r9_ = photon_tag.photon()->r9();
482  tagPho_pixelSeed_ = photon_tag.photon()->hasPixelSeed();
486  tagPho_HcalIsoDR0412_ = photon_tag.photon()->hcalTowerSumEtConeDR04() + (photon_tag.photon()->hadronicOverEm() - photon_tag.photon()->hadTowOverEm())*(photon_tag.photon()->energy()/cosh((photon_tag.photon()->eta())));
487 
488  HERE("tt");
489 
490  tagPho_pfiso_myphoton03_ = pfEcalIso(photon_tag.photon(), pfHandle, 0.3, 0.0, 0.070, 0.015, 0.0, 0.0, 0.0, reco::PFCandidate::gamma);
491  tagPho_pfiso_myneutral03_ = pfHcalIso(photon_tag.photon(), pfHandle, 0.3, 0.0, reco::PFCandidate::h0);
492  HERE("calc charged pfiso");
493  tagPho_pfiso_mycharged03.push_back(pfTkIsoWithVertex(photon_tag.photon(), pfHandle, vtxHandle, 0.3, 0.02, 0.02, 0.0, 0.2, 0.1, reco::PFCandidate::h));
494 
495  HERE("got isolation");
496 
497  //tagPho_ConvSafeEleVeto_ = ((int)ConversionTools::hasMatchedPromptElectron(photon_tag.photon()->superCluster(), gsfElectronHandle, convH, beamSpotHandle->position()));
499 
500  HERE("get id");
501  if (workOnAOD_ < 2) {
502  HERE(Form("workOnAOD_<2. loose photon qual size=%d",int(loosePhotonQual->size())));
503 
504  edm::Ref<reco::PhotonCollection> photonRef(photons, photon_tag.idx());
505  HERE(Form("got photon ref, photon_tag.idx()=%d",photon_tag.idx()));
506 
507  //std::cout << "loosePhotonQual->at(photon_tag.idx())=" << loosePhotonQual->at(photon_tag.idx()) << std::endl;
508 
509  tagPho_idLoose_ = (loosePhotonQual.isValid()) ? (*loosePhotonQual)[photonRef] : -1;
510  tagPho_idTight_ = (tightPhotonQual.isValid()) ? (*tightPhotonQual)[photonRef] : -1;
511  }
512  else {
513  tagPho_idLoose_ = (loosePhotonQual_Vec.isValid()) ? loosePhotonQual_Vec->at(photon_tag.idx()) : -1;
514  tagPho_idTight_ = (tightPhotonQual_Vec.isValid()) ? tightPhotonQual_Vec->at(photon_tag.idx()) : -1;
515  }
516 
517  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "photon tag ID = "
518  << tagPho_idLoose_ << " and "
519  << tagPho_idTight_;
520 
521  HERE(Form("tagPhoID= %d and %d",tagPho_idLoose_,tagPho_idTight_));
522 
523  HERE("reset pho gen");
524 
525  tagPho_genPt_=0;
527  tagPho_genEta_=0;
528  tagPho_genPhi_=0;
530  if (doGenJets_) {
531  tagPho_genDeltaR_=9999.;
532  for (std::vector<reco::GenParticle>::const_iterator itmc=genparticles->begin();
533  itmc!=genparticles->end(); itmc++) {
534  if (itmc->status() == 1 && itmc->pdgId()==22) {
536  itmc->eta(),itmc->phi());
537  if (dR < tagPho_genDeltaR_) {
538  tagPho_genPt_ = itmc->pt();
539  tagPho_genEnergy_ = itmc->energy();
540  tagPho_genEta_ = itmc->eta();
541  tagPho_genPhi_ = itmc->phi();
543  }
544  }
545  }
546  }
547  }
548 
549  HERE("run over PFJets");
550 
551  // Run over PFJets //
552 
553  if(doPFJets_ && (nPFJets_>0)){
554 
555  // Get RecHits in HB and HE
557  iEvent.getByToken(tok_HBHE_,hbhereco);
558  if(!hbhereco.isValid() && !workOnAOD_) {
559  edm::LogWarning("GammaJetAnalysis") << "Could not find HBHERecHit named "
560  << hbheRecHitName_;
561  return;
562  }
563 
564  // Get RecHits in HF
566  iEvent.getByToken(tok_HF_,hfreco);
567  if(!hfreco.isValid() && !workOnAOD_) {
568  edm::LogWarning("GammaJetAnalysis") << "Could not find HFRecHit named "
569  << hfRecHitName_;
570  return;
571  }
572 
573  // Get RecHits in HO
575  iEvent.getByToken(tok_HO_,horeco);
576  if(!horeco.isValid() && !workOnAOD_) {
577  edm::LogWarning("GammaJetAnalysis") << "Could not find HORecHit named "
578  << hoRecHitName_;
579  return;
580  }
581 
582  HERE("get geometry");
583 
584  // Get geometry
585  edm::ESHandle<CaloGeometry> geoHandle;
586  evSetup.get<CaloGeometryRecord>().get(geoHandle);
587  const CaloSubdetectorGeometry *HBGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 1);
588  const CaloSubdetectorGeometry *HEGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 2);
589  const CaloSubdetectorGeometry *HOGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 3);
590  const CaloSubdetectorGeometry *HFGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 4);
591 
592  HERE("work");
593 
594  int HBHE_n = 0;
595  if (hbhereco.isValid()) {
596  for(edm::SortedCollection<HBHERecHit,edm::StrictWeakOrdering<HBHERecHit>>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){
597  HBHE_n++;
598  if(iEvent.id().event() == debugEvent){
599  if (debug_>1)
600  edm::LogInfo("GammaJetAnalysis") << (*ith).id().ieta() << " "
601  << (*ith).id().iphi();
602  }
603  }
604  }
605  int HF_n = 0;
606  if (hfreco.isValid()) {
607  for(edm::SortedCollection<HFRecHit,edm::StrictWeakOrdering<HFRecHit>>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){
608  HF_n++;
609  if(iEvent.id().event() == debugEvent){
610  }
611  }
612  }
613  int HO_n = 0;
614  if (horeco.isValid()) {
615  for(edm::SortedCollection<HORecHit,edm::StrictWeakOrdering<HORecHit>>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){
616  HO_n++;
617  if(iEvent.id().event() == debugEvent){
618  }
619  }
620  }
621 
622  HERE("Get primary vertices");
623 
624  // Get primary vertices
626  iEvent.getByToken(tok_PV_,pv);
627  if(!pv.isValid()) {
628  edm::LogWarning("GammaJetAnalysis") << "Could not find Vertex named "
629  << pvCollName_;
630  return;
631  }
632  pf_NPV_ = 0;
633  for(std::vector<reco::Vertex>::const_iterator it=pv->begin(); it!=pv->end(); ++it){
634  if(!it->isFake() && it->ndof() > 4) ++pf_NPV_;
635  }
636 
637  HERE("get corrector");
638 
639  // Get jet corrections
640  const JetCorrector* correctorPF = JetCorrector::getJetCorrector(pfJetCorrName_,evSetup);
641 
642  // sort jets by corrected et
643  std::set<PFJetCorretPair, PFJetCorretPairComp> pfjetcorretpairset;
644  for(reco::PFJetCollection::const_iterator it=pfjets->begin(); it!=pfjets->end(); ++it) {
645  const reco::PFJet* jet=&(*it);
646  // do not let the jet to be close to the tag photon
647  if (deltaR(photon_tag,jet)<0.5) continue;
648  double jec = correctorPF->correction(*it, iEvent, evSetup);
649  pfjetcorretpairset.insert( PFJetCorretPair(jet, jec));
650  }
651 
652  PFJetCorretPair pfjet_probe;
653  PFJetCorretPair pf_2ndjet;
654  PFJetCorretPair pf_3rdjet;
655  int jet_cntr=0;
656  for(std::set<PFJetCorretPair, PFJetCorretPairComp>::const_iterator it=pfjetcorretpairset.begin(); it!=pfjetcorretpairset.end(); ++it) {
657  PFJetCorretPair jet=(*it);
658  ++jet_cntr;
659  if(jet_cntr==1) pfjet_probe = jet;
660  else if(jet_cntr==2) pf_2ndjet = jet;
661  else if(jet_cntr==3) pf_3rdjet = jet;
662  //else break; // don't break for the statistics
663  }
664 
665  HERE("reached selection");
666 
667  // Check selection
668  int failSelPF = 0;
669 
670  if (!pfjet_probe.isValid()) failSelPF |= 1;
671  else {
672  if (pfjet_probe.scaledEt() < jetEtMin_) failSelPF |= 2;
673  if (calc_dPhi(photon_tag,pfjet_probe) < photonJetDPhiMin_) failSelPF |= 3;
674  if (deltaR(photon_tag,pfjet_probe.jet())<0.5) failSelPF |= 4;
675  if (pf_2ndjet.isValid() && (pf_2ndjet.scaledEt() > jet2EtMax_))
676  failSelPF |= 5;
677  if (pf_3rdjet.isValid() && (pf_3rdjet.scaledEt() > jet3EtMax_))
678  failSelPF |= 6;
679  }
680 
681  if (!failSelPF) {
682  // put values into 3rd jet quantities
683  if (pf_3rdjet.isValid()) {
684  pf_thirdjet_et_ = pf_3rdjet.jet()->et();
685  pf_thirdjet_pt_ = pf_3rdjet.jet()->pt();
686  pf_thirdjet_p_ = pf_3rdjet.jet()->p();
687  pf_thirdjet_px_ = pf_3rdjet.jet()->px();
688  pf_thirdjet_py_ = pf_3rdjet.jet()->py();
689  pf_thirdjet_E_ = pf_3rdjet.jet()->energy();
690  pf_thirdjet_eta_= pf_3rdjet.jet()->eta();
691  pf_thirdjet_phi_= pf_3rdjet.jet()->phi();
692  pf_thirdjet_scale_= pf_3rdjet.scale();
693  }
694  else {
695  pf_thirdjet_et_ = 0;
700  }
701 
702  HERE("fill PF jet");
703 
704  int types = 0;
705  int ntypes = 0;
706 
708  // Get PF constituents and fill HCAL towers
710 
711  // fill jet variables
712  // First start from a second jet, then fill the first jet
713  PFJetCorretPair pfjet_probe_store = pfjet_probe;
714  for (int iJet=2; iJet>0; iJet--) {
715  // prepare the container
717 
718  if (iJet==2) pfjet_probe= pf_2ndjet;
719  else pfjet_probe = pfjet_probe_store;
720 
721  if(!pfjet_probe.jet()) {
722  if (iJet==2) {
723  // put zeros into 2nd jet quantities
725  } else {
726  edm::LogWarning("GammaJetAnalysis") << "error in the code: leading pf jet is null";
727  }
728  continue;
729  }
730 
731  HERE("work further");
732 
733  // temporary variables
734  std::map<int,std::pair<int,std::set<float>>> ppfjet_rechits;
735  std::map<float,int> ppfjet_clusters;
736 
737  // fill the values
738  ppfjet_pt_ = pfjet_probe.jet()->pt();
739  ppfjet_p_ = pfjet_probe.jet()->p();
740  ppfjet_eta_ = pfjet_probe.jet()->eta();
741  ppfjet_area_ = pfjet_probe.jet()->jetArea();
742  ppfjet_E_ = pfjet_probe.jet()->energy();
744  ppfjet_phi_ = pfjet_probe.jet()->phi();
747  ppfjet_nConstituents_ = pfjet_probe.jet()->nConstituents();
751  ppfjet_scale_ = pfjet_probe.scale();
752  ppfjet_ntwrs_=0;
755 
756  HERE("Get PF constituents");
757 
758  // Get PF constituents and fill HCAL towers
759  std::vector<reco::PFCandidatePtr> probeconst=pfjet_probe.jet()->getPFConstituents();
760  HERE(Form("probeconst.size=%d",int(probeconst.size())));
761  int iPF=0;
762  for(std::vector<reco::PFCandidatePtr>::const_iterator it=probeconst.begin(); it!=probeconst.end(); ++it){
763  bool hasTrack = false;
764  if (!(*it)) HERE("\tnull probeconst iterator value\n");
765  reco::PFCandidate::ParticleType candidateType = (*it)->particleId();
766  iPF++;
767  HERE(Form("iPF=%d",iPF));
768 
769  // store information
770  switch(candidateType){
772  ppfjet_unkown_E_ += (*it)->energy();
773  ppfjet_unkown_px_ += (*it)->px();
774  ppfjet_unkown_py_ += (*it)->py();
775  ppfjet_unkown_pz_ += (*it)->pz();
776  ppfjet_unkown_EcalE_ += (*it)->ecalEnergy();
778  continue;
780  {
781  ppfjet_had_E_.push_back((*it)->energy());
782  ppfjet_had_px_.push_back((*it)->px());
783  ppfjet_had_py_.push_back((*it)->py());
784  ppfjet_had_pz_.push_back((*it)->pz());
785  ppfjet_had_EcalE_.push_back((*it)->ecalEnergy());
786  ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy());
787  ppfjet_had_id_.push_back(0);
788  ppfjet_had_ntwrs_.push_back(0);
789  ppfjet_had_n_++;
790 
791  if(doGenJets_){
792  float gendr = 99999;
793  float genE = 0;
794  int genpdgId = 0;
795  for(std::vector<reco::GenParticle>::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){
796  if(itmc->status() == 1 && itmc->pdgId() > 100){
797  double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi());
798  if(dr < gendr){
799  gendr = dr;
800  genE = itmc->energy();
801  genpdgId = itmc->pdgId();
802  }
803  }
804  }
805  ppfjet_had_E_mctruth_.push_back(genE);
806  ppfjet_had_mcpdgId_.push_back(genpdgId);
807  }
808 
809  reco::TrackRef trackRef = (*it)->trackRef();
810  if(trackRef.isNonnull()){
811  reco::Track track = *trackRef;
812  ppfjet_candtrack_px_.push_back(track.px());
813  ppfjet_candtrack_py_.push_back(track.py());
814  ppfjet_candtrack_pz_.push_back(track.pz());
815  ppfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy());
817  hasTrack = true;
819  }
820  else{
821  ppfjet_had_candtrackind_.push_back(-2);
822  }
823  }
824  break;
826  ppfjet_electron_E_ += (*it)->energy();
827  ppfjet_electron_px_ += (*it)->px();
828  ppfjet_electron_py_ += (*it)->py();
829  ppfjet_electron_pz_ += (*it)->pz();
830  ppfjet_electron_EcalE_ += (*it)->ecalEnergy();
832  continue;
834  ppfjet_muon_E_ += (*it)->energy();
835  ppfjet_muon_px_ += (*it)->px();
836  ppfjet_muon_py_ += (*it)->py();
837  ppfjet_muon_pz_ += (*it)->pz();
838  ppfjet_muon_EcalE_ += (*it)->ecalEnergy();
839  ppfjet_muon_n_++;
840  continue;
842  ppfjet_photon_E_ += (*it)->energy();
843  ppfjet_photon_px_ += (*it)->px();
844  ppfjet_photon_py_ += (*it)->py();
845  ppfjet_photon_pz_ += (*it)->pz();
846  ppfjet_photon_EcalE_ += (*it)->ecalEnergy();
848  continue;
850  {
851  ppfjet_had_E_.push_back((*it)->energy());
852  ppfjet_had_px_.push_back((*it)->px());
853  ppfjet_had_py_.push_back((*it)->py());
854  ppfjet_had_pz_.push_back((*it)->pz());
855  ppfjet_had_EcalE_.push_back((*it)->ecalEnergy());
856  ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy());
857  ppfjet_had_id_.push_back(1);
858  ppfjet_had_candtrackind_.push_back(-1);
859  ppfjet_had_ntwrs_.push_back(0);
860  ppfjet_had_n_++;
861 
862  if(doGenJets_){
863  float gendr = 99999;
864  float genE = 0;
865  int genpdgId = 0;
866  for(std::vector<reco::GenParticle>::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){
867  if(itmc->status() == 1 && itmc->pdgId() > 100){
868  double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi());
869  if(dr < gendr){
870  gendr = dr;
871  genE = itmc->energy();
872  genpdgId = itmc->pdgId();
873  }
874  }
875  }
876  ppfjet_had_E_mctruth_.push_back(genE);
877  ppfjet_had_mcpdgId_.push_back(genpdgId);
878  }
879 
880  break;
881  }
883  {
884  ppfjet_had_E_.push_back((*it)->energy());
885  ppfjet_had_px_.push_back((*it)->px());
886  ppfjet_had_py_.push_back((*it)->py());
887  ppfjet_had_pz_.push_back((*it)->pz());
888  ppfjet_had_EcalE_.push_back((*it)->ecalEnergy());
889  ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy());
890  ppfjet_had_id_.push_back(2);
891  ppfjet_had_candtrackind_.push_back(-1);
892  ppfjet_had_ntwrs_.push_back(0);
893  ppfjet_had_n_++;
894 
895  if(doGenJets_){
896  float gendr = 99999;
897  float genE = 0;
898  int genpdgId = 0;
899  for(std::vector<reco::GenParticle>::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){
900  if(itmc->status() == 1 && itmc->pdgId() > 100){
901  double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi());
902  if(dr < gendr){
903  gendr = dr;
904  genE = itmc->energy();
905  genpdgId = itmc->pdgId();
906  }
907  }
908  }
909  ppfjet_had_E_mctruth_.push_back(genE);
910  ppfjet_had_mcpdgId_.push_back(genpdgId);
911  }
912 
913  break;
914  }
916  {
917  ppfjet_had_E_.push_back((*it)->energy());
918  ppfjet_had_px_.push_back((*it)->px());
919  ppfjet_had_py_.push_back((*it)->py());
920  ppfjet_had_pz_.push_back((*it)->pz());
921  ppfjet_had_EcalE_.push_back((*it)->ecalEnergy());
922  ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy());
923  ppfjet_had_id_.push_back(3);
924  ppfjet_had_candtrackind_.push_back(-1);
925  ppfjet_had_ntwrs_.push_back(0);
926  ppfjet_had_n_++;
927 
928  if(doGenJets_){
929  float gendr = 99999;
930  float genE = 0;
931  int genpdgId = 0;
932  for(std::vector<reco::GenParticle>::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){
933  if(itmc->status() == 1 && itmc->pdgId() > 100){
934  double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi());
935  if(dr < gendr){
936  gendr = dr;
937  genE = itmc->energy();
938  genpdgId = itmc->pdgId();
939  }
940  }
941  }
942  ppfjet_had_E_mctruth_.push_back(genE);
943  ppfjet_had_mcpdgId_.push_back(genpdgId);
944  }
945 
946  break;
947  }
948  }
949 
950  float HFHAD_E = 0;
951  float HFEM_E = 0;
952  int HFHAD_n_ = 0;
953  int HFEM_n_ = 0;
954  int HF_type_ = 0;
955  int maxElement=(*it)->elementsInBlocks().size();
956  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "maxElement=" << maxElement;
957  if (workOnAOD_==1) {
958  maxElement=0;
959  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "forced 0";
960  }
961  HERE(Form("maxElement=%d",maxElement));
962  for(int e=0; e<maxElement; ++e){
963  // Get elements from block
964  reco::PFBlockRef blockRef = (*it)->elementsInBlocks()[e].first;
965  const edm::OwnVector<reco::PFBlockElement>& elements = blockRef->elements();
966  for(unsigned iEle=0; iEle<elements.size(); iEle++) {
967  if(elements[iEle].index() == (*it)->elementsInBlocks()[e].second){
968  if(elements[iEle].type() == reco::PFBlockElement::HCAL){ // Element is HB or HE
969  HF_type_ |= 0x1;
970  // Get cluster and hits
971  reco::PFClusterRef clusterref = elements[iEle].clusterRef();
972  reco::PFCluster cluster = *clusterref;
973  double cluster_dR = deltaR(ppfjet_eta_,ppfjet_phi_,cluster.eta(),cluster.phi());
974  if(ppfjet_clusters.count(cluster_dR) == 0){
975  ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_;
976  ppfjet_cluster_eta_.push_back(cluster.eta());
977  ppfjet_cluster_phi_.push_back(cluster.phi());
978  ppfjet_cluster_dR_.push_back(cluster_dR);
980  }
981  int cluster_ind = ppfjet_clusters[cluster_dR];
982  std::vector<std::pair<DetId,float>> hitsAndFracs = cluster.hitsAndFractions();
983 
984  // Run over hits and match
985  int nHits = hitsAndFracs.size();
986  for(int iHit=0; iHit<nHits; iHit++){
987  int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first);
988 
989  for(edm::SortedCollection<HBHERecHit,edm::StrictWeakOrdering<HBHERecHit>>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){
990  int etaPhiRecHit = getEtaPhi((*ith).id());
991  if(etaPhiPF == etaPhiRecHit){
993  if(ppfjet_rechits.count((*ith).id()) == 0){
994  ppfjet_twr_ieta_.push_back((*ith).id().ieta());
995  ppfjet_twr_iphi_.push_back((*ith).id().iphi());
996  ppfjet_twr_depth_.push_back((*ith).id().depth());
997  ppfjet_twr_subdet_.push_back((*ith).id().subdet());
998  ppfjet_twr_hade_.push_back((*ith).energy());
999  ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second);
1000  ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second);
1001  ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1);
1002  ppfjet_twr_elmttype_.push_back(0);
1003  ppfjet_twr_clusterind_.push_back(cluster_ind);
1004  if(hasTrack){
1006  }
1007  else{
1008  ppfjet_twr_candtrackind_.push_back(-1);
1009  }
1010  switch((*ith).id().subdet()){
1012  {
1013  const CaloCellGeometry *thisCell = HBGeom->getGeometry((*ith).id().rawId());
1014  const CaloCellGeometry::CornersVec& cv = thisCell->getCorners();
1015  float avgeta = (cv[0].eta() + cv[2].eta())/2.0;
1016  float avgphi = (static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1017  if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHB" << cv[0].phi() << " " << cv[2].phi();
1018  if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1019  ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi));
1020  break;
1021  }
1023  {
1024  const CaloCellGeometry *thisCell = HEGeom->getGeometry((*ith).id().rawId());
1025  const CaloCellGeometry::CornersVec& cv = thisCell->getCorners();
1026  float avgeta = (cv[0].eta() + cv[2].eta())/2.0;
1027  float avgphi = (static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1028  if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHE" << cv[0].phi() << " " << cv[2].phi();
1029  if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1030  ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi));
1031  break;
1032  }
1033  default:
1034  ppfjet_twr_dR_.push_back(-1);
1035  break;
1036  }
1037  ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_;
1038  ++ppfjet_ntwrs_;
1039  }
1040  else if(ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){
1041  ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second;
1042  if(cluster_dR < ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))){
1043  ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind;
1044  }
1045  ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second);
1046  }
1047  } // Test if ieta,iphi matches
1048  } // Loop over rechits
1049  } // Loop over hits
1050  } // Test if element is from HCAL
1051  else if(elements[iEle].type() == reco::PFBlockElement::HFHAD){ // Element is HF
1052  types |= 0x2;
1053  ntypes++;
1054  HFHAD_n_++;
1055  HF_type_ |= 0x2;
1056 
1058 
1059  for(edm::SortedCollection<HFRecHit,edm::StrictWeakOrdering<HFRecHit>>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){
1060  if((*ith).id().depth() == 1) continue; // Remove long fibers
1061  const CaloCellGeometry *thisCell = HFGeom->getGeometry((*ith).id().rawId());
1062  const CaloCellGeometry::CornersVec& cv = thisCell->getCorners();
1063 
1064  bool passMatch = false;
1065  if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){
1066  if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true;
1067  else if(cv[0].phi() < cv[2].phi()){
1068  if((*it)->phi() < cv[0].phi()) passMatch = true;
1069  else if((*it)->phi() > cv[2].phi()) passMatch = true;
1070  }
1071  }
1072 
1073  if(passMatch){
1074  ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++;
1075  ppfjet_twr_ieta_.push_back((*ith).id().ieta());
1076  ppfjet_twr_iphi_.push_back((*ith).id().iphi());
1077  ppfjet_twr_depth_.push_back((*ith).id().depth());
1078  ppfjet_twr_subdet_.push_back((*ith).id().subdet());
1079  ppfjet_twr_hade_.push_back((*ith).energy());
1080  ppfjet_twr_frac_.push_back(1.0);
1081  ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1);
1082  ppfjet_twr_elmttype_.push_back(1);
1083  ppfjet_twr_clusterind_.push_back(-1);
1084  ppfjet_twr_candtrackind_.push_back(-1);
1085  float avgeta = (cv[0].eta() + cv[2].eta())/2.0;
1086  float avgphi = (static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1087  if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHFhad" << cv[0].phi() << " " << cv[2].phi();
1088  if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1089  ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi));
1090  ++ppfjet_ntwrs_;
1091  HFHAD_E += (*ith).energy();
1092  }
1093  }
1094  }
1095  else if(elements[iEle].type() == reco::PFBlockElement::HFEM){ // Element is HF
1096  types |= 0x4;
1097  ntypes++;
1098  HFEM_n_++;
1099  HF_type_ |= 0x4;
1100 
1101  for(edm::SortedCollection<HFRecHit,edm::StrictWeakOrdering<HFRecHit>>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){
1102  if((*ith).id().depth() == 2) continue; // Remove short fibers
1103  const CaloCellGeometry *thisCell = HFGeom->getGeometry((*ith).id().rawId());
1104  const CaloCellGeometry::CornersVec& cv = thisCell->getCorners();
1105 
1106  bool passMatch = false;
1107  if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){
1108  if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true;
1109  else if(cv[0].phi() < cv[2].phi()){
1110  if((*it)->phi() < cv[0].phi()) passMatch = true;
1111  else if((*it)->phi() > cv[2].phi()) passMatch = true;
1112  }
1113  }
1114 
1115  if(passMatch){
1116  ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++;
1117  ppfjet_twr_ieta_.push_back((*ith).id().ieta());
1118  ppfjet_twr_iphi_.push_back((*ith).id().iphi());
1119  ppfjet_twr_depth_.push_back((*ith).id().depth());
1120  ppfjet_twr_subdet_.push_back((*ith).id().subdet());
1121  ppfjet_twr_hade_.push_back((*ith).energy());
1122  ppfjet_twr_frac_.push_back(1.0);
1123  ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1);
1124  ppfjet_twr_elmttype_.push_back(2);
1125  ppfjet_twr_clusterind_.push_back(-1);
1126  ppfjet_twr_candtrackind_.push_back(-1);
1127  float avgeta = (cv[0].eta() + cv[2].eta())/2.0;
1128  float avgphi = (static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1129  if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHFem" << cv[0].phi() << " " << cv[2].phi();
1130  if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1131  ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi));
1132  ++ppfjet_ntwrs_;
1133  HFEM_E += (*ith).energy();
1134  }
1135  }
1136  }
1137  else if(elements[iEle].type() == reco::PFBlockElement::HO){ // Element is HO
1138  types |= 0x8;
1139  ntypes++;
1140  HF_type_ |= 0x8;
1141  reco::PFClusterRef clusterref = elements[iEle].clusterRef();
1142  reco::PFCluster cluster = *clusterref;
1143  double cluster_dR = deltaR(ppfjet_eta_,ppfjet_phi_,cluster.eta(),cluster.phi());
1144  if(ppfjet_clusters.count(cluster_dR) == 0){
1145  ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_;
1146  ppfjet_cluster_eta_.push_back(cluster.eta());
1147  ppfjet_cluster_phi_.push_back(cluster.phi());
1148  ppfjet_cluster_dR_.push_back(cluster_dR);
1150  }
1151  int cluster_ind = ppfjet_clusters[cluster_dR];
1152 
1153  std::vector<std::pair<DetId,float>> hitsAndFracs = cluster.hitsAndFractions();
1154  int nHits = hitsAndFracs.size();
1155  for(int iHit=0; iHit<nHits; iHit++){
1156  int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first);
1157 
1158  for(edm::SortedCollection<HORecHit,edm::StrictWeakOrdering<HORecHit>>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){
1159  int etaPhiRecHit = getEtaPhi((*ith).id());
1160  if(etaPhiPF == etaPhiRecHit){
1161  ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++;
1162  if(ppfjet_rechits.count((*ith).id()) == 0){
1163  ppfjet_twr_ieta_.push_back((*ith).id().ieta());
1164  ppfjet_twr_iphi_.push_back((*ith).id().iphi());
1165  ppfjet_twr_depth_.push_back((*ith).id().depth());
1166  ppfjet_twr_subdet_.push_back((*ith).id().subdet());
1167  ppfjet_twr_hade_.push_back((*ith).energy());
1168  ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second);
1169  ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second);
1170  ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1);
1171  ppfjet_twr_elmttype_.push_back(3);
1172  ppfjet_twr_clusterind_.push_back(cluster_ind);
1173  if(hasTrack){
1175  }
1176  else{
1177  ppfjet_twr_candtrackind_.push_back(-1);
1178  }
1179  const CaloCellGeometry *thisCell = HOGeom->getGeometry((*ith).id().rawId());
1180  const CaloCellGeometry::CornersVec& cv = thisCell->getCorners();
1181  float avgeta = (cv[0].eta() + cv[2].eta())/2.0;
1182  float avgphi = (static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1183  if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHO" << cv[0].phi() << " " << cv[2].phi();
1184  if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast<double>(cv[0].phi()) + static_cast<double>(cv[2].phi()))/2.0;
1185 
1186  ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi));
1187  ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_;
1188  ++ppfjet_ntwrs_;
1189  }
1190  else if(ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){
1191  ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second;
1192  if(cluster_dR < ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))){
1193  ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind;
1194  }
1195  ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second);
1196  }
1197  } // Test if ieta,iphi match
1198  } // Loop over rechits
1199  } // Loop over hits
1200  } // Test if element is from HO
1201  } // Test for right element index
1202  } // Loop over elements
1203  } // Loop over elements in blocks
1204  switch(candidateType){
1206  ppfjet_had_emf_.push_back(HFEM_E/(HFEM_E + HFHAD_E));
1207  break;
1209  ppfjet_had_emf_.push_back(-1);
1210  break;
1211  default:
1212  ppfjet_had_emf_.push_back(-1);
1213  break;
1214  }
1215  } // Loop over PF constitutents
1216 
1217  if(doGenJets_){
1218  // fill genjet variables
1219  ppfjet_gendr_ = 99999.;
1220  ppfjet_genpt_ = 0;
1221  ppfjet_genp_ = 0;
1222  for(std::vector<reco::GenJet>::const_iterator it=genjets->begin(); it!=genjets->end(); ++it){
1223  const reco::GenJet* jet=&(*it);
1224  double dr=deltaR(jet, pfjet_probe.jet());
1225  if(dr<ppfjet_gendr_) {
1226  ppfjet_gendr_ = dr;
1227  ppfjet_genpt_ = jet->pt();
1228  ppfjet_genp_ = jet->p();
1229  ppfjet_genE_ = jet->energy();
1230  }
1231  }
1232  } // doGenJets_
1233  if (iJet==2) {
1235  }
1236  }
1237  // double jer= (ppfjet_genpt_==double(0)) ?
1238  // 0. : pfjet_probe.jet()->et()/ppfjet_genpt_;
1240 
1243  iEvent.getByToken(tok_PFMET_, pfmet_h);
1244  if (!pfmet_h.isValid()) {
1245  edm::LogWarning("GammaJetAnalysis") << " could not find " << pfMETColl;
1246  return;
1247  }
1248  met_value_ = pfmet_h->begin()->et();
1249  met_phi_ = pfmet_h->begin()->phi();
1250  met_sumEt_ = pfmet_h->begin()->sumEt();
1251 
1253  iEvent.getByToken(tok_PFType1MET_, pfmetType1_h);
1254  if ( pfmetType1_h.isValid()) {
1255  metType1_value_ = pfmetType1_h->begin()->et();
1256  metType1_phi_ = pfmetType1_h->begin()->phi();
1257  metType1_sumEt_ = pfmetType1_h->begin()->sumEt();
1258  }
1259  else {
1260  // do we need an exception here?
1261  metType1_value_ = -999.;
1262  metType1_phi_ = -999.;
1263  metType1_sumEt_ = -999.;
1264  }
1265 
1266 
1267  // fill photon+jet variables
1268  pf_tree_->Fill();
1269  }
1270  }
1271  return;
1272 
1273 }
1274 
1275 // ------------ method called once each job just before starting event loop ------------
1277 {
1278  rootfile_ = new TFile(rootHistFilename_.c_str(), "RECREATE");
1279  if (doPFJets_) {
1280  pf_tree_ = new TTree("pf_gammajettree", "tree for gamma+jet balancing using PFJets");
1281  assert(pf_tree_);
1282  }
1283 
1284  for (int iJet=0; iJet<2; iJet++) {
1285  bool doJet=doPFJets_;
1286  if (!doJet) continue;
1287  if (iJet>0) continue; // ! caloJet are no longer there, so store only once
1288  TTree *tree= pf_tree_;
1289 
1290  // Event triggers
1291  tree->Branch("photonTrig_fired", &photonTrigFired_);
1292  tree->Branch("photonTrig_prescale", &photonTrigPrescale_);
1293  tree->Branch("jetTrig_fired", &jetTrigFired_);
1294  tree->Branch("jetTrig_prescale", &jetTrigPrescale_);
1295 
1296  // Event info
1297  tree->Branch("RunNumber",&runNumber_, "RunNumber/I");
1298  tree->Branch("LumiBlock",&lumiBlock_, "LumiBlock/I");
1299  tree->Branch("EventNumber",&eventNumber_, "EventNumber/I");
1300  tree->Branch("EventWeight",&eventWeight_, "EventWeight/F");
1301  tree->Branch("EventPtHat",&eventPtHat_, "EventPtHat/F");
1302 
1303  // Photon info
1304  tree->Branch("rho2012", &rho2012_, "rho2012/F");
1305  tree->Branch("tagPho_pt", &tagPho_pt_, "tagPho_pt/F");
1306  tree->Branch("pho_2nd_pt", &pho_2nd_pt_, "pho_2nd_pt/F");
1307  tree->Branch("tagPho_energy", &tagPho_energy_, "tagPho_energy/F");
1308  tree->Branch("tagPho_eta", &tagPho_eta_, "tagPho_eta/F");
1309  tree->Branch("tagPho_phi", &tagPho_phi_, "tagPho_phi/F");
1310  tree->Branch("tagPho_sieie", &tagPho_sieie_, "tagPho_sieie/F");
1311  tree->Branch("tagPho_HoE", &tagPho_HoE_, "tagPho_HoE/F");
1312  tree->Branch("tagPho_r9", &tagPho_r9_, "tagPho_r9/F");
1313  tree->Branch("tagPho_EcalIsoDR04",&tagPho_EcalIsoDR04_, "tagPho_EcalIsoDR04/F");
1314  tree->Branch("tagPho_HcalIsoDR04",&tagPho_HcalIsoDR04_, "tagPho_HcalIsoDR04/F");
1315  tree->Branch("tagPho_HcalIsoDR0412",&tagPho_HcalIsoDR0412_, "tagPho_HcalIsoDR0412/F");
1316  tree->Branch("tagPho_TrkIsoHollowDR04",&tagPho_TrkIsoHollowDR04_, "tagPho_TrkIsoHollowDR04/F");
1317  tree->Branch("tagPho_pfiso_myphoton03",&tagPho_pfiso_myphoton03_, "tagPho_pfiso_myphoton03/F");
1318  tree->Branch("tagPho_pfiso_myneutral03",&tagPho_pfiso_myneutral03_, "tagPho_pfiso_myneutral03/F");
1319  tree->Branch("tagPho_pfiso_mycharged03","std::vector<std::vector<float> >", &tagPho_pfiso_mycharged03);
1320  tree->Branch("tagPho_pixelSeed", &tagPho_pixelSeed_, "tagPho_pixelSeed/I");
1321  tree->Branch("tagPho_ConvSafeEleVeto", &tagPho_ConvSafeEleVeto_, "tagPho_ConvSafeEleVeto/I");
1322  tree->Branch("tagPho_idTight",&tagPho_idTight_, "tagPho_idTight/I");
1323  tree->Branch("tagPho_idLoose",&tagPho_idLoose_, "tagPho_idLoose/I");
1324  // gen.info on photon
1325  if(doGenJets_){
1326  tree->Branch("tagPho_genPt",&tagPho_genPt_, "tagPho_genPt/F");
1327  tree->Branch("tagPho_genEnergy",&tagPho_genEnergy_,"tagPho_genEnergy/F");
1328  tree->Branch("tagPho_genEta",&tagPho_genEta_, "tagPho_genEta/F");
1329  tree->Branch("tagPho_genPhi",&tagPho_genPhi_, "tagPho_genPhi/F");
1330  tree->Branch("tagPho_genDeltaR",&tagPho_genDeltaR_,"tagPho_genDeltaR/F");
1331  }
1332  // counters
1333  tree->Branch("nPhotons",&nPhotons_, "nPhotons/I");
1334  tree->Branch("nGenJets",&nGenJets_, "nGenJets/I");
1335  }
1336 
1338 
1339  if (doPFJets_) {
1340 
1341  pf_tree_->Branch("nPFJets",&nPFJets_, "nPFJets/I");
1342 
1343  // Leading jet info
1344  pf_tree_->Branch("ppfjet_pt",&ppfjet_pt_, "ppfjet_pt/F");
1345  pf_tree_->Branch("ppfjet_p",&ppfjet_p_, "ppfjet_p/F");
1346  pf_tree_->Branch("ppfjet_E",&ppfjet_E_, "ppfjet_E/F");
1347  pf_tree_->Branch("ppfjet_E_NPVcorr",&ppfjet_E_NPVcorr_, "ppfjet_E_NPVcorr/F");
1348  pf_tree_->Branch("ppfjet_area",&ppfjet_area_, "ppfjet_area/F");
1349  pf_tree_->Branch("ppfjet_eta",&ppfjet_eta_, "ppfjet_eta/F");
1350  pf_tree_->Branch("ppfjet_phi",&ppfjet_phi_, "ppfjet_phi/F");
1351  pf_tree_->Branch("ppfjet_scale",&ppfjet_scale_, "ppfjet_scale/F");
1352  pf_tree_->Branch("ppfjet_NeutralHadronFrac", &ppfjet_NeutralHadronFrac_, "ppfjet_NeutralHadronFrac/F");
1353  pf_tree_->Branch("ppfjet_NeutralEMFrac", &ppfjet_NeutralEMFrac_, "ppfjet_NeutralEMFrac/F");
1354  pf_tree_->Branch("ppfjet_nConstituents", &ppfjet_nConstituents_, "ppfjet_nConstituents/I");
1355  pf_tree_->Branch("ppfjet_ChargedHadronFrac", &ppfjet_ChargedHadronFrac_, "ppfjet_ChargedHadronFrac/F");
1356  pf_tree_->Branch("ppfjet_ChargedMultiplicity", &ppfjet_ChargedMultiplicity_, "ppfjet_ChargedMultiplicity/F");
1357  pf_tree_->Branch("ppfjet_ChargedEMFrac", &ppfjet_ChargedEMFrac_, "ppfjet_ChargedEMFrac/F");
1358  if(doGenJets_){
1359  pf_tree_->Branch("ppfjet_genpt",&ppfjet_genpt_, "ppfjet_genpt/F");
1360  pf_tree_->Branch("ppfjet_genp",&ppfjet_genp_, "ppfjet_genp/F");
1361  pf_tree_->Branch("ppfjet_genE",&ppfjet_genE_, "ppfjet_genE/F");
1362  pf_tree_->Branch("ppfjet_gendr",&ppfjet_gendr_, "ppfjet_gendr/F");
1363  }
1364  pf_tree_->Branch("ppfjet_unkown_E",&ppfjet_unkown_E_, "ppfjet_unkown_E/F");
1365  pf_tree_->Branch("ppfjet_electron_E",&ppfjet_electron_E_, "ppfjet_electron_E/F");
1366  pf_tree_->Branch("ppfjet_muon_E",&ppfjet_muon_E_, "ppfjet_muon_E/F");
1367  pf_tree_->Branch("ppfjet_photon_E",&ppfjet_photon_E_, "ppfjet_photon_E/F");
1368  pf_tree_->Branch("ppfjet_unkown_px",&ppfjet_unkown_px_, "ppfjet_unkown_px/F");
1369  pf_tree_->Branch("ppfjet_electron_px",&ppfjet_electron_px_, "ppfjet_electron_px/F");
1370  pf_tree_->Branch("ppfjet_muon_px",&ppfjet_muon_px_, "ppfjet_muon_px/F");
1371  pf_tree_->Branch("ppfjet_photon_px",&ppfjet_photon_px_, "ppfjet_photon_px/F");
1372  pf_tree_->Branch("ppfjet_unkown_py",&ppfjet_unkown_py_, "ppfjet_unkown_py/F");
1373  pf_tree_->Branch("ppfjet_electron_py",&ppfjet_electron_py_, "ppfjet_electron_py/F");
1374  pf_tree_->Branch("ppfjet_muon_py",&ppfjet_muon_py_, "ppfjet_muon_py/F");
1375  pf_tree_->Branch("ppfjet_photon_py",&ppfjet_photon_py_, "ppfjet_photon_py/F");
1376  pf_tree_->Branch("ppfjet_unkown_pz",&ppfjet_unkown_pz_, "ppfjet_unkown_pz/F");
1377  pf_tree_->Branch("ppfjet_electron_pz",&ppfjet_electron_pz_, "ppfjet_electron_pz/F");
1378  pf_tree_->Branch("ppfjet_muon_pz",&ppfjet_muon_pz_, "ppfjet_muon_pz/F");
1379  pf_tree_->Branch("ppfjet_photon_pz",&ppfjet_photon_pz_, "ppfjet_photon_pz/F");
1380  pf_tree_->Branch("ppfjet_unkown_EcalE",&ppfjet_unkown_EcalE_, "ppfjet_unkown_EcalE/F");
1381  pf_tree_->Branch("ppfjet_electron_EcalE",&ppfjet_electron_EcalE_, "ppfjet_electron_EcalE/F");
1382  pf_tree_->Branch("ppfjet_muon_EcalE",&ppfjet_muon_EcalE_, "ppfjet_muon_EcalE/F");
1383  pf_tree_->Branch("ppfjet_photon_EcalE",&ppfjet_photon_EcalE_, "ppfjet_photon_EcalE/F");
1384  pf_tree_->Branch("ppfjet_unkown_n",&ppfjet_unkown_n_, "ppfjet_unkown_n/I");
1385  pf_tree_->Branch("ppfjet_electron_n",&ppfjet_electron_n_, "ppfjet_electron_n/I");
1386  pf_tree_->Branch("ppfjet_muon_n",&ppfjet_muon_n_, "ppfjet_muon_n/I");
1387  pf_tree_->Branch("ppfjet_photon_n",&ppfjet_photon_n_, "ppfjet_photon_n/I");
1388  pf_tree_->Branch("ppfjet_had_n",&ppfjet_had_n_, "ppfjet_had_n/I");
1389  pf_tree_->Branch("ppfjet_had_E",&ppfjet_had_E_);
1390  pf_tree_->Branch("ppfjet_had_px",&ppfjet_had_px_);
1391  pf_tree_->Branch("ppfjet_had_py",&ppfjet_had_py_);
1392  pf_tree_->Branch("ppfjet_had_pz",&ppfjet_had_pz_);
1393  pf_tree_->Branch("ppfjet_had_EcalE",&ppfjet_had_EcalE_);
1394  pf_tree_->Branch("ppfjet_had_rawHcalE",&ppfjet_had_rawHcalE_);
1395  pf_tree_->Branch("ppfjet_had_emf",&ppfjet_had_emf_);
1396  pf_tree_->Branch("ppfjet_had_id",&ppfjet_had_id_);
1397  pf_tree_->Branch("ppfjet_had_candtrackind",&ppfjet_had_candtrackind_);
1398  if(doGenJets_){
1399  pf_tree_->Branch("ppfjet_had_E_mctruth",&ppfjet_had_E_mctruth_);
1400  pf_tree_->Branch("ppfjet_had_mcpdgId",&ppfjet_had_mcpdgId_);
1401  }
1402  pf_tree_->Branch("ppfjet_had_ntwrs",&ppfjet_had_ntwrs_);
1403  pf_tree_->Branch("ppfjet_ntwrs",&ppfjet_ntwrs_, "ppfjet_ntwrs/I");
1404  pf_tree_->Branch("ppfjet_twr_ieta",&ppfjet_twr_ieta_);
1405  pf_tree_->Branch("ppfjet_twr_iphi",&ppfjet_twr_iphi_);
1406  pf_tree_->Branch("ppfjet_twr_depth",&ppfjet_twr_depth_);
1407  pf_tree_->Branch("ppfjet_twr_subdet",&ppfjet_twr_subdet_);
1408  pf_tree_->Branch("ppfjet_twr_hade",&ppfjet_twr_hade_);
1409  pf_tree_->Branch("ppfjet_twr_frac",&ppfjet_twr_frac_);
1410  pf_tree_->Branch("ppfjet_twr_candtrackind",&ppfjet_twr_candtrackind_);
1411  pf_tree_->Branch("ppfjet_twr_hadind",&ppfjet_twr_hadind_);
1412  pf_tree_->Branch("ppfjet_twr_elmttype",&ppfjet_twr_elmttype_);
1413  pf_tree_->Branch("ppfjet_twr_dR",&ppfjet_twr_dR_);
1414  pf_tree_->Branch("ppfjet_twr_clusterind",&ppfjet_twr_clusterind_);
1415  pf_tree_->Branch("ppfjet_cluster_n",&ppfjet_cluster_n_, "ppfjet_cluster_n/I");
1416  pf_tree_->Branch("ppfjet_cluster_eta",&ppfjet_cluster_eta_);
1417  pf_tree_->Branch("ppfjet_cluster_phi",&ppfjet_cluster_phi_);
1418  pf_tree_->Branch("ppfjet_cluster_dR",&ppfjet_cluster_dR_);
1419  pf_tree_->Branch("ppfjet_ncandtracks",&ppfjet_ncandtracks_, "ppfjet_ncandtracks/I");
1420  pf_tree_->Branch("ppfjet_candtrack_px",&ppfjet_candtrack_px_);
1421  pf_tree_->Branch("ppfjet_candtrack_py",&ppfjet_candtrack_py_);
1422  pf_tree_->Branch("ppfjet_candtrack_pz",&ppfjet_candtrack_pz_);
1423  pf_tree_->Branch("ppfjet_candtrack_EcalE",&ppfjet_candtrack_EcalE_);
1424 
1425  // Subleading jet info
1426  pf_tree_->Branch("pfjet2_pt",&pfjet2_pt_, "pfjet2_pt/F");
1427  pf_tree_->Branch("pfjet2_p",&pfjet2_p_, "pfjet2_p/F");
1428  pf_tree_->Branch("pfjet2_E",&pfjet2_E_, "pfjet2_E/F");
1429  pf_tree_->Branch("pfjet2_E_NPVcorr",&pfjet2_E_NPVcorr_, "pfjet2_E_NPVcorr/F");
1430  pf_tree_->Branch("pfjet2_area",&pfjet2_area_, "pfjet2_area/F");
1431  pf_tree_->Branch("pfjet2_eta",&pfjet2_eta_, "pfjet2_eta/F");
1432  pf_tree_->Branch("pfjet2_phi",&pfjet2_phi_, "pfjet2_phi/F");
1433  pf_tree_->Branch("pfjet2_scale",&pfjet2_scale_, "pfjet2_scale/F");
1434  pf_tree_->Branch("pfjet2_NeutralHadronFrac", &pfjet2_NeutralHadronFrac_, "pfjet2_NeutralHadronFrac/F");
1435  pf_tree_->Branch("pfjet2_NeutralEMFrac", &pfjet2_NeutralEMFrac_, "pfjet2_NeutralEMFrac/F");
1436  pf_tree_->Branch("pfjet2_nConstituents", &pfjet2_nConstituents_, "pfjet2_nConstituents/I");
1437  pf_tree_->Branch("pfjet2_ChargedHadronFrac", &pfjet2_ChargedHadronFrac_, "pfjet2_ChargedHadronFrac/F");
1438  pf_tree_->Branch("pfjet2_ChargedMultiplicity", &pfjet2_ChargedMultiplicity_, "pfjet2_ChargedMultiplicity/F");
1439  pf_tree_->Branch("pfjet2_ChargedEMFrac", &pfjet2_ChargedEMFrac_, "pfjet2_ChargedEMFrac/F");
1440  if(doGenJets_){
1441  pf_tree_->Branch("pfjet2_genpt",&pfjet2_genpt_, "pfjet2_genpt/F");
1442  pf_tree_->Branch("pfjet2_genp",&pfjet2_genp_, "pfjet2_genp/F");
1443  pf_tree_->Branch("pfjet2_genE",&pfjet2_genE_, "pfjet2_genE/F");
1444  pf_tree_->Branch("pfjet2_gendr",&pfjet2_gendr_, "pfjet2_gendr/F");
1445  }
1446  pf_tree_->Branch("pfjet2_unkown_E",&pfjet2_unkown_E_, "pfjet2_unkown_E/F");
1447  pf_tree_->Branch("pfjet2_electron_E",&pfjet2_electron_E_, "pfjet2_electron_E/F");
1448  pf_tree_->Branch("pfjet2_muon_E",&pfjet2_muon_E_, "pfjet2_muon_E/F");
1449  pf_tree_->Branch("pfjet2_photon_E",&pfjet2_photon_E_, "pfjet2_photon_E/F");
1450  pf_tree_->Branch("pfjet2_unkown_px",&pfjet2_unkown_px_, "pfjet2_unkown_px/F");
1451  pf_tree_->Branch("pfjet2_electron_px",&pfjet2_electron_px_, "pfjet2_electron_px/F");
1452  pf_tree_->Branch("pfjet2_muon_px",&pfjet2_muon_px_, "pfjet2_muon_px/F");
1453  pf_tree_->Branch("pfjet2_photon_px",&pfjet2_photon_px_, "pfjet2_photon_px/F");
1454  pf_tree_->Branch("pfjet2_unkown_py",&pfjet2_unkown_py_, "pfjet2_unkown_py/F");
1455  pf_tree_->Branch("pfjet2_electron_py",&pfjet2_electron_py_, "pfjet2_electron_py/F");
1456  pf_tree_->Branch("pfjet2_muon_py",&pfjet2_muon_py_, "pfjet2_muon_py/F");
1457  pf_tree_->Branch("pfjet2_photon_py",&pfjet2_photon_py_, "pfjet2_photon_py/F");
1458  pf_tree_->Branch("pfjet2_unkown_pz",&pfjet2_unkown_pz_, "pfjet2_unkown_pz/F");
1459  pf_tree_->Branch("pfjet2_electron_pz",&pfjet2_electron_pz_, "pfjet2_electron_pz/F");
1460  pf_tree_->Branch("pfjet2_muon_pz",&pfjet2_muon_pz_, "pfjet2_muon_pz/F");
1461  pf_tree_->Branch("pfjet2_photon_pz",&pfjet2_photon_pz_, "pfjet2_photon_pz/F");
1462  pf_tree_->Branch("pfjet2_unkown_EcalE",&pfjet2_unkown_EcalE_, "pfjet2_unkown_EcalE/F");
1463  pf_tree_->Branch("pfjet2_electron_EcalE",&pfjet2_electron_EcalE_, "pfjet2_electron_EcalE/F");
1464  pf_tree_->Branch("pfjet2_muon_EcalE",&pfjet2_muon_EcalE_, "pfjet2_muon_EcalE/F");
1465  pf_tree_->Branch("pfjet2_photon_EcalE",&pfjet2_photon_EcalE_, "pfjet2_photon_EcalE/F");
1466  pf_tree_->Branch("pfjet2_unkown_n",&pfjet2_unkown_n_, "pfjet2_unkown_n/I");
1467  pf_tree_->Branch("pfjet2_electron_n",&pfjet2_electron_n_, "pfjet2_electron_n/I");
1468  pf_tree_->Branch("pfjet2_muon_n",&pfjet2_muon_n_, "pfjet2_muon_n/I");
1469  pf_tree_->Branch("pfjet2_photon_n",&pfjet2_photon_n_, "pfjet2_photon_n/I");
1470  pf_tree_->Branch("pfjet2_had_n",&pfjet2_had_n_, "pfjet2_had_n/I");
1471  pf_tree_->Branch("pfjet2_had_E",&pfjet2_had_E_);
1472  pf_tree_->Branch("pfjet2_had_px",&pfjet2_had_px_);
1473  pf_tree_->Branch("pfjet2_had_py",&pfjet2_had_py_);
1474  pf_tree_->Branch("pfjet2_had_pz",&pfjet2_had_pz_);
1475  pf_tree_->Branch("pfjet2_had_EcalE",&pfjet2_had_EcalE_);
1476  pf_tree_->Branch("pfjet2_had_rawHcalE",&pfjet2_had_rawHcalE_);
1477  pf_tree_->Branch("pfjet2_had_emf",&pfjet2_had_emf_);
1478  pf_tree_->Branch("pfjet2_had_id",&pfjet2_had_id_);
1479  pf_tree_->Branch("pfjet2_had_candtrackind",&pfjet2_had_candtrackind_);
1480  if(doGenJets_){
1481  pf_tree_->Branch("pfjet2_had_E_mctruth",&pfjet2_had_E_mctruth_);
1482  pf_tree_->Branch("pfjet2_had_mcpdgId",&pfjet2_had_mcpdgId_);
1483  }
1484  pf_tree_->Branch("pfjet2_had_ntwrs",&pfjet2_had_ntwrs_);
1485  pf_tree_->Branch("pfjet2_ntwrs",&pfjet2_ntwrs_, "pfjet2_ntwrs/I");
1486  pf_tree_->Branch("pfjet2_twr_ieta",&pfjet2_twr_ieta_);
1487  pf_tree_->Branch("pfjet2_twr_iphi",&pfjet2_twr_iphi_);
1488  pf_tree_->Branch("pfjet2_twr_depth",&pfjet2_twr_depth_);
1489  pf_tree_->Branch("pfjet2_twr_subdet",&pfjet2_twr_subdet_);
1490  pf_tree_->Branch("pfjet2_twr_hade",&pfjet2_twr_hade_);
1491  pf_tree_->Branch("pfjet2_twr_frac",&pfjet2_twr_frac_);
1492  pf_tree_->Branch("pfjet2_twr_candtrackind",&pfjet2_twr_candtrackind_);
1493  pf_tree_->Branch("pfjet2_twr_hadind",&pfjet2_twr_hadind_);
1494  pf_tree_->Branch("pfjet2_twr_elmttype",&pfjet2_twr_elmttype_);
1495  pf_tree_->Branch("pfjet2_twr_dR",&pfjet2_twr_dR_);
1496  pf_tree_->Branch("pfjet2_twr_clusterind",&pfjet2_twr_clusterind_);
1497  pf_tree_->Branch("pfjet2_cluster_n",&pfjet2_cluster_n_, "pfjet2_cluster_n/I");
1498  pf_tree_->Branch("pfjet2_cluster_eta",&pfjet2_cluster_eta_);
1499  pf_tree_->Branch("pfjet2_cluster_phi",&pfjet2_cluster_phi_);
1500  pf_tree_->Branch("pfjet2_cluster_dR",&pfjet2_cluster_dR_);
1501  pf_tree_->Branch("pfjet2_ncandtracks",&pfjet2_ncandtracks_, "pfjet2_ncandtracks/I");
1502  pf_tree_->Branch("pfjet2_candtrack_px",&pfjet2_candtrack_px_);
1503  pf_tree_->Branch("pfjet2_candtrack_py",&pfjet2_candtrack_py_);
1504  pf_tree_->Branch("pfjet2_candtrack_pz",&pfjet2_candtrack_pz_);
1505  pf_tree_->Branch("pfjet2_candtrack_EcalE",&pfjet2_candtrack_EcalE_);
1506 
1507  // third pf jet
1508  pf_tree_->Branch("pf_thirdjet_et", &pf_thirdjet_et_, "pf_thirdjet_et/F");
1509  pf_tree_->Branch("pf_thirdjet_pt", &pf_thirdjet_pt_, "pf_thirdjet_pt/F");
1510  pf_tree_->Branch("pf_thirdjet_p", &pf_thirdjet_p_, "pf_thirdjet_p/F");
1511  pf_tree_->Branch("pf_thirdjet_px", &pf_thirdjet_px_, "pf_thirdjet_px/F");
1512  pf_tree_->Branch("pf_thirdjet_py", &pf_thirdjet_py_, "pf_thirdjet_py/F");
1513  pf_tree_->Branch("pf_thirdjet_E", &pf_thirdjet_E_, "pf_thirdjet_E/F");
1514  pf_tree_->Branch("pf_thirdjet_eta", &pf_thirdjet_eta_, "pf_thirdjet_eta/F");
1515  pf_tree_->Branch("pf_thirdjet_phi", &pf_thirdjet_phi_, "pf_thirdjet_phi/F");
1516  pf_tree_->Branch("pf_thirdjet_scale", &pf_thirdjet_scale_, "pf_thirdjet_scale/F");
1517 
1518  pf_tree_->Branch("met_value", &met_value_, "met_value/F");
1519  pf_tree_->Branch("met_phi", &met_phi_, "met_phi/F");
1520  pf_tree_->Branch("met_sumEt", &met_sumEt_, "met_sumEt/F");
1521  pf_tree_->Branch("metType1_value", &metType1_value_, "metType1_value/F");
1522  pf_tree_->Branch("metType1_phi", &metType1_phi_, "metType1_phi/F");
1523  pf_tree_->Branch("metType1_sumEt", &metType1_sumEt_, "metType1_sumEt/F");
1524  pf_tree_->Branch("pf_NPV",&pf_NPV_, "pf_NPV/I");
1525  }
1526 
1527  return;
1528 }
1529 
1530 // ------------ method called once each job just after ending the event loop ------------
1531 void
1533  rootfile_->cd();
1534 
1535  if(doPFJets_){
1536  pf_tree_->Write();
1537  }
1538  // write miscItems
1539  // Save info about the triggers and other misc items
1540  {
1541  rootfile_->cd();
1542  rootfile_->mkdir("miscItems");
1543  rootfile_->cd("miscItems");
1544  misc_tree_= new TTree("misc_tree","tree for misc.info");
1545  misc_tree_->Branch("ignoreHLT",&ignoreHLT_,"ignoreHLT/O");
1546  misc_tree_->Branch("doPFJets",&doPFJets_,"doPFJets/O");
1547  misc_tree_->Branch("doGenJets",&doGenJets_,"doGenJets/O");
1548  misc_tree_->Branch("workOnAOD",&workOnAOD_,"workOnAOD/O");
1549  misc_tree_->Branch("photonTriggerNames",&photonTrigNamesV_);
1550  misc_tree_->Branch("jetTriggerNames",&jetTrigNamesV_);
1551  misc_tree_->Branch("nProcessed",&nProcessed_,"nProcessed/l");
1552  // put time stamp
1553  time_t ltime;
1554  ltime=time(NULL);
1555  TString str = TString(asctime(localtime(&ltime)));
1556  if (str[str.Length()-1]=='\n') str.Remove(str.Length()-1,1);
1557  TObjString date(str);
1558  date.Write(str.Data());
1559  misc_tree_->Fill();
1560  misc_tree_->Write();
1561  rootfile_->cd();
1562  }
1563 
1564  rootfile_->Close();
1565 }
1566 
1567 
1568 // ---------------------------------------------------------------------
1569 
1571  const edm::EventSetup &setup) {
1572  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "beginRun()";
1573 
1574  if (!ignoreHLT_) {
1575  int noPhotonTrigger= (photonTrigNamesV_.size()==0) ? 1:0;
1576  int noJetTrigger= (jetTrigNamesV_.size()==0) ? 1:0;
1577  if (!noPhotonTrigger &&
1578  (photonTrigNamesV_.size()==1) &&
1579  (photonTrigNamesV_[0].length()==0)) noPhotonTrigger=1;
1580  if (!noJetTrigger &&
1581  (jetTrigNamesV_.size()==1) &&
1582  (jetTrigNamesV_[0].length()==0)) noJetTrigger=1;
1583  if (noPhotonTrigger && noJetTrigger) {
1584  ignoreHLT_=true;
1585  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "HLT trigger ignored: no trigger requested";
1586  }
1587  } else {
1588  // clear trigger names, if needed
1589  photonTrigNamesV_.clear();
1590  jetTrigNamesV_.clear();
1591  }
1592 
1593  if (!ignoreHLT_) {
1594  if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "Initializing trigger information for individual run";
1595  bool changed(true);
1596  std::string processName="HLT";
1597  if (hltConfig_.init(iRun,setup,processName,changed)) {
1598  // if init returns TRUE, initialisation has succeeded!
1599  if (changed) {
1600  // The HLT config has actually changed wrt the previous Run, hence rebook your
1601  // histograms or do anything else dependent on the revised HLT config
1602  }
1603  }
1604  else {
1605  // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
1606  // with the file and/or code and needs to be investigated!
1608  << " HLT config extraction failure with process name " << processName;
1609  // In this case, all access methods will return empty values!
1610  }
1611  }
1612 }
1613 
1614 // ---------------------------------------------------------------------
1615 
1616 // helper function
1617 
1618 float GammaJetAnalysis::pfEcalIso(const reco::Photon* localPho1, edm::Handle<reco::PFCandidateCollection> pfHandle, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel, float etaStripEndcap, float energyBarrel, float energyEndcap, reco::PFCandidate::ParticleType pfToUse) {
1619  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Inside pfEcalIso";
1620  reco::Photon* localPho = localPho1->clone();
1621  float dRVeto;
1622  float etaStrip;
1623 
1624  if (localPho->isEB()) {
1625  dRVeto = dRVetoBarrel;
1626  etaStrip = etaStripBarrel;
1627  } else {
1628  dRVeto = dRVetoEndcap;
1629  etaStrip = etaStripEndcap;
1630  }
1631  const reco::PFCandidateCollection* forIsolation = pfHandle.product();
1632  int nsize = forIsolation->size();
1633  float sum = 0;
1634  for (int i=0; i<nsize; i++) {
1635  const reco::PFCandidate& pfc = (*forIsolation)[i];
1636  if (pfc.particleId() == pfToUse) {
1637  // Do not include the PFCandidate associated by SC Ref to the reco::Photon
1638  if(pfc.superClusterRef().isNonnull() && localPho->superCluster().isNonnull()) {
1639  if (pfc.superClusterRef() == localPho->superCluster())
1640  continue;
1641  }
1642 
1643  if (localPho->isEB()) {
1644  if (fabs(pfc.pt()) < energyBarrel)
1645  continue;
1646  } else {
1647  if (fabs(pfc.energy()) < energyEndcap)
1648  continue;
1649  }
1650  // Shift the photon direction vector according to the PF vertex
1651  math::XYZPoint pfvtx = pfc.vertex();
1652  math::XYZVector photon_directionWrtVtx(localPho->superCluster()->x() - pfvtx.x(),
1653  localPho->superCluster()->y() - pfvtx.y(),
1654  localPho->superCluster()->z() - pfvtx.z());
1655 
1656  float dEta = fabs(photon_directionWrtVtx.Eta() - pfc.momentum().Eta());
1657  float dR = deltaR(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi());
1658 
1659  if (dEta < etaStrip)
1660  continue;
1661 
1662  if(dR > dRmax || dR < dRVeto)
1663  continue;
1664 
1665  sum += pfc.pt();
1666  }
1667  }
1668  return sum;
1669 }
1670 
1671 // ---------------------------------------------------------------------
1672 
1674  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Inside pfHcalIso";
1675  return pfEcalIso(localPho, pfHandle, dRmax, dRveto, dRveto, 0.0, 0.0, 0.0, 0.0, pfToUse);
1676 
1677 }
1678 
1679 // ---------------------------------------------------------------------
1680 
1681 std::vector<float> GammaJetAnalysis::pfTkIsoWithVertex(const reco::Photon* localPho1, edm::Handle<reco::PFCandidateCollection> pfHandle, edm::Handle<reco::VertexCollection> vtxHandle, float dRmax, float dRvetoBarrel, float dRvetoEndcap, float ptMin, float dzMax, float dxyMax, reco::PFCandidate::ParticleType pfToUse) {
1682 
1683  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Inside pfTkIsoWithVertex()";
1684  reco::Photon* localPho = localPho1->clone();
1685 
1686  float dRveto;
1687  if (localPho->isEB())
1688  dRveto = dRvetoBarrel;
1689  else
1690  dRveto = dRvetoEndcap;
1691 
1692  std::vector<float> result;
1693  const reco::PFCandidateCollection* forIsolation = pfHandle.product();
1694 
1695  //Calculate isolation sum separately for each vertex
1696  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "vtxHandle->size() = " << vtxHandle->size();
1697  for(unsigned int ivtx=0; ivtx<(vtxHandle->size()); ++ivtx) {
1698  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Vtx " << ivtx;
1699  // Shift the photon according to the vertex
1700  reco::VertexRef vtx(vtxHandle, ivtx);
1701  math::XYZVector photon_directionWrtVtx(localPho->superCluster()->x() - vtx->x(),
1702  localPho->superCluster()->y() - vtx->y(),
1703  localPho->superCluster()->z() - vtx->z());
1704  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "pfTkIsoWithVertex :: Will Loop over the PFCandidates";
1705  float sum = 0;
1706  // Loop over the PFCandidates
1707  for(unsigned i=0; i<forIsolation->size(); i++) {
1708  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "inside loop";
1709  const reco::PFCandidate& pfc = (*forIsolation)[i];
1710 
1711  //require that PFCandidate is a charged hadron
1712  if (debug_>1) {
1713  edm::LogInfo("GammaJetAnalysis") << "pfToUse=" << pfToUse;
1714  edm::LogInfo("GammaJetAnalysis") << "pfc.particleId()=" << pfc.particleId();
1715  }
1716 
1717  if (pfc.particleId() == pfToUse) {
1718  if (debug_>1) {
1719  edm::LogInfo("GammaJetAnalysis") << "\n ***** HERE pfc.particleId() == pfToUse ";
1720  edm::LogInfo("GammaJetAnalysis") << "pfc.pt()=" << pfc.pt();
1721  }
1722  if (pfc.pt() < ptMin) continue;
1723 
1724  float dz = fabs(pfc.trackRef()->dz(vtx->position()));
1725  if (dz > dzMax) continue;
1726 
1727  float dxy = fabs(pfc.trackRef()->dxy(vtx->position()));
1728  if(fabs(dxy) > dxyMax) continue;
1729  float dR = deltaR(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi());
1730  if(dR > dRmax || dR < dRveto) continue;
1731  sum += pfc.pt();
1732  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "pt=" << pfc.pt();
1733  }
1734  }
1735  if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "sum=" << sum;
1736  sum = sum*1.0;
1737  result.push_back(sum);
1738  }
1739  if (debug_>1) {
1740  edm::LogInfo("GammaJetAnalysis") << "Will return result";
1741  edm::LogInfo("GammaJetAnalysis") << "result" << &result;
1742  edm::LogInfo("GammaJetAnalysis") << "Result returned";
1743  }
1744  return result;
1745 }
1746 
1747 // ---------------------------------------------------------------------
1748 
1750  ppfjet_pt_ = ppfjet_p_ = ppfjet_E_ = 0;
1756  ppfjet_ChargedEMFrac_ = 0.;
1758  // Reset particle variables
1764  ppfjet_had_n_ = 0;
1765  ppfjet_ntwrs_ = 0;
1766  ppfjet_cluster_n_ = 0;
1767  ppfjet_ncandtracks_ = 0;
1768 
1769  ppfjet_had_E_.clear();
1770  ppfjet_had_px_.clear();
1771  ppfjet_had_py_.clear();
1772  ppfjet_had_pz_.clear();
1773  ppfjet_had_EcalE_.clear();
1774  ppfjet_had_rawHcalE_.clear();
1775  ppfjet_had_emf_.clear();
1776  ppfjet_had_E_mctruth_.clear();
1777  ppfjet_had_id_.clear();
1778  ppfjet_had_candtrackind_.clear();
1779  ppfjet_had_mcpdgId_.clear();
1780  ppfjet_had_ntwrs_.clear();
1781  ppfjet_twr_ieta_.clear();
1782  ppfjet_twr_iphi_.clear();
1783  ppfjet_twr_depth_.clear();
1784  ppfjet_twr_subdet_.clear();
1785  ppfjet_twr_candtrackind_.clear();
1786  ppfjet_twr_hadind_.clear();
1787  ppfjet_twr_elmttype_.clear();
1788  ppfjet_twr_hade_.clear();
1789  ppfjet_twr_frac_.clear();
1790  ppfjet_twr_dR_.clear();
1791  ppfjet_twr_clusterind_.clear();
1792  ppfjet_cluster_eta_.clear();
1793  ppfjet_cluster_phi_.clear();
1794  ppfjet_cluster_dR_.clear();
1795  ppfjet_candtrack_px_.clear();
1796  ppfjet_candtrack_py_.clear();
1797  ppfjet_candtrack_pz_.clear();
1798  ppfjet_candtrack_EcalE_.clear();
1799 
1800 }
1801 
1802 // ---------------------------------------------------------------------
1803 
1806  pfjet2_p_ = ppfjet_p_;
1807  pfjet2_E_ = ppfjet_E_;
1819 
1824 
1830 
1836 
1842 
1848 
1854 
1863 
1868 
1878 
1882 
1887 
1893 }
1894 
1895 // ---------------------------------------------------------------------
1896 
1897 double GammaJetAnalysis::deltaR(const reco::Jet* j1, const reco::Jet* j2)
1898 {
1899  double deta = j1->eta()-j2->eta();
1900  double dphi = std::fabs(j1->phi()-j2->phi());
1901  if(dphi>3.1415927) dphi = 2*3.1415927 - dphi;
1902  return std::sqrt(deta*deta + dphi*dphi);
1903 }
1904 
1905 // ---------------------------------------------------------------------
1906 
1907 double GammaJetAnalysis::deltaR(const double eta1, const double phi1, const double eta2, const double phi2)
1908 {
1909  double deta = eta1 - eta2;
1910  double dphi = std::fabs(phi1 - phi2);
1911  if(dphi>3.1415927) dphi = 2*3.1415927 - dphi;
1912  return std::sqrt(deta*deta + dphi*dphi);
1913 }
1914 
1915 // ---------------------------------------------------------------------
1916 
1917 /*
1918 // DetId rawId bits xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1919 // 1111222 3333345555556666666
1920 // 1 = detector
1921 // 2 = subdetector
1922 // 3 = depth
1923 // 4 = zside: 0 = negative z, 1 = positive z \
1924 // 5 = abs(ieta) | ieta,iphi
1925 // 6 = abs(iphi) /
1926 */
1927 
1928 // ---------------------------------------------------------------------
1929 
1931 {
1932  return id.rawId() & 0x3FFF; // Get 14 least-significant digits
1933 }
1934 
1935 // ---------------------------------------------------------------------
1936 
1938 {
1939  return id.rawId() & 0x3FFF; // Get 14 least-significant digits
1940 }
1941 
1942 // ---------------------------------------------------------------------
1943 
1944 
1945 //define this as a plug-in
1946 
RunNumber_t run() const
Definition: EventID.h:39
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
virtual Photon * clone() const
returns a clone of the candidate
T getUntrackedParameter(std::string const &, T const &) const
void copy_leadingPfJetVars_to_pfJet2()
std::vector< float > ppfjet_cluster_phi_
int i
Definition: DBlmapReader.cc:9
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:356
virtual double p() const
magnitude of momentum vector
bool isValid() const
std::vector< int > pfjet2_twr_ieta_
std::vector< int > pfjet2_had_id_
edm::EDGetTokenT< std::vector< Bool_t > > tok_tightPhotonV_
std::vector< int > pfjet2_twr_iphi_
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
void idx(int set_idx)
ParticleType
particle types
Definition: PFCandidate.h:44
std::vector< float > pfjet2_candtrack_px_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::vector< float > ppfjet_had_py_
std::vector< float > ppfjet_candtrack_px_
edm::EDGetTokenT< reco::ConversionCollection > tok_Conv_
edm::EDGetTokenT< GenEventInfoProduct > tok_GenEvInfo_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
virtual double et() const
transverse energy
std::vector< int > pfjet2_twr_hadind_
std::vector< float > ppfjet_candtrack_pz_
std::vector< int > pfjet2_twr_elmttype_
edm::EDGetTokenT< reco::PFCandidateCollection > tok_PFCand_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
std::vector< int > photonTrigFired_
std::vector< float > pfjet2_cluster_dR_
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< edm::SortedCollection< HFRecHit, edm::StrictWeakOrdering< HFRecHit > > > tok_HF_
float chargedHadronEnergyFraction() const
chargedHadronEnergyFraction
Definition: PFJet.h:100
Base class for all types of Jets.
Definition: Jet.h:20
std::vector< float > ppfjet_had_E_
edm::EDGetTokenT< double > tok_Rho_
edm::EDGetTokenT< edm::TriggerResults > tok_TrigRes_
std::vector< int > ppfjet_twr_ieta_
assert(m_qm.get())
std::vector< int > ppfjet_twr_hadind_
size_type size() const
Definition: OwnVector.h:254
std::string hoRecHitName_
std::vector< int > ppfjet_twr_subdet_
virtual Vector momentum() const
spatial momentum vector
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int > ppfjet_had_candtrackind_
list elements
Definition: asciidump.py:414
#define NULL
Definition: scimark2.h:8
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:354
const reco::PFJet * jet(void) const
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:192
std::vector< float > pfTkIsoWithVertex(const reco::Photon *localPho1, edm::Handle< reco::PFCandidateCollection > pfHandle, edm::Handle< reco::VertexCollection > vtxHandle, float dRmax, float dRvetoBarrel, float dRvetoEndcap, float ptMin, float dzMax, float dxyMax, reco::PFCandidate::ParticleType pfToUse)
std::string prodProcess_
std::string hbheRecHitName_
std::vector< float > pfjet2_had_E_
Strings::size_type size() const
Definition: TriggerNames.cc:39
edm::EDGetTokenT< reco::PFMETCollection > tok_PFMET_
edm::EDGetTokenT< reco::VertexCollection > tok_Vertex_
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:580
T eta() const
std::vector< float > pfjet2_had_EcalE_
std::vector< float > pfjet2_cluster_eta_
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
unsigned int debugEvent
edm::EDGetTokenT< reco::BeamSpot > tok_BS_
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:155
std::vector< float > pfjet2_candtrack_py_
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
Jets made from PFObjects.
Definition: PFJet.h:21
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
std::vector< int > pfjet2_twr_candtrackind_
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
std::string photonCollName_
std::vector< int > pfjet2_twr_clusterind_
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< int > pfjet2_twr_depth_
std::vector< int > pfjet2_had_candtrackind_
std::vector< float > ppfjet_twr_frac_
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< std::vector< reco::GenParticle > > tok_GenPart_
std::vector< int > ppfjet_had_id_
float neutralEmEnergyFraction() const
neutralEmEnergyFraction
Definition: PFJet.h:152
virtual double energy() const
energy
float met_value_
MET info.
std::vector< int > jetTrigPrescale_
int iEvent
Definition: GenABIO.cc:230
std::vector< int > ppfjet_twr_clusterind_
edm::EDGetTokenT< edm::SortedCollection< HORecHit, edm::StrictWeakOrdering< HORecHit > > > tok_HO_
std::string rootHistFilename_
std::string hfRecHitName_
std::vector< float > pfjet2_had_E_mctruth_
std::vector< float > ppfjet_candtrack_py_
float pfEcalIso(const reco::Photon *localPho1, edm::Handle< reco::PFCandidateCollection > pfHandle, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel, float etaStripEndcap, float energyBarrel, float energyEndcap, reco::PFCandidate::ParticleType pfToUse)
std::vector< float > pfjet2_had_py_
float pfHcalIso(const reco::Photon *localPho, edm::Handle< reco::PFCandidateCollection > pfHandle, float dRmax, float dRveto, reco::PFCandidate::ParticleType pfToUse)
std::vector< float > ppfjet_cluster_dR_
T sqrt(T t)
Definition: SSEVec.h:48
edm::EDGetTokenT< reco::PhotonCollection > tok_Photon_
double scale(void) const
float ppfjet_ChargedMultiplicity_
bool isValid() const
tuple result
Definition: query.py:137
float sigmaIetaIeta() const
Definition: Photon.h:192
std::vector< float > ppfjet_twr_hade_
std::vector< int > ppfjet_twr_elmttype_
unsigned int helper_findTrigger(const std::vector< std::string > &list, const std::string &name)
std::vector< float > ppfjet_had_rawHcalE_
edm::InputTag rhoCollection_
edm::EDGetTokenT< std::vector< Bool_t > > tok_loosePhotonV_
std::vector< int > ppfjet_twr_depth_
edm::EDGetTokenT< edm::ValueMap< Bool_t > > tok_tightPhoton_
const reco::Photon * photon(void) const
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:647
Jets made from MC generator particles.
Definition: GenJet.h:24
float neutralHadronEnergyFraction() const
neutralHadronEnergyFraction
Definition: PFJet.h:104
std::vector< float > pfjet2_candtrack_pz_
std::vector< float > pfjet2_twr_frac_
float hadTowOverEm() const
the ration of hadronic energy in towers behind the BCs in the SC and the SC energy ...
Definition: Photon.h:178
edm::InputTag pfMETColl
edm::InputTag pfType1METColl
std::vector< float > pfjet2_had_rawHcalE_
HLTConfigProvider hltConfig_
static std::string const triggerResults
Definition: EdmProvDump.cc:40
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
Definition: Photon.h:171
void beginRun(const edm::Run &, const edm::EventSetup &)
std::string genParticleCollName_
bool isValid() const
Definition: HandleBase.h:75
double p2[4]
Definition: TauolaWrapper.h:90
virtual void beginJob()
std::vector< float > ppfjet_twr_dR_
std::vector< float > ppfjet_candtrack_EcalE_
std::vector< float > ppfjet_cluster_eta_
dictionary cv
Definition: cuy.py:362
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:592
std::vector< float > pfjet2_cluster_phi_
std::string pfJetCollName_
double getNeutralPVCorr(double eta, int intNPV, double area, bool isMC_)
Definition: DetId.h:18
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
float chargedEmEnergyFraction() const
chargedEmEnergyFraction
Definition: PFJet.h:144
std::vector< std::string > photonTrigNamesV_
T const * product() const
Definition: Handle.h:81
virtual double px() const
x coordinate of momentum vector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< int > jetTrigFired_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::EDGetTokenT< reco::PFJetCollection > tok_PFJet_
std::vector< float > ppfjet_had_E_mctruth_
edm::EDGetTokenT< edm::ValueMap< Bool_t > > tok_loosePhoton_
bool hasPixelSeed() const
Bool flagging photons having a non-zero size vector of Ref to electornPixel seeds.
Definition: Photon.h:75
std::vector< std::string > jetTrigNamesV_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:55
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
edm::EDGetTokenT< std::vector< reco::Vertex > > tok_PV_
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger) const
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
std::vector< int > pfjet2_had_ntwrs_
std::string genEventInfoName_
std::string const & label() const
Definition: InputTag.h:42
double deltaR(const reco::Jet *j1, const reco::Jet *j2)
bool isEB() const
Definition: Photon.h:120
int getEtaPhi(const DetId id)
float trkSumPtHollowConeDR04() const
Definition: Photon.h:370
std::vector< float > pfjet2_twr_hade_
edm::EDGetTokenT< edm::SortedCollection< HBHERecHit, edm::StrictWeakOrdering< HBHERecHit > > > tok_HBHE_
edm::EventID id() const
Definition: EventBase.h:60
std::string genJetCollName_
void HERE(const char *msg)
double scaledEt() const
std::string pvCollName_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::vector< float > pfjet2_had_emf_
double p1[4]
Definition: TauolaWrapper.h:89
virtual float jetArea() const
get jet area
Definition: Jet.h:105
virtual int nConstituents() const
of constituents
Definition: Jet.h:65
std::vector< float > ppfjet_had_px_
std::vector< int > ppfjet_had_mcpdgId_
static std::atomic< unsigned int > counter
std::vector< float > pfjet2_twr_dR_
GammaJetAnalysis(const edm::ParameterSet &)
float r9() const
Definition: Photon.h:195
std::vector< float > pfjet2_had_pz_
edm::EDGetTokenT< reco::GsfElectronCollection > tok_GsfElec_
float pfjet2_ChargedMultiplicity_
double pt(void) const
std::vector< int > pfjet2_twr_subdet_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:52
std::vector< int > ppfjet_twr_iphi_
std::vector< int > photonTrigPrescale_
std::vector< int > ppfjet_had_ntwrs_
edm::EDGetTokenT< std::vector< reco::GenJet > > tok_GenJet_
std::vector< float > ppfjet_had_pz_
std::vector< float > pfjet2_candtrack_EcalE_
std::vector< int > pfjet2_had_mcpdgId_
edm::EDGetTokenT< reco::PFMETCollection > tok_PFType1MET_
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:166
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const CornersVec & getCorners() const
Returns the corner points of this cell&#39;s volume.
std::vector< float > ppfjet_had_emf_
virtual double phi() const
momentum azimuthal angle
std::vector< int > ppfjet_twr_candtrackind_
virtual void endJob()
float calc_dPhi(const PhotonPair &pho, const JetPair_type &jet)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual double py() const
y coordinate of momentum vector
std::vector< std::vector< float > > tagPho_pfiso_mycharged03
std::vector< float > ppfjet_had_EcalE_
std::vector< float > pfjet2_had_px_
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:586
std::string pfJetCorrName_
Definition: Run.h:41
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any
Definition: PFCandidate.cc:600
Definition: DDAxes.h:10