ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/HiJetResponseAnalyzer.cc
(Generate patch)

Comparing UserCode/CmsHi/JetAnalysis/src/HiJetResponseAnalyzer.cc (file contents):
Revision 1.6 by yilmaz, Mon Oct 18 16:13:37 2010 UTC vs.
Revision 1.8 by yilmaz, Thu Oct 21 16:24:04 2010 UTC

# Line 72 | Line 72 | struct JRA{
72     float weight;
73   };
74  
75
75   struct JRAV{
76 <
76 >  int index;
77    float jtpt;
78    float jtcorpt;
79    float refpt;
# Line 122 | Line 121 | class HiJetResponseAnalyzer : public edm
121     double n90Min_;
122     double n90hitMin_;
123  
124 <   edm::InputTag jetTag_;
124 >  edm::InputTag jetTag_;
125    edm::InputTag matchTag_;
126 +  std::vector<edm::InputTag> matchTags_;
127 +  
128 +  JRA jra_;
129 +  std::vector<JRA> jraMatch_;
130  
128   JRA jra_;
131     TTree* t;
132  
133     edm::Handle<edm::GenHIEvent> mc;
# Line 193 | Line 195 | HiJetResponseAnalyzer::HiJetResponseAnal
195  
196     jetTag_ = iConfig.getUntrackedParameter<edm::InputTag>("src",edm::InputTag("selectedPatJets"));
197     matchTag_ = iConfig.getUntrackedParameter<edm::InputTag>("match",edm::InputTag("selectedPatJets"));
198 +   matchTags_ = iConfig.getUntrackedParameter<std::vector<edm::InputTag> >("matches",std::vector<edm::InputTag>(0));
199   }
200  
201  
# Line 217 | Line 220 | HiJetResponseAnalyzer::analyze(const edm
220  
221     iEvent.getByLabel(jetTag_,jets);
222     if(usePat_)iEvent.getByLabel(jetTag_,patjets);
220   if(matchNew_)iEvent.getByLabel(matchTag_,matchedJets);
221
223     std::vector<JRAV> jraV;
224  
225     for(unsigned int j = 0 ; j < jets->size(); ++j){
225
226       if(filterJets_ && !selectJet(j)) continue;
227       const reco::Jet& jet = (*jets)[j];
228       JRAV jv;
# Line 230 | Line 230 | HiJetResponseAnalyzer::analyze(const edm
230       jv.jteta = jet.eta();
231       jv.jtphi = jet.phi();
232       jv.jtcorpt = jet.pt();
233 <
233 >     jv.index = j;
234       if(usePat_){
235         const pat::Jet& patjet = (*patjets)[j];
236  
# Line 242 | Line 242 | HiJetResponseAnalyzer::analyze(const edm
242           jv.refpt = patjet.genJet()->pt();
243           jv.refeta = patjet.genJet()->eta();
244           jv.refphi = patjet.genJet()->phi();
245
245         }else{
246           jv.refpt = -99;
247           jv.refeta = -99;
# Line 250 | Line 249 | HiJetResponseAnalyzer::analyze(const edm
249         }
250       }
251  
253     if(matchNew_){
254       for(unsigned int m = 0 ; m < matchedJets->size(); ++m){
255         const reco::Jet& match = (*matchedJets)[m];
256         double dr = reco::deltaR(jet.eta(),jet.phi(),match.eta(),match.phi());
257         if(dr < matchR_){
258           jv.refcorpt = -99;
259           jv.refpt = match.pt();
260           jv.refeta = match.eta();
261           jv.refphi = match.phi();
262         }
263       }
264     }
252       jraV.push_back(jv);
253     }
254  
# Line 272 | Line 259 | HiJetResponseAnalyzer::analyze(const edm
259  
260     for(unsigned int i = 0; i < jraV.size(); ++i){
261       JRAV& jv = jraV[i];
262 <     jra_.jtpt[jra_.nref] = jv.jtpt;
263 <     jra_.jteta[jra_.nref] = jv.jteta;
264 <     jra_.jtphi[jra_.nref] = jv.jtphi;
265 <     jra_.jtcorpt[jra_.nref] = jv.jtcorpt;
266 <     jra_.refpt[jra_.nref] = jv.refpt;
267 <     jra_.refeta[jra_.nref] = jv.refeta;
268 <     jra_.refphi[jra_.nref] = jv.refphi;
262 >     const reco::Jet& jet = (*jets)[jv.index];
263 >    
264 >     if(matchNew_){
265 >       for(unsigned int im = 0; im < matchTags_.size(); ++im){
266 >         iEvent.getByLabel(matchTags_[im],matchedJets);
267 >         for(unsigned int m = 0 ; m < matchedJets->size(); ++m){
268 >           const reco::Jet& match = (*matchedJets)[m];
269 >           double dr = reco::deltaR(jet.eta(),jet.phi(),match.eta(),match.phi());
270 >           if(dr < matchR_){
271 >             jraMatch_[im].jtcorpt[i] = -99;
272 >             jraMatch_[im].jtpt[i] = match.pt();
273 >             jraMatch_[im].jteta[i] = match.eta();
274 >             jraMatch_[im].jtphi[i] = match.phi();
275 >           }
276 >         }
277 >       }
278 >     }
279 >    
280 >     jra_.jtpt[i] = jv.jtpt;
281 >     jra_.jteta[i] = jv.jteta;
282 >     jra_.jtphi[i] = jv.jtphi;
283 >     jra_.jtcorpt[i] = jv.jtcorpt;
284 >     jra_.refpt[i] = jv.refpt;
285 >     jra_.refeta[i] = jv.refeta;
286 >     jra_.refphi[i] = jv.refphi;
287     }
288     jra_.nref = jraV.size();
289 <
289 >  
290     t->Fill();
291  
292   }
293  
289
294   // ------------ method called once each job just before starting event loop  ------------
291 void
292 HiJetResponseAnalyzer::beginJob()
293 {
295  
296 <   t= fs->make<TTree>("t","Jet Response Analyzer");
297 <   t->Branch("b",&jra_.b,"b/F");
298 <   t->Branch("hf",&jra_.hf,"hf/F");
299 <   t->Branch("nref",&jra_.nref,"nref/I");
300 <   t->Branch("jtpt",jra_.jtpt,"jtpt[nref]/F");
301 <   t->Branch("jtcorpt",jra_.jtcorpt,"jtcorpt[nref]/F");
302 <   t->Branch("refpt",jra_.refpt,"refpt[nref]/F");
303 <   t->Branch("refcorpt",jra_.refpt,"refcorpt[nref]/F");
304 <   t->Branch("jteta",jra_.jteta,"jteta[nref]/F");
296 >
297 > void
298 > HiJetResponseAnalyzer::beginJob(){
299 >  t= fs->make<TTree>("t","Jet Response Analyzer");
300 >  t->Branch("b",&jra_.b,"b/F");
301 >  t->Branch("hf",&jra_.hf,"hf/F");
302 >  t->Branch("nref",&jra_.nref,"nref/I");
303 >  t->Branch("jtpt",jra_.jtpt,"jtpt[nref]/F");
304 >  t->Branch("jtcorpt",jra_.jtcorpt,"jtcorpt[nref]/F");
305 >  t->Branch("jteta",jra_.jteta,"jteta[nref]/F");
306 >  t->Branch("jtphi",jra_.jtphi,"jtphi[nref]/F");
307 >  t->Branch("refpt",jra_.refpt,"refpt[nref]/F");
308 >  t->Branch("refcorpt",jra_.refpt,"refcorpt[nref]/F");
309     t->Branch("refeta",jra_.refeta,"refeta[nref]/F");
305   t->Branch("jtphi",jra_.jtphi,"jtphi[nref]/F");
310     t->Branch("refphi",jra_.refphi,"refphi[nref]/F");
311     t->Branch("weight",&jra_.weight,"weight/F");
312     t->Branch("bin",&jra_.bin,"bin/I");
313 <
314 <
315 <
313 >   for(unsigned int im = 0; im < matchTags_.size(); ++im){
314 >     JRA jrm;
315 >     jraMatch_.push_back(jrm);
316 >     t->Branch(Form("jtpt%d",im),jraMatch_[im].jtpt,Form("jtpt%d[nref]/F",im));
317 >     t->Branch(Form("jtcorpt%d",im),jraMatch_[im].jtcorpt,Form("jtcorpt%d[nref]/F",im));
318 >     t->Branch(Form("jteta%d",im),jraMatch_[im].jteta,Form("jteta%d[nref]/F",im));
319 >     t->Branch(Form("jtphi%d",im),jraMatch_[im].jtphi,Form("jtphi%d[nref]/F",im));
320 >   }
321 >  
322   }
323  
324   // ------------ method called once each job just after ending the event loop  ------------

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines