ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/HbbAnalyzer/plugins/HbbAnalyzerNew.cc
(Generate patch)

Comparing UserCode/VHbbAnalysis/HbbAnalyzer/plugins/HbbAnalyzerNew.cc (file contents):
Revision 1.3 by tboccali, Thu Jun 9 06:51:57 2011 UTC vs.
Revision 1.31 by tboccali, Fri Sep 9 12:34:45 2011 UTC

# Line 17 | Line 17 | Implementation:
17   //
18   //
19  
20 + #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
21 + #include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h"
22 + #include "JetMETCorrections/Objects/interface/JetCorrector.h"
23 + #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
24 + #include "DataFormats/TrackReco/interface/TrackFwd.h"
25 +
26   #include "VHbbAnalysis/HbbAnalyzer/interface/HbbAnalyzerNew.h"
21 #include "VHbbAnalysis/HbbAnalyzer/interface/VHbbEvent.h"
27  
28   #define GENPTOLOR(a) TLorentzVector((a).px(), (a).py(), (a).pz(), (a).energy())
29   #define GENPTOLORP(a) TLorentzVector((a)->px(), (a)->py(), (a)->pz(), (a)->energy())
30  
26 HbbAnalyzerNew::HbbAnalyzerNew(const edm::ParameterSet& iConfig):
27  eleLabel_(iConfig.getUntrackedParameter<edm::InputTag>("electronTag")),
28  muoLabel_(iConfig.getUntrackedParameter<edm::InputTag>("muonTag")),
29  jetLabel_(iConfig.getUntrackedParameter<edm::InputTag>("jetTag")),
30  subjetLabel_(iConfig.getUntrackedParameter<edm::InputTag>("subjetTag")),
31  simplejet1Label_(iConfig.getUntrackedParameter<edm::InputTag>("simplejet1Tag")),
32  simplejet2Label_(iConfig.getUntrackedParameter<edm::InputTag>("simplejet2Tag")),
33  simplejet3Label_(iConfig.getUntrackedParameter<edm::InputTag>("simplejet3Tag")),
34  simplejet4Label_(iConfig.getUntrackedParameter<edm::InputTag>("simplejet4Tag")),
35  tauLabel_(iConfig.getUntrackedParameter<edm::InputTag>("tauTag")),
36  metLabel_(iConfig.getUntrackedParameter<edm::InputTag>("metTag")),
37  phoLabel_(iConfig.getUntrackedParameter<edm::InputTag>("photonTag")),
38  dimuLabel_(iConfig.getUntrackedParameter<edm::InputTag>("dimuTag")),
39  dielecLabel_(iConfig.getUntrackedParameter<edm::InputTag>("dielecTag")),
40  hltResults_(iConfig.getUntrackedParameter<edm::InputTag>("hltResultsTag")),
41  runOnMC_(iConfig.getParameter<bool>("runOnMC")) {
31  
32 + struct CompareJetPtMuons {
33 +  bool operator()( const VHbbEvent::MuonInfo& j1, const  VHbbEvent::MuonInfo& j2 ) const {
34 +    return j1.p4.Pt() > j2.p4.Pt();
35 +  }
36 + };
37 + struct CompareJetPtElectrons {
38 +  bool operator()( const VHbbEvent::ElectronInfo& j1, const  VHbbEvent::ElectronInfo& j2 ) const {
39 +    return j1.p4.Pt() > j2.p4.Pt();
40 +  }
41 + };
42 + struct CompareJetPtTaus {
43 +  bool operator()( const VHbbEvent::TauInfo& j1, const  VHbbEvent::TauInfo& j2 ) const {
44 +    return j1.p4.Pt() > j2.p4.Pt();
45 +  }
46 + };
47 +
48 +
49 +
50 + HbbAnalyzerNew::HbbAnalyzerNew(const edm::ParameterSet& iConfig):
51 +  eleLabel_(iConfig.getParameter<edm::InputTag>("electronTag")),
52 +  muoLabel_(iConfig.getParameter<edm::InputTag>("muonTag")),
53 +  jetLabel_(iConfig.getParameter<edm::InputTag>("jetTag")),
54 +  subjetLabel_(iConfig.getParameter<edm::InputTag>("subjetTag")),
55 +  simplejet1Label_(iConfig.getParameter<edm::InputTag>("simplejet1Tag")),
56 +  simplejet2Label_(iConfig.getParameter<edm::InputTag>("simplejet2Tag")),
57 +  simplejet3Label_(iConfig.getParameter<edm::InputTag>("simplejet3Tag")),
58 +  simplejet4Label_(iConfig.getParameter<edm::InputTag>("simplejet4Tag")),
59 +  tauLabel_(iConfig.getParameter<edm::InputTag>("tauTag")),
60 +  metLabel_(iConfig.getParameter<edm::InputTag>("metTag")),
61 +  phoLabel_(iConfig.getParameter<edm::InputTag>("photonTag")),
62 +  dimuLabel_(iConfig.getParameter<edm::InputTag>("dimuTag")),
63 +  dielecLabel_(iConfig.getParameter<edm::InputTag>("dielecTag")),
64 +  hltResults_(iConfig.getParameter<edm::InputTag>("hltResultsTag")),
65 +  runOnMC_(iConfig.getParameter<bool>("runOnMC")), verbose_(iConfig.getUntrackedParameter<bool>("verbose")) {
66  
67    //
68    // put the setwhatproduced etc etc
69  
70    produces<VHbbEvent>();
71 +  produces<VHbbEventAuxInfo>();
72  
73  
74   }
# Line 68 | Line 92 | HbbAnalyzerNew::produce(edm::Event& iEve
92    using namespace edm;
93    using namespace reco;
94    
95 +  // JEC Uncertainty
96 +
97 +  //  JetCorrectionUncertainty *jecUnc=0;
98 +  edm::ESHandle<JetCorrectorParametersCollection> JetCorParColl;
99 +  iSetup.get<JetCorrectionsRecord>().get("AK5PF",JetCorParColl);
100 +  JetCorrectionUncertainty *jecUnc=0;
101 +  //  if (!runOnMC_){
102 +  JetCorrectorParameters const & JetCorPar = (*JetCorParColl)["Uncertainty"];
103 +  jecUnc = new JetCorrectionUncertainty(JetCorPar);
104 +  //  }
105    
106 <  std::auto_ptr<VHbbEvent> hbbInfo( new VHbbEvent() );
106 >  std::auto_ptr<VHbbEvent> hbbInfo( new VHbbEvent() );  
107 >  std::auto_ptr<VHbbEventAuxInfo> auxInfo( new VHbbEventAuxInfo() );
108    
109    //
110    // ??
111    
112    // trigger
113 +
114 +  // trigger
115    edm::Handle<edm::TriggerResults>  hltresults;
116    //iEvent.getByLabel("TriggerResults", hltresults);
117    
# Line 83 | Line 120 | HbbAnalyzerNew::produce(edm::Event& iEve
120    iEvent.getByLabel(hltResults_, hltresults);
121    
122    const edm::TriggerNames & triggerNames_ = iEvent.triggerNames(*hltresults);
86  
87  int ntrigs = hltresults->size();
88  if (ntrigs==0){std::cout << "%HLTInfo -- No trigger name given in TriggerResults of the input " << std::endl;}
89
90  for (int itrig = 0; itrig != ntrigs; ++itrig){
91
92    TString trigName=triggerNames_.triggerName(itrig);
93    bool accept = hltresults->accept(itrig);
94
95    if (accept){(hbbInfo->triggerInfo.flag)[itrig] = 1;}
96    else { (hbbInfo->triggerInfo.flag)[itrig] = 0;}
97
98    //    std::cout << "%HLTInfo --  Number of HLT Triggers: " << ntrigs << std::endl;
99    //    std::cout << "%HLTInfo --  HLTTrigger(" << itrig << "): " << trigName << " = " << accept << std::endl;
100  }
101
102  //
103  // big bloat
104  //
105
106
107  int goodDoubleMu3=0,goodDoubleMu3_2=0,  
108    goodMu9=0, goodIsoMu9=0, goodMu11=0, goodIsoMu13_3=0, goodMu15=0, goodMu15_1=0;
109  int goodDoubleElec10=0,goodDoubleElec15_1=0,goodDoubleElec17_1=0;
110  int goodMet100=0;
111  int goodSingleEle1=0,goodSingleEle2=0,goodSingleEle3=0,goodSingleEle4=0;
112  int goodBtagMu1=0,goodBtagMu2=0,goodBtagMu0=0,goodBtagMu11=0;  
113  int goodBtagMuJet1=0, goodBtagMuJet2=0, goodBtagMuJet3=0, goodBtagMuJet4=0;
114  int goodIsoMu15=0,goodIsoMu17v5=0,goodIsoMu17v6=0;
115
116  for (int itrig = 0; itrig != ntrigs; ++itrig){
117    TString trigName=triggerNames_.triggerName(itrig);
118    if(strcmp(trigName,"HLT_Mu9")==0) goodMu9++;
119    if(strcmp(trigName,"HLT_IsoMu9")==0) goodIsoMu9++;
120    if(strcmp(trigName,"HLT_IsoMu13_v3")==0) goodIsoMu13_3++;
121    if(strcmp(trigName,"HLT_Mu11")==0) goodMu11++;
122    if(strcmp(trigName,"HLT_DoubleMu3")==0) goodDoubleMu3++;
123    if(strcmp(trigName,"HLT_DoubleMu3_v2")==0) goodDoubleMu3_2++;
124    if(strcmp(trigName,"HLT_Mu15")==0) goodMu15++;
125    if(strcmp(trigName,"HLT_Mu15_v1")==0) goodMu15_1++;
126
127    if(strcmp(trigName,"HLT_DoubleEle10_SW_L1R")==0) goodDoubleElec10++;
128    if(strcmp(trigName,"HLT_DoubleEle15_SW_L1R_v1")==0) goodDoubleElec15_1++;
129    if(strcmp(trigName,"HLT_DoubleEle17_SW_L1R_v1")==0) goodDoubleElec17_1++;
130    if(strcmp(trigName,"HLT_MET100_v1")==0) goodMet100++;
131    if(strcmp(trigName,"HLT_Ele15_SW_L1R")==0) goodSingleEle1++;
132    if(strcmp(trigName,"HLT_Ele17_SW_TightEleId_L1R")==0) goodSingleEle2++;
133    if(strcmp(trigName,"HLT_Ele17_SW_TighterEleIdIsol_L1R_v2")==0) goodSingleEle3++;
134    if(strcmp(trigName,"HLT_Ele17_SW_TighterEleIdIsol_L1R_v3")==0) goodSingleEle4++;
135    if(strcmp(trigName,"HLT_BTagMu_DiJet20U_v1")==0) goodBtagMu1++;
136    if(strcmp(trigName,"HLT_BTagMu_DiJet30U_Mu5_v3")==0) goodBtagMu2++;
137    if(strcmp(trigName,"HLT_BTagMu_Jet20U")==0) goodBtagMu0++;
138    if(strcmp(trigName,"HLT_BTagMu_DiJet20U_Mu5_v1")==0) goodBtagMu11++;
139    if(strcmp(trigName,"HLT_Mu17_CentralJet30_BTagIP_v2")==0) goodBtagMuJet1++;
140    if(strcmp(trigName,"HLT_Mu17_CentralJet30_v2")==0) goodBtagMuJet2++;
141    if(strcmp(trigName,"HLT_HT200_Mu5_PFMHT35_v2")==0) goodBtagMuJet3++;
142    if(strcmp(trigName,"HLT_Mu12_CentralJet30_BTagIP_v2")==0) goodBtagMuJet4++;  
143
144    if(strcmp(trigName,"HLT_IsoMu15_v5")==0) goodIsoMu15++;
145    if(strcmp(trigName,"HLT_IsoMu17_v5")==0) goodIsoMu17v5++;  
146    if(strcmp(trigName,"HLT_IsoMu17_v6")==0) goodIsoMu17v6++;  
147  }
148  int itrig1=-99;
149  if(goodMu9!=0) itrig1 = triggerNames_.triggerIndex("HLT_Mu9");
150  int itrig2=-99;
151  if(goodIsoMu9!=0) itrig2 = triggerNames_.triggerIndex("HLT_IsoMu9");
152  int itrig3=-99;
153  if(goodIsoMu13_3!=0) itrig3 = triggerNames_.triggerIndex("HLT_IsoMu13_v3");
154  int itrig4=-99;
155  if(goodMu11!=0) itrig4 = triggerNames_.triggerIndex("HLT_Mu11");
156  int itrig5=-99;  
157  if(goodDoubleMu3!=0) itrig5 = triggerNames_.triggerIndex("HLT_DoubleMu3");
158  int itrig6=-99;
159  if(goodDoubleMu3_2!=0) itrig6 = triggerNames_.triggerIndex("HLT_DoubleMu3_v2");
160  int itrig7=-99;
161  if(goodMu15!=0) itrig7 = triggerNames_.triggerIndex("HLT_Mu15");
162  int itrig8=-99;
163  if(goodMu15_1!=0) itrig8 = triggerNames_.triggerIndex("HLT_Mu15_v1");
164
165  int itrig9=-99;
166  if(goodDoubleElec10!=0) itrig9 = triggerNames_.triggerIndex("HLT_DoubleEle10_SW_L1R");
167  int itrig10=-99;
168  if(goodDoubleElec15_1!=0) itrig10 = triggerNames_.triggerIndex("HLT_DoubleEle15_SW_L1R_v1");
169  int itrig11=-99;
170  if(goodDoubleElec17_1!=0) itrig11 = triggerNames_.triggerIndex("HLT_DoubleEle17_SW_L1R_v1");
171  int itrig12=-99;
172  if(goodMet100!=0) itrig12 = triggerNames_.triggerIndex("HLT_MET100_v1");
173
174  int itrig13=-99;
175  if(goodSingleEle1!=0) itrig13 = triggerNames_.triggerIndex("HLT_Ele15_SW_L1R");
176  int itrig14=-99;
177  if(goodSingleEle2!=0) itrig14 = triggerNames_.triggerIndex("HLT_Ele17_SW_TightEleId_L1R");
178  int itrig15=-99;
179  if(goodSingleEle3!=0) itrig15 = triggerNames_.triggerIndex("HLT_Ele17_SW_TighterEleIdIsol_L1R_v2");
180  int itrig16=-99;
181  if(goodSingleEle4!=0) itrig16 = triggerNames_.triggerIndex("HLT_Ele17_SW_TighterEleIdIsol_L1R_v3");
182
183  int itrig17=-99;
184  if(goodBtagMu1!=0) itrig17 = triggerNames_.triggerIndex("HLT_BTagMu_DiJet20U_v1");      
185  int itrig18=-99;
186  if(goodBtagMu2!=0) itrig18 = triggerNames_.triggerIndex("HLT_BTagMu_DiJet30U_Mu5_v3");    
187  int itrig19=-99;
188  if(goodBtagMu0!=0) itrig19 = triggerNames_.triggerIndex("HLT_BTagMu_Jet20U");
189  int itrig20=-99;
190  if(goodBtagMu11!=0) itrig20 = triggerNames_.triggerIndex("HLT_BTagMu_DiJet20U_Mu5_v1");
191  int itrig21=-99;
192  if(goodBtagMuJet1!=0) itrig21 = triggerNames_.triggerIndex("HLT_Mu17_CentralJet30_BTagIP_v2");
193  int itrig22=-99;
194  if(goodBtagMuJet2!=0) itrig22 = triggerNames_.triggerIndex("HLT_Mu17_CentralJet30_v2");
195  int itrig23=-99;
196  if(goodBtagMuJet3!=0) itrig23 = triggerNames_.triggerIndex("HLT_HT200_Mu5_PFMHT35_v2");
197  int itrig231=-99;
198  if(goodBtagMuJet4!=0) itrig231 = triggerNames_.triggerIndex("HLT_Mu12_CentralJet30_BTagIP_v2");  
199
200  int itrig24=-99;
201  if(goodIsoMu15!=0) itrig24 = triggerNames_.triggerIndex("HLT_IsoMu15_v5");
202  int itrig25=-99;
203  if(goodIsoMu17v5!=0) itrig25 = triggerNames_.triggerIndex("HLT_IsoMu17_v5");
204  int itrig26=-99;
205  if(goodIsoMu17v6!=0) itrig26 = triggerNames_.triggerIndex("HLT_IsoMu17_v6");
206  
207  if (itrig1!=-99 && hltresults->accept(itrig1))  hbbInfo->triggerInfo.triggerMu9=1; else hbbInfo->triggerInfo.triggerMu9=0;
208  if (itrig2!=-99 && hltresults->accept(itrig2))  hbbInfo->triggerInfo.triggerIsoMu9=1; else hbbInfo->triggerInfo.triggerIsoMu9=0;
209  if (itrig3!=-99 && hltresults->accept(itrig3))  hbbInfo->triggerInfo.triggerIsoMu13_3=1; else hbbInfo->triggerInfo.triggerIsoMu13_3=0;
210  if (itrig4!=-99 && hltresults->accept(itrig4))  hbbInfo->triggerInfo.triggerMu11=1; else hbbInfo->triggerInfo.triggerMu11=0;
211  if (itrig5!=-99 && hltresults->accept(itrig5))  hbbInfo->triggerInfo.triggerDoubleMu3=1; else hbbInfo->triggerInfo.triggerDoubleMu3=0;
212  if (itrig6!=-99 && hltresults->accept(itrig6))  hbbInfo->triggerInfo.triggerDoubleMu3_2=1; else hbbInfo->triggerInfo.triggerDoubleMu3_2=0;
213  if (itrig7!=-99 && hltresults->accept(itrig7))  hbbInfo->triggerInfo.triggerMu15=1; else hbbInfo->triggerInfo.triggerMu15=0;
214  if (itrig8!=-99 && hltresults->accept(itrig8))  hbbInfo->triggerInfo.triggerMu15_1=1; else hbbInfo->triggerInfo.triggerMu15_1=0;  
215  
216  if (itrig9!=-99 && hltresults->accept(itrig9))  hbbInfo->triggerInfo.triggerDoubleElec10=1; else hbbInfo->triggerInfo.triggerDoubleElec10=0;  
217  if (itrig10!=-99 && hltresults->accept(itrig10))  hbbInfo->triggerInfo.triggerDoubleElec15_1=1; else hbbInfo->triggerInfo.triggerDoubleElec15_1=0;  
218  if (itrig11!=-99 && hltresults->accept(itrig11))  hbbInfo->triggerInfo.triggerDoubleElec17_1=1; else hbbInfo->triggerInfo.triggerDoubleElec17_1=0;  
219  if (itrig12!=-99 && hltresults->accept(itrig12))  hbbInfo->triggerInfo.triggerMet100_1=1; else hbbInfo->triggerInfo.triggerMet100_1=0;
220  
221  if (itrig13!=-99 && hltresults->accept(itrig13))  hbbInfo->triggerInfo.triggerSingleEle1=1; else hbbInfo->triggerInfo.triggerSingleEle1=0;
222  if (itrig14!=-99 && hltresults->accept(itrig14))  hbbInfo->triggerInfo.triggerSingleEle2=1; else hbbInfo->triggerInfo.triggerSingleEle2=0;
223  if (itrig15!=-99 && hltresults->accept(itrig15))  hbbInfo->triggerInfo.triggerSingleEle3=1; else hbbInfo->triggerInfo.triggerSingleEle3=0;
224  if (itrig16!=-99 && hltresults->accept(itrig16))  hbbInfo->triggerInfo.triggerSingleEle4=1; else hbbInfo->triggerInfo.triggerSingleEle4=0;
225  
226  if (itrig17!=-99 && hltresults->accept(itrig17))  hbbInfo->triggerInfo.triggerBtagMu1=1; else hbbInfo->triggerInfo.triggerBtagMu1=0;  
227  if (itrig18!=-99 && hltresults->accept(itrig18))  hbbInfo->triggerInfo.triggerBtagMu2=1; else hbbInfo->triggerInfo.triggerBtagMu2=0;
228  if (itrig19!=-99 && hltresults->accept(itrig19))  hbbInfo->triggerInfo.triggerBtagMu0=1; else hbbInfo->triggerInfo.triggerBtagMu0=0;
229  if (itrig20!=-99 && hltresults->accept(itrig20))  hbbInfo->triggerInfo.triggerBtagMu11=1; else hbbInfo->triggerInfo.triggerBtagMu11=0;
230  if (itrig21!=-99 && hltresults->accept(itrig21))  hbbInfo->triggerInfo.triggerBtagMuJet1=1; else hbbInfo->triggerInfo.triggerBtagMuJet1=0;
231  if (itrig22!=-99 && hltresults->accept(itrig22))  hbbInfo->triggerInfo.triggerBtagMuJet2=1; else hbbInfo->triggerInfo.triggerBtagMuJet2=0;
232  if (itrig23!=-99 && hltresults->accept(itrig23))  hbbInfo->triggerInfo.triggerBtagMuJet3=1; else hbbInfo->triggerInfo.triggerBtagMuJet3=0;
233  if (itrig231!=-99 && hltresults->accept(itrig231))  hbbInfo->triggerInfo.triggerBtagMuJet4=1; else hbbInfo->triggerInfo.triggerBtagMuJet4=0;
234  
235  if (itrig24!=-99 && hltresults->accept(itrig24))  hbbInfo->triggerInfo.triggerIsoMu15=1; else hbbInfo->triggerInfo.triggerIsoMu15=0;
236  if (itrig25!=-99 && hltresults->accept(itrig25))  hbbInfo->triggerInfo.triggerIsoMu17v5=1; else hbbInfo->triggerInfo.triggerIsoMu17v5=0;
237  if (itrig26!=-99 && hltresults->accept(itrig26))  hbbInfo->triggerInfo.triggerIsoMu17v6=1; else hbbInfo->triggerInfo.triggerIsoMu17v6=0;
238  
239  if (itrig1==-99)  hbbInfo->triggerInfo.triggerMu9=-99;
240  if (itrig2==-99)  hbbInfo->triggerInfo.triggerIsoMu9=-99;
241  if (itrig3==-99)  hbbInfo->triggerInfo.triggerIsoMu13_3=-99;
242  if (itrig4==-99)  hbbInfo->triggerInfo.triggerMu11=-99;
243  if (itrig5==-99)  hbbInfo->triggerInfo.triggerDoubleMu3=-99;
244  if (itrig6==-99)  hbbInfo->triggerInfo.triggerDoubleMu3_2=-99;
245  if (itrig7==-99)  hbbInfo->triggerInfo.triggerMu15=-99;
246  if (itrig8==-99)  hbbInfo->triggerInfo.triggerMu15_1=-99;
247
248  if (itrig9==-99)  hbbInfo->triggerInfo.triggerDoubleElec10=-99;
249  if (itrig10==-99)  hbbInfo->triggerInfo.triggerDoubleElec15_1=-99;
250  if (itrig11==-99)  hbbInfo->triggerInfo.triggerDoubleElec17_1=-99;
251  if (itrig12==-99) hbbInfo->triggerInfo.triggerMet100_1=-99;
252
253  if (itrig13==-99) hbbInfo->triggerInfo.triggerSingleEle1=-99;
254  if (itrig14==-99) hbbInfo->triggerInfo.triggerSingleEle2=-99;
255  if (itrig15==-99) hbbInfo->triggerInfo.triggerSingleEle3=-99;
256  if (itrig16==-99) hbbInfo->triggerInfo.triggerSingleEle4=-99;
257
258  if(itrig17==-99)  hbbInfo->triggerInfo.triggerBtagMu1=-99;  
259  if(itrig18==-99)  hbbInfo->triggerInfo.triggerBtagMu2=-99;
260  if(itrig19==-99)  hbbInfo->triggerInfo.triggerBtagMu0=-99;
261  if(itrig20==-99)  hbbInfo->triggerInfo.triggerBtagMu11=-99;
262  if(itrig21==-99)  hbbInfo->triggerInfo.triggerBtagMuJet1=-99;
263  if(itrig22==-99)  hbbInfo->triggerInfo.triggerBtagMuJet2=-99;
264  if(itrig23==-99)  hbbInfo->triggerInfo.triggerBtagMuJet3=-99;
265  if(itrig231==-99)  hbbInfo->triggerInfo.triggerBtagMuJet4=-99;
266
267  if(itrig24==-99)  hbbInfo->triggerInfo.triggerIsoMu15=-99;
268  if(itrig25==-99)  hbbInfo->triggerInfo.triggerIsoMu17v5=-99;
269  if(itrig26==-99)  hbbInfo->triggerInfo.triggerIsoMu17v6=-99;
270
271  //  MinDRMu=-99.,MCBestMuId=-99,MCBestMuMomId=-99,MCBestMuGMomId=-99;
272  //  for(int i=0;i<50;i++) {DeltaRMu[i]=-99;}
273
123  
124 +  int ntrigs = hltresults->size();
125 +  if (ntrigs==0){std::cerr << "%HLTInfo -- No trigger name given in TriggerResults of the input " << std::endl;}
126  
127    BeamSpot vertexBeamSpot;
128    edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
# Line 289 | Line 140 | HbbAnalyzerNew::produce(edm::Event& iEve
140    Handle<reco::VertexCollection> recVtxs;
141    iEvent.getByLabel("offlinePrimaryVertices", recVtxs);
142    
143 +  auxInfo->pvInfo.nVertices = recVtxs->size();
144 +
145    for(size_t i = 0; i < recVtxs->size(); ++ i) {
146      const Vertex &vtx = (*recVtxs)[i];
147      double RecVtxProb=TMath::Prob(vtx.chi2(),vtx.ndof());
# Line 301 | Line 154 | HbbAnalyzerNew::produce(edm::Event& iEve
154    const Vertex &RecVtx = (*recVtxs)[VtxIn];
155    const Vertex &RecVtxFirst = (*recVtxs)[0];
156    
157 <  hbbInfo->pvInfo.firstPVInPT2 = TVector3(RecVtxFirst.x(), RecVtxFirst.y(), RecVtxFirst.z());
158 <  hbbInfo->pvInfo.firstPVInProb = TVector3(RecVtx.x(), RecVtx.y(), RecVtx.z());
157 >  auxInfo->pvInfo.firstPVInPT2 = TVector3(RecVtxFirst.x(), RecVtxFirst.y(), RecVtxFirst.z());
158 >  auxInfo->pvInfo.firstPVInProb = TVector3(RecVtx.x(), RecVtx.y(), RecVtx.z());
159  
160      
161    edm::Handle<double> rhoHandle;
162 <  iEvent.getByLabel(edm::InputTag("kt6PFJets", "rho"),rhoHandle); // configure srcRho = cms.InputTag('kt6PFJets")
310 <  hbbInfo->puInfo.rho = *rhoHandle;
162 >  iEvent.getByLabel(edm::InputTag("kt6PFJets", "rho"),rhoHandle);   auxInfo->puInfo.rho = *rhoHandle;
163    
164    //// real start
165    
# Line 319 | Line 171 | HbbAnalyzerNew::produce(edm::Event& iEve
171    
172    if(runOnMC_){
173      
174 <    int Hin=-99,Win=-99,Zin=-99,bin=-99,bbarin=-99;
323 <    
324 <    iEvent.getByLabel("genParticles", genParticles);
174 >   iEvent.getByLabel("genParticles", genParticles);
175      
176      for(size_t i = 0; i < genParticles->size(); ++ i) {
177 +    
178        const GenParticle & p = (*genParticles)[i];
179        int id = p.pdgId();
180        int st = p.status();  
181 <        
181 >      
182        if(id==25){
183 <          
184 <        /*          int wh=0;
185 <                    int nMoth = p.numberOfMothers();
186 <                    for(size_t jj = 0; jj < nMoth; ++ jj) {
187 <                    const Candidate * mom = p.mother( jj );
188 <                    int nmomdau= mom->numberOfDaughters();
189 <                    for(size_t j = 0; j < nmomdau; ++ j) {
190 <                    const Candidate * Wmomdau = mom->daughter( j );
340 <                    if(abs(Wmomdau->pdgId())==24) wh++;
341 <                    }
342 <                    }
343 <                      
344 <                    if(wh==0) continue;
345 <        */
346 <        Hin=i;
347 <        hbbInfo->mcH.status=st;
348 <        hbbInfo->mcH.charge=p.charge();
349 <        if(p.mother(0)!=0) hbbInfo->mcH.momid=p.mother(0)->pdgId();
350 <        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) hbbInfo->mcH.gmomid=p.mother(0)->mother(0)->pdgId();
351 <        hbbInfo->mcH.fourMomentum = GENPTOLOR(p);
352 <          
183 >        
184 >        VHbbEventAuxInfo::ParticleMCInfo htemp;
185 >        htemp.status=st;
186 >        htemp.charge=p.charge();
187 >        if(p.mother(0)!=0) htemp.momid=p.mother(0)->pdgId();
188 >        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) htemp.gmomid=p.mother(0)->mother(0)->pdgId();
189 >        htemp.p4 = GENPTOLOR(p);
190 >        
191          int ndau = p.numberOfDaughters();
192          for(int j = 0; j < ndau; ++ j) {
193            const Candidate * Hdau = p.daughter( j );
194 <          hbbInfo->mcH.dauid.push_back(Hdau->pdgId());
195 <          hbbInfo->mcH.dauFourMomentum.push_back(GENPTOLORP(Hdau));
194 >          htemp.dauid.push_back(Hdau->pdgId());
195 >          htemp.dauFourMomentum.push_back(GENPTOLORP(Hdau));
196          }
197 +        (auxInfo->mcH).push_back(htemp);
198        }
199 +      
200 +      
201 +      if(abs(id)==24){
202          
203 +        VHbbEventAuxInfo::ParticleMCInfo wtemp;
204 +        wtemp.status=st;
205 +        wtemp.charge=p.charge();
206 +        if(p.mother(0)!=0) wtemp.momid=p.mother(0)->pdgId();
207 +        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) wtemp.gmomid=p.mother(0)->mother(0)->pdgId();
208 +        wtemp.p4=GENPTOLOR(p);
209          
362      if(abs(id)==24){
363          
364        Win=i;
365        hbbInfo->mcW.status=st;
366        hbbInfo->mcW.charge=p.charge();
367        if(p.mother(0)!=0) hbbInfo->mcW.momid=p.mother(0)->pdgId();
368        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) hbbInfo->mcW.gmomid=p.mother(0)->mother(0)->pdgId();
369        hbbInfo->mcW.fourMomentum=GENPTOLOR(p);
370
210          int ndau = p.numberOfDaughters();
211          for(int j = 0; j < ndau; ++ j) {
212            const Candidate * Wdau = p.daughter( j );
213 <          hbbInfo->mcW.dauid.push_back(Wdau->pdgId());
214 <          hbbInfo->mcW.dauFourMomentum.push_back(GENPTOLORP(Wdau));
213 >          wtemp.dauid.push_back(Wdau->pdgId());
214 >          wtemp.dauFourMomentum.push_back(GENPTOLORP(Wdau));
215          }
216 +        auxInfo->mcW.push_back(wtemp);
217        }
218          
219        if(abs(id)==23){
220  
221 <        Zin=i;
222 <        hbbInfo->mcZ.status=st;
223 <        hbbInfo->mcZ.charge=p.charge();
224 <        if(p.mother(0)!=0) hbbInfo->mcZ.momid=p.mother(0)->pdgId();
225 <        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) hbbInfo->mcZ.gmomid=p.mother(0)->mother(0)->pdgId();
226 <        hbbInfo->mcZ.fourMomentum=GENPTOLOR(p);
221 >
222 >        VHbbEventAuxInfo::ParticleMCInfo ztemp;
223 >        ztemp.status=st;
224 >        ztemp.charge=p.charge();
225 >        if(p.mother(0)!=0) ztemp.momid=p.mother(0)->pdgId();
226 >        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) ztemp.gmomid=p.mother(0)->mother(0)->pdgId();
227 >        ztemp.p4=GENPTOLOR(p);
228  
229          int ndau = p.numberOfDaughters();
230          for(int j = 0; j < ndau; ++ j) {
231            const Candidate * Zdau = p.daughter( j );
232 <          hbbInfo->mcZ.dauid.push_back(Zdau->pdgId());
233 <          hbbInfo->mcZ.dauFourMomentum.push_back(GENPTOLOR(p));
232 >          ztemp.dauid.push_back(Zdau->pdgId());
233 >          ztemp.dauFourMomentum.push_back(GENPTOLOR(p));
234          }
235 +        auxInfo->mcZ.push_back(ztemp);
236        }
237        //
238        // binfo
239        //
240 <
240 >      
241        
242        if(id==5){
243 <        bin=i;
244 <        hbbInfo->mcB.status=st;
245 <        hbbInfo->mcB.charge=p.charge();
246 <        if(p.mother(0)!=0) hbbInfo->mcB.momid=p.mother(0)->pdgId();
247 <        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) hbbInfo->mcB.gmomid=p.mother(0)->mother(0)->pdgId();
243 >
244 >        VHbbEventAuxInfo::ParticleMCInfo btemp;
245 >        btemp.status=st;
246 >        btemp.charge=p.charge();
247 >        if(p.mother(0)!=0) btemp.momid=p.mother(0)->pdgId();
248 >        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) btemp.gmomid=p.mother(0)->mother(0)->pdgId();
249 >
250 >        btemp.p4=GENPTOLOR(p);
251 >        
252 >        int nHDaubdau = p.numberOfDaughters();
253 >        for(int j = 0; j < nHDaubdau; ++ j) {
254 >          const Candidate * Bdau = p.daughter( j );
255 >          btemp.dauid.push_back(Bdau->pdgId());
256 >        }
257 >        auxInfo->mcB.push_back(btemp);
258        }
259        
260        if(id==-5){
409        bbarin=i;
410        hbbInfo->mcBbar.status=st;
411        hbbInfo->mcBbar.charge=p.charge();
412        if(p.mother(0)!=0) hbbInfo->mcBbar.momid=p.mother(0)->pdgId();
413        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) hbbInfo->mcBbar.gmomid=p.mother(0)->mother(0)->pdgId();
414      }
415      
416      if(abs(id)==4){
417        hbbInfo->mcC.status=st;
418        hbbInfo->mcC.charge=p.charge();
419        if(p.mother(0)!=0) hbbInfo->mcC.momid=p.mother(0)->pdgId();
420        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) hbbInfo->mcC.gmomid=p.mother(0)->mother(0)->pdgId();
421      }
261  
262 +        VHbbEventAuxInfo::ParticleMCInfo bbtemp;
263 +        
264 +        bbtemp.status=st;
265 +        bbtemp.charge=p.charge();
266 +        if(p.mother(0)!=0) bbtemp.momid=p.mother(0)->pdgId();
267 +        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) bbtemp.gmomid=p.mother(0)->mother(0)->pdgId();
268  
269 <    }
269 >        bbtemp.p4=GENPTOLOR(p);
270 >        
271 >        int nHDaubdau = p.numberOfDaughters();
272 >        for(int j = 0; j < nHDaubdau; ++ j) {
273 >          const Candidate * Bdau = p.daughter( j );
274 >          bbtemp.dauid.push_back(Bdau->pdgId());
275 >        }
276  
277  
278 <    if(bin!=-99 && bbarin!=-99){
279 <      const Candidate & bGen = (*genParticles)[bin];
429 <      const Candidate & bbarGen = (*genParticles)[bbarin];
430 <      hbbInfo->mcB.fourMomentum=GENPTOLOR(bGen);
431 <      hbbInfo->mcBbar.fourMomentum=GENPTOLOR(bbarGen);
278 >        auxInfo->mcBbar.push_back(bbtemp);
279 >     }
280        
281 <      int nHDaubdau = bGen.numberOfDaughters();
282 <      for(int j = 0; j < nHDaubdau; ++ j) {
283 <        const Candidate * Bdau = bGen.daughter( j );
284 <        hbbInfo->mcB.dauid.push_back(Bdau->pdgId());
285 <        hbbInfo->mcB.dauFourMomentum.push_back(GENPTOLORP(Bdau));
286 <      }
439 <      int nHDaubbardau = bbarGen.numberOfDaughters();
440 <      for(int j = 0; j < nHDaubbardau; ++ j) {
441 <        const Candidate * Bbardau = bbarGen.daughter( j );
442 <        hbbInfo->mcBbar.dauid.push_back(Bbardau->pdgId());
443 <        hbbInfo->mcBbar.dauFourMomentum.push_back(GENPTOLORP(Bbardau));
444 <      }
281 >      if(abs(id)==4){
282 >        VHbbEventAuxInfo::ParticleMCInfo ctemp;
283 >        ctemp.status=st;
284 >        ctemp.charge=p.charge();
285 >        if(p.mother(0)!=0) ctemp.momid=p.mother(0)->pdgId();
286 >        if(p.mother(0)!=0 && p.mother(0)->mother(0)!=0) ctemp.gmomid=p.mother(0)->mother(0)->pdgId();
287  
288 <  
288 >        ctemp.p4=GENPTOLOR(p);
289 >        
290 >        int nHDaubdau = p.numberOfDaughters();
291 >        for(int j = 0; j < nHDaubdau; ++ j) {
292 >          const Candidate * Bdau = p.daughter( j );
293 >          ctemp.dauid.push_back(Bdau->pdgId());
294 >        }
295  
296 <    }
296 >        auxInfo->mcC.push_back(ctemp);  
297  
298 +      }
299 +
300 +    }
301  
302    }   // isMC
303  
# Line 490 | Line 341 | HbbAnalyzerNew::produce(edm::Event& iEve
341    iEvent.getByLabel(eleLabel_,electronHandle);
342    edm::View<pat::Electron> electrons = *electronHandle;
343  
493  edm::Handle<edm::View<pat::MET> > metHandle;
494  iEvent.getByLabel(metLabel_,metHandle);
495  edm::View<pat::MET> mets = *metHandle;
344  
345    //   edm::Handle<edm::View<pat::Photon> > phoHandle;
346    //   iEvent.getByLabel(phoLabel_,phoHandle);
# Line 508 | Line 356 | HbbAnalyzerNew::produce(edm::Event& iEve
356    edm::Handle<CandidateView> dielectrons;
357    iEvent.getByLabel(dielecLabel_,dielectrons);
358  
359 +  //BTAGGING SCALE FACTOR FROM DATABASE
360 +  //Combined Secondary Vertex Loose
361 +  edm::ESHandle<BtagPerformance> bTagSF_CSVL_;
362 +  iSetup.get<BTagPerformanceRecord>().get("BTAGCSVL",bTagSF_CSVL_);
363 +  const BtagPerformance & bTagSF_CSVL = *(bTagSF_CSVL_.product());
364 +  //Combined Secondary Vertex Medium
365 +  edm::ESHandle<BtagPerformance> bTagSF_CSVM_;
366 +  iSetup.get<BTagPerformanceRecord>().get("BTAGCSVM",bTagSF_CSVM_);
367 +  const BtagPerformance & bTagSF_CSVM = *(bTagSF_CSVM_.product());
368 +  //Combined Secondary Vertex Tight
369 +  edm::ESHandle<BtagPerformance> bTagSF_CSVT_;
370 +  iSetup.get<BTagPerformanceRecord>().get("BTAGCSVT",bTagSF_CSVT_);
371 +  const BtagPerformance & bTagSF_CSVT = *(bTagSF_CSVT_.product());
372 +
373 +  edm::ESHandle<BtagPerformance> mistagSF_CSVL_;
374 +  iSetup.get<BTagPerformanceRecord>().get("MISTAGCSVL",mistagSF_CSVL_);
375 +  const BtagPerformance & mistagSF_CSVL = *(mistagSF_CSVL_.product());
376 +  //Combined Secondary Vertex Medium
377 +  edm::ESHandle<BtagPerformance> mistagSF_CSVM_;
378 +  iSetup.get<BTagPerformanceRecord>().get("MISTAGCSVM",mistagSF_CSVM_);
379 +  const BtagPerformance & mistagSF_CSVM = *(mistagSF_CSVM_.product());
380 +  //Combined Secondary Vertex Tight
381 +  edm::ESHandle<BtagPerformance> mistagSF_CSVT_;
382 +  iSetup.get<BTagPerformanceRecord>().get("MISTAGCSVT",mistagSF_CSVT_);
383 +  const BtagPerformance & mistagSF_CSVT = *(mistagSF_CSVT_.product());
384 +
385 + BTagSFContainer btagSFs;
386 +  btagSFs.BTAGSF_CSVL = (bTagSF_CSVL_.product());
387 +  btagSFs.BTAGSF_CSVM = (bTagSF_CSVM_.product());
388 +  btagSFs.BTAGSF_CSVT = (bTagSF_CSVT_.product());
389 +  btagSFs.MISTAGSF_CSVL = (mistagSF_CSVL_.product());
390 +  btagSFs.MISTAGSF_CSVM = (mistagSF_CSVM_.product());
391 +  btagSFs.MISTAGSF_CSVT = (mistagSF_CSVT_.product());
392  
393    for(edm::View<pat::Jet>::const_iterator jet_iter = simplejets1.begin(); jet_iter!=simplejets1.end(); ++jet_iter){
394      //     if(jet_iter->pt()>50)
395      //       njetscounter++;
396      VHbbEvent::SimpleJet sj;
397 <    sj.flavour = jet_iter->partonFlavour();
398 <
397 >    fillSimpleJet(sj,jet_iter);
398 >    //    if(!runOnMC_)
399  
400 <    sj.tche=jet_iter->bDiscriminator("trackCountingHighEffBJetTags");
520 <    sj.tchp=jet_iter->bDiscriminator("trackCountingHighPurBJetTags");
521 <    sj.jp=jet_iter->bDiscriminator("jetProbabilityBJetTags");
522 <    sj.jpb=jet_iter->bDiscriminator("jetBProbabilityBJetTags");
523 <    sj.ssvhe=jet_iter->bDiscriminator("simpleSecondaryVertexHighEffBJetTags");
524 <    sj.csv=jet_iter->bDiscriminator("combinedSecondaryVertexBJetTags");
525 <    sj.csvmva=jet_iter->bDiscriminator("combinedSecondaryVertexMVABJetTags");
526 <    sj.charge=jet_iter->jetCharge();
527 <    sj.ntracks=jet_iter->associatedTracks().size();
528 <    sj.fourMomentum=GENPTOLORP(jet_iter);
400 >   setJecUnc(sj,jecUnc);
401  
402      Particle::LorentzVector p4Jet = jet_iter->p4();
403  
404      if(runOnMC_){
405 <      double minb1DR=9999.;
406 <      for(size_t i = 0; i < genParticles->size(); ++ i) {
407 <        const GenParticle & p = (*genParticles)[i];
408 <        int id = p.pdgId();
409 <        if(abs(id)<=6 || id==21 || id==23 || abs(id)==24){
410 <          double bb1DR=TMath::Sqrt((p.eta()-p4Jet.eta())*(p.eta()-p4Jet.eta())+
411 <                                   (p.phi()-p4Jet.phi())*(p.phi()-p4Jet.phi()));
412 <          if(bb1DR<minb1DR) {minb1DR=bb1DR; sj.b1BestMCid=id; if(p.mother()!=0) sj.b1BestMCmomid=p.mother()->pdgId();}
405 >
406 >      fillScaleFactors(sj, btagSFs);
407 >
408 >      //PAT genJet matching
409 >      //genJet
410 >      const reco::GenJet *gJ = jet_iter->genJet();
411 >      //physical parton for mother info ONLY
412 >      if( (jet_iter->genParton())
413 >          and (jet_iter->genParton()->mother()) )
414 >        sj.bestMCmomid=jet_iter->genParton()->mother()->pdgId();
415 >      TLorentzVector gJp4;
416 >      if(gJ){
417 >        gJp4.SetPtEtaPhiE(gJ->pt(),gJ->eta(),gJ->phi(),gJ->energy());
418 >        sj. bestMCp4mom = gJp4;
419 >        if(verbose_){
420 >          std::clog << "genJet matched Pt = " << gJp4.Pt() << std::endl;
421 >          std::clog << "genJet matched eta = " << gJp4.Eta() << std::endl;
422 >          std::clog << "genJet matched deltaR = " <<gJp4.DeltaR(sj.p4) << std::endl;
423 >          std::clog << "genJet matched mother id = " << sj.bestMCmomid << std::endl;
424          }
425        }
426 <    } //isMC    
426 >      
427 >    } //isMC
428      hbbInfo->simpleJets.push_back(sj);
429      
430    }
431 <  
431 >
432 >  for(edm::View<pat::Jet>::const_iterator jet_iter = simplejets3.begin(); jet_iter!=simplejets3.end(); ++jet_iter){
433 >    //     if(jet_iter->pt()>50)
434 >    //       njetscounter++;
435 >    VHbbEvent::SimpleJet sj;
436 >    fillSimpleJet(sj,jet_iter);
437 >    //    if(!runOnMC_)  
438 >  setJecUnc(sj,jecUnc);
439 >
440 >
441 >   Particle::LorentzVector p4Jet = jet_iter->p4();
442 >
443 >    if(runOnMC_){
444 >
445 >      fillScaleFactors(sj, btagSFs);
446 >
447 >      //PAT genJet matching
448 >      //genJet
449 >      const reco::GenJet *gJ = jet_iter->genJet();
450 >      //physical parton for mother info ONLY
451 >      if( (jet_iter->genParton())
452 >          and (jet_iter->genParton()->mother()) )
453 >        sj.bestMCmomid=jet_iter->genParton()->mother()->pdgId();
454 >      TLorentzVector gJp4;
455 >      if(gJ){
456 >        gJp4.SetPtEtaPhiE(gJ->pt(),gJ->eta(),gJ->phi(),gJ->energy());
457 >        sj. bestMCp4mom = gJp4;
458 >        if(verbose_){
459 >          std::clog << "genJet matched Pt = " << gJp4.Pt() << std::endl;
460 >          std::clog << "genJet matched eta = " << gJp4.Eta() << std::endl;
461 >          std::clog << "genJet matched deltaR = " <<gJp4.DeltaR(sj.p4) << std::endl;
462 >          std::clog << "genJet matched mother id = " << sj.bestMCmomid << std::endl;
463 >        }
464 >      }
465 >      
466 >    } //isMC
467 >    hbbInfo->simpleJets3.push_back(sj);
468 >    
469 >  }
470 >
471 >  for(edm::View<pat::Jet>::const_iterator jet_iter = simplejets4.begin(); jet_iter!=simplejets4.end(); ++jet_iter){
472 >    //     if(jet_iter->pt()>50)
473 >    //       njetscounter++;
474 >    VHbbEvent::SimpleJet sj;
475 >    fillSimpleJet(sj,jet_iter);
476 >    //    if(!runOnMC_)  
477 >    setJecUnc(sj,jecUnc);
478 >
479 >
480 >    Particle::LorentzVector p4Jet = jet_iter->p4();
481 >
482 >    if(runOnMC_){
483 >
484 >      fillScaleFactors(sj, btagSFs);
485 >
486 >      //PAT genJet matching
487 >      //genJet
488 >      const reco::GenJet *gJ = jet_iter->genJet();
489 >      //physical parton for mother info ONLY
490 >      if( (jet_iter->genParton())
491 >          and (jet_iter->genParton()->mother()) )
492 >        sj.bestMCmomid=jet_iter->genParton()->mother()->pdgId();
493 >      TLorentzVector gJp4;
494 >      if(gJ){
495 >        gJp4.SetPtEtaPhiE(gJ->pt(),gJ->eta(),gJ->phi(),gJ->energy());
496 >        sj. bestMCp4mom = gJp4;
497 >        if(verbose_){
498 >          std::clog << "genJet matched Pt = " << gJp4.Pt() << std::endl;
499 >          std::clog << "genJet matched eta = " << gJp4.Eta() << std::endl;
500 >          std::clog << "genJet matched deltaR = " <<gJp4.DeltaR(sj.p4) << std::endl;
501 >          std::clog << "genJet matched mother id = " << sj.bestMCmomid << std::endl;
502 >        }
503 >      }
504 >      
505 >    } //isMC
506 >    hbbInfo->simpleJets4.push_back(sj);
507 >    
508 >  }
509 >
510    
511    for(edm::View<pat::Jet>::const_iterator jet_iter = simplejets2.begin(); jet_iter!=simplejets2.end(); ++jet_iter){
512      
513      VHbbEvent::SimpleJet sj;
514 <    sj.flavour = jet_iter->partonFlavour();
514 >    fillSimpleJet(sj,jet_iter);    
515 >    //  if(!runOnMC_)  
516 > setJecUnc(sj,jecUnc);
517 >    /*    sj.flavour = jet_iter->partonFlavour();
518      
519      
520      sj.tche=jet_iter->bDiscriminator("trackCountingHighEffBJetTags");
# Line 561 | Line 526 | HbbAnalyzerNew::produce(edm::Event& iEve
526      sj.csvmva=jet_iter->bDiscriminator("combinedSecondaryVertexMVABJetTags");
527      sj.charge=jet_iter->jetCharge();
528      sj.ntracks=jet_iter->associatedTracks().size();
529 <    sj.fourMomentum=GENPTOLORP(jet_iter);
529 >    sj.p4=GENPTOLORP(jet_iter);
530 >    sj.chargedTracksFourMomentum=(getChargedTracksMomentum(&*(jet_iter)));
531 >    sj.SF_CSVL=1;
532 >    sj.SF_CSVM=1;
533 >    sj.SF_CSVT=1;
534 >    sj.SF_CSVLerr=0;
535 >    sj.SF_CSVMerr=0;
536 >    sj.SF_CSVTerr=0;
537 >
538 >    //
539 >    // addtaginfo for csv
540 >    //
541 >
542 >    if (jet_iter->hasTagInfo("SimpleSecondaryVertex")) {
543 >
544 >      const reco::SecondaryVertexTagInfo * tf = jet_iter->tagInfoSecondaryVertex();
545 >      sj.vtxMass = tf->secondaryVertex(0).p4().mass();
546 >      sj.vtxNTracks = tf->secondaryVertex(0).nTracks();
547 >      Measurement1D m = tf->flightDistance(0);
548 >      sj.vtx3dL = m.value();
549 >      sj.vtx3deL = m.error();
550 >    }
551  
552 +
553 +    //
554 +    // add tVector
555 +    //
556 +    sj.tVector = getTvect(&(*jet_iter));
557 +    */
558      Particle::LorentzVector p4Jet = jet_iter->p4();
559  
560 +
561      if(runOnMC_){
562 <      double minb2DR=9999.;
563 <      for(size_t i = 0; i < genParticles->size(); ++ i) {
564 <        const GenParticle & p = (*genParticles)[i];
565 <        int id = p.pdgId();
566 <        if(abs(id)<=6 || id==21 || id==23 || abs(id)==24){
567 <          double bb2DR=TMath::Sqrt((p.eta()-p4Jet.eta())*(p.eta()-p4Jet.eta())+
568 <                                   (p.phi()-p4Jet.phi())*(p.phi()-p4Jet.phi()));
569 <          if(bb2DR<minb2DR) {minb2DR=bb2DR; sj.b1BestMCid=id; if(p.mother()!=0) sj.b1BestMCmomid=p.mother()->pdgId();}
562 >
563 >      //BTV scale factors
564 >      fillScaleFactors(sj, btagSFs);
565 >
566 >      //PAT genJet matching
567 >      //genJet
568 >      const reco::GenJet *gJ = jet_iter->genJet();
569 >      //physical parton for mother info ONLY
570 >      if( (jet_iter->genParton())
571 >          and (jet_iter->genParton()->mother()) )
572 >        sj.bestMCmomid=jet_iter->genParton()->mother()->pdgId();
573 >      TLorentzVector gJp4;
574 >      if(gJ){
575 >        gJp4.SetPtEtaPhiE(gJ->pt(),gJ->eta(),gJ->phi(),gJ->energy());
576 >        sj. bestMCp4mom = gJp4;
577 >        if(verbose_){
578 >          std::clog << "genJet matched Pt = " << gJp4.Pt() << std::endl;
579 >          std::clog << "genJet matched eta = " << gJp4.Eta() << std::endl;
580 >          std::clog << "genJet matched deltaR = " << gJp4.DeltaR(sj.p4) << std::endl;
581 >          std::clog << "genJet matched mother id = " << sj.bestMCmomid << std::endl;
582          }
583        }
584 +
585      }   //isMC
586      
587      hbbInfo->simpleJets2.push_back(sj);
# Line 613 | Line 619 | HbbAnalyzerNew::produce(edm::Event& iEve
619      //    if(printJet) {std::cout << "NsubJets: " << constituents.size() << "\n";}
620      VHbbEvent::HardJet hj;
621      hj.constituents=constituents.size();
622 <    hj.fourMomentum =GENPTOLORP(jet_iter);
623 <
622 >    hj.p4 =GENPTOLORP(jet_iter);
623 >    
624      for (unsigned int iJC(0); iJC<constituents.size(); ++iJC ){
625        Jet::Constituent icandJet = constituents[iJC];
626  
# Line 625 | Line 631 | HbbAnalyzerNew::produce(edm::Event& iEve
631        hj.subFourMomentum.push_back(GENPTOLORP(icandJet));
632        hj.etaSub.push_back(icandJet->eta());
633        hj.phiSub.push_back(icandJet->phi());
628
634      
635      }
636      hbbInfo->hardJets.push_back(hj);
# Line 648 | Line 653 | HbbAnalyzerNew::produce(edm::Event& iEve
653                              << "," << subjet_iter->bDiscriminator("combinedSecondaryVertexBJetTags") << "\n";}
654  
655      VHbbEvent::SimpleJet sj;
656 <
657 <    sj.flavour = subjet_iter->partonFlavour();
658 <    
656 >    fillSimpleJet(sj,subjet_iter);
657 >    //  if(!runOnMC_)  
658 >    setJecUnc(sj,jecUnc);
659 >    /*    sj.flavour = subjet_iter->partonFlavour();
660 >    sj.tVector = getTvect(&(*subjet_iter));
661      sj.tche=subjet_iter->bDiscriminator("trackCountingHighEffBJetTags");
662      sj.tchp=subjet_iter->bDiscriminator("trackCountingHighPurBJetTags");
663      sj.jp=subjet_iter->bDiscriminator("jetProbabilityBJetTags");
# Line 660 | Line 667 | HbbAnalyzerNew::produce(edm::Event& iEve
667      sj.csvmva=subjet_iter->bDiscriminator("combinedSecondaryVertexMVABJetTags");
668      sj.charge=subjet_iter->jetCharge();
669      sj.ntracks=subjet_iter->associatedTracks().size();
670 <    sj.fourMomentum=GENPTOLORP(subjet_iter);
670 >    sj.p4=GENPTOLORP(subjet_iter);
671 >    sj.p4=(getChargedTracksMomentum(&*(subjet_iter)));
672  
673 +    //
674 +    // addtaginfo for csv
675 +    //
676 +
677 +    if (subjet_iter->hasTagInfo("SimpleSecondaryVertex")) {
678 +
679 +      const reco::SecondaryVertexTagInfo * tf = subjet_iter->tagInfoSecondaryVertex();
680 +      sj.vtxMass = tf->secondaryVertex(0).p4().mass();
681 +      sj.vtxNTracks = tf->secondaryVertex(0).nTracks();
682 +      Measurement1D m = tf->flightDistance(0);
683 +      sj.vtx3dL = m.value();
684 +      sj.vtx3deL = m.error();
685 +    }
686 +    */
687      hbbInfo->subJets.push_back(sj);
688  
689    }
# Line 671 | Line 693 | HbbAnalyzerNew::produce(edm::Event& iEve
693    // met is calomet
694    //
695  
674
675  for(edm::View<pat::MET>::const_iterator met = mets.begin(); met!=mets.end(); ++met){
676    hbbInfo->calomet.sumEt=met->sumEt();
677    hbbInfo->calomet.metSig=met->mEtSig();
678    hbbInfo->calomet.eLong=met->e_longitudinal();
679    hbbInfo->calomet.fourMomentum=GENPTOLORP(met);
680  }
681
696    edm::Handle<edm::View<pat::MET> > metTCHandle;
697    iEvent.getByLabel("patMETsTC",metTCHandle);
698    edm::View<pat::MET> metsTC = *metTCHandle;
699 <  for(edm::View<pat::MET>::const_iterator metTC = metsTC.begin(); metTC!=metsTC.end(); ++metTC){
700 <    hbbInfo->calomet.sumEt=metTC->sumEt();
701 <    hbbInfo->calomet.metSig=metTC->mEtSig();
702 <    hbbInfo->calomet.eLong=metTC->e_longitudinal();
703 <    hbbInfo->calomet.fourMomentum=GENPTOLORP(metTC);
699 >  if(metsTC.size()){
700 >    hbbInfo->tcmet.sumEt=(metsTC[0]).sumEt();
701 >    hbbInfo->tcmet.metSig=(metsTC[0]).mEtSig();
702 >    hbbInfo->tcmet.eLong=(metsTC[0]).e_longitudinal();
703 >    hbbInfo->tcmet.p4=GENPTOLOR((metsTC[0]));
704 >    if (verbose_)     std::cout <<" METTC "<<     hbbInfo->tcmet.metSig <<" " <<     hbbInfo->tcmet.sumEt<<std::endl;
705    }
706 +  
707 +
708 +  edm::Handle<edm::View<reco::MET> > mHTHandle;
709 +  iEvent.getByLabel("patMETsHT",mHTHandle);
710 +  edm::View<reco::MET> metsHT = *mHTHandle;
711 +  if(metsHT.size()){
712 +    hbbInfo->mht.sumEt=(metsHT[0]).sumEt();
713 +    hbbInfo->mht.metSig=(metsHT[0]).mEtSig();
714 +    hbbInfo->mht.eLong=(metsHT[0]).e_longitudinal();
715 +    hbbInfo->mht.p4=GENPTOLOR((metsHT[0]));
716 +    if (verbose_)     std::cout <<" METHT "<<     hbbInfo->mht.metSig <<" " <<     hbbInfo->mht.sumEt<<std::endl;
717 +  }
718 +  
719 +  edm::Handle<edm::View<pat::MET> > metHandle;
720 +  iEvent.getByLabel(metLabel_,metHandle);
721 +  edm::View<pat::MET> mets = *metHandle;
722 +  
723 +  if(mets.size()){
724 +    hbbInfo->calomet.sumEt=(mets[0]).sumEt();
725 +    hbbInfo->calomet.metSig=(mets[0]).mEtSig();
726 +    hbbInfo->calomet.eLong=(mets[0]).e_longitudinal();
727 +    hbbInfo->calomet.p4=GENPTOLOR((mets[0]));
728 +    if (verbose_)     std::cout <<" METCALO "<<     hbbInfo->calomet.metSig <<" " <<     hbbInfo->calomet.sumEt<<std::endl;
729 +  }
730 +  
731    edm::Handle<edm::View<pat::MET> > metPFHandle;
732    iEvent.getByLabel("patMETsPF",metPFHandle);
733    edm::View<pat::MET> metsPF = *metPFHandle;
734 <  for(edm::View<pat::MET>::const_iterator metPF = metsPF.begin(); metPF!=metsPF.end(); ++metPF){
735 <    hbbInfo->calomet.sumEt=metPF->sumEt();
736 <    hbbInfo->calomet.metSig=metPF->mEtSig();
737 <    hbbInfo->calomet.eLong=metPF->e_longitudinal();
738 <    hbbInfo->calomet.fourMomentum=GENPTOLORP(metPF);
734 >  
735 >  if(metsPF.size()){
736 >    hbbInfo->pfmet.sumEt=(metsPF[0]).sumEt();
737 >    hbbInfo->pfmet.metSig=(metsPF[0]).mEtSig();
738 >    hbbInfo->pfmet.eLong=(metsPF[0]).e_longitudinal();
739 >    hbbInfo->pfmet.p4=GENPTOLOR((metsPF[0]));
740 >    if (verbose_)     std::cout <<" METPF "<<     hbbInfo->pfmet.metSig <<" " <<     hbbInfo->pfmet.sumEt<<std::endl;
741 >  }
742 >  
743 >  
744 >  if(verbose_){
745 >    std::cout << "METs: calomet "<<mets.size()<<" tcmet"<<metsTC.size()<<" pfmet "<<metsPF.size()<<" MHT" <<metsHT.size()<<std::endl;  
746    }
747  
748 <
748 >  if(verbose_)
749 >    std::cout << " INPUT MUONS "<<muons.size()<<std::endl;
750  
751    for(edm::View<pat::Muon>::const_iterator mu = muons.begin(); mu!=muons.end(); ++mu){
752      VHbbEvent::MuonInfo mf;
753 <    mf.fourMomentum =GENPTOLORP( mu);
753 >    mf.p4 =GENPTOLORP( mu);
754      mf.charge=mu->charge();
755      mf.tIso=mu->trackIso();
756      mf.eIso=mu->ecalIso();
757      mf.hIso=mu->hcalIso();
758 <    Geom::Phi<double> deltaphi(mu->phi()-atan2(mf.fourMomentum.Px(), mf.fourMomentum.Py()));
758 >    mf.pfChaIso=mu->chargedHadronIso();
759 >    mf.pfPhoIso=mu->photonIso();
760 >    mf.pfNeuIso=mu->neutralHadronIso();
761 >    Geom::Phi<double> deltaphi(mu->phi()-atan2(mf.p4.Px(), mf.p4.Py()));
762      double acop = deltaphi.value();
763      mf.acop=acop;
764  
765      mf.ipDb=mu->dB();
766      mf.ipErrDb=mu->edB();
767 <    if(mu->isGlobalMuon()) mf.cat=1;
768 <    else if(mu->isTrackerMuon()) mf.cat=2;
769 <    else mf.cat=3;
767 >    mf.cat=0;
768 >    if(mu->isGlobalMuon()) mf.cat|=1;
769 >    if(mu->isTrackerMuon()) mf.cat|=2;
770 >    if(mu->isStandAloneMuon()) mf.cat|=4;
771      TrackRef trkMu1Ref = mu->get<TrackRef>();
772      if(trkMu1Ref.isNonnull()){
773        const Track* MuTrk1 = mu->get<TrackRef>().get();
# Line 732 | Line 784 | HbbAnalyzerNew::produce(edm::Event& iEve
784        const reco::HitPattern& q = gTrack->hitPattern();
785        mf.globChi2=gTrack.get()->normalizedChi2();
786        mf.globNHits=q.numberOfValidMuonHits();
787 +      mf. validMuStations = q. muonStationsWithValidHits();
788      }else{
789        mf.globChi2=-99;
790        mf.globNHits=-99;
791      }
792  
793 +    //Muon trigger matching
794 +    for (int itrig = 0; itrig != ntrigs; ++itrig){
795 +      std::string trigName=triggerNames_.triggerName(itrig);
796 +      if( (mu->triggerObjectMatchesByPath(trigName,false,false).size() != 0) ){
797 +        mf.hltMatchedBits.push_back(itrig);
798 +        if(verbose_){
799 +          std::clog << "Trigger Matching box" << std::endl;
800 +          std::clog << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
801 +          std::clog << "Matching parameters are defined in the cfg" << std::endl;
802 +          std::clog << "Trigger bit = " << itrig << std::endl;
803 +          std::clog << "Trigger name = " << trigName << std::endl;
804 +          std::clog << "Trigger object matched collection size = " << mu->triggerObjectMatchesByPath(trigName,false,false).size() << std::endl;
805 +          std::clog << "Pat Muon pt = " << mf.p4.Pt() << " HLT object matched = " << mu->triggerObjectMatch(0)->p4().Pt() << std::endl;
806 +          std::clog << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
807 +        }
808 +      }
809 +    }
810 +    //
811 +
812 +    // add stamuon
813 +
814 +    //    if (mu->isStandAloneMuon()) {
815 +    //      reco::TrackRef sta = mu->standAloneMuon();
816 +    //      
817 +    //    }
818 +
819 +
820      //     int muInfo[12];
821      //     fillMuBlock(mu,  muInfo);
822      if(runOnMC_){
# Line 750 | Line 830 | HbbAnalyzerNew::produce(edm::Event& iEve
830      hbbInfo->muInfo.push_back(mf);
831    }
832  
833 <
833 > if(verbose_)
834 >    std::cout << " INPUT electrons "<<electrons.size()<<std::endl;
835    for(edm::View<pat::Electron>::const_iterator elec = electrons.begin(); elec!=electrons.end(); ++elec){
836      VHbbEvent::ElectronInfo ef;
837 <    ef.fourMomentum=GENPTOLORP(elec);
837 >    ef.p4=GENPTOLORP(elec);
838      ef.scEta =elec->superCluster()->eta();
839      ef.scPhi =elec->superCluster()->phi();
840      //    if(ElecEta[eleccont]!=0) ElecEt[eleccont]=elec->superCluster()->energy()/cosh(elec->superCluster()->eta());
# Line 761 | Line 842 | HbbAnalyzerNew::produce(edm::Event& iEve
842      ef.tIso=elec->trackIso();
843      ef.eIso=elec->ecalIso();
844      ef.hIso=elec->hcalIso();
845 <    Geom::Phi<double> deltaphi(elec->superCluster()->phi()-atan2(hbbInfo->calomet.fourMomentum.Py(),hbbInfo->calomet.fourMomentum.Px()));
845 >    ef.pfChaIso=elec->chargedHadronIso();
846 >    ef.pfPhoIso=elec->photonIso();
847 >    ef.pfNeuIso=elec->neutralHadronIso();
848 >
849 >    Geom::Phi<double> deltaphi(elec->superCluster()->phi()-atan2(hbbInfo->calomet.p4.Py(),hbbInfo->calomet.p4.Px()));
850      ef.acop = deltaphi.value();
851 <    
851 >    //
852 >    // fill eleids
853 >    //    
854 > /*    ef.id95 = elec->electronID("simpleEleId95cIso");
855 >    ef.id85 = elec->electronID("simpleEleId85cIso");
856 >    ef.id70 = elec->electronID("simpleEleId70cIso");
857 >    ef.id95r = elec->electronID("simpleEleId95relIso");
858 >    ef.id70r = elec->electronID("simpleEleId70relIso");
859 >    ef.id85r = elec->electronID("simpleEleId85relIso");
860 > */
861 >    ef.id95 =elec->electronID("eidVBTFCom95");
862 >    ef.id95r=elec->electronID("eidVBTFRel95");
863 >    ef.id85 =elec->electronID("eidVBTFCom85");
864 >    ef.id85r=elec->electronID("eidVBTFRel85");
865 >    ef.id80 =elec->electronID("eidVBTFCom80");
866 >    ef.id80r=elec->electronID("eidVBTFRel80");
867 >    ef.id70 =elec->electronID("eidVBTFCom70");
868 >    ef.id70r=elec->electronID("eidVBTFRel70");
869 >
870 >    //Electron trigger matching
871 >    for (int itrig = 0; itrig != ntrigs; ++itrig){
872 >      std::string trigName=triggerNames_.triggerName(itrig);
873 >      if( (elec->triggerObjectMatchesByPath(trigName).size() != 0) ){
874 >        ef.hltMatchedBits.push_back(itrig);
875 >        if(verbose_){
876 >          std::clog << "Trigger Matching box" << std::endl;
877 >          std::clog << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
878 >          std::clog << "Matching parameters are defined in the cfg" << std::endl;
879 >          std::clog << "Trigger bit = " << itrig << std::endl;
880 >          std::clog << "Trigger name = " << trigName << std::endl;
881 >          std::clog << "Trigger object matched collection size = " << elec->triggerObjectMatchesByPath(trigName).size() << std::endl;
882 >          std::clog << "Pat Electron pt = " << ef.p4.Pt() << " HLT object matched = " << elec->triggerObjectMatch(0)->p4().Pt() << std::endl;
883 >          std::clog << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
884 >        }
885 >      }
886 >    }
887 >
888      if(runOnMC_){
889        const GenParticle* elecMc = elec->genLepton();
890        if(elecMc!=0){
# Line 775 | Line 896 | HbbAnalyzerNew::produce(edm::Event& iEve
896      hbbInfo->eleInfo.push_back(ef);
897    }
898  
899 +  if(verbose_)
900 +    std::cout << " INPUT taus "<<taus.size()<<std::endl;
901    for(edm::View<pat::Tau>::const_iterator tau = taus.begin(); tau!=taus.end(); ++tau){
902      VHbbEvent::TauInfo tf;
903 <    tf.fourMomentum=GENPTOLORP(tau);
903 >    tf.p4=GENPTOLORP(tau);
904      tf.charge=tau->charge();
905      tf.tIso=tau->trackIso();
906      tf.eIso=tau->ecalIso();
907      tf.hIso=tau->hcalIso();
908 <    Geom::Phi<double> deltaphi(tau->phi()-atan2(hbbInfo->calomet.fourMomentum.Py(),hbbInfo->calomet.fourMomentum.Px()));
908 >    Geom::Phi<double> deltaphi(tau->phi()-atan2(hbbInfo->calomet.p4.Py(),hbbInfo->calomet.p4.Px()));
909      double acop = deltaphi.value();
910      tf.acop=acop;
911      tf.idbyIso=tau->tauID("byIsolation");
# Line 795 | Line 918 | HbbAnalyzerNew::produce(edm::Event& iEve
918      hbbInfo->tauInfo.push_back(tf);
919    }
920  
921 +  CompareJetPtMuons ptComparatorMu;
922 +  CompareJetPtElectrons ptComparatorE;
923 +  CompareJetPtTaus ptComparatorTau;
924 +
925 +  std::sort(hbbInfo->muInfo.begin(), hbbInfo->muInfo.end(), ptComparatorMu);
926 +  std::sort(hbbInfo->eleInfo.begin(), hbbInfo->eleInfo.end(), ptComparatorE);
927 +  std::sort(hbbInfo->tauInfo.begin(), hbbInfo->tauInfo.end(), ptComparatorTau);
928 +
929  
930    // dimuons and dielectrons
931  
932    for( size_t i = 0; i < dimuons->size(); i++ ) {
933      VHbbEvent::DiMuonInfo df;
934      const Candidate & dimuonCand = (*dimuons)[ i ];
935 <    df.fourMomentum= GENPTOLOR(dimuonCand);
935 >    df.p4= GENPTOLOR(dimuonCand);
936      const Candidate * lep0 = dimuonCand.daughter( 0 );
937      const Candidate * lep1 = dimuonCand.daughter( 1 );
938      // needed to access specific methods of pat::Muon
939      const pat::Muon & muonDau0 = dynamic_cast<const pat::Muon &>(*lep0->masterClone());
940      const pat::Muon & muonDau1 = dynamic_cast<const pat::Muon &>(*lep1->masterClone());
941      
942 <    df.daughter1.fourMomentum=GENPTOLOR(muonDau0);
943 <    df.daughter2.fourMomentum=GENPTOLOR(muonDau1);
942 >    df.daughter1.p4=GENPTOLOR(muonDau0);
943 >    df.daughter2.p4=GENPTOLOR(muonDau1);
944      
945      df.daughter1.tIso= muonDau0.trackIso();
946      df.daughter2.tIso= muonDau1.trackIso();
# Line 826 | Line 957 | HbbAnalyzerNew::produce(edm::Event& iEve
957      df.daughter1.ipErrDb=muonDau0.edB();
958      df.daughter2.ipErrDb=muonDau1.edB();
959  
960 <
961 <    if(muonDau0.isGlobalMuon()) df.daughter1.cat =1;
962 <    else if(muonDau0.isTrackerMuon()) df.daughter1.cat=2;
963 <    else df.daughter1.cat=3;
964 <    if(muonDau1.isGlobalMuon()) df.daughter2.cat =1;
965 <    else if(muonDau1.isTrackerMuon()) df.daughter2.cat=2;
966 <    else df.daughter2.cat=3;
960 >    df.daughter1.cat=0;
961 >    if(muonDau0.isGlobalMuon()) df.daughter1.cat|=1;
962 >    if(muonDau0.isTrackerMuon()) df.daughter1.cat|=2;
963 >    if(muonDau0.isStandAloneMuon()) df.daughter1.cat|=4;
964 >    df.daughter2.cat=0;
965 >    if(muonDau1.isGlobalMuon()) df.daughter2.cat|=1;
966 >    if(muonDau1.isTrackerMuon()) df.daughter2.cat|=2;
967 >    if(muonDau1.isStandAloneMuon()) df.daughter2.cat|=4;
968  
969      TrackRef trkMu1Ref = muonDau0.get<TrackRef>();
970      TrackRef trkMu2Ref = muonDau1.get<TrackRef>();
# Line 864 | Line 996 | HbbAnalyzerNew::produce(edm::Event& iEve
996          const reco::HitPattern& q = gTrack->hitPattern();
997          df.daughter1.globNHits=q.numberOfValidMuonHits();
998          df.daughter1.globChi2=gTrack.get()->normalizedChi2();
999 +        df.daughter1.validMuStations = q. muonStationsWithValidHits();
1000        }
1001        if(muonDau1.isGlobalMuon()){
1002          TrackRef gTrack = muonDau1.globalTrack();
1003          const reco::HitPattern& q = gTrack->hitPattern();
1004          df.daughter2.globNHits=q.numberOfValidMuonHits();
1005          df.daughter2.globChi2=gTrack.get()->normalizedChi2();
1006 +        df.daughter2.validMuStations = q. muonStationsWithValidHits();
1007        }
1008    
1009      }
# Line 881 | Line 1015 | HbbAnalyzerNew::produce(edm::Event& iEve
1015      VHbbEvent::DiElectronInfo df;
1016      const Candidate & dielecCand = (*dielectrons)[ i ];
1017  
1018 <    df.fourMomentum=GENPTOLOR(dielecCand);
1018 >    df.p4=GENPTOLOR(dielecCand);
1019  
1020      // accessing the daughters of the dimuon candidate
1021      const Candidate * lep0 = dielecCand.daughter( 0 );
# Line 890 | Line 1024 | HbbAnalyzerNew::produce(edm::Event& iEve
1024      const pat::Electron & elecDau0 = dynamic_cast<const pat::Electron &>(*lep0->masterClone());
1025      const pat::Electron & elecDau1 = dynamic_cast<const pat::Electron &>(*lep1->masterClone());
1026  
1027 <    df.daughter1.fourMomentum = GENPTOLOR(elecDau0);
1028 <    df.daughter2.fourMomentum = GENPTOLOR(elecDau1);
1027 >    df.daughter1.p4 = GENPTOLOR(elecDau0);
1028 >    df.daughter2.p4= GENPTOLOR(elecDau1);
1029  
1030      df.daughter1.tIso = elecDau0.trackIso();
1031      df.daughter2.tIso = elecDau1.trackIso();
# Line 902 | Line 1036 | HbbAnalyzerNew::produce(edm::Event& iEve
1036      df.daughter1.hIso = elecDau0.hcalIso();
1037      df.daughter2.hIso = elecDau1.hcalIso();
1038      
1039 <    
1039 >    // ids
1040 >    /*df.daughter1.id95 = elecDau0.electronID("simpleEleId95cIso");
1041 >    df.daughter1.id85 = elecDau0.electronID  ("simpleEleId85cIso");
1042 >    df.daughter1.id70 = elecDau0.electronID  ("simpleEleId70cIso");
1043 >    df.daughter1.id95r = elecDau0.electronID ("simpleEleId95relIso");
1044 >    df.daughter1.id85r = elecDau0.electronID ("simpleEleId85relIso");
1045 >    df.daughter1.id70r = elecDau0.electronID ("simpleEleId70relIso");
1046 >
1047 >
1048 >    df.daughter2.id95 = elecDau1.electronID("simpleEleId95cIso");
1049 >    df.daughter2.id85 = elecDau1.electronID  ("simpleEleId85cIso");
1050 >    df.daughter2.id70 = elecDau1.electronID  ("simpleEleId70cIso");
1051 >    df.daughter2.id95r = elecDau1.electronID ("simpleEleId95relIso");
1052 >    df.daughter2.id85r = elecDau1.electronID ("simpleEleId85relIso");
1053 >    df.daughter2.id70r = elecDau1.electronID ("simpleEleId70relIso");
1054 > */
1055      hbbInfo->diElectronInfo.push_back(df);
1056      
1057    }
1058 +   if (verbose_){
1059 +     std::cout <<" Pushing hbbInfo "<<std::endl;
1060 +     std::cout <<" SimpleJets1 = "<<hbbInfo->simpleJets.size()<<std::endl<<
1061 +       " SimpleJets2 = "<<hbbInfo->simpleJets2.size()<<std::endl<<
1062 +       " SubJets = "<<hbbInfo->subJets.size()<<std::endl<<
1063 +       " HardJets = "<<hbbInfo->hardJets.size()<<std::endl<<
1064 +       " Muons = "<<hbbInfo->muInfo.size()<<std::endl<<
1065 +       " Electrons = "<<hbbInfo->eleInfo.size()<<std::endl<<
1066 +       " Taus = "<<hbbInfo->tauInfo.size()<<std::endl<<
1067 +       " Electrons = "<<hbbInfo->eleInfo.size()<<std::endl<<
1068 +       "--------------------- "<<std::endl;
1069 +  }
1070 +
1071 +
1072    iEvent.put(hbbInfo);
1073 +  iEvent.put(auxInfo);
1074 +
1075  
1076   }
1077    
# Line 941 | Line 1106 | void
1106   HbbAnalyzerNew::endJob() {
1107   }
1108  
1109 + TVector2 HbbAnalyzerNew::getTvect( const pat::Jet* patJet ){
1110 +
1111 +  TVector2 t_Vect(0,0);
1112 +  TVector2 null(0,0);
1113 +  TVector2 ci(0,0);
1114 +  TLorentzVector pi(0,0,0,0);
1115 +  TLorentzVector J(0,0,0,0);
1116 +  TVector2 r(0,0);
1117 +  double patJetpfcPt = 1e10;
1118 +  double r_mag = 1e10;
1119 +  unsigned int nOfconst = 0;
1120 +
1121 +
1122 +  if (patJet->isPFJet() == false) {
1123 +    return t_Vect;
1124 +  }
1125 +  
1126 +
1127 +  //re-reconstruct the jet direction with the charged tracks
1128 +  std::vector<reco::PFCandidatePtr>
1129 +    patJetpfc = patJet->getPFConstituents();
1130 +  for(size_t idx = 0; idx < patJetpfc.size(); idx++){
1131 +    if( patJetpfc.at(idx)->charge() != 0 ){
1132 +      pi.SetPtEtaPhiE( patJetpfc.at(idx)->pt(), patJetpfc.at(idx)->eta(), patJetpfc.at(idx)->phi(), patJetpfc.at(idx)->energy() );
1133 +      J += pi;
1134 +      nOfconst++;
1135 +    }
1136 +  }
1137 + // if there are less than two charged tracks do not calculate the pull (there is not enough info). It returns a null vector
1138 +
1139 +  if( nOfconst < 2 )
1140 +    return null;
1141 +  
1142 +
1143 +
1144 +  TVector2 v_J( J.Rapidity(), J.Phi() );
1145 + //calculate TVector using only charged tracks
1146 +  for(size_t idx = 0; idx < patJetpfc.size(); idx++){
1147 +    if( patJetpfc.at(idx)->charge() != 0  ){
1148 +      patJetpfcPt = patJetpfc.at(idx)->pt();
1149 +      pi.SetPtEtaPhiE( patJetpfc.at(idx)->pt(), patJetpfc.at(idx)->eta(), patJetpfc.at(idx)->phi(), patJetpfc.at(idx)->energy() );
1150 +      r.Set( pi.Rapidity() - J.Rapidity(), Geom::deltaPhi( patJetpfc.at(idx)->phi(), J.Phi() ) );
1151 +      r_mag = r.Mod();
1152 +      t_Vect += ( patJetpfcPt / J.Pt() ) * r_mag * r;
1153 +    }
1154 +  }
1155 +
1156 +  
1157 +  return t_Vect;
1158 +  
1159 + }
1160 +
1161 + TLorentzVector HbbAnalyzerNew::getChargedTracksMomentum(const pat::Jet* patJet ){
1162 +  //  return TLorentzVector();
1163 +  TLorentzVector pi(0,0,0,0);
1164 +  TLorentzVector v_j1(0,0,0,0);
1165 +
1166 +
1167 +  //  std::cout <<"fff ECCCCCCOOOOO "<<patJet->isPFJet()<<std::endl;
1168 +
1169 +  if (patJet->isPFJet() == false ){
1170 +      v_j1 = GENPTOLORP(patJet);
1171 +      return v_j1;
1172 +  }
1173 +  std::vector<reco::PFCandidatePtr>
1174 +    j1pfc = patJet->getPFConstituents();
1175 +  for(size_t idx = 0; idx < j1pfc.size(); idx++){
1176 +    if( j1pfc.at(idx)->charge() != 0 ){
1177 +      pi.SetPtEtaPhiE( j1pfc.at(idx)->pt(), j1pfc.at(idx)->eta(), j1pfc.at(idx)->phi(), j1pfc.at(idx)->energy() );
1178 +      v_j1 += pi;
1179 +    }
1180 +  }
1181 +  return v_j1;
1182 +  //re-
1183 + }
1184 +
1185 +
1186 + //Btagging scale factors
1187 + void HbbAnalyzerNew::fillScaleFactors(VHbbEvent::SimpleJet sj, BTagSFContainer iSF){
1188 +
1189 +
1190 +  BinningPointByMap measurePoint;
1191 +  //for a USDG
1192 +  //for CB jets
1193 +  //scale factor 1 for CB jets over 240GeV/c
1194 +  if( TMath::Abs(sj.flavour) == 4 or TMath::Abs(sj.flavour) == 5 ){
1195 +    measurePoint.insert( BinningVariables::JetEt, sj.p4.Et() );
1196 +    measurePoint.insert( BinningVariables::JetAbsEta, fabs(sj.p4.Eta()) );
1197 +    if( iSF.BTAGSF_CSVL->isResultOk(PerformanceResult::BTAGBEFFCORR , measurePoint) ){
1198 +      sj.SF_CSVL = iSF.BTAGSF_CSVL->getResult(PerformanceResult::BTAGBEFFCORR , measurePoint);
1199 +      sj.SF_CSVLerr = iSF.BTAGSF_CSVL->getResult(PerformanceResult::BTAGBERRCORR , measurePoint);        
1200 +      if(verbose_){
1201 +        std::clog << "C/B Jet flavour = " << sj.flavour << std::endl;
1202 +        std::clog << "C/B Jet Et = " << sj.p4.Et() << std::endl;
1203 +        std::clog << "C/B Jet eta = " << sj.p4.Eta() << std::endl;          
1204 +        std::clog << "C/B CSVL Scale Factor = " << sj.SF_CSVL << std::endl;
1205 +        std::clog << "C/B CSVL Scale Factor error = " << sj.SF_CSVLerr << std::endl;
1206 +      }
1207 +    }
1208 +    if( iSF.BTAGSF_CSVM->isResultOk(PerformanceResult::BTAGBEFFCORR , measurePoint) ){
1209 +      sj.SF_CSVM = iSF.BTAGSF_CSVM->getResult(PerformanceResult::BTAGBEFFCORR , measurePoint);
1210 +      sj.SF_CSVMerr = iSF.BTAGSF_CSVM->getResult(PerformanceResult::BTAGBERRCORR , measurePoint);        
1211 +    }
1212 +    if( iSF.BTAGSF_CSVT->isResultOk(PerformanceResult::BTAGBEFFCORR , measurePoint) ){
1213 +      sj.SF_CSVT = iSF.BTAGSF_CSVT->getResult(PerformanceResult::BTAGBEFFCORR , measurePoint);
1214 +      sj.SF_CSVTerr = iSF.BTAGSF_CSVT->getResult(PerformanceResult::BTAGBERRCORR , measurePoint);        
1215 +    }
1216 +    else{
1217 +      if(verbose_){
1218 +        std::cerr << "No SF found in the database for this jet" << std::endl;
1219 +        std::clog << "No SF found: Jet flavour = " << sj.flavour << std::endl;
1220 +        std::clog << "No SF found: Jet Et = " << sj.p4.Et() << std::endl;
1221 +        std::clog << "No SF found: Jet eta = " << sj.p4.Eta() << std::endl;
1222 +      }
1223 +    }
1224 +  }
1225 +  else {
1226 +    measurePoint.insert( BinningVariables::JetEt, sj.p4.Et() );
1227 +    measurePoint.insert( BinningVariables::JetAbsEta, fabs(sj.p4.Eta()) );
1228 +    if( iSF.MISTAGSF_CSVL->isResultOk(PerformanceResult::BTAGLEFFCORR , measurePoint) ){
1229 +      sj.SF_CSVL = iSF.MISTAGSF_CSVL->getResult(PerformanceResult::BTAGLEFFCORR , measurePoint);
1230 +      sj.SF_CSVLerr = iSF.MISTAGSF_CSVL->getResult(PerformanceResult::BTAGLERRCORR , measurePoint);
1231 +      if(verbose_){
1232 +        std::clog << "Light Jet flavour = " << sj.flavour << std::endl;
1233 +        std::clog << "Light Jet Et = " << sj.p4.Et() << std::endl;
1234 +        std::clog << "Light Jet eta = " << sj.p4.Eta() << std::endl;        
1235 +        std::clog << "Light CSVL Scale Factor = " << sj.SF_CSVL << std::endl;
1236 +        std::clog << "Light CSVL Scale Factor error = " << sj.SF_CSVLerr << std::endl;
1237 +      }
1238 +    }
1239 +    if( iSF.MISTAGSF_CSVM->isResultOk(PerformanceResult::BTAGLEFFCORR , measurePoint) ){
1240 +      sj.SF_CSVM = iSF.MISTAGSF_CSVM->getResult(PerformanceResult::BTAGLEFFCORR , measurePoint);
1241 +      sj.SF_CSVMerr = iSF.MISTAGSF_CSVM->getResult(PerformanceResult::BTAGLERRCORR , measurePoint);
1242 +    }
1243 +    if( iSF.MISTAGSF_CSVT->isResultOk(PerformanceResult::BTAGLEFFCORR , measurePoint) ){
1244 +      sj.SF_CSVT = iSF.MISTAGSF_CSVT->getResult(PerformanceResult::BTAGLEFFCORR , measurePoint);
1245 +      sj.SF_CSVTerr = iSF.MISTAGSF_CSVT->getResult(PerformanceResult::BTAGLERRCORR , measurePoint);
1246 +    }
1247 +    else{
1248 +      if(verbose_){
1249 +        std::cerr << "No SF found in the database for this jet" << std::endl;
1250 +        std::clog << "No SF found: Jet flavour = " << sj.flavour << std::endl;
1251 +        std::clog << "No SF found: Jet Et = " << sj.p4.Et() << std::endl;
1252 +        std::clog << "No SF found: Jet eta = " << sj.p4.Eta() << std::endl;
1253 +      }
1254 +    }
1255 +  }
1256 +    
1257 + }
1258 +
1259 + void HbbAnalyzerNew::setJecUnc(VHbbEvent::SimpleJet& sj,JetCorrectionUncertainty* jecunc){
1260 +  //
1261 +  // test
1262 +  //
1263 +
1264 +  return;
1265 +  double eta = sj.p4.Eta();
1266 +  double pt = sj.p4.Pt();
1267 +  
1268 +  jecunc->setJetEta(eta);
1269 +  jecunc->setJetPt(pt); // here you must use the CORRECTED jet pt
1270 +  double unc = jecunc->getUncertainty(true);
1271 +  sj.jecunc= unc;
1272 + }
1273 +
1274 +
1275 + void HbbAnalyzerNew ::fillSimpleJet (VHbbEvent::SimpleJet& sj, edm::View<pat::Jet>::const_iterator jet_iter){
1276 +      sj.flavour = jet_iter->partonFlavour();
1277 +
1278 +    sj.tche=jet_iter->bDiscriminator("trackCountingHighEffBJetTags");
1279 +    sj.tchp=jet_iter->bDiscriminator("trackCountingHighPurBJetTags");
1280 +    sj.jp=jet_iter->bDiscriminator("jetProbabilityBJetTags");
1281 +    sj.jpb=jet_iter->bDiscriminator("jetBProbabilityBJetTags");
1282 +    sj.ssvhe=jet_iter->bDiscriminator("simpleSecondaryVertexHighEffBJetTags");
1283 +    sj.csv=jet_iter->bDiscriminator("combinedSecondaryVertexBJetTags");
1284 +    sj.csvmva=jet_iter->bDiscriminator("combinedSecondaryVertexMVABJetTags");
1285 +    sj.charge=jet_iter->jetCharge();
1286 +    sj.ntracks=jet_iter->associatedTracks().size();
1287 +    sj.p4=GENPTOLORP(jet_iter);
1288 +    sj.chargedTracksFourMomentum=(getChargedTracksMomentum(&*(jet_iter)));
1289 +    sj.SF_CSVL=1;
1290 +    sj.SF_CSVM=1;
1291 +    sj.SF_CSVT=1;
1292 +    sj.SF_CSVLerr=0;
1293 +    sj.SF_CSVMerr=0;
1294 +    sj.SF_CSVTerr=0;
1295 +
1296 +    
1297 +    if (jet_iter->isPFJet() == true) {
1298 +
1299 +      sj.chargedHadronEFraction = jet_iter-> chargedHadronEnergyFraction();
1300 +      sj.neutralHadronEFraction = jet_iter-> neutralHadronEnergyFraction ();
1301 +      sj.chargedEmEFraction = jet_iter-> chargedEmEnergyFraction ();
1302 +      sj.neutralEmEFraction = jet_iter-> neutralEmEnergyFraction ();
1303 +      sj. nConstituents = jet_iter->getPFConstituents().size();
1304 +      
1305 +    }
1306 +    //
1307 +    // addtaginfo for csv
1308 +    //
1309 +
1310 +    //    if (jet_iter->hasTagInfo("SimpleSecondaryVertex")) {
1311 +
1312 +    const reco::SecondaryVertexTagInfo * tf = jet_iter->tagInfoSecondaryVertex();
1313 +   if (tf){
1314 +      std::cout <<" PIPPO!!!!"<<std::endl;
1315 +      std::cout <<" PIPPO!!!!ddd "<<tf->nVertices()<<std::endl;
1316 +      sj.vtxMass = tf->secondaryVertex(0).p4().mass();
1317 +      std::cout <<" PIPPO2!!!!"<<std::endl;
1318 +      sj.vtxNTracks = tf->secondaryVertex(0).nTracks();
1319 +      std::cout <<" PIPPO3!!!!"<<std::endl;
1320 +      std::vector<reco::TrackBaseRef >::const_iterator tit =  tf->secondaryVertex(0).tracks_begin();
1321 +      std::cout <<" PIPPO4!!!!"<<std::endl;
1322 +      for (; tit<  tf->secondaryVertex(0).tracks_end(); ++tit){
1323 +        sj.vtxTrackIds.push_back(tit->key());
1324 +      }
1325 +      Measurement1D m = tf->flightDistance(0);
1326 +      sj.vtx3dL = m.value();
1327 +      sj.vtx3deL = m.error();
1328 +    }
1329 +   //
1330 +    // add tVector
1331 +    //
1332 +    sj.tVector = getTvect(&(*jet_iter));
1333 + }
1334 +
1335 +
1336   //define this as a plug-in
1337   DEFINE_FWK_MODULE(HbbAnalyzerNew);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines