-
Notifications
You must be signed in to change notification settings - Fork 0
/
SusyAna_MC_phoEff.cc
1171 lines (963 loc) · 46.8 KB
/
SusyAna_MC_phoEff.cc
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
// -*- C++ -*-
//
// Package: SusyNtuplizer
// Class: SusyAna_MC_phoEff.cc
//
/*
Description: an analyzer for susy::Event
Implementation:
*/
//
// Original Author: Dongwook Jang
// $Id: SusyAna_MC_phoEff.cc,v 1.12 2012/05/03 19:58:51 dwjang Exp $
//
#define SusyAna_MC_phoEff_cxx
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TH1F.h>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <utility>
#include "SusyAna_MC_phoEff.h"
#include "SusyEventPrinter.h"
#include "../jec/JetMETObjects/interface/JetCorrectorParameters.h"
#include "../jec/JetMETObjects/interface/FactorizedJetCorrector.h"
//my additions
#include "TAxis.h"
#include "TMath.h"
#include <TH3.h>
#include "TFile.h"
#include "TTree.h"
#include "TLegend.h"
#include "TLorentzVector.h"
#include "TGraphErrors.h"
#include "TF1.h"
#include <iostream>
#include <fstream>
//user defiend
#include "utilities.h"
#include "cuts.h"
#include "params_arg.h"
#include "GetError.h"
#include "hggx_analysers.h"
#include "quicksave.C"
#include "CMSStyle.C"
#include "TVector3.h"
#include "TLorentzVector.h"
#include "MCpoint.h"
using namespace std;
using namespace params;
template<typename T> bool EtGreater(const T* p1, const T* p2) {
return (p1->momentum.Et() > p2->momentum.Et());
}
template<typename T> bool EtGreaterpho(const T* p1, const T* p2) {
if(useMVAphoP) return (p1->MVAcorrMomentum.Et() > p2->MVAcorrMomentum.Et());
else return (p1->momentum.Et() > p2->momentum.Et());
}
void SusyAna_MC_phoEff::InitializePerEvent() {
}
bool SusyAna_MC_phoEff::isSameObject(TLorentzVector& p1, TLorentzVector& p2) {
float dEta = p1.Eta() - p2.Eta();
float dPhi = TVector2::Phi_mpi_pi(p1.Phi() - p2.Phi());
return std::sqrt(dEta*dEta + dPhi*dPhi) < 0.5;
}//dR05 cut
float SusyAna_MC_phoEff::d0correction(TVector3& beamSpot, susy::Track& track) const {
return track.d0() - beamSpot.X()*std::sin(track.phi()) + beamSpot.Y()*std::cos(track.phi());
}
//float SusyAna_MC_phoEff::d0correction_(TVector3& beamSpot, susy::Track& track){
// float d0 = track.d0() - beamSpot.X()*std::sin(track.phi()) + beamSpot.Y()*std::cos(track.phi());
// return d0;
//}
bool SusyAna_MC_phoEff::PassTrigger(TString path) {
//Does not have to be an exact name. the trigger name must contain "path". So you can ignore the trigger version.
bool pass = false;
for(susy::TriggerMap::iterator it = event->hltMap.begin(); it != event->hltMap.end(); it++) {
if(it->first.Contains(path) && (int(it->second.second)) ) {
pass = true;
break;
}
}
return pass;
}
bool SusyAna_MC_phoEff::isfarFromPhotons(TLorentzVector& lep, std::vector<susy::Photon*> & photons){
bool isFar = true;
for(std::vector<susy::Photon*>::iterator it = photons.begin(); it != photons.end(); it++) {
//TLorentzVector ltmp = (*it)->momentum;
TLorentzVector ltmp = useMVAphoP?(*it)->MVAcorrMomentum:(*it)->momentum;
isFar &= ! SusyAna_MC_phoEff::isSameObject(lep,ltmp);
}
return isFar;
}
bool SusyAna_MC_phoEff::PassTriggers() {
bool pass = false;
for(std::vector<TString>::iterator it = hltNames.begin(); it != hltNames.end(); it++) {
if(PassTrigger(*it)) {
pass = true;
break;
}
}
return pass;
}
typedef std::map<string, int> nameint;
void addCounter(nameint & C, vector<string> & V, string label){
C[label]=0;
V.push_back(label);
}
void remove_duplicate_photons(std::vector<susy::Photon*> & photons,bool keep_hardest_matched_photon=true){
/*
This takes a pt-sorted vector of Photon*. It looks through all pairs of photons, for dR matches (dR<0.6 or dPhi < 0.05)
If it finds a match and keep_hardest_matched_photon, it keeps the hardest one and deletes the others from the vector.
If it finds a match and !keep_hardest_matched_photon, it deletes all photons involved int the match. David Morse and I do the former.
*/
if (photons.size()<2) return;
std::vector<susy::Photon*>::iterator i_p1 = photons.begin(); int I_p1 = 0;
int size = photons.size();
while(I_p1+1 < size){
bool match_found = false;
//cout<<"phoA. i="<<I_p1<<" "<<*i_p1<<endl;
TLorentzVector p1 = useMVAphoP?(*i_p1)->MVAcorrMomentum:(*i_p1)->momentum;
//TLorentzVector p1 = (*i_p1)->momentum;
std::vector<susy::Photon*>::iterator i_p2 = i_p1+1; int I_p2 = I_p1+1;
while(I_p2 < size){ //increments to the terminator, then does not terminate.
//while(i_p2 != photons.end()){ //increments to the terminator, then does not terminate.
//cout<<"phoB, i= "<<I_p2<<" "<<*i_p2<<endl;
//TLorentzVector p2 = (*i_p2)->momentum;
TLorentzVector p2 = useMVAphoP?(*i_p2)->MVAcorrMomentum:(*i_p2)->momentum;
//cout<<"rem4"<<endl;
if (dR(p1,p2)<0.6 || dPhi(p1,p2) < 0.05 ) {
std::vector<susy::Photon*>::iterator temp = i_p2+1;
i_p2 = photons.erase(i_p2);//this is supposed to return the next element but does not.
//cout<<"found match phoB new address: "<<*i_p2<<endl;
i_p2 = temp;
//cout<<"after =temp, address: "<<*i_p2<<endl;
size--;
match_found = true;
if(I_p2 == (int)photons.size()-1) break;
}
else{ i_p2++; I_p2++;}
}//end while2
if (match_found && !keep_hardest_matched_photon) {
i_p1 = photons.erase(i_p1);
}
else {i_p1++; I_p1++;}
}//end while
}//end remove_duplicate_photons
void PrintPhotonTriggers(susy::Event* event){
for(susy::TriggerMap::iterator it = event->hltMap.begin(); it != event->hltMap.end(); it++) {
if (it->first.Contains("Photon")) {
std::cout << "\t" << it->first << "(prescale=" << it->second.first << ", fire=" << int(it->second.second) << ")" << std::endl;
}
}
}
void SusyAna_MC_phoEff::Loop() {
cout<<"hello world"<<endl;
printLevel = 0;
if (fChain == 0) return;
//probe p = probe();
//p.p("probe");
Long64_t nentries = fChain->GetEntries();
std::cout << "k " << nentries << std::endl;
if(processNEvents <= 0 || processNEvents > nentries) processNEvents = nentries;
std::cout << "total events in files : " << nentries << std::endl;
std::cout << "events to be processed : " << processNEvents << std::endl;
//Initialize Counters
if(printLevel > 0) std::cout << "Initialize event counters." << std::endl;
vector <string> Counter_order;
nameint Counters;
addCounter(Counters,Counter_order,"no cuts");
addCounter(Counters,Counter_order,"pass Json");
addCounter(Counters,Counter_order,"pass duplicate check");
addCounter(Counters,Counter_order,"pass HLT");
addCounter(Counters,Counter_order,"pass MET Filter");
addCounter(Counters,Counter_order,"pass two loose photons");
addCounter(Counters,Counter_order,"pass 2 loose pho over thresh");
addCounter(Counters,Counter_order,"pass phoM 100 cuts");
addCounter(Counters,Counter_order,"have 2 tight photons");
//addCounter(Counters,Counter_order,"have 2 tight photons passing dR cuts");
addCounter(Counters,Counter_order,"pass a primary vertex reqirement");
addCounter(Counters,Counter_order,"has met map");
addCounter(Counters,Counter_order,"number filtered");
//no extra cuts.
// int nFiltered = 0;
// TTree* filterTree = 0;
// cout << "enableFilter is set to "<<enableFilter<<endl;
// if (enableFilter){
// enableFilter = false;
// cout << "setting it to false"<<endl;
// }
// if(enableFilter) {
// cout << "Making Filter File"<<endl;
MCpoint* thisMCpoint = setupMCpoint(which_MC_to_use2);
TFile* b_tag_eff_file = new TFile(thisMCpoint->btageff_file.c_str(),"RECREATE");
//float ptmin[] = {20, 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500, 600, 800};
//float ptmax[] = {30, 40, 50, 60, 70, 80,100, 120, 160, 210, 260, 320, 400, 500, 600, 800};
TH1F* nPhoGen_Pt = new TH1f("nPhoGen_Pt","nPhoGen_Pt",4, 0.f, 144);
int nPhoGen = 0;
TH1F* nPhoPV_Pt = new TH1f("nPhoPV_Pt","nPhoPV_Pt",4, 0.f, 144);
int nPhoPV_obs = 0;
TH1F* nPhoEV_Pt = new TH1f("nPhoEV_Pt","nPhoEV_Pt",4, 0.f, 144);
int nPhoEV_obs = 0;
TH1F* nEle_Pt = new TH1f("nEle_Pt","nEle_Pt",4, 0.f, 144);
int nEle_obs = 0;
/*
TH1F* bjetEffDen = new TH1F("bjetEffDen","denominator",nbins,ptmin);
TH1F* bjetEff_CSVLNum = new TH1F("bjetEff_CSVLNum","CSVL Numerator;Pt",nbins,ptmin);
TH1F* bjetEff_CSVMNum = new TH1F("bjetEff_CSVMNum","CSVM Numerator;Pt",nbins,ptmin);
TH1F* bjetEff_CSVTNum = new TH1F("bjetEff_CSVTNum","CSVT Numerator;Pt",nbins,ptmin);
TH1F* nbjets_dist = new TH1F("nbjets","Number of B-jets;n b-jets",8,0,8);
TH1F* bjetEff_CSVL = new TH1F("bjetEff_CSVL","CSVL Efficiency;Pt;Efficiency",nbins,ptmin);
TH1F* bjetEff_CSVM = new TH1F("bjetEff_CSVM","CSVM Efficiency;Pt;Efficiency",nbins,ptmin);
TH1F* bjetEff_CSVT = new TH1F("bjetEff_CSVT","CSVT Efficiency;Pt;Efficiency",nbins,ptmin);
TH1F* bMistagDen = new TH1F("bMistagDen","denominator",nbins,ptmin);
TH1F* bMistag_CSVLNum = new TH1F("bMistag_CSVLNum","CSVL Numerator;Pt",nbins,ptmin);
TH1F* bMistag_CSVMNum = new TH1F("bMistag_CSVMNum","CSVM Numerator;Pt",nbins,ptmin);
TH1F* bMistag_CSVTNum = new TH1F("bMistag_CSVTNum","CSVT Numerator;Pt",nbins,ptmin);
TH1F* nMistagsL_dist = new TH1F("nMistagsL","Number of CSVL mistags per event;n jets",8,0,8);
TH1F* nMistagsM_dist = new TH1F("nMistagsM","Number of CSVM mistags per event;n jets",8,0,8);
TH1F* nMistagsT_dist = new TH1F("nMistagsT","Number of CSVT mistags per event;n jets",8,0,8);
TH1F* bMistag_CSVL = new TH1F("bMistag_CSVL","CSVL Mistag Rate;Pt;Efficiency",nbins,ptmin);
TH1F* bMistag_CSVM = new TH1F("bMistag_CSVM ","CSVM Mistag Rate;Pt;Efficiency",nbins,ptmin);
TH1F* bMistag_CSVT = new TH1F("bMistag_CSVT ","CSVT Mistag Rate;Pt;Efficiency",nbins,ptmin);
*/
//ofstream eventlist;
//eventlist.open ("beff_eventlist.txt");//everything passing the ntuplizer.
//ofstream eventlist2;
//eventlist2.open ("ntuplized_passingTrip_eventlist.txt");//passing the ntuplizer and also passing the cuts in this context.
//plots of things I cut on.
cout<<"start on trigger"<<endl;
const int Nnonr9Triggers = 9;
const int Nr9Triggers = 4;
//const int NT = Nnonr9Triggers+Nr9Triggers;
//bool passHLTs[NT];
/*TString dmason_triggers[4] = { //not using these.
"HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50",
"HLT_Photon36_CaloId10_Iso50_Photon22_R9Id85",
"HLT_Photon36_R9Id85_Photon22_CaloId10_Iso50",
"HLT_Photon36_R9Id85_Photon22_R9Id85"};*/
TString R9triggers[Nr9Triggers] = {
"HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50", //dmason
"HLT_Photon36_CaloIdL_Photon22_CaloIdL",
"HLT_Photon32_CaloIdL_Photon26_CaloIdL",
"HLT_Photon26_CaloId10_Iso50_Photon18_CaloId10_Iso50_Mass60"};
TString nonR9triggers[Nnonr9Triggers] = {
"HLT_Photon36_R9Id85_Photon22_R9Id85", //dmason
"HLT_Photon36_R9Id85_Photon22_CaloId10_Iso50", //dmason
"HLT_Photon36_CaloId10_Iso50_Photon22_R9Id85", //dmason
"HLT_Photon26_R9Id85_OR_CaloId10_Iso50_Photon18_R9Id85_OR_CaloId10_Iso50_Mass60",
"HLT_Photon26_R9Id85_OR_CaloId10_Iso50_Photon18_R9Id85_OR_CaloId10_Iso50_Mass70",
"HLT_Photon26_R9Id85_Photon18_R9Id85_Mass60",
"HLT_Photon26_R9Id85_Photon18_CaloId10_Iso50_Mass60",
"HLT_Photon26_CaloId10_Iso50_Photon18_R9Id85_Mass60",
"HLT_Photon36_R9Id85_OR_CaloId10_Iso50_Photon22_R9Id85_OR_CaloId10_Iso50"};
//if(!useTrigger){
//useTrigger = true;
//cout<< endl<<"By some black magic, useTrigger is false, setting it to true"<<endl;
//}
if (!useTrigger) cout << endl << endl << "WARNING!! NOT USING THE TRIGGER!!!"<<endl<<endl<<endl;
else cout << endl << "TRIGGER ON"<<endl<<endl;
if (!useJSON) cout << endl << endl << "WARNING!! NOT USING THE JSON FILE!!!"<<endl<<endl<<endl;
else cout << endl << "USING JSON"<<endl<<endl;
// to check duplicated events
std::map<int, std::set<int> > allEvents;
// start event looping
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry < processNEvents; jentry++) {
//for (Long64_t jentry=0; jentry < 500; jentry++) { //master loop
if(jentry > 10001) break;//limit this to the first 10k entries.
if(printLevel > 0) std::cout << "Get the tree contents." << std::endl;
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
Counters["no cuts"]++;
nb = fChain->GetEntry(jentry); nbytes += nb;
if(printLevel > -1 && (printInterval > 0 && (jentry >= printInterval && jentry%printInterval == 0)) ) {
std::cout << int(jentry) << " events processed with run="
<< event->runNumber << ", event=" << event->eventNumber << std::endl;
//every 100 print intervals, print the trigger list. It should always on the first event.
//if (jentry%(printInterval*100) == 0) PrintPhotonTriggers(event);
}//end if millionth event.
if(printLevel > 0) std::cout << "Initialize any global variables to be reset per event." << std::endl;
InitializePerEvent();
if(event->runNumber<0){
if(printLevel > 0) std::cout << "Warning: run number less than zero" << std::endl;
continue;
}
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"probe is at point A"<<endl;
if(printLevel > 0) std::cout << "Apply good run list." << std::endl;
if(event->isRealData && useJSON && !isInJson(event->runNumber,event->luminosityBlockNumber)) continue;
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"probe passes JSON"<<endl;
Counters["pass Json"]++; // total number of events that pass Json
//Print(*event); // uncomment this to print all ntuple variables
if(printLevel > 1) cout << "Check duplicated events for data only." << endl;
if(event->isRealData){
bool duplicateEvent = ! (allEvents[event->runNumber].insert(event->eventNumber)).second;
if(duplicateEvent){
cout<<"Duplicate Event! Run "<<event->runNumber<<" Event "<<event->eventNumber<<endl;
continue;
}
}
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"probe passes Duplicate Filter"<<endl;
Counters["pass duplicate check"]++;
// if(printLevel > 0) Print(*event); // uncomment this to print all ntuple variables
if(printLevel > 0) std::cout << "Apply trigger selection in the event." << std::endl;
bool pass_non_r9id_trigger = false;
bool pass_r9id_trigger = false;
bool passHLT = false;
for (int i=0; i<Nnonr9Triggers; i++) {
pass_non_r9id_trigger |= PassTrigger(nonR9triggers[i]);
}
for (int i=0; i<Nr9Triggers; i++) {
pass_r9id_trigger |= PassTrigger(R9triggers[i]);
}
passHLT = pass_r9id_trigger || pass_non_r9id_trigger;
if(event->isRealData && useTrigger && !passHLT) continue;
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"probe passes HLT"<<endl;
Counters["pass HLT"]++;
//Print(event->hltMap);cout << endl << endl;
if(useMETFilter_data && event->isRealData && !event->passMetFilters()) continue; //don't use the met filter for MC, nothing passes.
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"probe passes MetFilter"<<endl;
Counters["pass MET Filter"]++;
if(printLevel > 0) std::cout << "Setup object vectors." << std::endl;
//float myST = 0.0;
//float myPhotonST = 0.0;
//float myLeptonST = 0.0;
std::vector<susy::Photon*> loose_photons; // loose objects have all standard cuts except for isolation
//std::vector<susy::Photon*> tight_susy11_photons; // tight objects hava isolation cuts applied on top of loose objects
//std::vector<susy::Photon*> tight_susy11Star_photons; // tight objects hava isolation cuts applied on top of loose objects
//std::vector<susy::Photon*> medium_susy12_photons; // tight objects hava isolation cuts applied on top of loose objects
std::vector<susy::Photon*> loose_susy12_photons; // tight objects hava isolation cuts applied on top of loose objects
//std::vector<susy::Photon*> tight_VG11_photons;
//std::vector<susy::Photon*>* p_photonVector;
//std::vector<susy::Photon*>* p_photonVector = &tight_susy11_photons;
//use as (*p_photonVector)
std::vector<susy::PFJet*> pfJets;
std::vector<susy::PFJet*> pfBJets;
std::vector<susy::PFJet*> pfBJetsLoose;
std::vector<susy::PFJet*> pfBJetsMedium;
std::vector<susy::PFJet*> pfBJetsTight;
std::vector<susy::Photon*> loose_susy12_photons;
std::vector<susy::Photon*> loose_susy12_photons_pixelSeedVeto;
std::vector<susy::Photon*> loose_susy12_photons_pixelSeedReq;
std::vector<susy::Vertex*> good_vtx;
std::vector<susy::Muon*> ra3_muons;
std::vector<susy::Muon*> Muons;//DM's collection
std::vector<susy::PFJet*> ra3_pfjets;
std::vector<susy::Electron*> pfEles;
/////////////////////////////////////////////////////////////////
//////////////////////////// PHOTONS ////////////////////////////
/////////////////////////////////////////////////////////////////
if(printLevel > 0) std::cout << "Find loose and tight photons in the event." << std::endl;
std::map<TString, std::vector<susy::Photon> >::iterator phoMap = event->photons.find("photons");
if(phoMap != event->photons.end()) {
int j = 0;
for(std::vector<susy::Photon>::iterator it = phoMap->second.begin();
it != phoMap->second.end(); it++) {
/*bool looseCut = is_vloose_pho(
useMVAphoP?it-> MVAcorrMomentum.Et():it->momentum.Et(),//it->momentum.Et(),
it->caloPosition.Eta(),
it->trkSumPtHollowConeDR03,
it->ecalRecHitSumEtConeDR03,
it->hcalTowerSumEtConeDR03(),
it->hadronicOverEm,
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->r9,
it->nPixelSeeds,
event->rho25);
bool is_tightSusy_photons = is_tight_combIso_BFrancis(
useMVAphoP?it-> MVAcorrMomentum.Et():it->momentum.Et(),//it->momentum.Et(),
it->caloPosition.Eta(),
it->trkSumPtHollowConeDR03,
it->ecalRecHitSumEtConeDR03,
it->hcalTowerSumEtConeDR03(),
it->hadronicOverEm,
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->r9,
it->nPixelSeeds,
event->rho25);
bool is_tightStar_photons = is_tight_susyStar(
useMVAphoP?it-> MVAcorrMomentum.Et():it->momentum.Et(),//it->momentum.Et(),
it->caloPosition.Eta(),
it->trkSumPtHollowConeDR03,
it->ecalRecHitSumEtConeDR03,
it->hcalTowerSumEtConeDR03(),
it->hadronicOverEm,
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->r9,
it->nPixelSeeds,
event->rho25);
bool ismedium2012Cut = is_medium_2012(
useMVAphoP?it-> MVAcorrMomentum.Et():it->momentum.Et(),//it->momentum.Et(),
it->caloPosition.Eta(),
it->chargedHadronIso,
it->neutralHadronIso,
it->photonIso,
it->hadTowOverEm, //single tower, same cut though
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->passelectronveto, //replaces pixel seed veto
event->rho25);*/
bool isloose2012Cut = is_loose_2012(
//useMVAphoP?it-> MVAcorrMomentum.Et():it->momentum.Et(),//it->momentum.Et(),
((useMVAphoP?MVAcor:1.0)*it->momentum).Et(),
it->caloPosition.Eta(),
it->chargedHadronIso,
it->neutralHadronIso,
it->photonIso,
it->hadTowOverEm, //single tower, same cut though
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->passelectronveto, //replaces pixel seed veto
event->rho25);
bool isloose2012_pixelSeedVeto = is_loose_2012_PixelSeedVeto(
((useMVAphoP?MVAcor:1.0)*it->momentum).Et(),
it->caloPosition.Eta(),
it->chargedHadronIso,
it->neutralHadronIso,
it->photonIso,
it->hadTowOverEm, //single tower, same cut though
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->nPixelSeeds,
event->rho25);
bool isloose2012_pixelSeedReq = is_loose_2012_PixelSeedReq(
((useMVAphoP?MVAcor:1.0)*it->momentum).Et(),
it->caloPosition.Eta(),
it->chargedHadronIso,
it->neutralHadronIso,
it->photonIso,
it->hadTowOverEm, //single tower, same cut though
it->sigmaIetaIeta,
it->sigmaIphiIphi,
it->nPixelSeeds,
event->rho25);
//it's failing the ele veto 100% of the time.
//p.p(Form("I'm in the photon for loop and the bool is %i",isloose2012Cut));//ok, there are frequently two photons.
//printf("Et %f Eta %f ChadIso %f nHadIso %f phoIso %f\n",it->momentum.Et(),it->caloPosition.Eta(),it->chargedHadronIso,it->neutralHadronIso,it->photonIso);
//printf("he %f sieie %f sipip %f pass eleveto %i rho %f\n",it->hadTowOverEm,it->sigmaIetaIeta,it->sigmaIphiIphi,it->passelectronveto,event->rho25);
//if(is_tightSusy_photons) { tight_susy11_photons.push_back(&*it); }
//if(is_tightStar_photons){ tight_susy11Star_photons.push_back(&*it); }
//if(is_tightEg11_photons) { tightEg11_photons.push_back(&*it); }
//if(ismedium2012Cut){ medium_susy12_photons.push_back(&*it); }
//if(looseCut) { loose_photons.push_back(&*it); }
if(isloose2012Cut){
loose_susy12_photons.push_back(&*it);
}
if(isloose2012_pixelSeedVeto){
loose_susy12_photons_pixelSeedVeto.push_back(&*it);
}
if(isloose2012_pixelSeedReq){
loose_susy12_photons_pixelSeedReq.push_back(&*it);
}
j++;
}// for all photon
} //end if pho map
else {
continue; //else there are no photons
}
std::sort(loose_susy12_photons.begin(),loose_susy12_photons.end(),EtGreaterpho<susy::Photon>);
std::sort(loose_susy12_photons_pixelSeedVeto.begin(),loose_susy12_photons_pixelSeedVeto.end(),EtGreaterpho<susy::Photon>);
std::sort(loose_susy12_photons_pixelSeedReq.begin(),loose_susy12_photons_pixelSeedReq.end(),EtGreaterpho<susy::Photon>);
remove_duplicate_photons(loose_susy12_photons);
remove_duplicate_photons(loose_susy12_photons_pixelSeedVeto);
remove_duplicate_photons(loose_susy12_photons_pixelSeedReq);
if((int) loose_susy12_photons.size() >=2){
if ((useMVAphoP?loose_susy12_photons[0]->MVAcorrMomentum.Et():loose_susy12_photons[0]->momentum.Et()) > phoEtThresh0 &&
(useMVAphoP?loose_susy12_photons[1]->MVAcorrMomentum.Et():loose_susy12_photons[1]->momentum.Et()) > phoEtThresh1){
//fill Loose
}
} //end if LooseSusy12
if (((int)loose_susy12_photons.size())<2){ continue; }
Counters["pass two loose photons"]++;
if ((useMVAphoP?loose_susy12_photons[0]->MVAcorrMomentum.Et():loose_susy12_photons[0]->momentum.Et()) < phoEtThresh0 ||
(useMVAphoP?loose_susy12_photons[1]->MVAcorrMomentum.Et():loose_susy12_photons[1]->momentum.Et()) < phoEtThresh1){
continue;
}
Counters["pass 2 loose pho over thresh"]++;
std::sort(loose_susy12_photons.begin(),loose_susy12_photons.end(),EtGreaterpho<susy::Photon>);
remove_duplicate_photons(loose_susy12_photons);
TLorentzVector p0, p1;
p0 = useMVAphoP?loose_susy12_photons[0]->MVAcorrMomentum:loose_susy12_photons[0]->momentum;
p1 = useMVAphoP?loose_susy12_photons[1]->MVAcorrMomentum:loose_susy12_photons[1]->momentum;
/////////////////////////////////////////////////////////////////
//////////////////////// FIND THE PRIMARY VERTEX ////////////////
/////////////////////////////////////////////////////////////////
if(printLevel > 0) std::cout << "Find primary vertex in the event." << std::endl;
//TVector3* primVtx = 0;
//if(event->vertices.size() > 0) primVtx = &(event->vertices[0].position);
for(std::vector<susy::Vertex>::iterator it = event->vertices.begin(); it != event->vertices.end(); it++) {
if(ok_vtx(it)) good_vtx.push_back(&*it);
}
int nPVertex = good_vtx.size();
if(nPVertex<1){
if(printLevel > 1) cout<<"No Good Vertex!!!! Run: "<<event->runNumber<<" Event: "<<event->eventNumber<<endl;
continue;
}
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"pass Vertex"<<endl;
Counters["pass a primary vertex reqirement"]++;
/////////////////////////////////////////////////////////////////
//////////////////////// FIND MUONS ////////////////////////////
/////////////////////////////////////////////////////////////////
if(printLevel > 1) cout << "Find Muons in the event." << endl;
std::map<TString, std::vector<susy::Muon> >::iterator muMap = event->muons.find("muons");
if(muMap != event->muons.end()) {
for(std::vector<susy::Muon>::iterator it_Mu= muMap->second.begin(); it_Mu!= muMap->second.end(); it_Mu++) {
//////////////////////
/*if(printLevel > 1) cout << "Find Muons in the event." << endl;
for(std::vector<susy::Muon>::iterator it_Mu = event->muons.begin(); it_Mu != event->muons.end(); it_Mu++)
std::map<TString,UChar_t>::iterator idPair = it_Mu->idPairs.find("muidGlobalMuonPromptTight");
if(idPair == it_Mu->idPairs.end()) continue;
if(int(idPair->second) == 0) continue;
*/
if(printLevel > 1) cout<<"looping over muon collection"<<endl;
susy::Track& innerTrack = event->tracks[it_Mu->trackIndex];
if(ok_muon_DMoris(it_Mu,innerTrack) &&
isfarFromPhotons(it_Mu->momentum, loose_susy12_photons)
){
Muons.push_back(&*it_Mu);
//myLeptonST += (it_Mu)->momentum.Et();
}
}
}//end it_Mu muon loop
//sort Muons by Pt
std::sort(Muons.begin(), Muons.end(), EtGreater<susy::Muon>);
if(printLevel>1)cout<<"Muons size= "<<Muons.size()<<endl;
//Find Muons Yueh-Feng's way
/*
for(std::vector<susy::Muon>::iterator it = event->muons.begin();
it != event->muons.end(); it++) {
if(ok_muon(it)) ra3_muons.push_back(&*it);
}//muon
std::sort(ra3_muons.begin(),ra3_muons.end(),EtGreater<susy::Muon>);
*/
/////////////////////////////////////////////////////////////////
//////////////////////// FIND pfElectrons //////////////////////
/////////////////////////////////////////////////////////////////
std::map<TString, std::vector<susy::Electron> >::iterator eleMap = event->electrons.find("gsfElectrons");
if(eleMap != event->electrons.end()) {
//loop over electron collection
for(std::vector<susy::Electron>::iterator it_Ele = eleMap->second.begin(); it_Ele != eleMap->second.end(); it_Ele++) {
if(printLevel > 1) cout<<"looping over electron collection"<<endl;
//float relIso=(it_Ele->chargedHadronIso + it_Ele->neutralHadronIso + it_Ele->photonIso)/it_Ele->momentum.Pt();
if(ok_ele(it_Ele) &&
isfarFromPhotons(it_Ele->momentum, loose_susy12_photons)){
pfEles.push_back(&*it_Ele);
//myLeptonST += (it_Ele)->momentum.Et();
}
}//end it_Ele electron loop
std::sort(pfEles.begin(), pfEles.end(), EtGreater<susy::Electron>); //sort pfEles by Pt
if(printLevel>1)cout<<"pfEles size= "<<pfEles.size()<<endl;
}//end eleMap
//import
float HT_all = 0;
//float MHT_all = 0;
float MHT_x_all =0;
float MHT_y_all =0;
if(printLevel > 0) std::cout << "Find pfJets in the event." << std::endl;
std::map<TString,susy::PFJetCollection>::iterator pfJets_it = event->pfJets.find("ak5");
if(pfJets_it != event->pfJets.end()){
susy::PFJetCollection& jetColl = pfJets_it->second;
for(std::vector<susy::PFJet>::iterator it = jetColl.begin();it != jetColl.end(); it++) {
std::map<TString,Float_t>::iterator s_it = it->jecScaleFactors.find("L1FastL2L3");
if (s_it == it->jecScaleFactors.end()) {
std::cout << "JEC is not abailable for this jet!!!" << std::endl;
continue;
}
float scale = s_it->second;
TLorentzVector corrP4 = scale * it->momentum;
if(corrP4.Pt() < 30) continue;
if(std::fabs(corrP4.Eta()) > 2.6) continue; //AN_11_409
float uncorrE = it->momentum.E();
float NeutralHadronFraction = (it->neutralHadronEnergy)/uncorrE;
float NeutralEMFraction =(it->neutralEmEnergy)/uncorrE;
float ChargedHadronFraction = (it->chargedHadronEnergy)/uncorrE;
float ChargedEMFraction = (it->chargedEmEnergy)/uncorrE;
if(std::fabs(corrP4.Eta()) < 2.4){ //AN_11_409 selection
if((int(it->nConstituents) <= 1) ||
(NeutralHadronFraction > 0.99) ||
(NeutralEMFraction > 0.99) ||
(ChargedHadronFraction <= 0) ||
(ChargedEMFraction > 0.99) ||
(int(it->chargedHadronMultiplicity) <= 0)) continue;
}
else { //eta in 2.4-2.6. We the jet misses the tracker but hits HCAL, so ignore charged criteria.
if((int(it->nConstituents) <= 1) ||
(NeutralHadronFraction > 0.99) ||
(NeutralEMFraction > 0.99) ) continue;
}
if(event->eventNumber == ((unsigned int)probeevent)){
printf("PFjet Pt %.1f Eta %.2f Phi %.2f\n",corrP4.Pt(),corrP4.Eta(),corrP4.Phi());
}
//Make sure the jet is not a photon
bool same_pho_object = false; //exclude the two photons you use for analysis.
for(std::vector<susy::Photon*>::iterator p_it = loose_susy12_photons.begin(); p_it != loose_susy12_photons.end(); p_it++) {
TLorentzVector it_pho = useMVAphoP?(*p_it)->MVAcorrMomentum:(*p_it)->momentum;
if(event->eventNumber == ((unsigned int)probeevent)){
printf(" Photon Pt %.1f Eta %.2f Phi %.2f\n",it_pho.Pt(),it_pho.Eta(),it_pho.Phi());
//printf(" Photon Pt %.1f Eta %.2f Phi %.2f\n",(*p_it)->momentum.Pt(),(*p_it)->momentum.Eta(),(*p_it)->momentum.Phi());
//cout<<" object match: "<<isSameObject(corrP4,(*p_it)->momentum)<<endl;
cout<<" object match: "<<isSameObject(corrP4,it_pho)<<endl;
}
same_pho_object |= isSameObject(corrP4,it_pho);
}
//Make sure the jet is not an electron
bool same_emobject = false;
for(std::vector<susy::Electron*>::iterator m_it = pfEles.begin(); m_it != pfEles.end(); m_it++) {
if(event->eventNumber == ((unsigned int)probeevent)){
printf(" Ele Pt %.1f Eta %.2f Phi %.2f\n",(*m_it)->momentum.Pt(),(*m_it)->momentum.Eta(),(*m_it)->momentum.Phi());
cout<<" object match: "<<isSameObject(corrP4,(*m_it)->momentum)<<endl;
}
same_emobject |= isSameObject(corrP4,(*m_it)->momentum);
}
//Make sure the jet is not an muon
bool same_muon = false;
for(std::vector<susy::Muon*>::iterator m_it = Muons.begin(); m_it != Muons.end(); m_it++){
if(event->eventNumber == ((unsigned int)probeevent)){
printf(" Muon Pt %.1f Eta %.2f Phi %.2f\n",(*m_it)->momentum.Pt(),(*m_it)->momentum.Eta(),(*m_it)->momentum.Phi());
cout<<" object match: "<<isSameObject(corrP4,(*m_it)->momentum)<<endl;
}
same_muon |= isSameObject(corrP4,(*m_it)->momentum);
}
if(!same_emobject && !same_muon && !same_pho_object){
ra3_pfjets.push_back(&*it);
HT_all += corrP4.Pt();
MHT_x_all -= corrP4.Px();
MHT_y_all -= corrP4.Py();
}
}// pfjet
}//if
std::sort(ra3_pfjets.begin(),ra3_pfjets.end(),EtGreater<susy::PFJet>);
//MHT_all = std::sqrt(MHT_x_all*MHT_x_all + MHT_y_all*MHT_y_all);
/////////////////////////////////////////////////////////////////
//////////////////////// FIND B-JETS ///////////////////////////
/////////////////////////////////////////////////////////////////
for(std::vector<susy::PFJet*>::iterator it = ra3_pfjets.begin(); it != ra3_pfjets.end(); it++) {
if((*it)->bTagDiscriminators[5] > 0.898) pfBJetsTight.push_back(*it);//CSV medium working point
if((*it)->bTagDiscriminators[5] > 0.679) pfBJetsMedium.push_back(*it);//CSV medium working point
if((*it)->bTagDiscriminators[5] > 0.244) pfBJetsLoose.push_back(*it);//CSV loose working point
}
//////////////////////// GET MET ///////////////////////////
if(printLevel > 0) std::cout << "Select which met will be used in the event." << std::endl;
std::map<TString, susy::MET>::iterator met_it = event->metMap.find("pfMet");
if(met_it == event->metMap.end()) {
std::cout << "MET map is not availabel!!!" << std::endl;
continue;
}
Counters["has met map"]++;
susy::MET* pfmet = &(met_it->second);
bool spillguts = false;
if(event->eventNumber == ((unsigned int)probeevent)) spillguts = true;
//float corrmet = JEC_MET(pfmet,ra3_pfjets,spillguts);
float metX,metY;
float corrmet = JEC_MET(pfmet,ra3_pfjets,metX,metY,spillguts);
corrmet = PhoEC_MET(corrmet,loose_susy12_photons,metX,metY,spillguts);
//metPhi = TMath::ATan(MHT_y_all/MHT_x_all);
//myST = HT_all + myPhotonST + corrmet + myLeptonST;
//met = corrmet;
/*if(corrmet<30){
cout<<endl<<"WARNING!! MET < 30 met = "<<corrmet<<" uc pfMET="<<pfmet->met()<<endl;
cout<<"list "<<event->runNumber<<" "<<event->luminosityBlockNumber<<" "<<event->eventNumber<<endl;
}*/
//Get the denominators: look at all reco jets, categorize as MC b-jets and non-b's.
/*int ib = 0;//count how many MC true b-jets there are.
for(std::vector<susy::PFJet*>::iterator itj = ra3_pfjets.begin(); itj != ra3_pfjets.end(); itj++) {
bool isB = false;
for(std::vector<susy::Particle>::iterator it = event->genParticles.begin(); !isB && it != event->genParticles.end(); it++) {
isB |= abs(it->pdgId) == 5 && (*itj)->momentum.DeltaR(it->momentum)<0.5;
}
if(isB){
bjetEffDen->Fill((*itj)->momentum.Pt());
ib++;
}
else bMistagDen->Fill((*itj)->momentum.Pt());
}
nbjets_dist->Fill(ib);
int im = 0;
for(std::vector<susy::PFJet*>::iterator itb = pfBJetsTight.begin(); itb != pfBJetsTight.end(); itb++) {
bool isB = false;
for(std::vector<susy::Particle>::iterator it = event->genParticles.begin();!isB && it != event->genParticles.end(); it++) {
isB |= abs(it->pdgId) == 5 && (*itb)->momentum.DeltaR(it->momentum)<0.5;
}
if(isB) bjetEff_CSVTNum->Fill((*itb)->momentum.Pt());
else {
bMistag_CSVTNum->Fill((*itb)->momentum.Pt());
im++;
}
}
nMistagsT_dist->Fill(im);
im = 0;
for(std::vector<susy::PFJet*>::iterator itb = pfBJetsMedium.begin(); itb != pfBJetsMedium.end(); itb++) {
bool isB = false;
for(std::vector<susy::Particle>::iterator it = event->genParticles.begin();!isB && it != event->genParticles.end(); it++) {
isB |= abs(it->pdgId) == 5 && (*itb)->momentum.DeltaR(it->momentum)<0.5;
}
if(isB) bjetEff_CSVMNum->Fill((*itb)->momentum.Pt());
else{
bMistag_CSVMNum->Fill((*itb)->momentum.Pt());
im++;
}
}
nMistagsM_dist->Fill(im);
im = 0;
for(std::vector<susy::PFJet*>::iterator itb = pfBJetsLoose.begin(); itb != pfBJetsLoose.end(); itb++) {
bool isB = false;
for(std::vector<susy::Particle>::iterator it = event->genParticles.begin(); !isB && it != event->genParticles.end(); it++) {
isB |= abs(it->pdgId) == 5 && (*itb)->momentum.DeltaR(it->momentum)<0.5;
}
if(isB) bjetEff_CSVLNum->Fill((*itb)->momentum.Pt());
else{
bMistag_CSVLNum->Fill((*itb)->momentum.Pt());
im++;
}
}
nMistagsL_dist->Fill(im);
*/
//END LOOKING AT MC TRUTH
//flatskimtree->Fill();
if(event->eventNumber == ((unsigned int)probeevent)) cout<<"probe: corrmet "<<corrmet<<" uncorrmet "<< pfmet->met() <<endl;
//eventlist<<event->runNumber<<" "<<event->luminosityBlockNumber<<" "<<event->eventNumber<<endl;
if(event->eventNumber == ((unsigned int)probeevent)){//probe
TLorentzVector gg_trip = p0 + p1;// loose_susy12_photons[0]->momentum + loose_susy12_photons[1]->momentum;
float mgg_trip = gg_trip.M();
float pigg_trip = gg_trip.Pt()/mgg_trip;
cout<<endl<<"*** Probe Event ***"<<endl;
cout<<"run "<< event->runNumber <<" lumi "<< event->luminosityBlockNumber << " event "<< event->eventNumber <<endl;
printf("phoPt[0] %.2f Eta %.2f Phi %.2f\n", p0.Pt(), p0.Eta(), p0.Phi() );
printf("phoPt[1] %.2f Eta %.2f Phi %.2f\n", p1.Pt(), p1.Eta(), p1.Phi() );
printf("met %f phi %.2f\n",corrmet,pigg_trip);
}//end probe
} // for every jentry
///AT THIS POINT WE DECLARE THE EVENT PHYSICS-GOOD
for (int i=0; i<int(Counter_order.size()); i++) {
cout << Counters[Counter_order[i]] << " " << Counter_order[i] << endl;
}
/*bjetEffDen->Sumw2();
bjetEff_CSVLNum->Sumw2();
bjetEff_CSVMNum->Sumw2();
bjetEff_CSVTNum->Sumw2();
bjetEff_CSVL->Divide(bjetEff_CSVLNum,bjetEffDen);
bjetEff_CSVM->Divide(bjetEff_CSVMNum,bjetEffDen);
bjetEff_CSVT->Divide(bjetEff_CSVTNum,bjetEffDen);
bjetEff_CSVL->Sumw2();
bjetEff_CSVM->Sumw2();
bjetEff_CSVT->Sumw2();
bMistagDen->Sumw2();
bMistag_CSVLNum->Sumw2();
bMistag_CSVMNum->Sumw2();
bMistag_CSVTNum->Sumw2();
bMistag_CSVL->Divide(bMistag_CSVLNum,bMistagDen);
bMistag_CSVM->Divide(bMistag_CSVMNum,bMistagDen);
bMistag_CSVT->Divide(bMistag_CSVTNum,bMistagDen);
bMistag_CSVL->Sumw2();
bMistag_CSVM->Sumw2();
bMistag_CSVT->Sumw2();
b_tag_eff_file->cd();
bjetEff_CSVL->Write();
bjetEff_CSVM->Write();
bjetEff_CSVT->Write();
nbjets_dist->Write();
bMistag_CSVL->Write();
bMistag_CSVM->Write();
bMistag_CSVT->Write();
nMistagsL_dist->Write();
nMistagsM_dist->Write();
nMistagsT_dist->Write();
b_tag_eff_file->Close();*/
//eventlist.close();
// close the output file
//flatskim.cd();
//flatskimtree->Write();
//flatskim.Close();
//eventlist2.close();
// fout->cd();
// fout->Write();
// fout->Close();
//
// if(enableFilter) {
// filterTree->GetCurrentFile()->cd();
// filterTree->GetCurrentFile()->Write();
// filterTree->GetCurrentFile()->Close();
// }//end if filter enabled
}//end Loop
bool SusyAna_MC_phoEff::ok_muon(std::vector<susy::Muon>::iterator it){ //Yu Feng
// std::map<TString,UChar_t>::iterator idPair = it->idPairs.find("muidGlobalMuonPromptTight");
if (//(idPair == it->idPairs.end()) ||
//(int(idPair->second) == 0) || that belongs in the loop
(std::fabs(it->momentum.Eta()) > 2.1) || //dm: >2.6
(it->momentum.Pt() < 20) || //dm: 15
(it->nValidTrackerHits < 11) ||
(it->combinedTrackIndex < 0) ||
((it->ecalIsoR03 + it->hcalIsoR03 + it->trackIsoR03)/(it->momentum.Pt()) > 0.1) || //relIso > 0.1
(it->emEnergy > 4.0) ||
(it->hadEnergy > 6.0)) return false;
susy::Track& combinedTrack = event->tracks[it->combinedTrackIndex];
float normChi2 = combinedTrack.chi2 / combinedTrack.ndof;
float d0 = std::abs(d0correction(event->beamSpot,combinedTrack));
if(normChi2 >= 10.f || d0 >= 0.2 ) return false;
else return true;
}
bool SusyAna_MC_phoEff::ok_muon_AN_11_409(std::vector<susy::Muon>::iterator it,susy::Track& combinedTrack, float pVtx_Z){ //probably inner track instead
//get combinedTrack using susy::Track& combinedTrack = event->tracks[it->combinedTrackIndex];
//I don't see where
if(!it->isGlobalMuon()) return false;
if(!it->isPFMuon()) return false;
// std::map<TString,UChar_t>::iterator idPair = it->idPairs.find("muidGlobalMuonPromptTight");
if (
//(idPair == it->idPairs.end()) ||
//(int(idPair->second) == 0) ||
(std::fabs(it->momentum.Eta()) > 2.4) || //dm: >2.6
(it->momentum.Pt() < 10) ||
(it->nValidTrackerHits < 11) ||
(it->combinedTrackIndex < 0) ||
((it->ecalIsoR03 + it->hcalIsoR03 + it->trackIsoR03)/(it->momentum.Pt()) >= 0.15) || //relIso > 0.15
//(it->emEnergy > 4.0) ||