-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEventCalculator.C
10206 lines (8311 loc) · 394 KB
/
EventCalculator.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "EventCalculator.h"
#include "PUConstants.h"
#include "TH1.h"
#include "TF1.h"
#include "TLorentzVector.h"
#include "TRandom3.h"
#include "TTree.h"
#include "TFile.h"
#include "TMatrixT.h"
#include "TMatrixDEigen.h"
#include "TStopwatch.h"
#include "TVector3.h"
#include <RooRealVar.h>
#include <RooMinuit.h>
#include <RooTransverseThrustVar.h>
#include <cassert>
#include <fstream>
#include <algorithm>
using namespace std;
EventCalculator::EventCalculator(const TString & sampleName, jetType theJetType, METType theMETType) :
sampleName_(sampleName),
sampleIsSignal_(false),
theScanType_(kNotScan),
theMETType_(theMETType),
theJetType_(theJetType),
theJESType_(kJES0),
theJERType_(kJER0),
theMETuncType_(kMETunc0),
thePUuncType_(kPUunc0),
theBTagEffType_(kBTagEff04),
theHLTEffType_(kHLTEff0),
theBTaggerType_(kCSVM),
//default settings for the collection pointers
//this is what used to be in 'InitializeStuff()'
myJetsPF( &jet2), //selectedPatJetsPF
myJetsPFhelper( &jethelper2),
myElectronsPF( &electron1),
myElectronsRECO( &electron),
myElectronsPFhelper( &electronhelper1),
myElectronsRECOhelper( &electronhelper),
myMuonsPF(&muon1),
myMuonsRECO(&muon),
myMuonsPFhelper(&muonhelper1),
myMuonsRECOhelper(&muonhelper),
myTausPF(&tau),
myMETPF(&met1),
myMETPFType1(&met4),
myMETcalo(&met),
myVertex(&vertex),
myGenParticles(&genparticlehelperra2),
myGenWeight(&geneventinfoproduct_weight),
myJetsPF_temp(0),
myMETPF_temp(0),
myEDM_bunchCrossing ( &eventhelper_bunchCrossing),
myEDM_event ( &eventhelper_event),
myEDM_isRealData ( &eventhelper_isRealData),
myEDM_luminosityBlock ( &eventhelper_luminosityBlock),
myEDM_run ( &eventhelper_run),
crossSectionTanb40_10_(0),
crossSectionTanb40_05_(0),
crossSectionTanb40_20_(0),
smsCrossSectionFile_(0),
f_eff_ht300_(0),
f_eff_ht350_(0),
htgraph_ht300_(0),
htgraphPlus_ht300_(0),
htgraphMinus_ht300_(0),
htgraph_ht350_(0),
htgraphPlus_ht350_(0),
htgraphMinus_ht350_(0),
f_eff_mht_(0),
mhtgraph_(0),
mhtgraphPlus_(0),
mhtgraphMinus_(0),
fDataJetRes_(0),
hEta0_0p5_(0),
hEta0p5_1_(0),
hEta1_1p5_(0),
hEta1p5_2_(0),
hEta2_2p5_(0),
hEta2p5_3_(0),
hEta3_5_(0),
hDiyGaus_(0),
hDiy3Gaus_(0),
ResJetPar_(new JetCorrectorParameters("START42_V13_AK5PFchs_L2L3Residual.txt") ),
L3JetPar_( new JetCorrectorParameters("START42_V13_AK5PFchs_L3Absolute.txt") ),
L2JetPar_(new JetCorrectorParameters("START42_V13_AK5PFchs_L2Relative.txt") ),
L1JetPar_(new JetCorrectorParameters("START42_V13_AK5PFchs_L1FastJet.txt") ),
JetCorrector_(0 ),
jecUnc_(new JetCorrectionUncertainty("START42_V13_AK5PFchs_Uncertainty.txt")),
starttime_(0),
recalculatedVariables_(false),
watch_(0)
{
if ( sampleName_.Contains("mSUGRA") ) {
theScanType_ = kmSugra;
std::cout<<"\tDetected that I'm running over an mSugra scan!"<<std::endl;
sampleIsSignal_=true;
}
else if (sampleName_.Contains("T1bbbb") || sampleName_.Contains("T2bb") || sampleName_.Contains("T2tt") || sampleName_.Contains("T1tttt")) {
theScanType_ = kSMS;
std::cout<<"\tDetected that I'm running over an SMS scan!"<<std::endl;
sampleIsSignal_=true;
}
else if (sampleName_.Contains("LM")) {
sampleIsSignal_=true;
std::cout<<"\tDetected that I'm running over a SUSY sample!"<<std::endl;
}
else std::cout<<"\tRunning on a SM sample"<<std::endl;
initEnumNames();
loadSusyScanCrossSections();
checkConsistency();
//loadHLTMHTeff();
loadHLTHTeff();
loadDataJetRes();
loadDiySmear();
loadECALStatus();//could also be in reducedTree
vPar_.clear(); //should be overkill
vPar_.push_back(*L1JetPar_);
vPar_.push_back(*L2JetPar_);
vPar_.push_back(*L3JetPar_);
vPar_.push_back(*ResJetPar_);
JetCorrector_ = new FactorizedJetCorrector(vPar_);
loadJetTagEffMaps();
}
EventCalculator::~EventCalculator() {}
//for now we pretend that we don't need to clean anything up
void EventCalculator::initEnumNames() {
theBTaggerNames_[kSSVM]="SSVHEM";
theBTaggerNames_[kTCHET]="TCHET";
theBTaggerNames_[kSSVHPT]="SSVHPT";
theBTaggerNames_[kTCHPT]="TCHPT";
theBTaggerNames_[kTCHPM]="TCHPM";
theBTaggerNames_[kCSVM]="CSVM";
theMETNames_[kPFMET] = "PFMET";
theMETNames_[kPFMETTypeI] = "PFMETTypeI";
theJetNames_[kPF2PAT]="PF2PATjets";
theJetNames_[kRECOPF]="RecoPFjets";
theJESNames_[kJES0]="JES0";
theJESNames_[kJESup]="JESup";
theJESNames_[kJESdown]="JESdown";
theJESNames_[kJESFLY]="JESFLY";
theMETuncNames_[kMETunc0]="METunc0";
theMETuncNames_[kMETuncUp]="METuncUp";
theMETuncNames_[kMETuncDown]="METuncDown";
thePUuncNames_[kPUunc0]="PUunc0";
thePUuncNames_[kPUuncUp]="PUuncUp";
thePUuncNames_[kPUuncDown]="PUuncDown";
theBTagEffNames_[kBTagEff0]="BTagEff0";
theBTagEffNames_[kBTagEffup]="BTagEffup";
theBTagEffNames_[kBTagEffdown]="BTagEffdown";
theBTagEffNames_[kBTagEff02]="BTagEff02";
theBTagEffNames_[kBTagEffup2]="BTagEffup2";
theBTagEffNames_[kBTagEffdown2]="BTagEffdown2";
theBTagEffNames_[kBTagEff03]="BTagEff03";
theBTagEffNames_[kBTagEffup3]="BTagEffup3";
theBTagEffNames_[kBTagEffdown3]="BTagEffdown3";
theBTagEffNames_[kBTagEff04]="BTagEff04";
theBTagEffNames_[kBTagEffup4]="BTagEffup4";
theBTagEffNames_[kBTagEffdown4]="BTagEffdown4";
theHLTEffNames_[kHLTEff0]="HLTEff0";
theHLTEffNames_[kHLTEffup]="HLTEffup";
theHLTEffNames_[kHLTEffdown]="HLTEffdown";
theJERNames_[kJER0]="JER0";
theJERNames_[kJERup]="JERup";
theJERNames_[kJERbias]="JERbias";
theJERNames_[kJERra2]="JERra2";
theJERNames_[kJERdown]="JERdown";
}
void EventCalculator::checkConsistency() {
//this is probably bad coding, but the only thing I can think of for this already horribly-constructed code
std::string jettype = typeid( *myJetsPF ).name();
std::string recopfjet = "jet_s";
//std::string pf2patjet = "jet1_s";
std::string pf2patjet = "jet2_s";
if( theJetType_==kPF2PAT && std::string::npos != jettype.find(recopfjet)) {
//std::cout << "myJetsPF is pointing to recopfjet" << std::endl;
std::cout << "ERROR: theJetType_ is set to kPF2PAT jets, while myJetsPF is pointing to something else. "
<< "This will screw up (at least) the cleaning selection. Aborting." << std::endl;
assert(0);
}
if( theJetType_==kRECOPF && std::string::npos != jettype.find(pf2patjet)){
//std::cout << "myJetsPF is pointing to pf2patjet" << std::endl;
std::cout << "ERROR: theJetType_ is set to kRECOPF jets, while myJetsPF is pointing to something else. "
<< "This will screw up (at least) the cleaning selection. Aborting." << std::endl;
assert(0);
}
std::string mettype = typeid( *myMETPF ).name();
std::string rawpfmet = "met1_s";
//std::string type1pfmet = "met2_s";
std::string type1pfmet = "met4_s";
if( theMETType_ == kPFMETTypeI && std::string::npos != jettype.find(type1pfmet)){ //FIXME why a reference to jettype here?
std::cout << "ERROR: theMETType_ is set to PFMETTypeI, while myMETsPF is also pointing to type1pfmet. "
<< "This will double-correct the MET! Aborting." << std::endl;
assert(0);
}
//theScanType_ is set automatically now, so this is basically redundant
if (theScanType_!=kNotScan && sampleName_.Contains("LM")) {cout<<"LM point is not a scan! Check theScanType_!"<<endl; assert(0);}
if (theScanType_!=kmSugra && sampleName_.Contains("SUGRA")) {cout<<"mSugra is a scan! Check theScanType_!"<<endl; assert(0);}
if (theScanType_!=kSMS && sampleName_.Contains("T1bbbb")) {cout<<"T1bbbb is a scan! Check theScanType_!"<<endl; assert(0);}
if (theScanType_!=kSMS && sampleName_.Contains("T2bb")) {cout<<"T2bb is a scan! Check theScanType_!"<<endl; assert(0);}
if (theScanType_!=kSMS && sampleName_.Contains("T2tt")) {cout<<"T2tt is a scan! Check theScanType_!"<<endl; assert(0);}
}
void EventCalculator::stopTimer(const Long64_t ntotal) {
TDatime stoptime; //default ctor is for current time
double elapsed= stoptime.Convert() - starttime_->Convert();
std::cout<<"events / time = "<<ntotal<<" / "<<elapsed<<" = "<<double(ntotal)/double(elapsed)<<" Hz"<<std::endl;
delete starttime_;
starttime_=0;
}
void EventCalculator::loadSusyScanCrossSections() {
if (theScanType_ == kmSugra ) {
crossSectionTanb40_10_ = new CrossSectionTable("NLOxsec_tanb40_10.txt");
crossSectionTanb40_05_ = new CrossSectionTable("NLOxsec_tanb40_05.txt");
crossSectionTanb40_20_ = new CrossSectionTable("NLOxsec_tanb40_20.txt");
}
}
void EventCalculator::setOptions( const TString & opt) {
//cannot set the b tagger, or the jet type, or the met type, or the scan type
//but all other options must be set here
if (opt=="") return;
cout<<opt<<endl;
//i wish i could think of a more clever way to code this
if ( getOptPiece("JES",opt)== theJESNames_[kJES0]) theJESType_ = kJES0;
else if ( getOptPiece("JES",opt)== theJESNames_[kJESup]) theJESType_ = kJESup;
else if ( getOptPiece("JES",opt)== theJESNames_[kJESdown]) theJESType_ = kJESdown;
else if ( getOptPiece("JES",opt)== theJESNames_[kJESFLY]) theJESType_ = kJESFLY;
else {cout<<"problem with opt in JES"<<endl; assert(0) ;} //enforce a complete set of options!
if ( getOptPiece("JER",opt)== theJERNames_[kJER0]) theJERType_ = kJER0;
else if ( getOptPiece("JER",opt)== theJERNames_[kJERup]) theJERType_ = kJERup;
else if ( getOptPiece("JER",opt)== theJERNames_[kJERdown]) theJERType_ = kJERdown;
else if ( getOptPiece("JER",opt)== theJERNames_[kJERbias]) theJERType_ = kJERbias;
else if ( getOptPiece("JER",opt)== theJERNames_[kJERra2]) theJERType_ = kJERra2;
else {cout<<"problem with opt in JER"<<endl; assert(0);} //enforce a complete set of options!
if ( getOptPiece("METunc",opt)== theMETuncNames_[kMETunc0]) theMETuncType_ = kMETunc0;
else if ( getOptPiece("METunc",opt)== theMETuncNames_[kMETuncUp]) theMETuncType_ = kMETuncUp;
else if ( getOptPiece("METunc",opt)== theMETuncNames_[kMETuncDown]) theMETuncType_ = kMETuncDown;
else {cout<<"problem with opt in METunc"<<endl; assert(0) ;} //enforce a complete set of options!
if ( getOptPiece("PUunc",opt)== thePUuncNames_[kPUunc0]) thePUuncType_ = kPUunc0;
else if ( getOptPiece("PUunc",opt)== thePUuncNames_[kPUuncUp]) thePUuncType_ = kPUuncUp;
else if ( getOptPiece("PUunc",opt)== thePUuncNames_[kPUuncDown]) thePUuncType_ = kPUuncDown;
else {cout<<"problem with opt in PU"<<endl; assert(0) ;} //enforce a complete set of options!
if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEff0]) theBTagEffType_ = kBTagEff0;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffup]) theBTagEffType_ = kBTagEffup;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffdown]) theBTagEffType_ = kBTagEffdown;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEff02]) theBTagEffType_ = kBTagEff02;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffup2]) theBTagEffType_ = kBTagEffup2;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffdown2]) theBTagEffType_ = kBTagEffdown2;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEff03]) theBTagEffType_ = kBTagEff03;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffup3]) theBTagEffType_ = kBTagEffup3;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffdown3]) theBTagEffType_ = kBTagEffdown3;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEff04]) theBTagEffType_ = kBTagEff04;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffup4]) theBTagEffType_ = kBTagEffup4;
else if ( getOptPiece("BTag",opt)== theBTagEffNames_[kBTagEffdown4]) theBTagEffType_ = kBTagEffdown4;
else {cout<<"problem with opt in btag"<<endl; assert(0) ;} //enforce a complete set of options!
if ( getOptPiece("HLT",opt)== theHLTEffNames_[kHLTEff0]) theHLTEffType_ = kHLTEff0;
else if ( getOptPiece("HLT",opt)== theHLTEffNames_[kHLTEffup]) theHLTEffType_ = kHLTEffup;
else if ( getOptPiece("HLT",opt)== theHLTEffNames_[kHLTEffdown]) theHLTEffType_ = kHLTEffdown;
else {cout<<"problem with opt in HLT"<<endl;assert(0) ;} //enforce a complete set of options!
cout<<"Got options: "<<endl
<<theJESNames_[theJESType_]<<endl
<<theJERNames_[theJERType_]<<endl
<<theMETuncNames_[theMETuncType_]<<endl
<<thePUuncNames_[thePUuncType_]<<endl
<<theBTagEffNames_[theBTagEffType_]<<endl
<<theHLTEffNames_[theHLTEffType_]<<endl;
}
double EventCalculator::getWeight(Long64_t nentries) {
if( isSampleRealData() ) return 1;
if (theScanType_==kmSugra) return 1;//special weighting in effect
else if (theScanType_==kSMS) return 1;//special weighting in effect
double sigma = getCrossSection();
double w = lumi_ * sigma / double(nentries);
if (sampleName_.Contains("QCD_Pt_15to3000_TuneZ2_Flat_7TeV_pythia6")) w *= (*myGenWeight);
return w;
}
//1d reweighting
float EventCalculator::getPUWeight(reweight::LumiReWeighting lumiWeights) {
if (isSampleRealData() ) return 1;
float weight;
//float sum_nvtx = 0;
int npv = 0;
for ( unsigned int i = 0; i<pileupsummaryinfo.size() ; i++) {
//consider only in-time PU
int BX = pileupsummaryinfo.at(i).addpileupinfo_getBunchCrossing;
if(BX == 0) {
npv = pileupsummaryinfo.at(i).addpileupinfo_getPU_NumInteractions;
}
//else {
// cout<<"[EventCalculator::getPUweight 1D] is this supposed to happen?"<<endl;
//}
}
//in-time PU only
weight = lumiWeights.ITweight( npv );
return weight;
}
//3d reweighting
float EventCalculator::getPUWeight(Lumi3DReWeighting lumiWeights) {
if (isSampleRealData() ) return 1;
float weight;
int nm1 = -1; int n0 = -1; int np1 = -1;
for ( unsigned int i = 0; i<pileupsummaryinfo.size() ; i++) {
//npv = pileupsummaryinfo.at(i).addpileupinfo_getPU_NumInteractions;
//sum_nvtx += float(npv);
int BX = pileupsummaryinfo.at(i).addpileupinfo_getBunchCrossing;
if(BX == -1) {
nm1 = pileupsummaryinfo.at(i).addpileupinfo_getPU_NumInteractions;
}
else if(BX == 0) {
n0 = pileupsummaryinfo.at(i).addpileupinfo_getPU_NumInteractions;
}
else if(BX == 1) {
np1 = pileupsummaryinfo.at(i).addpileupinfo_getPU_NumInteractions;
}
}
//3d reweighting
weight = lumiWeights.weight3D( nm1,n0,np1);
//Outdated. PU systematics now done via scale-factor in reducedTree()
////following: https://twiki.cern.ch/twiki/bin/viewauth/CMS/PileupSystematicErrors
//reweight::PoissonMeanShifter PShift;
//if(thePUuncType_ == kPUuncDown){
// PShift = reweight::PoissonMeanShifter(-0.6);
// //weight = weight * PShift.ShiftWeight( ave_nvtx );
// weight = weight * PShift.ShiftWeight( npv );
//}
//else if(thePUuncType_ == kPUuncUp){
// PShift = reweight::PoissonMeanShifter(0.6);
// //weight = weight * PShift.ShiftWeight( ave_nvtx );
// weight = weight * PShift.ShiftWeight( npv );
//}
//if this is ttbar Fall11 MC
if (sampleName_.Contains("TTJets_TuneZ2_7TeV-madgraph-tauola_Fall11_v2") ) {
int nPV = countGoodPV();
//From Kristen (via RA4 group)
double pvweights[25]={0 , 0.549398 , 0.854301 , 1.0274 , 1.19307 ,
1.29101 , 1.33746 , 1.25162 , 1.16767 , 1.12114 ,
0.954877 , 0.771361 , 0.583225 , 0.46853 , 0.343897 ,
0.238567 , 0.160576 , 0.11326 , 0.0544237 , 0.0236446 ,
0 , 0.0850062 , 0 , 0 , 0};
//this is applied to normalize the nGoodPV distribution
//of ttbar Fall MC to that of data after applying the following cuts
//{HT>400,MET>250,njets>=3,bjets>=1}
//(Kristen is applying the same weighting)
double corr[25] = {0., 0.8919, 0.8289, 1.1152, 1.0013, 0.8529, 1.0224, 0.9010, 1.0397,
0.9782, 1.0765, 1.2540, 1.3285, 0.8122, 0.9539, 1.5913, 1.3473, 1.9760,
0., 0., 0., 0., 0., 0., 0.};
if(nPV > 24) weight =0;
else weight = pvweights[nPV]*0.975*corr[nPV];
//else weight = pvweights[nPV];
}
return weight;
}
bool EventCalculator::isGoodMuon(const unsigned int imuon, const bool disableRelIso, const float ptthreshold) {
if (myMuonsPF->at(imuon).pt >= ptthreshold
&& fabs(myMuonsPF->at(imuon).eta)<2.4
&& myMuonsPF->at(imuon).GlobalMuonPromptTight == 1
&& myMuonsPF->at(imuon).isTrackerMuon == 1
&& myMuonsPF->at(imuon).innerTrack_numberOfValidHits >=11
&& myMuonsPF->at(imuon).track_hitPattern_numberOfValidPixelHits >= 1
//&& fabs(myMuonsPF->at(imuon).dB) < 0.02
&& fabs(myMuonsPFhelper->at(imuon).dxywrtBeamSpot) < 0.02
&& fabs(myMuonsPF->at(imuon).vz - myVertex->at(0).z ) <1
&& ((myMuonsPF->at(imuon).chargedHadronIso
+ myMuonsPF->at(imuon).photonIso
+ myMuonsPF->at(imuon).neutralHadronIso)/myMuonsPF->at(imuon).pt <0.2 ||disableRelIso)
) {
return true;
}
return false;
}
bool EventCalculator::isGoodRecoMuon(const unsigned int imuon, const bool disableRelIso, const float ptthreshold) {
assert(disableRelIso); //the iso calculation below is completely worthless. it uses PF quantities on RECO muons.
if (myMuonsRECO->at(imuon).pt >= ptthreshold
&& fabs(myMuonsRECO->at(imuon).eta)<2.4
&& myMuonsRECO->at(imuon).GlobalMuonPromptTight == 1
&& myMuonsRECO->at(imuon).isTrackerMuon == 1
&& myMuonsRECO->at(imuon).innerTrack_numberOfValidHits >=11
&& myMuonsRECO->at(imuon).track_hitPattern_numberOfValidPixelHits >= 1
&& fabs(myMuonsRECOhelper->at(imuon).dxywrtBeamSpot) < 0.02
&& fabs(myMuonsRECO->at(imuon).vz - myVertex->at(0).z ) <1
&& ((myMuonsRECO->at(imuon).chargedHadronIso
+ myMuonsRECO->at(imuon).photonIso
+ myMuonsRECO->at(imuon).neutralHadronIso)/myMuonsRECO->at(imuon).pt <0.2 ||disableRelIso)
) {
return true;
}
return false;
}
bool EventCalculator::isInAccRecoMuon(const unsigned int imuon, const float ptthreshold) {
if (myMuonsRECO->at(imuon).pt >= ptthreshold && fabs(myMuonsRECO->at(imuon).eta)<2.4)
return true;
return false;
}
bool EventCalculator::isCleanMuon(const unsigned int imuon, const float ptthreshold) {
if (!isGoodMuon(imuon,false,ptthreshold)) return false;
//clean muons if using reco-pfjets
if(theJetType_ == kRECOPF) {
bool isNearJet = false;
for ( unsigned int j = 0; j< myJetsPF->size(); j++) {
if( isGoodJet(j) && jmt::deltaR( myJetsPF->at(j).eta, myJetsPF->at(j).phi,myMuonsPF->at(imuon).eta, myMuonsPF->at(imuon).phi)<0.3 ) {
isNearJet = true ; break;
}
}
if(isNearJet) return false;
}
return true;
}
//this bool could be turned into a more powerful selector for N-1 studies. keep it simple for now
bool EventCalculator::isGoodElectron(const unsigned int iele, const bool disableRelIso, const float ptthreshold) {
if (myElectronsPF->at(iele).pt >= ptthreshold
&& fabs(myElectronsPF->at(iele).superCluster_eta) < 2.5
&& !(fabs(myElectronsPF->at(iele).superCluster_eta) > 1.4442
&& fabs(myElectronsPF->at(iele).superCluster_eta) < 1.566)
&& myElectronsPF->at(iele).gsfTrack_trackerExpectedHitsInner_numberOfLostHits <= 1
//&& fabs(myElectronsPF->at(iele).dB) < 0.02
&& fabs(myElectronsPFhelper->at(iele).dxywrtBeamSpot) < 0.02
&& fabs(myElectronsPF->at(iele).vz - myVertex->at(0).z ) <1
&& ((myElectronsPF->at(iele).chargedHadronIso
+ myElectronsPF->at(iele).photonIso
+ myElectronsPF->at(iele).neutralHadronIso)/myElectronsPF->at(iele).pt <0.2 || disableRelIso)
) {
return true;
}
return false;
}
//try a tighter tag electron definition to try to get rid of fakes?
bool EventCalculator::isTightElectron(const unsigned int iele, const float isothreshold, const float ptthreshold) {
if (myElectronsPF->at(iele).pt >= ptthreshold
&& fabs(myElectronsPF->at(iele).superCluster_eta) < 2.5
&& !(fabs(myElectronsPF->at(iele).superCluster_eta) > 1.4442
&& fabs(myElectronsPF->at(iele).superCluster_eta) < 1.566)
&& myElectronsPF->at(iele).gsfTrack_trackerExpectedHitsInner_numberOfLostHits <= 1
//&& fabs(myElectronsPF->at(iele).dB) < 0.02
&& fabs(myElectronsPFhelper->at(iele).dxywrtBeamSpot) < 0.02
&& fabs(myElectronsPF->at(iele).vz - myVertex->at(0).z ) <1
//add the other id stuff (based on medium point of: https://twiki.cern.ch/twiki/bin/view/CMS/EgammaCutBasedIdentification)
&& ((fabs(myElectronsPF->at(iele).superCluster_eta) < 1.479 //barrel ID
&& fabs(myElectronsPF->at(iele).deltaEtaSuperClusterTrackAtVtx)<0.004
&& fabs(myElectronsPF->at(iele).deltaPhiSuperClusterTrackAtVtx)<0.06
&& myElectronsPF->at(iele).hadronicOverEm<0.12
&& myElectronsPF->at(iele).sigmaIetaIeta<0.01
)
||
(fabs(myElectronsPF->at(iele).superCluster_eta) > 1.479 //endcap ID
&& fabs(myElectronsPF->at(iele).deltaEtaSuperClusterTrackAtVtx)<0.007
&& fabs(myElectronsPF->at(iele).deltaPhiSuperClusterTrackAtVtx)<0.03
&& myElectronsPF->at(iele).hadronicOverEm<0.10
&& myElectronsPF->at(iele).sigmaIetaIeta<0.03
)
)
&& ((myElectronsPF->at(iele).chargedHadronIso
+ myElectronsPF->at(iele).photonIso
+ myElectronsPF->at(iele).neutralHadronIso)/myElectronsPF->at(iele).pt <isothreshold)
) {
return true;
}
return false;
}
bool EventCalculator::isInAccRecoElectron(const unsigned int iele, const float ptthreshold) {
if (myElectronsRECO->at(iele).pt >= ptthreshold
&& fabs(myElectronsRECO->at(iele).superCluster_eta) < 2.5
&& !(fabs(myElectronsRECO->at(iele).superCluster_eta) > 1.4442
&& fabs(myElectronsRECO->at(iele).superCluster_eta) < 1.566)
){
return true;
}
return false;
}
bool EventCalculator::isIDRecoElectron(const unsigned int iele, const float ptthreshold) {
if (isInAccRecoElectron(iele,ptthreshold)
&& myElectronsRECO->at(iele).gsfTrack_trackerExpectedHitsInner_numberOfLostHits <= 1
//&& fabs(myElectronsRECO->at(iele).dB) < 0.02
&& fabs(myElectronsRECOhelper->at(iele).dxywrtBeamSpot) < 0.02
&& fabs(myElectronsRECO->at(iele).vz - myVertex->at(0).z ) <1
){
return true;
}
return false;
}
unsigned int EventCalculator::countEle(const float ptthreshold) {
unsigned int ngoodele=0;
for (unsigned int i=0; i <myElectronsPF->size() ; i++) {
if(isGoodElectron(i,false,ptthreshold)) ++ngoodele;
}
return ngoodele;
}
unsigned int EventCalculator::countMu(const float ptthreshold) {
unsigned int ngoodmu=0;
unsigned int nmu = myMuonsPF->size();
for ( unsigned int i = 0; i< nmu; i++) {
if (isCleanMuon(i,ptthreshold)) {
//once we reach here we've got a good muon in hand
++ngoodmu;
}
}
return ngoodmu;
}
bool EventCalculator::isZmumuCandidateEvent(const float ptthreshold, const float mllthreshold, float& m_ll) {
m_ll = -99;
//give me a list of all the indices of the good, high pt muons
std::vector<uint> goodmuons;
unsigned int nmu = myMuonsPF->size();
for ( unsigned int i = 0; i< nmu; i++) {
if (isCleanMuon(i,ptthreshold)) {
goodmuons.push_back( i );
}
}
//if there are at least two high pt leptons
if( goodmuons.size() >=2 ){
//loop through the lepton pairs, and check if they are
//opposite-signed and form an invariant mass within the Z-mass
for ( unsigned int i = 0; i< goodmuons.size(); i++) {
for ( unsigned int j = i+1; j< goodmuons.size(); j++) {
//check opposite charge
if(TMath::Nint(myMuonsPF->at( goodmuons.at(i) ).charge) != TMath::Nint(myMuonsPF->at( goodmuons.at(j) ).charge) ){
//check invariant mass
double z_en = myMuonsPF->at(goodmuons.at(i)).energy + myMuonsPF->at(goodmuons.at(j)).energy;
double z_px = myMuonsPF->at(goodmuons.at(i)).pt*cos( myMuonsPF->at(goodmuons.at(i)).phi) + myMuonsPF->at(goodmuons.at(j)).pt*cos( myMuonsPF->at(goodmuons.at(j)).phi);
double z_py = myMuonsPF->at(goodmuons.at(i)).pt*sin( myMuonsPF->at(goodmuons.at(i)).phi) + myMuonsPF->at(goodmuons.at(j)).pt*sin( myMuonsPF->at(goodmuons.at(j)).phi);
double z_pz = myMuonsPF->at(goodmuons.at(i)).pt*sinh(myMuonsPF->at(goodmuons.at(i)).eta) + myMuonsPF->at(goodmuons.at(j)).pt*sinh(myMuonsPF->at(goodmuons.at(j)).eta);
m_ll = sqrt(z_en*z_en - z_px*z_px - z_py*z_py - z_pz*z_pz);
if( fabs(m_ll - mZ_) < mllthreshold ){
//save these two candidates
ZmumuCand1_ = goodmuons.at(i); ZmumuCand2_ = goodmuons.at(j);
//std::cout << "found Zmumu candidate event, m_ll = " << m_ll << std::endl;
return true;
}
}
}// j loop
}//i loop
} //two high pt leptons
return false;
}
bool EventCalculator::isZeeCandidateEvent(const float ptthreshold, const float mllthreshold, float& m_ll) {
m_ll = -99;
//give me a list of all the good high pt muons
std::vector<uint> goodelectrons;
unsigned int nele = myElectronsPF->size();
for ( unsigned int i = 0; i< nele; i++) {
if (isGoodElectron(i,false,ptthreshold)) {
goodelectrons.push_back( i );
}
}
//if there are at least two high pt leptons
if( goodelectrons.size() >=2 ){
//loop through the lepton pairs, and check if they are
//opposite-signed and form an invariant mass within the Z-mass
for ( unsigned int i = 0; i< goodelectrons.size(); i++) {
for ( unsigned int j = i+1; j< goodelectrons.size(); j++) {
//check opposite charge
if(TMath::Nint(myElectronsPF->at(goodelectrons.at(i)).charge) != TMath::Nint(myElectronsPF->at(goodelectrons.at(j)).charge) ){
//check invariant mass
double z_en = myElectronsPF->at(goodelectrons.at(i)).energy + myElectronsPF->at(goodelectrons.at(j)).energy;
double z_px = myElectronsPF->at(goodelectrons.at(i)).pt*cos( myElectronsPF->at(goodelectrons.at(i)).phi) + myElectronsPF->at(goodelectrons.at(j)).pt*cos( myElectronsPF->at(goodelectrons.at(j)).phi);
double z_py = myElectronsPF->at(goodelectrons.at(i)).pt*sin( myElectronsPF->at(goodelectrons.at(i)).phi) + myElectronsPF->at(goodelectrons.at(j)).pt*sin( myElectronsPF->at(goodelectrons.at(j)).phi);
double z_pz = myElectronsPF->at(goodelectrons.at(i)).pt*sinh(myElectronsPF->at(goodelectrons.at(i)).eta) + myElectronsPF->at(goodelectrons.at(j)).pt*sinh(myElectronsPF->at(goodelectrons.at(j)).eta);
m_ll = sqrt(z_en*z_en - z_px*z_px - z_py*z_py - z_pz*z_pz);
if( fabs(m_ll - mZ_) < mllthreshold ){
//save these two candidates
ZeeCand1_ = goodelectrons.at(i); ZeeCand2_ = goodelectrons.at(j);
//std::cout << "found Zee candidate event, m_ll = " << m_ll << std::endl;
return true;
}
}
}// j loop
}//i loop
} //two high pt leptons
return false;
}
bool EventCalculator::isGoodTau(const unsigned int itau, const float pTthreshold, const float etaMax) {
if( getTauPt(itau) >= pTthreshold
&& fabs(myTausPF->at(itau).eta) < etaMax
&& myTausPF->at(itau).tauID_againstElectron > 0
&& myTausPF->at(itau).tauID_againstMuon > 0
&& myTausPF->at(itau).tauID_byTaNCfrHalfPercent > 0
){
return true;
}
return false;
}
float EventCalculator::getTauPt( unsigned int itau) {
float pt = myTausPF->at(itau).pt;
return pt;
}
unsigned int EventCalculator::countTau() {
unsigned int ngoodtau=0;
for (unsigned int i=0; i <myTausPF->size() ; i++) {
if(isGoodTau(i)) ++ngoodtau;
}
return ngoodtau;
}
bool EventCalculator::passHLT() {
//RA2b - 2011 Triggers
bool passTrig = false;
if ( isSampleRealData() ) {
ULong64_t runnumber = getRunNumber();
//edmtriggerresults is a double - possible values are 0 (failed trigger), 1 (passed trigger), -9999 (trig result not available)
/* using BTagIP triggers
if(runnumber >= 160431 && runnumber < 161205) passTrig = (edmtriggerresults_HLT_HT260_MHT60_v2 > 0);
else if (runnumber >= 161205 && runnumber < 163269) passTrig = (edmtriggerresults_HLT_HT250_MHT60_v2 > 0);
else if (runnumber >= 163269 && runnumber < 164924) passTrig = (edmtriggerresults_HLT_HT250_MHT60_v3 > 0);
else if (runnumber >= 164924 && runnumber < 165922) passTrig = edmtriggerresults_HLT_HT300_CentralJet30_BTagIP_PFMHT55_v2;
else if (runnumber >= 165922 && runnumber < 166301) passTrig = edmtriggerresults_HLT_HT300_CentralJet30_BTagIP_PFMHT55_v3;
//else if (runnumber >= 166301 && runnumber < 166374 ) passTrig = edmtriggerresults_HLT_HT300_CentralJet30_BTagIP_PFMHT55_v4;
else if (runnumber >= 166374 && runnumber < 167078) passTrig = edmtriggerresults_HLT_HT300_CentralJet30_BTagIP_PFMHT55_v3;
//else if (runnumber >= 167078) passTrig = edmtriggerresults_HLT_HT300_CentralJet30_BTagIP_PFMHT55_v5;
*/
//jmt -- 6 July 2011 -- use agreed RA2b triggers for Summer 2011
if (runnumber >= 160431 && runnumber <= 161204) passTrig = (triggerresultshelper_HLT_HT260_MHT60_v2 > 0);
else if (runnumber >= 161205 && runnumber <= 163268) passTrig = (triggerresultshelper_HLT_HT250_MHT60_v2 > 0);
else if (runnumber >= 163269 && runnumber <= 164923) passTrig = (triggerresultshelper_HLT_HT250_MHT60_v3 > 0);
else if (runnumber >= 164924 && runnumber <= 165921) passTrig = (triggerresultshelper_HLT_HT250_MHT70_v1 > 0);
else if (runnumber >= 165922 && runnumber <= 166300) passTrig = (triggerresultshelper_HLT_HT300_MHT75_v7 > 0);
else if (runnumber >= 166301 && runnumber <= 166373) passTrig = (triggerresultshelper_HLT_HT300_MHT75_v8 > 0);
else if (runnumber >= 166374 && runnumber <= 166978) passTrig = (triggerresultshelper_HLT_HT300_MHT75_v7 > 0);
else if (runnumber >= 166979 && runnumber <= 170064) passTrig = (triggerresultshelper_HLT_HT300_MHT80_v1 > 0);
//end of summer 11 result data
else if (runnumber >= 170065 && runnumber <= 173211) passTrig = (triggerresultshelper_HLT_HT300_MHT80_v2 > 0);
else if (runnumber >= 173212 && runnumber <= 176544) passTrig = (triggerresultshelper_HLT_HT300_MHT90_v2 > 0);
else if (runnumber >= 176545 && runnumber <= 178410) passTrig = (triggerresultshelper_HLT_HT350_MHT90_v1 > 0);
else if (runnumber >= 178411) passTrig = (triggerresultshelper_HLT_HT350_MHT110_v3 > 0);
else {cout<<"No trigger assigned for run = "<<runnumber<<endl; assert(0);}
}
else passTrig = true; //use no trigger for MC
return passTrig;
}
bool EventCalculator::passUtilityHLT(int &version, int &prescale) {
if( !isSampleRealData()) return true;
bool passTrig = false;
ULong64_t runnumber = getRunNumber();
if (runnumber >= 160431 && runnumber <= 161204) {
passTrig = (triggerresultshelper_HLT_HT300_v2 > 0);
version = 2;
prescale = triggerresultshelper_HLT_HT300_v2_prs;
}
else if (runnumber >= 161205 && runnumber <= 163268){
passTrig = (triggerresultshelper_HLT_HT300_v3 > 0);
version = 3;
prescale = triggerresultshelper_HLT_HT300_v3_prs;
}
else if (runnumber >= 163269 && runnumber <= 164923){
passTrig = (triggerresultshelper_HLT_HT300_v4 > 0);
version = 4;
prescale = triggerresultshelper_HLT_HT300_v4_prs;
}
else if (runnumber >= 164924 && runnumber <= 165921){
passTrig = (triggerresultshelper_HLT_HT300_v5 > 0);
version = 5;
prescale = triggerresultshelper_HLT_HT300_v5_prs;
}
else if (runnumber >= 165922 && runnumber <= 166300){
passTrig = (triggerresultshelper_HLT_HT300_v6 > 0);
version = 6;
prescale = triggerresultshelper_HLT_HT300_v6_prs;
}
else if (runnumber >= 166301 && runnumber <= 166373){
passTrig = (triggerresultshelper_HLT_HT300_v7 > 0);
version = 7;
prescale = triggerresultshelper_HLT_HT300_v7_prs;
}
else if (runnumber >= 166374 && runnumber <= 166978){
passTrig = (triggerresultshelper_HLT_HT300_v6 > 0);
version = 6;
prescale = triggerresultshelper_HLT_HT300_v6_prs;
}
else if (runnumber >= 166979 && runnumber <= 167077){
passTrig = (triggerresultshelper_HLT_HT300_v6 > 0);
version = 6;
prescale = triggerresultshelper_HLT_HT300_v6_prs;
}
else if (runnumber >= 167078 && runnumber <= 170064){
passTrig = (triggerresultshelper_HLT_HT300_v8 > 0);
version = 8;
prescale = triggerresultshelper_HLT_HT300_v8_prs;
}
//end of summer 11 result data
else if (runnumber >= 170065 && runnumber <= 173211){
passTrig = (triggerresultshelper_HLT_HT300_v9 > 0);
version = 9;
prescale = triggerresultshelper_HLT_HT300_v9_prs;
}
else if (runnumber >= 173212 && runnumber <= 176544){
passTrig = (triggerresultshelper_HLT_HT300_v9 > 0);
version = 9;
prescale = triggerresultshelper_HLT_HT300_v9_prs;
}
else if (runnumber >= 176545 && runnumber <= 178410){
passTrig = (triggerresultshelper_HLT_HT350_v8 > 0);
version = 108;
prescale = triggerresultshelper_HLT_HT350_v8_prs;
}
else if (runnumber >= 178411){
passTrig = (triggerresultshelper_HLT_HT350_v11 > 0);
version = 111;
prescale = triggerresultshelper_HLT_HT350_v11_prs;
}
return passTrig;
}
bool EventCalculator::passUtilityPrescaleModuleHLT() {
if( !isSampleRealData()) return true;
bool passTrig = false;
ULong64_t runnumber = getRunNumber();
if (runnumber >= 173212 && runnumber <= 176544){
passTrig = (triggerresultshelper1_passprescaleHT300Filter > 0);
}
else if (runnumber >= 176545 && runnumber <= 178410){
passTrig = (triggerresultshelper1_passprescaleHT350Filter > 0);
}
else if (runnumber >= 178411){
passTrig = (triggerresultshelper1_passprescaleHT350Filter > 0);
}
return passTrig;
}
bool EventCalculator::passZmumuHLT() {
bool passTrig = false;
if ( isSampleRealData() ) {
ULong64_t runnumber = getRunNumber();
if (runnumber >= 160431 && runnumber <= 163268) passTrig = (triggerresultshelper_HLT_DoubleMu7_v1 > 0);
else if (runnumber >= 163269 && runnumber <= 164923) passTrig = (triggerresultshelper_HLT_DoubleMu7_v2 > 0);
else if (runnumber >= 164924 && runnumber <= 166300) passTrig = (triggerresultshelper_HLT_Mu13_Mu8_v2 > 0);
else if (runnumber >= 166301 && runnumber <= 166373) passTrig = (triggerresultshelper_HLT_Mu13_Mu8_v3 > 0);
else if (runnumber >= 166374 && runnumber <= 167077) passTrig = (triggerresultshelper_HLT_Mu13_Mu8_v2 > 0);
else if (runnumber >= 167078 && runnumber <= 170064) passTrig = (triggerresultshelper_HLT_Mu13_Mu8_v4 > 0);
//end of summer 11 result data
else if (runnumber >= 170065 && runnumber <= 173211) passTrig = (triggerresultshelper_HLT_Mu13_Mu8_v6 > 0);
else if (runnumber >= 173212 && runnumber <= 178410) passTrig = (triggerresultshelper_HLT_Mu13_Mu8_v7 > 0);
else if (runnumber >= 178411 && runnumber <= 179941) passTrig = (triggerresultshelper_HLT_Mu17_Mu8_v10 > 0);
else if (runnumber >= 179942) passTrig = (triggerresultshelper_HLT_Mu17_Mu8_v11 > 0);
else {cout<<"No trigger assigned for run = "<<runnumber<<endl; assert(0);}
}
else passTrig = true; //use no trigger for MC
return passTrig;
}
bool EventCalculator::passZeeHLT() {
bool passTrig = false;
if ( isSampleRealData() ) {
ULong64_t runnumber = getRunNumber();
if (runnumber >= 160431 && runnumber <= 161204) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v1 > 0);
else if (runnumber >= 161205 && runnumber <= 163268) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v2 > 0);
else if (runnumber >= 163269 && runnumber <= 164923) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_Ele8_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_v3 > 0);
else if (runnumber >= 164924 && runnumber <= 165921) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_Ele8_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_v4 > 0);
else if (runnumber >= 165922 && runnumber <= 166978) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_Ele8_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_v5 > 0);
else if (runnumber >= 166979 && runnumber <= 170064) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v5 > 0);
//end of summer 11 result data
else if (runnumber >= 170065 && runnumber <= 170825) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v6 > 0);
else if (runnumber >= 170826 && runnumber <= 173211) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v7 > 0);
else if (runnumber >= 173212 && runnumber <= 178410) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v8 > 0);
else if (runnumber >= 178411 && runnumber <= 179941) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v9 > 0);
else if (runnumber >= 179942) passTrig = (triggerresultshelper_HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v10 > 0);
else {cout<<"No trigger assigned for run = "<<runnumber<<endl; assert(0);}
}
else passTrig = true; //use no trigger for MC
return passTrig;
}
unsigned int EventCalculator::utilityHLT_HT300_CentralJet30_BTagIP(){
if( !isSampleRealData()) return 999; //return a *large* dummy value for MC, so that we can use cuts like >=1
unsigned int passTrig = 0;
if(triggerresultshelper_HLT_HT300_CentralJet30_BTagIP_v2>0) passTrig = 2;
if(triggerresultshelper_HLT_HT300_CentralJet30_BTagIP_v3>0) passTrig = 3;
if(triggerresultshelper_HLT_HT300_CentralJet30_BTagIP_v4>0) passTrig = 4;
if(triggerresultshelper_HLT_HT300_CentralJet30_BTagIP_v5>0) passTrig = 5;
return passTrig;
}
void EventCalculator::loadHLTMHTeff() {
if (f_eff_mht_==0) {
//there are four curves
//not sure what the best way to combine them are
f_eff_mht_ = new TFile("mht_eff_uptojul6.root","READ");
//mhtgraph = (TGraphAsymmErrors *) f_eff_mht->Get("eff_MHT60");
//mhtgraph = (TGraphAsymmErrors *) f_eff_mht->Get("eff_MHT70");
//mhtgraph = (TGraphAsymmErrors *) f_eff_mht->Get("eff_MHT75");
mhtgraph_ = (TGraphAsymmErrors *) f_eff_mht_->Get("eff_MHT80");
//fill the graphs with plus and minus variations
mhtgraphPlus_ = new TGraphAsymmErrors(mhtgraph_->GetN());
mhtgraphMinus_ = new TGraphAsymmErrors(mhtgraph_->GetN());
for (int i=0; i<mhtgraph_->GetN(); i++) {
double x,y;
mhtgraph_->GetPoint(i,x,y);
double exl= mhtgraph_->GetErrorXlow(i);
double exh= mhtgraph_->GetErrorXhigh(i);
double eyl= mhtgraph_->GetErrorYlow(i);
double eyh= mhtgraph_->GetErrorYhigh(i);
//shift y
double yup = y+eyh > 1? 1: y+eyh;
double ydown = y-eyl < 0 ? 0: y-eyl;
mhtgraphPlus_->SetPoint(i,x,yup);
mhtgraphMinus_->SetPoint(i,x,ydown);
mhtgraphPlus_->SetPointError(i,exl,exh,eyl,eyh); //the errors don't matter
mhtgraphMinus_->SetPointError(i,exl,exh,eyl,eyh);
}
}
}
float EventCalculator::getHLTMHTeff(float offMET, float offHT, uint nElectrons, uint nMuons, double mindphin) {
float eff=1;
bool isSingleE = (nElectrons==1 && nMuons==0);
bool isSingleMu = (nElectrons==0 && nMuons==1);
bool is0L = (nElectrons==0 && nMuons==0);
//TGraphAsymmErrors * gr=mhtgraph_;
//if ( theHLTEffType_ ==kHLTEffup) gr=htgraphPlus;
//else if ( theHLTEffType_ ==kHLTEffdown) gr=htgraphMinus;
//for prelim summer result
//eff = gr->Eval(offMET);
//for 2011 full result
//updated with pixelLumiCalc numbers
if(offHT>400 && offMET>=150 && offMET<250){