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

Comparing UserCode/CmsHi/JetAnalysis/src/HiInclusiveJetAnalyzer.cc (file contents):
Revision 1.1 by yilmaz, Tue Sep 20 19:45:06 2011 UTC vs.
Revision 1.24 by yilmaz, Fri May 25 23:22:28 2012 UTC

# Line 21 | Line 21
21   #include "DataFormats/HeavyIonEvent/interface/Centrality.h"
22  
23   #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
24 #include "DataFormats/PatCandidates/interface/Jet.h"
24   #include "DataFormats/JetReco/interface/CaloJetCollection.h"
25   #include "SimDataFormats/HiGenData/interface/GenHIEvent.h"
26   #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
27 + #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
28   #include "DataFormats/JetReco/interface/GenJetCollection.h"
29   #include "DataFormats/VertexReco/interface/Vertex.h"
30   #include "DataFormats/Math/interface/deltaPhi.h"
# Line 43 | Line 43 | using namespace edm;
43   using namespace reco;
44  
45   HiInclusiveJetAnalyzer::HiInclusiveJetAnalyzer(const edm::ParameterSet& iConfig) {
46  
46  
47    jetTag_ = iConfig.getParameter<InputTag>("jetTag");
48 <        vtxTag_ = iConfig.getUntrackedParameter<edm::InputTag>("vtxTag",edm::InputTag("hiSelectedVertex"));
48 >  matchTag_ = iConfig.getUntrackedParameter<InputTag>("matchTag",jetTag_);
49 >
50 >  vtxTag_ = iConfig.getUntrackedParameter<edm::InputTag>("vtxTag",edm::InputTag("hiSelectedVertex"));  
51 >  trackTag_ = iConfig.getParameter<InputTag>("trackTag");
52 >  useQuality_ = iConfig.getUntrackedParameter<bool>("useQuality",1);
53 >  trackQuality_ = iConfig.getUntrackedParameter<string>("trackQuality","highPurity");
54  
55    isMC_ = iConfig.getUntrackedParameter<bool>("isMC",false);
56 +  fillGenJets_ = iConfig.getUntrackedParameter<bool>("fillGenJets",false);
57 +
58 +  doTrigger_ = iConfig.getUntrackedParameter<bool>("doTrigger",false);
59 +
60 +  rParam = iConfig.getParameter<double>("rParam");
61 +  hardPtMin_ = iConfig.getUntrackedParameter<double>("hardPtMin",4);  
62  
63    if(isMC_){
64      genjetTag_ = iConfig.getParameter<InputTag>("genjetTag");
# Line 57 | Line 67 | HiInclusiveJetAnalyzer::HiInclusiveJetAn
67    verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false);
68  
69    useCentrality_ = iConfig.getUntrackedParameter<bool>("useCentrality",false);
70 <  useVtx_ = iConfig.getUntrackedParameter<bool>("useVtx",true);
70 >  useVtx_ = iConfig.getUntrackedParameter<bool>("useVtx",false);
71    useJEC_ = iConfig.getUntrackedParameter<bool>("useJEC",true);
72 +  usePat_ = iConfig.getUntrackedParameter<bool>("usePAT",true);
73  
74 <  if(!isMC_){
74 >  doLifeTimeTagging_ = iConfig.getUntrackedParameter<bool>("doLifeTimeTagging",false);
75 >  doLifeTimeTaggingExtras_ = iConfig.getUntrackedParameter<bool>("doLifeTimeTaggingExtras",true);
76 >  saveBfragments_  = iConfig.getUntrackedParameter<bool>("saveBfragments",false);
77 >
78 >  pfCandidateLabel_ = iConfig.getUntrackedParameter<edm::InputTag>("pfCandidateLabel",edm::InputTag("particleFlowTmp"));
79 >
80 >  if(doTrigger_){
81      L1gtReadout_ = iConfig.getParameter<edm::InputTag>("L1gtReadout");
82      hltResName_ = iConfig.getUntrackedParameter<string>("hltTrgResults","TriggerResults::HLT");
83      
# Line 77 | Line 94 | HiInclusiveJetAnalyzer::HiInclusiveJetAn
94    }
95  
96    cout<<" jet collection : "<<jetTag_<<endl;
97 <  if(isMC_)cout<<" genjet collection : "<<genjetTag_<<endl;
97 >  doSubEvent_ = 0;
98  
99 +  if(isMC_){
100 +     cout<<" genjet collection : "<<genjetTag_<<endl;
101 +     genPtMin_ = iConfig.getUntrackedParameter<double>("genPtMin",0);
102 +     doSubEvent_ = iConfig.getUntrackedParameter<bool>("doSubEvent",1);
103 +  }
104  
105    
106   }
# Line 102 | Line 124 | HiInclusiveJetAnalyzer::beginJob() {
124    string jetTagTitle = jetTag_.label()+" Jet Analysis Tree";
125    t = fs1->make<TTree>("t",jetTagTitle.c_str());
126  
105
127    //  TTree* t= new TTree("t","Jet Response Analyzer");
128 <  t->Branch("run",&jets_.run,"run/I");
128 >  //t->Branch("run",&jets_.run,"run/I");
129    t->Branch("evt",&jets_.evt,"evt/I");
130 <  t->Branch("lumi",&jets_.lumi,"lumi/I");
130 >  //t->Branch("lumi",&jets_.lumi,"lumi/I");
131    t->Branch("b",&jets_.b,"b/F");
132 <  t->Branch("vx",&jets_.vx,"vx/F");
133 <  t->Branch("vy",&jets_.vy,"vy/F");
134 <  t->Branch("vz",&jets_.vz,"vz/F");
135 <  t->Branch("hf",&jets_.hf,"hf/F");
132 >  if (useVtx_) {
133 >     t->Branch("vx",&jets_.vx,"vx/F");
134 >     t->Branch("vy",&jets_.vy,"vy/F");
135 >     t->Branch("vz",&jets_.vz,"vz/F");
136 >  }
137 >  if (useCentrality_) {
138 >     t->Branch("hf",&jets_.hf,"hf/F");
139 >     t->Branch("bin",&jets_.bin,"bin/I");
140 >  }
141 >
142    t->Branch("nref",&jets_.nref,"nref/I");
116  t->Branch("bin",&jets_.bin,"bin/I");
143    t->Branch("rawpt",jets_.rawpt,"rawpt[nref]/F");
144    t->Branch("jtpt",jets_.jtpt,"jtpt[nref]/F");
145    t->Branch("jteta",jets_.jteta,"jteta[nref]/F");
146    t->Branch("jty",jets_.jty,"jty[nref]/F");
147    t->Branch("jtphi",jets_.jtphi,"jtphi[nref]/F");
148 +  t->Branch("jtpu",jets_.jtpu,"jtpu[nref]/F");
149 +  t->Branch("jtm",jets_.jtm,"jtm[nref]/F");
150 +
151 +  // jet ID information, jet composition
152 +  t->Branch("discr_fr01", jets_.discr_fr01,"discr_fr01[nref]/F");
153 +
154 +  t->Branch("trackMax", jets_.trackMax,"trackMax[nref]/F");
155 +  t->Branch("trackSum", jets_.trackSum,"trackSum[nref]/F");
156 +  t->Branch("trackN", jets_.trackN,"trackN[nref]/I");
157 +  t->Branch("trackHardSum", jets_.trackHardSum,"trackHardSum[nref]/F");
158 +  t->Branch("trackHardN", jets_.trackHardN,"trackHardN[nref]/I");
159 +
160 +  t->Branch("chargedMax", jets_.chargedMax,"chargedMax[nref]/F");
161 +  t->Branch("chargedSum", jets_.chargedSum,"chargedSum[nref]/F");
162 +  t->Branch("chargedN", jets_.chargedN,"chargedN[nref]/I");
163 +  t->Branch("chargedHardSum", jets_.chargedHardSum,"chargedHardSum[nref]/F");
164 +  t->Branch("chargedHardN", jets_.chargedHardN,"chargedHardN[nref]/I");
165 +
166 +  t->Branch("photonMax", jets_.photonMax,"photonMax[nref]/F");
167 +  t->Branch("photonSum", jets_.photonSum,"photonSum[nref]/F");
168 +  t->Branch("photonN", jets_.photonN,"photonN[nref]/I");
169 +  t->Branch("photonHardSum", jets_.photonHardSum,"photonHardSum[nref]/F");
170 +  t->Branch("photonHardN", jets_.photonHardN,"photonHardN[nref]/I");
171 +
172 +  t->Branch("neutralMax", jets_.neutralMax,"neutralMax[nref]/F");
173 +  t->Branch("neutralSum", jets_.neutralSum,"neutralSum[nref]/F");
174 +  t->Branch("neutralN", jets_.neutralN,"neutralN[nref]/I");
175 +
176 +  t->Branch("eMax", jets_.eMax,"eMax[nref]/F");
177 +  t->Branch("eSum", jets_.eSum,"eSum[nref]/F");
178 +  t->Branch("eN", jets_.eN,"eN[nref]/I");
179 +
180 +  t->Branch("muMax", jets_.muMax,"muMax[nref]/F");
181 +  t->Branch("muSum", jets_.muSum,"muSum[nref]/F");
182 +  t->Branch("muN", jets_.muN,"muN[nref]/I");
183 +
184 +  t->Branch("matchedPt", jets_.matchedPt,"matchedPt[nref]/F");
185 +  t->Branch("matchedR", jets_.matchedR,"matchedR[nref]/F");
186 +
187 +  // b-jet discriminators
188 +  if (doLifeTimeTagging_) {
189 +
190 +    t->Branch("discr_csvMva",jets_.discr_csvMva,"discr_csvMva[nref]/F");
191 +    t->Branch("discr_csvSimple",jets_.discr_csvSimple,"discr_csvSimple[nref]/F");
192 +    t->Branch("discr_muByIp3",jets_.discr_muByIp3,"discr_muByIp3[nref]/F");
193 +    t->Branch("discr_muByPt",jets_.discr_muByPt,"discr_muByPt[nref]/F");
194 +    t->Branch("discr_prob",jets_.discr_prob,"discr_prob[nref]/F");
195 +    t->Branch("discr_probb",jets_.discr_probb,"discr_probb[nref]/F");
196 +    t->Branch("discr_tcHighEff",jets_.discr_tcHighEff,"discr_tcHighEff[nref]/F");
197 +    t->Branch("discr_tcHighPur",jets_.discr_tcHighPur,"discr_tcHighPur[nref]/F");
198 +    
199 +    t->Branch("nsvtx",    jets_.nsvtx,    "nsvtx[nref]/I");
200 +    t->Branch("svtxntrk", jets_.svtxntrk, "svtxntrk[nref]/I");
201 +    t->Branch("svtxdl",   jets_.svtxdl,   "svtxdl[nref]/F");
202 +    t->Branch("svtxdls",  jets_.svtxdls,  "svtxdls[nref]/F");
203 +    t->Branch("svtxm",    jets_.svtxm,    "svtxm[nref]/F");
204 +    t->Branch("svtxpt",   jets_.svtxpt,   "svtxpt[nref]/F");
205 +    
206 +    t->Branch("nIPtrk",jets_.nIPtrk,"nIPtrk[nref]/I");
207 +    t->Branch("nselIPtrk",jets_.nselIPtrk,"nselIPtrk[nref]/I");
208 +
209 +    if (doLifeTimeTaggingExtras_) {
210 +      t->Branch("nIP",&jets_.nIP,"nIP/I");
211 +      t->Branch("ipJetIndex",jets_.ipJetIndex,"ipJetIndex[nIP]/I");
212 +      t->Branch("ipPt",jets_.ipPt,"ipPt[nIP]/F");
213 +      t->Branch("ipProb0",jets_.ipProb0,"ipProb0[nIP]/F");
214 +      t->Branch("ipProb1",jets_.ipProb1,"ipProb1[nIP]/F");
215 +      t->Branch("ip2d",jets_.ip2d,"ip2d[nIP]/F");
216 +      t->Branch("ip2dSig",jets_.ip2dSig,"ip2dSig[nIP]/F");
217 +      t->Branch("ip3d",jets_.ip3d,"ip3d[nIP]/F");
218 +      t->Branch("ip3dSig",jets_.ip3dSig,"ip3dSig[nIP]/F");
219 +      t->Branch("ipDist2Jet",jets_.ipDist2Jet,"ipDist2Jet[nIP]/F");
220 +      t->Branch("ipDist2JetSig",jets_.ipDist2JetSig,"ipDist2JetSig[nIP]/F");
221 +      t->Branch("ipClosest2Jet",jets_.ipClosest2Jet,"ipClosest2Jet[nIP]/F");
222 +
223 +    }      
224 +
225 +    t->Branch("mue",     jets_.mue,     "mue[nref]/F");
226 +    t->Branch("mupt",    jets_.mupt,    "mupt[nref]/F");
227 +    t->Branch("mueta",   jets_.mueta,   "mueta[nref]/F");
228 +    t->Branch("muphi",   jets_.muphi,   "muphi[nref]/F");
229 +    t->Branch("mudr",    jets_.mudr,    "mudr[nref]/F");
230 +    t->Branch("muptrel", jets_.muptrel, "muptrel[nref]/F");
231 +    t->Branch("muchg",   jets_.muchg,   "muchg[nref]/I");
232 +  }
233  
234 +  
235    if(isMC_){
236 +    t->Branch("beamId1",&jets_.beamId1,"beamId1/I");    
237 +    t->Branch("beamId2",&jets_.beamId2,"beamId2/I");    
238 +
239      t->Branch("pthat",&jets_.pthat,"pthat/F");    
240  
241      // Only matched gen jets
# Line 132 | Line 247 | HiInclusiveJetAnalyzer::beginJob() {
247      t->Branch("refdrjt",jets_.refdrjt,"refdrjt[nref]/F");
248      // matched parton
249      t->Branch("refparton_pt",jets_.refparton_pt,"refparton_pt[nref]/F");
250 <    t->Branch("refparton_flavor",jets_.refparton_flavor,"refparton_flavor[nref]/F");
250 >    t->Branch("refparton_flavor",jets_.refparton_flavor,"refparton_flavor[nref]/I");
251 >    t->Branch("refparton_flavorForB",jets_.refparton_flavorForB,"refparton_flavorForB[nref]/I");
252 >
253 >    if(fillGenJets_){
254 >       // For all gen jets, matched or unmatched
255 >       t->Branch("ngen",&jets_.ngen,"ngen/I");
256 >       t->Branch("genmatchindex",jets_.genmatchindex,"genmatchindex[ngen]/I");
257 >       t->Branch("genpt",jets_.genpt,"genpt[ngen]/F");
258 >       t->Branch("geneta",jets_.geneta,"geneta[ngen]/F");
259 >       t->Branch("geny",jets_.geny,"geny[ngen]/F");
260 >       t->Branch("genphi",jets_.genphi,"genphi[ngen]/F");
261 >       t->Branch("gendphijt",jets_.gendphijt,"gendphijt[ngen]/F");
262 >       t->Branch("gendrjt",jets_.gendrjt,"gendrjt[ngen]/F");
263 >      
264 >       if(doSubEvent_){
265 >          t->Branch("gensubid",jets_.gensubid,"gensubid[ngen]/I");
266 >       }
267 >    }
268 >    
269 >    if(saveBfragments_  ) {
270 >      t->Branch("bMult",&jets_.bMult,"bMult/I");
271 >      t->Branch("bJetIndex",jets_.bJetIndex,"bJetIndex[bMult]/I");
272 >      t->Branch("bStatus",jets_.bStatus,"bStatus[bMult]/I");
273 >      t->Branch("bVx",jets_.bVx,"bVx[bMult]/F");
274 >      t->Branch("bVy",jets_.bVy,"bVy[bMult]/F");
275 >      t->Branch("bVz",jets_.bVz,"bVz[bMult]/F");
276 >      t->Branch("bPt",jets_.bPt,"bPt[bMult]/F");
277 >      t->Branch("bEta",jets_.bEta,"bEta[bMult]/F");
278 >      t->Branch("bPhi",jets_.bPhi,"bPhi[bMult]/F");
279 >      t->Branch("bPdg",jets_.bPdg,"bPdg[bMult]/I");
280 >      t->Branch("bChg",jets_.bChg,"bChg[bMult]/I");
281 >    }
282  
137    // For all gen jets, matched or unmatched
138    t->Branch("ngen",&jets_.ngen,"ngen/I");
139    t->Branch("genmatchindex",jets_.genmatchindex,"genmatchindex[ngen]/I");
140    t->Branch("genpt",jets_.genpt,"genpt[ngen]/F");
141    t->Branch("geneta",jets_.geneta,"geneta[ngen]/F");
142    t->Branch("geny",jets_.geny,"geny[ngen]/F");
143    t->Branch("genphi",jets_.genphi,"genphi[ngen]/F");
144    t->Branch("gendphijt",jets_.gendphijt,"gendphijt[ngen]/F");
145    t->Branch("gendrjt",jets_.gendrjt,"gendrjt[ngen]/F");
283    }
284 <  
284 >  /*
285    if(!isMC_){
286      t->Branch("nL1TBit",&jets_.nL1TBit,"nL1TBit/I");
287      t->Branch("l1TBit",jets_.l1TBit,"l1TBit[nL1TBit]/O");
# Line 156 | Line 293 | HiInclusiveJetAnalyzer::beginJob() {
293      t->Branch("hltBit",jets_.hltBit,"hltBit[nHLTBit]/O");
294  
295    }
296 <
296 >  */
297    TH1D::SetDefaultSumw2();
298    
299    
# Line 177 | Line 314 | HiInclusiveJetAnalyzer::analyze(const Ev
314  
315    LogDebug("HiInclusiveJetAnalyzer")<<"START event: "<<event<<" in run "<<run<<endl;
316  
180
317   int bin = -1;
318    double hf = 0.;
319    double b = 999.;
320  
321    if(useCentrality_){
186    //if(!isMC_){
322        if(!centrality_) centrality_ = new CentralityProvider(iSetup);      
323        centrality_->newEvent(iEvent,iSetup); // make sure you do this first in every event
324        //double c = centrality_->centralityValue();
# Line 193 | Line 328 | HiInclusiveJetAnalyzer::analyze(const Ev
328  
329        bin = centrality_->getBin();
330        b = centrality_->bMean();
196      //}
197      /*
198    else{
199
200      TFile * centFile = new TFile("/net/hidsk0001/d00/scratch/mnguyen/CMSSW_3_9_1_patch1/src/macros/Hydjet_CentTable.root");
201
202      edm::Handle<reco::Centrality> cent;
203      iEvent.getByLabel(edm::InputTag("hiCentrality"),cent);
204      //cout<<" grabbed centrality "<<endl;
205      CentralityBins::RunMap cmap = getCentralityFromFile(centFile, "makeCentralityTableTFile", "HFhitsHydjet_2760GeV", 1, 1);
206
207      // Still getting cent from hits.  When tower tables become available, we need to switch
208      hf = cent->EtHFhitSum();
209      //cout<<" hf "<<hf<<endl;
210      bin = cmap[run]->getBin(hf);
211      b = cmap[run]->bMeanOfBin(bin);
212    }
213      */
331    }
332    
216
217
218
219  //double jetPtMin = 35.;
220
221
333     // loop the events
334    
335     jets_.bin = bin;
# Line 236 | Line 347 | HiInclusiveJetAnalyzer::analyze(const Ev
347        }
348           }
349    
350 +   edm::Handle<pat::JetCollection> patjets;
351 +   if(usePat_)iEvent.getByLabel(jetTag_, patjets);
352  
353 <
354 <   edm::Handle<pat::JetCollection> jets;
353 >   edm::Handle<pat::JetCollection> matchedjets;
354 >   iEvent.getByLabel(matchTag_, matchedjets);
355 >  
356 >   edm::Handle<reco::JetView> jets;
357     iEvent.getByLabel(jetTag_, jets);
358  
359 <  
360 <   // FILL JRA TREE
359 >   edm::Handle<reco::PFCandidateCollection> pfCandidates;
360 >   iEvent.getByLabel(pfCandidateLabel_,pfCandidates);  
361 >
362 >   edm::Handle<reco::TrackCollection> tracks;
363 >   iEvent.getByLabel(trackTag_,tracks);
364  
365 +   // FILL JRA TREE
366     jets_.b = b;
367     jets_.nref = 0;
368 +
369    
370 <   if(!isMC_){
370 >   if(doTrigger_){
371       fillL1Bits(iEvent);
372       fillHLTBits(iEvent);
373     }
374  
375 <   for(unsigned int j = 0 ; j < jets->size(); ++j){
376 <     const pat::Jet& jet = (*jets)[j];
375 >   for(unsigned int j = 0; j < jets->size(); ++j){
376 >     const reco::Jet& jet = (*jets)[j];    
377 >     if (useJEC_ && usePat_){
378 >       jets_.rawpt[jets_.nref]=(*patjets)[j].correctedJet("Uncorrected").pt();
379 >     }
380      
381 <     //cout<<" jet pt "<<jet.pt()<<endl;
382 <     //if(jet.pt() < jetPtMin) continue;
383 <     if (useJEC_) jets_.rawpt[jets_.nref]=jet.correctedJet("Uncorrected").pt();
381 >     if(doLifeTimeTagging_){
382 >      
383 >       if(jetTag_.label()=="icPu5patJets"){
384 >         jets_.discr_csvMva[jets_.nref]    = (*patjets)[j].bDiscriminator("icPu5CombinedSecondaryVertexMVABJetTags");
385 >         jets_.discr_csvSimple[jets_.nref] = (*patjets)[j].bDiscriminator("icPu5CombinedSecondaryVertexBJetTags");
386 >         jets_.discr_muByIp3[jets_.nref]   = (*patjets)[j].bDiscriminator("icPu5SoftMuonByIP3dBJetTags");
387 >         jets_.discr_muByPt[jets_.nref]    = (*patjets)[j].bDiscriminator("icPu5SoftMuonByPtBJetTags");
388 >         jets_.discr_prob[jets_.nref]      = (*patjets)[j].bDiscriminator("icPu5JetBProbabilityBJetTags");
389 >         jets_.discr_probb[jets_.nref]     = (*patjets)[j].bDiscriminator("icPu5JetProbabilityBJetTags");
390 >         jets_.discr_tcHighEff[jets_.nref] = (*patjets)[j].bDiscriminator("icPu5TrackCountingHighEffBJetTags");
391 >         jets_.discr_tcHighPur[jets_.nref] = (*patjets)[j].bDiscriminator("icPu5TrackCountingHighPurBJetTags");
392 >       }
393 >       else if(jetTag_.label()=="akPu3PFpatJets"){
394 >         jets_.discr_csvMva[jets_.nref]    = (*patjets)[j].bDiscriminator("akPu3PFCombinedSecondaryVertexMVABJetTags");
395 >         jets_.discr_csvSimple[jets_.nref] = (*patjets)[j].bDiscriminator("akPu3PFCombinedSecondaryVertexBJetTags");
396 >         jets_.discr_muByIp3[jets_.nref]   = (*patjets)[j].bDiscriminator("akPu3PFSoftMuonByIP3dBJetTags");
397 >         jets_.discr_muByPt[jets_.nref]    = (*patjets)[j].bDiscriminator("akPu3PFSoftMuonByPtBJetTags");
398 >         jets_.discr_prob[jets_.nref]      = (*patjets)[j].bDiscriminator("akPu3PFJetBProbabilityBJetTags");
399 >         jets_.discr_probb[jets_.nref]     = (*patjets)[j].bDiscriminator("akPu3PFJetProbabilityBJetTags");
400 >         jets_.discr_tcHighEff[jets_.nref] = (*patjets)[j].bDiscriminator("akPu3PFTrackCountingHighEffBJetTags");
401 >         jets_.discr_tcHighPur[jets_.nref] = (*patjets)[j].bDiscriminator("akPu3PFTrackCountingHighPurBJetTags");
402 >       }
403 >       else{
404 >         cout<<" b-tagging variables not filled for this collection, turn of doLifeTimeTagging "<<endl;
405 >       }
406 >
407 >       const reco::SecondaryVertexTagInfo& tagInfoSV=*(*patjets)[j].tagInfoSecondaryVertex();
408 >      
409 >       jets_.nsvtx[jets_.nref]     = tagInfoSV.nVertices();      
410 >      
411 >       if (tagInfoSV.nVertices()>0) {
412 >         jets_.svtxntrk[jets_.nref]  = tagInfoSV.nVertexTracks(0);
413 >         // this is the 3d flight distance, for 2-D use (0,true)
414 >         Measurement1D m1D = tagInfoSV.flightDistance(0);        
415 >         jets_.svtxdl[jets_.nref]    = m1D.value();
416 >         jets_.svtxdls[jets_.nref]   = m1D.significance();
417 >        
418 >         const reco::Vertex& svtx = tagInfoSV.secondaryVertex(0);        
419 >         //cout<<" SV:  vx: "<<svtx.x()<<" vy "<<svtx.y()<<" vz "<<svtx.z()<<endl;
420 >         //cout<<" PV:  vx: "<<jet.vx()<<" vy "<<jet.vy()<<" vz "<<jet.vz()<<endl;      
421 >         jets_.svtxm[jets_.nref]    = svtx.p4().mass();
422 >         jets_.svtxpt[jets_.nref]   = svtx.p4().pt();    
423 >         //cout<<" chi2 "<<svtx.chi2()<<" ndof "<<svtx.ndof()<<endl;
424 >       }
425 >      
426 >       const reco::TrackIPTagInfo& tagInfoIP=*(*patjets)[j].tagInfoTrackIP();
427 >      
428 >       jets_.nIPtrk[jets_.nref] = tagInfoIP.tracks().size();
429 >       jets_.nselIPtrk[jets_.nref] = tagInfoIP.selectedTracks().size();
430 >
431 >       if (doLifeTimeTaggingExtras_) {
432 >
433 >         TrackRefVector selTracks=tagInfoIP.selectedTracks();
434 >        
435 >         GlobalPoint pv(tagInfoIP.primaryVertex()->position().x(),tagInfoIP.primaryVertex()->position().y(),tagInfoIP.primaryVertex()->position().z());
436 >        
437 >         for(int it=0;it<jets_.nselIPtrk[jets_.nref] ;it++)
438 >           {
439 >             jets_.ipJetIndex[jets_.nIP + it]= jets_.nref;
440 >             TrackIPTagInfo::TrackIPData data = tagInfoIP.impactParameterData()[it];  
441 >             jets_.ipPt[jets_.nIP + it] = selTracks[it]->pt();
442 >             jets_.ipProb0[jets_.nIP + it] = tagInfoIP.probabilities(0)[it];
443 >             jets_.ipProb1[jets_.nIP + it] = tagInfoIP.probabilities(1)[it];
444 >             jets_.ip2d[jets_.nIP + it] = data.ip2d.value();
445 >             jets_.ip2dSig[jets_.nIP + it] = data.ip2d.significance();
446 >             jets_.ip3d[jets_.nIP + it] = data.ip3d.value();
447 >             jets_.ip3dSig[jets_.nIP + it] = data.ip3d.significance();
448 >             jets_.ipDist2Jet[jets_.nIP + it] = data.distanceToJetAxis.value();
449 >             jets_.ipDist2JetSig[jets_.nIP + it] = data.distanceToJetAxis.significance();
450 >             jets_.ipClosest2Jet[jets_.nIP + it] = (data.closestToJetAxis - pv).mag();  //decay length  
451 >           }
452 >
453 >         jets_.nIP += jets_.nselIPtrk[jets_.nref];
454 >
455 >       }
456 >      
457 >       const reco::PFCandidateCollection *pfCandidateColl = &(*pfCandidates);
458 >       int pfMuonIndex = getPFJetMuon(jet, pfCandidateColl);
459 >       if(pfMuonIndex >=0){
460 >         const reco::PFCandidate muon = pfCandidateColl->at(pfMuonIndex);
461 >         jets_.mupt[jets_.nref]    =  muon.pt();
462 >         jets_.mueta[jets_.nref]   =  muon.eta();
463 >         jets_.muphi[jets_.nref]   =  muon.phi();  
464 >         jets_.mue[jets_.nref]     =  muon.energy();
465 >         jets_.mudr[jets_.nref]    =  reco::deltaR(jet,muon);
466 >         jets_.muptrel[jets_.nref] =  getPtRel(muon, jet);
467 >         jets_.muchg[jets_.nref]   =  muon.charge();
468 >       }else{
469 >         jets_.mupt[jets_.nref]    =  0.0;
470 >         jets_.mueta[jets_.nref]   =  0.0;
471 >         jets_.muphi[jets_.nref]   =  0.0;
472 >         jets_.mue[jets_.nref]     =  0.0;
473 >         jets_.mudr[jets_.nref]    =  9.9;
474 >         jets_.muptrel[jets_.nref] =  0.0;
475 >         jets_.muchg[jets_.nref]   = 0;
476 >       }
477 >
478 >     }
479 >
480 >     // Jet ID variables
481 >
482 >     jets_.muMax[jets_.nref] = 0;
483 >     jets_.muSum[jets_.nref] = 0;
484 >     jets_.muN[jets_.nref] = 0;
485 >
486 >     jets_.eMax[jets_.nref] = 0;
487 >     jets_.eSum[jets_.nref] = 0;
488 >     jets_.eN[jets_.nref] = 0;
489 >
490 >     jets_.neutralMax[jets_.nref] = 0;
491 >     jets_.neutralSum[jets_.nref] = 0;
492 >     jets_.neutralN[jets_.nref] = 0;
493 >
494 >     jets_.photonMax[jets_.nref] = 0;
495 >     jets_.photonSum[jets_.nref] = 0;
496 >     jets_.photonN[jets_.nref] = 0;
497 >     jets_.photonHardSum[jets_.nref] = 0;
498 >     jets_.photonHardN[jets_.nref] = 0;
499 >
500 >     jets_.chargedMax[jets_.nref] = 0;
501 >     jets_.chargedSum[jets_.nref] = 0;
502 >     jets_.chargedN[jets_.nref] = 0;
503 >     jets_.chargedHardSum[jets_.nref] = 0;
504 >     jets_.chargedHardN[jets_.nref] = 0;
505 >
506 >     jets_.trackMax[jets_.nref] = 0;
507 >     jets_.trackSum[jets_.nref] = 0;
508 >     jets_.trackN[jets_.nref] = 0;
509 >     jets_.trackHardSum[jets_.nref] = 0;
510 >     jets_.trackHardN[jets_.nref] = 0;
511 >
512 >     for(unsigned int icand = 0; icand < tracks->size(); ++icand){
513 >        const reco::Track& track = (*tracks)[icand];
514 >        if(useQuality_ ){
515 >           bool goodtrack = track.quality(reco::TrackBase::qualityByName(trackQuality_));
516 >           if(!goodtrack) continue;
517 >        }
518 >
519 >        double dr = deltaR(jet,track);
520 >        if(dr < rParam){
521 >           double ptcand = track.pt();
522 >           jets_.trackSum[jets_.nref] += ptcand;
523 >           jets_.trackN[jets_.nref] += 1;
524 >
525 >           if(ptcand > hardPtMin_){
526 >              jets_.trackHardSum[jets_.nref] += ptcand;
527 >              jets_.trackHardN[jets_.nref] += 1;
528 >
529 >           }
530 >           if(ptcand > jets_.trackMax[jets_.nref]) jets_.trackMax[jets_.nref] = ptcand;
531 >
532 >        }
533 >     }
534 >
535 >     for(unsigned int icand = 0; icand < pfCandidates->size(); ++icand){
536 >        const reco::PFCandidate& track = (*pfCandidates)[icand];
537 >        double dr = deltaR(jet,track);
538 >        if(dr < rParam){
539 >           double ptcand = track.pt();
540 >           int pfid = track.particleId();
541 >
542 >           switch(pfid){
543 >
544 >           case 1:
545 >              jets_.chargedSum[jets_.nref] += ptcand;
546 >              jets_.chargedN[jets_.nref] += 1;
547 >              if(ptcand > hardPtMin_){
548 >                 jets_.chargedHardSum[jets_.nref] += ptcand;
549 >                 jets_.chargedHardN[jets_.nref] += 1;
550 >              }
551 >              if(ptcand > jets_.chargedMax[jets_.nref]) jets_.chargedMax[jets_.nref] = ptcand;
552 >              break;
553 >
554 >           case 2:
555 >              jets_.eSum[jets_.nref] += ptcand;
556 >              jets_.eN[jets_.nref] += 1;
557 >              if(ptcand > jets_.eMax[jets_.nref]) jets_.eMax[jets_.nref] = ptcand;
558 >              break;
559 >
560 >           case 3:
561 >              jets_.muSum[jets_.nref] += ptcand;
562 >              jets_.muN[jets_.nref] += 1;
563 >              if(ptcand > jets_.muMax[jets_.nref]) jets_.muMax[jets_.nref] = ptcand;
564 >              break;
565 >
566 >           case 4:
567 >              jets_.photonSum[jets_.nref] += ptcand;
568 >              jets_.photonN[jets_.nref] += 1;
569 >              if(ptcand > hardPtMin_){
570 >                 jets_.photonHardSum[jets_.nref] += ptcand;
571 >                 jets_.photonHardN[jets_.nref] += 1;
572 >              }
573 >              if(ptcand > jets_.photonMax[jets_.nref]) jets_.photonMax[jets_.nref] = ptcand;
574 >              break;
575 >
576 >           case 5:
577 >              jets_.neutralSum[jets_.nref] += ptcand;
578 >              jets_.neutralN[jets_.nref] += 1;
579 >              if(ptcand > jets_.neutralMax[jets_.nref]) jets_.neutralMax[jets_.nref] = ptcand;
580 >              break;
581 >
582 >           default:
583 >             break;
584 >
585 >           }
586 >        }
587 >     }
588 >
589 >     double drMin = 100;
590 >     for(unsigned int imatch = 0 ; imatch < matchedjets->size(); ++imatch){
591 >        const reco::Jet& mjet = (*matchedjets)[imatch];
592 >
593 >        double dr = deltaR(jet,mjet);
594 >        if(dr < drMin){
595 >           jets_.matchedPt[jets_.nref] = mjet.pt();
596 >           jets_.matchedR[jets_.nref] = dr;
597 >           drMin = dr;
598 >        }
599 >     }
600 >  
601 >     //     if(etrk.quality(reco::TrackBase::qualityByName(qualityString_))) pev_.trkQual[pev_.nTrk]=1;
602 >
603 >        /////////////////////////////////////////////////////////////////
604 >        // Jet core pt^2 discriminant for fake jets
605 >        // Edited by Yue Shi Lai <ylai@mit.edu>
606 >
607 >        // Initial value is 0
608 >        jets_.discr_fr01[jets_.nref] = 0;
609 >        // Start with no directional adaption, i.e. the fake rejection
610 >        // axis is the jet axis
611 >        float pseudorapidity_adapt = jets_.jteta[jets_.nref];
612 >        float azimuth_adapt = jets_.jtphi[jets_.nref];
613 >
614 >        // Unadapted discriminant with adaption search
615 >        for (size_t iteration = 0; iteration < 2; iteration++) {
616 >                float pseudorapidity_adapt_new = pseudorapidity_adapt;
617 >                float azimuth_adapt_new = azimuth_adapt;
618 >                float max_weighted_perp = 0;
619 >                float perp_square_sum = 0;
620 >
621 >                for (size_t index_pf_candidate = 0;
622 >                         index_pf_candidate < pfCandidates->size();
623 >                         index_pf_candidate++) {
624 >                        const reco::PFCandidate &p =
625 >                                (*pfCandidates)[index_pf_candidate];
626 >
627 >                        switch (p.particleId()) {
628 >                          //case 1:     // Charged hadron
629 >                          //case 3:     // Muon
630 >                        case 4: // Photon
631 >                                {
632 >                                        const float dpseudorapidity =
633 >                                                p.eta() - pseudorapidity_adapt;
634 >                                        const float dazimuth =
635 >                                                reco::deltaPhi(p.phi(), azimuth_adapt);
636 >                                        // The Gaussian scale factor is 0.5 / (0.1 * 0.1)
637 >                                        // = 50
638 >                                        const float angular_weight =
639 >                                                exp(-50.0F * (dpseudorapidity * dpseudorapidity +
640 >                                                                          dazimuth * dazimuth));
641 >                                        const float weighted_perp =
642 >                                                angular_weight * p.pt() * p.pt();
643 >                                        const float weighted_perp_square =
644 >                                                weighted_perp * p.pt();
645 >
646 >                                        perp_square_sum += weighted_perp_square;
647 >                                        if (weighted_perp >= max_weighted_perp) {
648 >                                                pseudorapidity_adapt_new = p.eta();
649 >                                                azimuth_adapt_new = p.phi();
650 >                                                max_weighted_perp = weighted_perp;
651 >                                        }
652 >                                }
653 >                        default:                                                  
654 >                          break;
655 >                        }
656 >                }
657 >                // Update the fake rejection value
658 >                jets_.discr_fr01[jets_.nref] = std::max(
659 >                        jets_.discr_fr01[jets_.nref], perp_square_sum);
660 >                // Update the directional adaption
661 >                pseudorapidity_adapt = pseudorapidity_adapt_new;
662 >                azimuth_adapt = azimuth_adapt_new;
663 >        }
664 >
665       jets_.jtpt[jets_.nref] = jet.pt();                            
666       jets_.jteta[jets_.nref] = jet.eta();
667       jets_.jtphi[jets_.nref] = jet.phi();
668       jets_.jty[jets_.nref] = jet.eta();
669 <    
669 >     jets_.jtpu[jets_.nref] = jet.pileup();
670 >     jets_.jtm[jets_.nref] = jet.mass();
671          
672 <     if(jet.genJet()){
268 <       jets_.refpt[jets_.nref] = jet.genJet()->pt();                            
269 <       jets_.refeta[jets_.nref] = jet.genJet()->eta();
270 <       jets_.refphi[jets_.nref] = jet.genJet()->phi();
271 <       jets_.refy[jets_.nref] = jet.genJet()->eta();
272 <       jets_.refdphijt[jets_.nref] = reco::deltaPhi(jet.phi(),jet.genJet()->phi());    
273 <       jets_.refdrjt[jets_.nref] = reco::deltaR(jet.eta(),jet.phi(),jet.genJet()->eta(),jet.genJet()->phi());          
274 <     }                  
275 <     else{
276 <       jets_.refpt[jets_.nref] = -999.;
277 <       jets_.refeta[jets_.nref] = -999.;
278 <       jets_.refphi[jets_.nref] = -999.;
279 <       jets_.refy[jets_.nref] = -999.;
280 <       jets_.refdphijt[jets_.nref] = -999.;
281 <       jets_.refdrjt[jets_.nref] = -999.;
282 <     }
672 >     if(isMC_ && usePat_){
673  
674 <     // matched partons
675 <     if (jet.genParton()) {
676 <       jets_.refparton_pt[jets_.nref] = jet.genParton()->pt();
677 <       jets_.refparton_flavor[jets_.nref] = jet.genParton()->pdgId();
678 <     } else {
679 <       jets_.refparton_pt[jets_.nref] = -999;
680 <       jets_.refparton_flavor[jets_.nref] = -999;
681 <     }
674 >       const reco::GenJet * genjet = (*patjets)[j].genJet();
675 >        
676 >       if(genjet){
677 >         jets_.refpt[jets_.nref] = genjet->pt();        
678 >         jets_.refeta[jets_.nref] = genjet->eta();
679 >         jets_.refphi[jets_.nref] = genjet->phi();
680 >         jets_.refy[jets_.nref] = genjet->eta();
681 >         jets_.refdphijt[jets_.nref] = reco::deltaPhi(jet.phi(), genjet->phi());        
682 >         jets_.refdrjt[jets_.nref] = reco::deltaR(jet.eta(),jet.phi(),genjet->eta(),genjet->phi());            
683 >       }else{
684 >         jets_.refpt[jets_.nref] = -999.;
685 >         jets_.refeta[jets_.nref] = -999.;
686 >         jets_.refphi[jets_.nref] = -999.;
687 >         jets_.refy[jets_.nref] = -999.;
688 >         jets_.refdphijt[jets_.nref] = -999.;
689 >         jets_.refdrjt[jets_.nref] = -999.;
690 >       }
691 >
692 >       jets_.refparton_flavorForB[jets_.nref] = (*patjets)[j].partonFlavour();
693 >      
694 >       // matched partons
695 >       const reco::GenParticle & parton = *(*patjets)[j].genParton();
696 >
697 >       if((*patjets)[j].genParton()){
698 >         jets_.refparton_pt[jets_.nref] = parton.pt();
699 >         jets_.refparton_flavor[jets_.nref] = parton.pdgId();
700 >        
701 >         if(saveBfragments_ && abs(jets_.refparton_flavorForB[jets_.nref])==5){
702 >
703 >           usedStringPts.clear();
704 >          
705 >           // uncomment this if you want to know the ugly truth about parton matching -matt
706 >           //if(jet.pt() > 50 &&abs(parton.pdgId())!=5 && parton.pdgId()!=21)
707 >           // cout<<" Identified as a b, but doesn't match b or gluon, id = "<<parton.pdgId()<<endl;
708 >          
709 >           jets_.bJetIndex[jets_.bMult] = jets_.nref;
710 >           jets_.bStatus[jets_.bMult] = parton.status();
711 >           jets_.bVx[jets_.bMult] = parton.vx();
712 >           jets_.bVy[jets_.bMult] = parton.vy();
713 >           jets_.bVz[jets_.bMult] = parton.vz();
714 >           jets_.bPt[jets_.bMult] = parton.pt();
715 >           jets_.bEta[jets_.bMult] = parton.eta();
716 >           jets_.bPhi[jets_.bMult] = parton.phi();
717 >           jets_.bPdg[jets_.bMult] = parton.pdgId();
718 >           jets_.bChg[jets_.bMult] = parton.charge();
719 >           jets_.bMult++;
720 >           saveDaughters(parton);
721 >         }
722 >
723 >
724 >       } else {
725 >         jets_.refparton_pt[jets_.nref] = -999;
726 >         jets_.refparton_flavor[jets_.nref] = -999;
727 >       }
728 >      
729  
730 +     }
731  
732       jets_.nref++;
733        
# Line 299 | Line 737 | HiInclusiveJetAnalyzer::analyze(const Ev
737  
738     if(isMC_){
739  
740 +     edm::Handle<HepMCProduct> hepMCProduct;
741 +     iEvent.getByLabel(eventInfoTag_,hepMCProduct);
742 +     const HepMC::GenEvent* MCEvt = hepMCProduct->GetEvent();
743 +
744 +        std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beamParticles = MCEvt->beam_particles();
745 +        if(beamParticles.first != 0)jets_.beamId1 = beamParticles.first->pdg_id();
746 +        if(beamParticles.second != 0)jets_.beamId2 = beamParticles.second->pdg_id();
747 +
748       edm::Handle<GenEventInfoProduct> hEventInfo;
749       iEvent.getByLabel(eventInfoTag_,hEventInfo);
750       //jets_.pthat = hEventInfo->binningValues()[0];
# Line 316 | Line 762 | HiInclusiveJetAnalyzer::analyze(const Ev
762         float genjet_pt = genjet.pt();
763        
764         // threshold to reduce size of output in minbias PbPb
765 <       if(genjet_pt>20.){
765 >       if(genjet_pt>genPtMin_){
766  
767           jets_.genpt[jets_.ngen] = genjet_pt;                            
768           jets_.geneta[jets_.ngen] = genjet.eta();
769           jets_.genphi[jets_.ngen] = genjet.phi();
770           jets_.geny[jets_.ngen] = genjet.eta();
771          
772 +         if(doSubEvent_){
773 +            const GenParticle* gencon = genjet.getGenConstituent(0);
774 +            jets_.gensubid[jets_.ngen] = gencon->collisionId();
775 +         }
776          
777           // find matching patJet if there is one
778          
779           jets_.gendrjt[jets_.ngen] = -1.0;
780           jets_.genmatchindex[jets_.ngen] = -1;
781          
332        
782           for(unsigned int ijet = 0 ; ijet < jets->size(); ++ijet){
783             const pat::Jet& jet = (*jets)[ijet];
784 <          
785 <           if(jet.genJet()){
786 <             if(fabs(genjet.pt()-jet.genJet()->pt())<0.0001 &&
787 <                fabs(genjet.eta()-jet.genJet()->eta())<0.0001 &&
788 <                (fabs(genjet.phi()-jet.genJet()->phi())<0.0001 || fabs(genjet.phi()-jet.genJet()->phi() - 2.0*TMath::Pi()) < 0.0001 )){
784 >           const reco::GenJet* matchedGenJet = (*patjets)[ijet].genJet();
785 >           if(matchedGenJet){
786 >             // poor man's matching, someone fix please
787 >             if(fabs(genjet.pt()-matchedGenJet->pt())<0.0001 &&
788 >                fabs(genjet.eta()-matchedGenJet->eta())<0.0001 &&
789 >                (fabs(genjet.phi()-matchedGenJet->phi())<0.0001 || fabs(genjet.phi()-matchedGenJet->phi() - 2.0*TMath::Pi()) < 0.0001 )){
790                
791                 jets_.genmatchindex[jets_.ngen] = (int)ijet;
792                 jets_.gendphijt[jets_.ngen] = reco::deltaPhi(jet.phi(),genjet.phi());    
# Line 352 | Line 802 | HiInclusiveJetAnalyzer::analyze(const Ev
802       }
803      
804     }
805 +
806     t->Fill();
807 +   memset(&jets_,0,sizeof jets_);
808 +
809   }
810  
811  
# Line 452 | Line 905 | inline bool HiInclusiveJetAnalyzer::getP
905   }
906  
907  
908 + int
909 + HiInclusiveJetAnalyzer::getPFJetMuon(const pat::Jet& pfJet, const reco::PFCandidateCollection *pfCandidateColl)
910 + {
911 +  
912 +  int pfMuonIndex = -1;
913 +  float ptMax = 0.;
914 +
915 +
916 +  for(unsigned icand=0;icand<pfCandidateColl->size(); icand++) {
917 +    const reco::PFCandidate pfCandidate = pfCandidateColl->at(icand);      
918 +    
919 +    int id = pfCandidate.particleId();
920 +    if(abs(id) != 3) continue;
921 +
922 +    if(reco::deltaR(pfJet,pfCandidate)>0.5) continue;      
923 +    
924 +    double pt =  pfCandidate.pt();
925 +    if(pt>ptMax){
926 +      ptMax = pt;
927 +      pfMuonIndex = (int) icand;
928 +    }
929 +  }
930 +
931 +  return pfMuonIndex;  
932 +
933 + }
934 +
935 +
936 + double
937 + HiInclusiveJetAnalyzer::getPtRel(const reco::PFCandidate lep, const pat::Jet& jet )
938 + {
939 +  
940 +  float lj_x = jet.p4().px();
941 +  float lj_y = jet.p4().py();
942 +  float lj_z = jet.p4().pz();
943 +  
944 +  // absolute values squared
945 +  float lj2  = lj_x*lj_x+lj_y*lj_y+lj_z*lj_z;
946 +  float lep2 = lep.px()*lep.px()+lep.py()*lep.py()+lep.pz()*lep.pz();
947 +  
948 +  // projection vec(mu) to lepjet axis
949 +  float lepXlj = lep.px()*lj_x+lep.py()*lj_y+lep.pz()*lj_z;
950 +  
951 +  // absolute value squared and normalized
952 +  float pLrel2 = lepXlj*lepXlj/lj2;
953 +  
954 +  // lep2 = pTrel2 + pLrel2
955 +  float pTrel2 = lep2-pLrel2;
956 +  
957 +  return (pTrel2 > 0) ? std::sqrt(pTrel2) : 0.0;
958 + }
959 +
960 + // Recursive function, but this version gets called only the first time
961 + void
962 + HiInclusiveJetAnalyzer::saveDaughters(const reco::GenParticle &gen){
963 +  
964 +  for(unsigned i=0;i<gen.numberOfDaughters();i++){
965 +    const reco::Candidate & daughter = *gen.daughter(i);
966 +    double daughterPt = daughter.pt();
967 +    if(daughterPt<1.) continue;
968 +    double daughterEta = daughter.eta();
969 +    if(fabs(daughterEta)>3.) continue;
970 +    int daughterPdgId = daughter.pdgId();
971 +    int daughterStatus = daughter.status();
972 +    // Special case when b->b+string, both b and string contain all daughters, so only take the string
973 +    if(gen.pdgId()==daughterPdgId && gen.status()==3 && daughterStatus==2) continue;
974 +
975 +    // cheesy way of finding strings which were already used
976 +    if(daughter.pdgId()==92){
977 +      for(unsigned ist=0;ist<usedStringPts.size();ist++){
978 +        if(fabs(daughter.pt() - usedStringPts[ist]) < 0.0001) return;
979 +      }
980 +      usedStringPts.push_back(daughter.pt());
981 +    }
982 +    jets_.bJetIndex[jets_.bMult] = jets_.nref;
983 +    jets_.bStatus[jets_.bMult] = daughterStatus;
984 +    jets_.bVx[jets_.bMult] = daughter.vx();
985 +    jets_.bVy[jets_.bMult] = daughter.vy();
986 +    jets_.bVz[jets_.bMult] = daughter.vz();
987 +    jets_.bPt[jets_.bMult] = daughterPt;
988 +    jets_.bEta[jets_.bMult] = daughterEta;
989 +    jets_.bPhi[jets_.bMult] = daughter.phi();
990 +    jets_.bPdg[jets_.bMult] = daughterPdgId;
991 +    jets_.bChg[jets_.bMult] = daughter.charge();
992 +    jets_.bMult++;
993 +    saveDaughters(daughter);
994 +  }
995 + }
996 +
997 + // This version called for all subsequent calls
998 + void
999 + HiInclusiveJetAnalyzer::saveDaughters(const reco::Candidate &gen){
1000 +
1001 +  for(unsigned i=0;i<gen.numberOfDaughters();i++){
1002 +    const reco::Candidate & daughter = *gen.daughter(i);
1003 +    double daughterPt = daughter.pt();
1004 +    if(daughterPt<1.) continue;
1005 +    double daughterEta = daughter.eta();
1006 +    if(fabs(daughterEta)>3.) continue;
1007 +    int daughterPdgId = daughter.pdgId();
1008 +    int daughterStatus = daughter.status();
1009 +    // Special case when b->b+string, both b and string contain all daughters, so only take the string
1010 +    if(gen.pdgId()==daughterPdgId && gen.status()==3 && daughterStatus==2) continue;
1011 +
1012 +    // cheesy way of finding strings which were already used
1013 +    if(daughter.pdgId()==92){
1014 +      for(unsigned ist=0;ist<usedStringPts.size();ist++){
1015 +        if(fabs(daughter.pt() - usedStringPts[ist]) < 0.0001) return;
1016 +      }
1017 +      usedStringPts.push_back(daughter.pt());
1018 +    }
1019  
1020 +    jets_.bJetIndex[jets_.bMult] = jets_.nref;
1021 +    jets_.bStatus[jets_.bMult] = daughterStatus;
1022 +    jets_.bVx[jets_.bMult] = daughter.vx();
1023 +    jets_.bVy[jets_.bMult] = daughter.vy();
1024 +    jets_.bVz[jets_.bMult] = daughter.vz();
1025 +    jets_.bPt[jets_.bMult] = daughterPt;
1026 +    jets_.bEta[jets_.bMult] = daughterEta;
1027 +    jets_.bPhi[jets_.bMult] = daughter.phi();
1028 +    jets_.bPdg[jets_.bMult] = daughterPdgId;
1029 +    jets_.bChg[jets_.bMult] = daughter.charge();
1030 +    jets_.bMult++;
1031 +    saveDaughters(daughter);
1032 +  }
1033 + }
1034                                                                          
1035   DEFINE_FWK_MODULE(HiInclusiveJetAnalyzer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines