ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/SelectionFuncs.cc
Revision: 1.20
Committed: Wed Feb 6 22:31:34 2013 UTC (12 years, 3 months ago) by anlevin
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +1 -1 lines
Log Message:
fixed problems so MitHzz4l compiles

File Contents

# Content
1 #include "SelectionFuncs.h"
2
3 extern vector<SimpleLepton> failingLeptons;
4 extern vector<SimpleLepton> passingLeptons;
5
6 extern vector<unsigned> cutvec;
7 extern vector<vector<unsigned> > zcutvec;
8 extern vector<vector<unsigned> > zzcutvec;
9 extern map<unsigned,float> evtrhoMap;
10 extern bool passes_HLT_MC;
11 extern RunLumiRangeMap rlrm;
12
13 //----------------------------------------------------------------------------------------
14 void increment(map<TString, map<TString,int>* > &counterMap, TString cutName, int z1type, int z2type)
15 //----------------------------------------------------------------------------------------
16 // increment counters that keep track of event counts at each cut
17 {
18 assert(counterMap.find(cutName) != counterMap.end());
19 (*(counterMap[cutName]))["all"] ++;
20 if(z1type!=0 && z2type!=0) {
21 assert(counterMap.find(cutName) != counterMap.end());
22 (*(counterMap[cutName]))[getChannel(z1type,z2type)] ++;
23 }
24 }
25 //----------------------------------------------------------------------------
26 bool setPV(ControlFlags &ctrl,
27 const mithep::Array<mithep::Vertex> * vtxArr,
28 const mithep::Vertex* &vtx)
29 //----------------------------------------------------------------------------
30 {
31
32 const mithep::Vertex *bestPV = 0;
33 float best_sumpt=-1;
34
35 // good PV requirements
36 const UInt_t fMinNTracksFit = 0;
37 const Double_t fMinNdof = 4;
38 const Double_t fMaxAbsZ = 24;
39 const Double_t fMaxRho = 2;
40
41 for(int i=0; i<vtxArr->GetEntries(); ++i) {
42 const mithep::Vertex *pv = (mithep::Vertex*)(vtxArr->At(i));
43 if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl;
44
45 // Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used
46 if(!pv->IsValid()) continue;
47 if(pv->NTracksFit() < fMinNTracksFit) continue;
48 if(pv->Ndof() < fMinNdof) continue;
49 if(fabs(pv->Z()) > fMaxAbsZ) continue;
50 if(pv->Position().Rho() > fMaxRho) continue;
51
52 // take the first ...
53 bestPV = pv;
54 break;
55
56 // this never reached ...
57 float tmp_sumpt=0;
58 for( int t=0; t<pv->NTracks(); t++ )
59 tmp_sumpt += pv->Trk(t)->Pt();
60
61 if( tmp_sumpt > best_sumpt ) {
62 bestPV = pv;
63 best_sumpt = tmp_sumpt;
64 if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl;
65 }
66 }
67
68 // sync
69 if(!bestPV)
70 return false;
71 else {
72 vtx = bestPV;
73 return true;
74 }
75 }
76 //----------------------------------------------------------------------------------------
77 void writeEntries(ControlFlags ctrl, unsigned total_unskimmed)
78 {
79 ofstream ofs;
80 TString ofname(ctrl.outputfile);
81 ofs.open(ofname.ReplaceAll(".root",".nevents"));
82 assert(ofs.is_open());
83 ofs << total_unskimmed << endl;
84 ofs.close();
85 }
86 //----------------------------------------------------------------------------------------
87 void getEATargets(ControlFlags &ctrl, mithep::MuonTools::EMuonEffectiveAreaTarget &eraMu, mithep::ElectronTools::EElectronEffectiveAreaTarget &eraEle)
88 {
89 if( !ctrl.mc && ctrl.era == 2011 ) {
90 eraMu = mithep::MuonTools::kMuEAData2011;
91 eraEle = mithep::ElectronTools::kEleEAData2011;
92 } else if( !ctrl.mc && ctrl.era == 2012 ) {
93 eraMu = mithep::MuonTools::kMuEAData2012;
94 eraEle = mithep::ElectronTools::kEleEAData2012;
95 } else if( ctrl.mc && ctrl.era == 2011 ) {
96 eraMu = mithep::MuonTools::kMuEAFall11MC;
97 eraEle = mithep::ElectronTools::kEleEAFall11MC;
98 } else if( ctrl.mc && ctrl.era == 2012 ) {
99 eraMu = mithep::MuonTools::kMuEAData2012;
100 eraEle = mithep::ElectronTools::kEleEAData2012;
101 } else {
102 cerr << "unknown era for effective areas ... quitting." << endl;
103 exit(1);
104 }
105 }
106 //----------------------------------------------------------------------------
107 unsigned makePFnoPUArray(const mithep::Array<PFCandidate> * fPFCandidates,
108 vector<bool> &pfNoPileUpflag,
109 const mithep::Array<mithep::Vertex> * vtxArr )
110 //----------------------------------------------------------------------------
111 //
112 // Make a vector of ints, one for each pf candidate, where we only include it in
113 // the isolation sum if it's 1
114 //
115 {
116 assert(pfNoPileUpflag.size() == 0); // make sure we remembered to clear it after the last event
117 for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {
118 const PFCandidate *pf = fPFCandidates->At(i);
119 assert(pf);
120
121 if(pf->PFType() == PFCandidate::eHadron) {
122 if(pf->HasTrackerTrk() &&
123 vtxArr->At(0)->HasTrack(pf->TrackerTrk()) &&
124 vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) {
125
126 pfNoPileUpflag.push_back(1);
127
128 } else {
129
130 Bool_t vertexFound = kFALSE;
131 const Vertex *closestVtx = 0;
132 Double_t dzmin = 10000;
133
134 // loop over vertices
135 for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) {
136 const Vertex *vtx = vtxArr->At(j);
137 assert(vtx);
138
139 if(pf->HasTrackerTrk() &&
140 vtx->HasTrack(pf->TrackerTrk()) &&
141 vtx->TrackWeight(pf->TrackerTrk()) > 0) {
142 vertexFound = kTRUE;
143 closestVtx = vtx;
144 break;
145 }
146 Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z());
147 if(dz < dzmin) {
148 closestVtx = vtx;
149 dzmin = dz;
150 }
151 }
152
153 // if(fCheckClosestZVertex) {
154 if(1) {
155 // Fallback: if track is not associated with any vertex,
156 // associate it with the vertex closest in z
157 if(vertexFound || closestVtx != vtxArr->At(0)) {
158 // pfPileUp->Add(pf);
159 pfNoPileUpflag.push_back(0); // i.e., don't use it in the isolation sum
160 } else {
161 pfNoPileUpflag.push_back(1); // use it
162 }
163 } else {
164 if(vertexFound && closestVtx != vtxArr->At(0)) {
165 // pfPileUp->Add(pf);
166 pfNoPileUpflag.push_back(0);
167 } else {
168 // PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is
169 pfNoPileUpflag.push_back(1);
170 }
171 }
172 } //hadron & trk stuff
173 } else { // hadron
174 // PFCandidate * ptr = pfNoPileUp->AddNew();
175 pfNoPileUpflag.push_back(1);
176 }
177 } // Loop over PF candidates
178
179 return pfNoPileUpflag.size();
180 }
181 //--------------------------------------------------------------------------------
182 void setEfficiencyWeights(ControlFlags &ctrl,
183 unsigned era,
184 EventData & evtdat,
185 std::bitset<1024> triggerBits,
186 mithep::TriggerTable *hltTable,
187 mithep::Array<mithep::TriggerObject> *hltObjArr,
188 mithep::TriggerObjectsTable *fTrigObjs,
189 WeightStruct & weights )
190 //--------------------------------------------------------------------------------
191 {
192 //
193 // offline weights
194 //
195 vector<SimpleLepton> lepvec = evtdat.Z1leptons;
196 lepvec.insert(lepvec.end(), evtdat.Z2leptons.begin(), evtdat.Z2leptons.end());
197
198 // get eff for each leg, for each lepton
199 vector< pair <double,double> > wlegs; // pair here is eff & err
200 for( int k=0; k<lepvec.size(); k++ ) {
201 double absEta = fabs(lepvec[k].vec.Eta());
202 double pt = lepvec[k].vec.Pt();
203 if( abs(lepvec[k].type) == 13 )
204 wlegs.push_back( muonPerLegOfflineEfficiencyWeight( ctrl, era, absEta, pt ) );
205 else
206 wlegs.push_back( elePerLegOfflineEfficiencyWeight( ctrl, era, absEta, pt, lepvec[k].isTight ) );
207 }
208 // combine weights and propagate uncertainties
209 pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs );
210 weights.woff = offpair.first;
211 weights.werroff = offpair.second;
212
213 //
214 // online weights
215 //
216 vector<SimpleLepton> muvec, elvec;
217 if(abs(evtdat.Z1leptons[0].type) == 11 ) {
218 elvec.push_back(evtdat.Z1leptons[0]);
219 elvec.push_back(evtdat.Z1leptons[1]);
220 } else {
221 muvec.push_back(evtdat.Z1leptons[0]);
222 muvec.push_back(evtdat.Z1leptons[1]);
223 }
224 if(abs(evtdat.Z2leptons[0].type) == 11 ) {
225 elvec.push_back(evtdat.Z2leptons[0]);
226 elvec.push_back(evtdat.Z2leptons[1]);
227 } else {
228 muvec.push_back(evtdat.Z2leptons[0]);
229 muvec.push_back(evtdat.Z2leptons[1]);
230 }
231 pair<double,double> onpair = getOnlineEfficiencyWeight( ctrl, triggerBits, hltTable, hltObjArr, fTrigObjs, muvec, elvec );
232 weights.won = onpair.first;
233 weights.werron = onpair.second;
234 }
235 //----------------------------------------------------------------------------
236 void initEvtRhoMap( map<unsigned, float> & evtrhoMap )
237 //----------------------------------------------------------------------------
238 {
239 unsigned evt;
240 float rho;
241
242 cout << "initialzing EvtRhoMap ";
243 //FILE * f = fopen("evtrho.dat", "r");
244 // FILE * f = fopen("allrho.cali.uniq.dat", "r");
245 // FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r");
246 assert(fopen("/scratch/dkralph/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat","r")); FILE * f = fopen("/scratch/dkralph/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r");
247 int lcount=0;
248 while( fscanf( f, "%u:%f", &evt, &rho ) ) {
249 if( feof(f) ) break;
250 evtrhoMap[evt] = rho;
251 lcount++;
252 if( !(lcount%1000) ) cout << "."; flush(cout);
253 }
254 cout << " done" << endl;
255 }
256
257 //----------------------------------------------------------------------------------------
258 void setEra(string fname, ControlFlags &ctrl)
259 {
260 //----------------------------------------------------------------------------------------
261 if( ctrl.mc && (fname.find("f11-") != string::npos) ) ctrl.era=2011 ;
262 else if( ctrl.mc && (fname.find("s12-") != string::npos) ) ctrl.era=2012 ;
263 else if( !ctrl.mc && (fname.find("r11") != string::npos) ) ctrl.era=2011 ;
264 else if( !ctrl.mc && (fname.find("r12") != string::npos) ) ctrl.era=2012 ;
265 else assert(0);
266 }
267
268 //----------------------------------------------------------------------------------------
269 unsigned getNPU(mithep::Array<mithep::PileupInfo> *puArr, int bx)
270 //----------------------------------------------------------------------------------------
271 {
272
273 // Identify bunch crossing 0 in PU info
274 int ibx0=-1, ibxm=-1, ibxp=-1;
275 assert(puArr);
276 for(unsigned i=0; i<puArr->GetEntries(); ++i) {
277 if(puArr->At(i)->GetBunchCrossing() == 0) ibx0=i;
278 if(puArr->At(i)->GetBunchCrossing() ==-1) ibxm=i;
279 if(puArr->At(i)->GetBunchCrossing() == 1) ibxp=i;
280 }
281
282 if(bx==0) return puArr->At(ibx0)->GetPU_NumInteractions();
283 else if(bx==-1) return puArr->At(ibxm)->GetPU_NumInteractions();
284 else if(bx== 1) return puArr->At(ibxp)->GetPU_NumInteractions();
285 else assert(0);
286
287 return 0;
288 }
289
290
291 //----------------------------------------------------------------------------
292 void initPUWeights()
293 //----------------------------------------------------------------------------
294 {
295 // TFile * puf;
296
297 // puf = new TFile("data/pileup/PUWeights_F11To2011.root");
298 // hpu_2011 = (TH1D*)(puf->Get("puWeights"));
299 // hpu_2011->SetDirectory(0);
300 // puf->Close();
301
302 // puf = new TFile("data/pileup/PUWeights_S12To2012_190456-199011.root");
303 // hpu_2012 = (TH1D*)(puf->Get("puWeights"));
304 // hpu_2012->SetDirectory(0);
305 // puf->Close();
306 }
307
308 //----------------------------------------------------------------------------
309 double getPUWeight(int era, TString fname, unsigned npu)
310 //----------------------------------------------------------------------------
311 {
312 if(npu > 59) npu = 59; // hardcoded crap in the pu functions
313
314 if(era==2011)
315 return weightTrue2011(npu);
316 else assert(era==2012);
317
318 // assume that if it's in /029/ that we want to reweigh to 53x data
319 TString vers,dataVers,mcVers;
320 if(fname.Contains("/028/")) dataVers = mcVers = vers = "52x";
321 else if(fname.Contains("/029/")) dataVers = mcVers = vers = "53x";
322 else {
323 // if(ctrl.debug)
324 // cout << "WARNING in getPUWeight(): couldn't figure out if this is 52x or 53x, so just using 53x" << endl;
325 dataVers = mcVers = vers = "53x";
326 }
327
328 if(dataVers=="52x" && mcVers=="52x")
329 return weightTruePileupV07toIchep52X(npu);
330 else if(dataVers=="53x" && mcVers=="53x")
331 return weightTruePileupSummer12toMoriond(npu);
332 // else if(dataVers=="53x" && mcVers=="53x")
333 // return weightTruePileupV10toHcp53X(npu);
334 // else if(dataVers=="53x" && mcVers=="52x") // umm... can't really do this a.t.m..., but this would be the proper function
335 // return weightTruePileupV07toHcp53X(npu);
336 else { cout << "Couldn't work out which npu to use!" << endl; assert(0); };
337
338 return 1;
339 }
340 //----------------------------------------------------------------------------------------
341 void initJets(ControlFlags ctrl,
342 string cmsswpath,
343 vector<TString> &fJetCorrParsv,
344 vector<JetCorrectorParameters> &correctionParameters,
345 FactorizedJetCorrector *&fJetCorrector,
346 JetIDMVA *&fJetIDMVA)
347 //----------------------------------------------------------------------------------------
348 {
349 //
350 // jet energy corrections
351 //
352 vector<TString> corrTypes;
353 corrTypes.push_back("L1FastJet");
354 corrTypes.push_back("L2Relative");
355 corrTypes.push_back("L3Absolute");
356 if(!ctrl.mc)
357 corrTypes.push_back("L2L3Residual");
358
359 TString tag;
360 if(ctrl.era==2011) {
361 cout << "\n\nNOTE: dont have the right JEC tags yet!\n\n" << endl;
362
363 //these are the right tags for 42X monte carlo
364 if(ctrl.mc) tag = "START42_V14B";
365 else tag = "GR_R_42_V23"; //same as GR_R_44_V15C and GR_R_42_V25;
366 } else if(ctrl.era==2012) {
367 cout << "\n\nNOTE: dont have the right JEC tags yet!\n\n" << endl;
368 if(ctrl.mc) tag = "START53_V7F"; //same as START53_V10
369 else tag = "GR_P_V41_AN2"; //same as GR_P_V41_AN1
370 assert(TString(cmsswpath).Contains("CMSSW_5_3"));
371 } else assert(0);
372
373 TString dataPath = TString(cmsswpath) + "/MitPhysics/data/";
374 for(unsigned icorr=0; icorr<corrTypes.size(); icorr++) {
375 if(ctrl.era==2011) corrTypes[icorr] = "AK5PF_" + corrTypes[icorr];
376 else if(ctrl.era==2012) corrTypes[icorr] = corrTypes[icorr] + "_AK5PF";
377 else assert(0);
378 TString fname(dataPath + tag + "_" + corrTypes[icorr] + ".txt");
379 if( !fopen(fname, "r") ) { cout << " no such file! " << fname << endl; assert(0); }
380 addJetCorr(fname, fJetCorrParsv);
381 }
382
383 for(unsigned icorr=0; icorr<fJetCorrParsv.size(); icorr++)
384 correctionParameters.push_back(JetCorrectorParameters(fJetCorrParsv[icorr].Data()));
385 fJetCorrector = new FactorizedJetCorrector(correctionParameters);
386
387 //
388 // jet ID
389 //
390 fJetIDMVA = new JetIDMVA();
391 JetIDMVA::MVAType mvaType;
392 TString loPtXml(dataPath+"mva_JetID_lowpt.weights.xml");
393 TString cfi(cmsswpath+"/MitPhysics/Utils/python/JetIdParams_hzz4l_moriond_cfi.py");
394 //TString cfi(cmsswpath+"/MitPhysics/Utils/python/JetIdParams_cfi.py");
395 TString Xml;
396 if(ctrl.era==2011) {
397 mvaType = JetIDMVA::k42;
398 Xml = dataPath+"TMVAClassification_PuJetIdOptMVA.weights.xml";
399 } else if(ctrl.era==2012) {
400 mvaType = JetIDMVA::k52;
401 Xml = dataPath+"TMVAClassification_5x_BDT_fullPlusRMS.weights.xml";
402 } else assert(0);
403
404 fJetIDMVA->Initialize(JetIDMVA::kLoose, loPtXml, Xml, mvaType, cfi);
405 }
406 //----------------------------------------------------------------------------------------
407 int getGenSampleType(TString ofname)
408 {
409 if(ofname.Contains(TRegexp("-zz4[em]-"))) return ESampleType::kVV; // powheg ZZ
410 else if(ofname.Contains(TRegexp("-zz2e2m-"))) return ESampleType::kVV; // ggZZ
411 else if(ofname.Contains(TRegexp("-zz4l-gf"))) return -1; // damn ggZZ has differences so MC parsing code fails ESampleType::kVV; // ggZZ
412 else if(ofname.Contains(TRegexp("-zz2l2l-gf"))) return -1; // damn ggZZ has differences so MC parsing code fails ESampleType::kVV; // ggZZ
413 else if(ofname.Contains(TRegexp("-ggzz4l-"))) return -1; // damn ggZZ has differences so MC parsing code fails ESampleType::kVV; // ggZZ
414 else if(ofname.Contains(TRegexp("-ggzz2l2l-"))) return -1; // damn ggZZ has differences so MC parsing code fails ESampleType::kVV; // ggZZ
415 else if(ofname.Contains(TRegexp("-x12[0-9]zz4l-"))) return ESampleType::kHZZJHU; // spin samples
416 else if(ofname.Contains(TRegexp("-h[0-9][0-9]*zz4l-"))) return ESampleType::kHZZ; // powheg HZZ
417 else if(ofname.Contains(TRegexp("-h[0-9][0-9]*-"))) return ESampleType::kHZZ; // powheg HZZ where I fucked up the name
418 else if(ofname.Contains(TRegexp("-zllm50-"))) return ESampleType::kZ; // drell-yan
419 else if(ofname.Contains(TRegexp("-zllm1050-"))) return ESampleType::kZ; // drell-yan
420 else if(ofname.Contains(TRegexp("-zjets-"))) return ESampleType::kZ; // drell-yan
421 else assert(0);
422 }
423 //----------------------------------------------------------------------------------------
424 TString getChannel(int z1type, int z2type)
425 {
426 if( abs(z1type) == 11 && abs(z2type) == 11 ) return "4e";//0;
427 else if( abs(z1type) == 13 && abs(z2type) == 13 ) return "4m";//1;
428 else return "2e2m";//2;
429 }
430 //----------------------------------------------------------------------------------------
431 // START: functions from Mangano
432 //----------------------------------------------------------------------------------------
433 float weightTruePileupSummer12toMoriond(float input){
434
435
436 double w[60] = {
437 0.252009,
438 0.327043,
439 0.335502,
440 0.352291,
441 0.324698,
442 0.582754,
443 0.455286,
444 0.441035,
445 0.607629,
446 0.930019,
447 1.3379,
448 1.69521,
449 1.74041,
450 1.54857,
451 1.32193,
452 1.15754,
453 1.07437,
454 1.05152,
455 1.07105,
456 1.11463,
457 1.15493,
458 1.17791,
459 1.18516,
460 1.17815,
461 1.1528,
462 1.10551,
463 1.03652,
464 0.948613,
465 0.844304,
466 0.728083,
467 0.607242,
468 0.489813,
469 0.381767,
470 0.287126,
471 0.207777,
472 0.144102,
473 0.0957851,
474 0.0611744,
475 0.0376984,
476 0.0226007,
477 0.0133203,
478 0.00782018,
479 0.00464555,
480 0.00284065,
481 0.00182028,
482 0.00123555,
483 0.000891118,
484 0.000679799,
485 0.000543107,
486 0.000449514,
487 0.000382089,
488 0.000331034,
489 0.000290923,
490 0.00025824,
491 0.000230472,
492 0.000206238,
493 0.000184523,
494 0.000164717,
495 0.000146364,
496 0.000271879};
497
498 //return w[(int)floor(input+0.5)];
499 return w[(int)floor(input)];
500 }
501
502
503 float weightTruePileupV07toIchep52X(float input){
504 float w[60] = {
505 2.59113e-07,
506 1.77107e-05,
507 0.0263017,
508 1.66396,
509 0.16421,
510 0.754166,
511 2.84622,
512 5.57103,
513 8.66558,
514 11.5716,
515 11.8712,
516 12.8102,
517 10.3421,
518 8.91019,
519 7.614,
520 6.10397,
521 4.52745,
522 3.26031,
523 2.39558,
524 1.83297,
525 1.47821,
526 1.26728,
527 1.14716,
528 1.06707,
529 0.98066,
530 0.860877,
531 0.708281,
532 0.539789,
533 0.37652,
534 0.237298,
535 0.1338,
536 0.0671236,
537 0.0299236,
538 0.0118723,
539 0.00420968,
540 0.00134235,
541 0.000389563,
542 0.000104892,
543 2.69214e-05,
544 6.79674e-06,
545 1.73307e-06,
546 4.52553e-07,
547 1.21124e-07,
548 3.29924e-08,
549 9.10616e-09,
550 2.53998e-09,
551 7.16146e-10,
552 2.03786e-10,
553 5.84308e-11,
554 1.68192e-11,
555 4.8434e-12,
556 1.38959e-12,
557 3.96112e-13,
558 1.11358e-13,
559 3.17245e-14,
560 5.34916e-15,
561 0,
562 0,
563 0,
564 0};
565
566 //return w[(int)floor(input+0.5)];
567 return w[(int)floor(input)];
568
569 /*
570 TH1F h("boh","boh",60,0.,60.);
571 for(int k=0;k<60;k++){
572 h.SetBinContent(k+1,w[k]);
573 }
574 return h.GetBinContent(h.FindBin(input));
575 */
576 }
577
578
579 float weightTruePileupV07toHcp53X(float input){
580 float w[60] = {
581 0.0447136,
582 0.11785,
583 0.23825,
584 1.08447,
585 0.102575,
586 0.454605,
587 1.79761,
588 4.00271,
589 6.83281,
590 9.83701,
591 10.7966,
592 12.2356,
593 10.0247,
594 8.49395,
595 7.1125,
596 5.69527,
597 4.31256,
598 3.19305,
599 2.42035,
600 1.91666,
601 1.58485,
602 1.36297,
603 1.21166,
604 1.09466,
605 0.978941,
606 0.84653,
607 0.699235,
608 0.548996,
609 0.408673,
610 0.288194,
611 0.193367,
612 0.124653,
613 0.0781124,
614 0.0479268,
615 0.0287763,
616 0.0167744,
617 0.00941834,
618 0.00507877,
619 0.00264364,
620 0.00134612,
621 0.000682678,
622 0.000351412,
623 0.0001864,
624 0.00010259,
625 5.87818e-05,
626 3.5033e-05,
627 2.17116e-05,
628 1.39777e-05,
629 9.36123e-06,
630 6.53328e-06,
631 4.76598e-06,
632 3.64139e-06,
633 2.92018e-06,
634 2.4602e-06,
635 2.17291e-06,
636 2.01107e-06,
637 1.94392e-06,
638 1.9598e-06,
639 2.0583e-06,
640 2.24895e-06};
641
642 return w[(int)floor(input)];
643 }
644
645
646 float weightTruePileupV10toIchep53X(float input){
647 float w[60] = {
648 2.35693e-06,
649 7.51928e-05,
650 0.0263529,
651 0.609947,
652 0.737917,
653 1.29365,
654 0.994503,
655 0.85454,
656 1.01559,
657 1.33243,
658 1.72454,
659 2.01264,
660 2.00573,
661 1.80333,
662 1.56328,
663 1.37452,
664 1.24753,
665 1.16481,
666 1.11738,
667 1.09701,
668 1.08843,
669 1.08796,
670 1.09768,
671 1.10763,
672 1.09328,
673 1.0339,
674 0.92408,
675 0.771537,
676 0.59283,
677 0.41266,
678 0.256892,
679 0.14188,
680 0.0692543,
681 0.029902,
682 0.0114564,
683 0.00391383,
684 0.00120625,
685 0.000341485,
686 9.09127e-05,
687 2.34008e-05,
688 5.95438e-06,
689 1.5122e-06,
690 3.82094e-07,
691 9.51794e-08,
692 2.32205e-08,
693 5.51698e-09,
694 1.27267e-09,
695 2.84346e-10,
696 6.12799e-11,
697 1.26731e-11,
698 2.50309e-12,
699 4.69797e-13,
700 8.35153e-14,
701 1.39452e-14,
702 2.24718e-15,
703 2.03841e-16,
704 0,
705 0,
706 0,
707 0};
708
709 return w[(int)floor(input)];
710 }
711
712
713
714 float weightTruePileupV10toHcp53X(float input){
715 float w[60] = {
716 0.409409,
717 0.527276,
718 0.39328,
719 0.507892,
720 0.48029,
721 0.787701,
722 0.632356,
723 0.618033,
724 0.806089,
725 1.14018,
726 1.5788,
727 1.93507,
728 1.957,
729 1.73004,
730 1.46737,
731 1.28278,
732 1.18189,
733 1.13388,
734 1.12578,
735 1.14415,
736 1.16048,
737 1.1618,
738 1.15318,
739 1.13405,
740 1.09239,
741 1.01915,
742 0.914837,
743 0.786744,
744 0.644879,
745 0.502039,
746 0.371688,
747 0.263586,
748 0.18067,
749 0.120472,
750 0.0780184,
751 0.0486113,
752 0.0289039,
753 0.0163367,
754 0.00879674,
755 0.00456046,
756 0.0023098,
757 0.00115977,
758 0.000583207,
759 0.000294815,
760 0.000149865,
761 7.62892e-05,
762 3.87537e-05,
763 1.96105e-05,
764 9.87744e-06,
765 4.95418e-06,
766 2.47913e-06,
767 1.23919e-06,
768 6.19751e-07,
769 3.10125e-07,
770 1.54934e-07,
771 7.71425e-08,
772 3.8182e-08,
773 1.87455e-08,
774 9.10765e-09,
775 9.19802e-09};
776 return w[(int)floor(input)];
777 }
778
779
780
781
782
783
784
785
786
787 float weightTrue2011(float input){
788 if(input>50)
789 return 1;
790
791
792 float w[50];
793
794
795 w[0]= 0.212929;
796 w[1]= 0.0208114;
797 w[2]= 0.0584048;
798 w[3]= 0.538898;
799 w[4]= 1.357;
800 w[5]= 1.49913;
801 w[6]= 1.42247;
802 w[7]= 1.35904;
803 w[8]= 1.29946;
804 w[9]= 1.27925;
805 w[10]= 1.37845;
806 w[11]= 1.71246;
807 w[12]= 1.5291;
808 w[13]= 1.35234;
809 w[14]= 1.22215;
810 w[15]= 1.0155;
811 w[16]= 1.01137;
812 w[17]= 0.395465;
813 w[18]= 0.230984;
814 w[19]= 0.109883;
815 w[20]= 0.0433739;
816 w[21]= 0.0111497;
817 w[22]= 0.00408801;
818 w[23]= 0.00115678;
819 w[24]= 0.000365505;
820 w[25]= 0.000112391;
821 w[26]= 3.83894e-05;
822 w[27]= 1.60651e-05;
823 w[28]= 4.81412e-06;
824 w[29]= 1.39717e-06;
825 w[30]= 1.92368e-06;
826 w[31]= 4.10748e-06;
827 w[32]= 2.33157e-05;
828 w[33]= 4.0181e-05;
829 w[34]= 4.87786e-05;
830 w[35]= 0.00194128;
831 w[36]= 8.97414e-05;
832 w[37]= 1;
833 w[38]= 1;
834 w[39]= 0.000162709;
835 w[40]= 1;
836 w[41]= 1;
837 w[42]= 1;
838 w[43]= 1;
839 w[44]= 1;
840 w[45]= 1;
841 w[46]= 1;
842 w[47]= 1;
843 w[48]= 1;
844 w[49]= 1;
845
846
847 TH1F h("boh","boh",50,0.,50.);
848
849 for(int k=0;k<50;k++){
850 h.SetBinContent(k+1,w[k]);
851 }
852
853 return h.GetBinContent(h.FindBin(input));
854
855 }
856 //----------------------------------------------------------------------------------------
857 float weightTrue2011to2012(float input){
858 if(input>50)
859 return 1;
860
861 float w[50];
862
863 w[0]= 0.000443112;
864 w[1]= 0.000248044;
865 w[2]= 0.000273111;
866 w[3]= 0.00109511;
867 w[4]= 0.00195699;
868 w[5]= 0.00480746;
869 w[6]= 0.027013;
870 w[7]= 0.074795;
871 w[8]= 0.166231;
872 w[9]= 0.309545;
873 w[10]= 0.577657;
874 w[11]= 1.12488;
875 w[12]= 1.36899;
876 w[13]= 1.56925;
877 w[14]= 1.89846;
878 w[15]= 2.20828;
879 w[16]= 3.14112;
880 w[17]= 1.87712;
881 w[18]= 1.97062;
882 w[19]= 2.07067;
883 w[20]= 2.17791;
884 w[21]= 1.7176;
885 w[22]= 2.10953;
886 w[23]= 2.0805;
887 w[24]= 2.29498;
888 w[25]= 2.42189;
889 w[26]= 2.80303;
890 w[27]= 3.94091;
891 w[28]= 3.67917;
892 w[29]= 2.26081;
893 w[30]= 2.99726;
894 w[31]= 3.76553;
895 w[32]= 11.285;
896 w[33]= 10.2781;
897 w[34]= 6.73407;
898 w[35]= 148.182;
899 w[36]= 3.88144;
900 w[37]= 1;
901 w[38]= 1;
902 w[39]= 1.48128;
903 w[40]= 1;
904 w[41]= 1;
905 w[42]= 1;
906 w[43]= 1;
907 w[44]= 1;
908 w[45]= 1;
909 w[46]= 1;
910 w[47]= 1;
911 w[48]= 1;
912 w[49]= 1;
913
914
915 TH1F h("boh","boh",50,0.,50.);
916
917 for(int k=0;k<50;k++){
918 h.SetBinContent(k+1,w[k]);
919 }
920
921 return h.GetBinContent(h.FindBin(input));
922
923 }
924 //----------------------------------------------------------------------------------------
925 // END: functions from Mangano
926 //----------------------------------------------------------------------------------------