-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalysisReader_hhbbtt.cxx
executable file
·3629 lines (2926 loc) · 167 KB
/
AnalysisReader_hhbbtt.cxx
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 <EventLoop/Worker.h>
#include "TSystem.h"
#include <CxAODReader_HH_bbtautau/AnalysisReader_hhbbtt.h>
#include <CxAODTools_HH_bbtautau/HHbbtautauLepHadSelection.h>
#include <CxAODTools_HH_bbtautau/HHbbtautauHadHadSelection.h>
#include <CxAODTools_HH_bbtautau/HHbbtautauLepHadJetSelection.h>
#include <CxAODTools_HH_bbtautau/HHbbtautauHadHadJetSelection.h>
#include <CxAODTools_HH_bbtautau/HHbbtautauBoostedSelection.h>
#include <CxAODTools_HH_bbtautau/HHbbtautauBoostedJetSelection.h>
#include "Mt2/mt2_bisect.h"
#define length(array) (sizeof(array)/sizeof(*(array)))
ClassImp(AnalysisReader_hhbbtt)
AnalysisReader_hhbbtt::AnalysisReader_hhbbtt() :
AnalysisReader(),
m_analysisType(""),
m_doTruthTagging("false"),
m_use2DbTagCut("false"),
m_fillCR("false"),
m_tree(nullptr),
m_FF_File(nullptr),
m_FF_File_boosted(nullptr), //boostedFF
m_2DFF(nullptr)
//m_tree_vbf(nullptr)
{
m_trkBTagLimit = -0.3098; // added for Higgs Tagger
}
AnalysisReader_hhbbtt :: ~AnalysisReader_hhbbtt()
{
delete m_FF_File;
delete m_FF_File_boosted; //boostedFF
}
EL::StatusCode AnalysisReader_hhbbtt :: initializeSelection()
{
m_config->getif<string>("analysisType", m_analysisType);
m_config->getif<string>("analysisStrategy", m_analysisStrategy);
// For 2D cut only use merged
m_config->getif<bool>("use2DbTagCut", m_use2DbTagCut);
if (m_use2DbTagCut){
if(m_analysisStrategy != "Merged"){
Error("initializeSelection()","Running with 2DbTagCut. Only possible for merged analysis, but %s is chosen. Exiting!",m_analysisStrategy.c_str());
return EL::StatusCode::FAILURE;
}
Warning("initializeSelection()","Running with 2DbTagCut. b-tagging for calo jets disabled!!");
}
Info("initializeSelection()", "Initialize analysis '%s'.", m_analysisType.c_str());
if (m_analysisType== "hadhad") {
m_eventSelection = new HHbbtautauHadHadSelection(m_config);
m_eventPostSelection = new HHbbtautauHadHadJetSelection(m_config);
m_fillFunction = std::bind(&AnalysisReader_hhbbtt::fill_hadhad, this);
} else if (m_analysisType=="lephad") {
m_eventSelection = new HHbbtautauLepHadSelection(m_config);
m_eventPostSelection = new HHbbtautauLepHadJetSelection(m_config);
m_fillFunction = std::bind(&AnalysisReader_hhbbtt::fill_lephad, this);
}else if (m_analysisType == "boosted") {
m_eventSelection = new HHbbtautauBoostedSelection(m_config);
m_eventPostSelection = new HHbbtautauBoostedJetSelection(m_config);
m_fillFunction = std::bind(&AnalysisReader_hhbbtt::fill_boosted, this);
} else {
Error("initializeSelection()", "Invalid analysis type %s", m_analysisType.c_str());
return EL::StatusCode::FAILURE;
}
// TODO move to base class?
bool writeMVATree = false;
bool readMVA = false;
m_config->getif< bool >("writeMVATree", writeMVATree);
m_config->getif< bool >("readMVA", readMVA);
// initialize MVATree
m_tree = new MVATree_hhbbtt(writeMVATree, readMVA, m_analysisType, wk(), m_variations, false);
//do truth tagging?
m_config->getif<bool>("doTruthTagging", m_doTruthTagging);
return EL::StatusCode::SUCCESS;
}
//Added this initialization since it was currectly getting called in generic reader and running on unwanted samples
EL::StatusCode AnalysisReader_hhbbtt::initializeCorrsAndSysts ()
{
m_doTruthTagging&=m_isMC;
Info("initializeSelection()","truth tagging1? %i",m_doTruthTagging);
if (!m_isMC) return EL::StatusCode::SUCCESS;
std::string comEnergy = m_config->get<std::string>("COMEnergy");
if ((comEnergy != "8TeV") || (comEnergy != "7TeV")) comEnergy = "13TeV";
TString csname;
std::string debugname;
//if (m_analysisType == "hadhad") { csname = comEnergy + "_HadHad"; debugname = comEnergy + "_HadHad"; }
if (m_analysisType == "hadhad" || m_analysisType == "boosted") { csname = comEnergy + "_ZeroLepton"; debugname = comEnergy + "_ZeroLepton"; }
Info("initializeCorrsAndSysts()", "Initializing CorrsAndSysts for %s", debugname.c_str());
m_corrsAndSysts = new CorrsAndSysts(csname);
return EL::StatusCode::SUCCESS;
} // initializeCorrsAndSysts
EL::StatusCode AnalysisReader_hhbbtt::initializeTools ()
{
EL_CHECK("AnalysisReader_hhbbtt::initializeTools()", AnalysisReader::initializeTools());
m_getFFInputs=false;
m_config->getif<bool>("fillFakeHists", m_getFFInputs);
m_applyFF=false;
m_config->getif<bool>("ApplyQCDFF", m_applyFF);
bool m_FillSR=false;
m_config->getif<bool>("FillSR", m_FillSR);
bool m_FillSS=false;
m_config->getif<bool>("FillSS", m_FillSS);
if(m_applyFF) {
std::string rootcore_path = gSystem->Getenv("ROOTCOREBIN");
m_FF_File = TFile::Open((rootcore_path+"/data/FrameworkExe_HH_bbtautau/QCDFF.root").c_str(),"READ");
if(m_FF_File==nullptr){
std::cout << "File was not open" << std::endl;
return EL::StatusCode::FAILURE;
}
}
if(m_analysisType == "boosted") { // boostedFF
m_applyFF = false;
m_calculateFF = false;
m_config->getif<bool>("applyFF", m_applyFF);
m_config->getif<bool>("calculateFF", m_calculateFF);
if(m_calculateFF) m_applyFF = false;
if(m_applyFF){
std::string rootcore_path = gSystem->Getenv("ROOTCOREBIN");
m_FF_File_boosted = TFile::Open((rootcore_path+"/data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root").c_str(),"READ");
if(m_FF_File_boosted==nullptr){
std::cout << "File was not open" << std::endl;
return EL::StatusCode::FAILURE;
}
std::cout<<"Getting histogram: h_overallFFforEachRegion from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_overallFFperRegion = (TH1D*)m_FF_File_boosted->Get("h_overallFFforEachRegion");
std::cout<<"Getting FakeFactor hist named: h_FF_Pt_EtaCentralbinned_dPhiFFR_0tag from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_1DFF_0tagEtaCentral_dPhiFFR_boosted = (TH1D*)m_FF_File_boosted->Get("h_FF_Pt_EtaCentralbinned_dPhiFFR_0tag");
std::cout<<"Getting FakeFactor hist named: h_FF_Pt_EtaCentralbinned_dPhiFFR_1tag from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_1DFF_1tagEtaCentral_dPhiFFR_boosted = (TH1D*)m_FF_File_boosted->Get("h_FF_Pt_EtaCentralbinned_dPhiFFR_1tag");
std::cout<<"Getting FakeFactor hist named: h_FF_Pt_EtaForwardbinned_dPhiFFR_0tag from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_1DFF_0tagEtaForward_dPhiFFR_boosted = (TH1D*)m_FF_File_boosted->Get("h_FF_Pt_EtaForwardbinned_dPhiFFR_0tag");
std::cout<<"Getting FakeFactor hist named: h_FF_Pt_EtaForwardbinned_dPhiFFR_1tag from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_1DFF_1tagEtaForward_dPhiFFR_boosted = (TH1D*)m_FF_File_boosted->Get("h_FF_Pt_EtaForwardbinned_dPhiFFR_1tag");
std::cout<<"Getting FakeFactor hist named: h_FF_Pt_EtaCentralbinned_0tag from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_1DFF_0tagEtaCentral_boosted = (TH1D*)m_FF_File_boosted->Get("h_FF_Pt_EtaCentralbinned_0tag");
std::cout<<"Getting FakeFactor hist named: h_FF_Pt_EtaForwardbinned_0tag from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_1DFF_0tagEtaForward_boosted = (TH1D*)m_FF_File_boosted->Get("h_FF_Pt_EtaForwardbinned_0tag");
/*
m_FFFatJetPtCut = 400.0; // this value must be the same as in histo name
if(m_FFFatJetPtCut == 500.0){
// 0tag
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiVR_0tag_FJPt500 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_0tag_dPhiVR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiVR_0tag_FJPt500");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiNotSR_0tag_FJPt500 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_0tag_dPhiNotSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiNotSR_0tag_FJPt500");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiSR_0tag_FJPt500 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_0tag_dPhiSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiSR_0tag_FJPt500");
// 1tag
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiVR_1tag_FJPt500 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_1tag_dPhiVR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiVR_1tag_FJPt500");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiNotSR_1tag_FJPt500 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_1tag_dPhiNotSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiNotSR_1tag_FJPt500");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiSR_1tag_FJPt500 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_1tag_dPhiSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiSR_1tag_FJPt500");
}
if(m_FFFatJetPtCut == 400.0){
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiVR_0tag_FJPt400 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_0tag_dPhiVR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiVR_0tag_FJPt400");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiNotSR_0tag_FJPt400 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_0tag_dPhiNotSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiNotSR_0tag_FJPt400");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiSR_0tag_FJPt400 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_0tag_dPhiSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiSR_0tag_FJPt400");
// 1tag
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiVR_1tag_FJPt400 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_1tag_dPhiVR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiVR_1tag_FJPt400");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiNotSR_1tag_FJPt400 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_1tag_dPhiNotSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiNotSR_1tag_FJPt400");
std::cout<<"Getting FakeFactor 2d hist named: h_FF_PtEtabinned_dPhiSR_1tag_FJPt400 from: /data/FrameworkSub_HH_bbtautau/FFqcd_boosted.root"<<std::endl;
m_2DFF_1tag_dPhiSR_boosted = (TH2D*)m_FF_File_boosted->Get("h_FF_PtEtabinned_dPhiSR_1tag_FJPt400");
}*/
}
}
bool m_writeMVATree = false;
bool m_readMVA = false;
m_config->getif< bool >("writeMVA", m_writeMVATree);
m_config->getif< bool >("readMVA", m_readMVA);
m_tree = new MVATree_hhbbtt(m_writeMVATree, m_readMVA, m_analysisType, wk(), m_variations, false);
if(m_writeMVATree || m_readMVA) m_tree->SetVariation(m_currentVar);
m_FillSRSel260_300 = false;
m_config->getif< bool >("FillSRSel260_300", m_FillSRSel260_300);
m_FillSRSel400 = false;
m_config->getif< bool >("FillSRSel400", m_FillSRSel400);
m_FillSRSel500_600_700 = false;
m_config->getif< bool >("FillSRSel500_600_700", m_FillSRSel500_600_700);
m_FillSRSel800_900_1000 = false;
m_config->getif< bool >("FillSRSel800_900_1000", m_FillSRSel800_900_1000);
return EL::StatusCode::SUCCESS;
} //initializeTools
EL::StatusCode AnalysisReader_hhbbtt::initializeIsMC ()
{
Info("initializeIsMC()", "Initialize isMC.");
// get nominal event info
// -------------------------------------------------------------
const xAOD::EventInfo *eventInfo = m_eventInfoReader->getObjects("Nominal");
if (!eventInfo) return EL::StatusCode::FAILURE;
// get MC flag - different info on data/MC files
// -----------------------------------------------
m_isMC = Props::isMC.get(eventInfo);
Info("initializeIsMC()", "isMC = %i", m_isMC);
// COM energy
std::string comEnergy = m_config->get<std::string>("COMEnergy");
std::string xSectionFile = gSystem->Getenv("ROOTCOREBIN");
xSectionFile += "/data/FrameworkSub_HH_bbtautau/XSections_";
xSectionFile += comEnergy;
xSectionFile += ".txt";
m_xSectionProvider = new XSectionProvider(xSectionFile);
if (!m_xSectionProvider) {
Error("initializeXSections()", "XSection provider not initialized!");
return EL::StatusCode::FAILURE;
}
return EL::StatusCode::SUCCESS;
} // initializeIsMC
EL::StatusCode AnalysisReader_hhbbtt :: initializeSumOfWeights()
{
Info("initializeSumOfWeights()", "Initialize sum of weights.");
if (!m_isMC) {
return EL::StatusCode::SUCCESS;
}
// which analysis
std::string ana_read = "";
if (m_analysisType == "hadhad") ana_read = "hadhad";
else if (m_analysisType == "lephad") ana_read = "lephad";
else if (m_analysisType == "boosted") ana_read = "boosted";
else {
Warning("initializeSumOfWeights()", "Invalid analysis type %s", m_analysisType.c_str());
return EL::StatusCode::FAILURE;
}
// COM energy
std::string comEnergy = m_config->get<std::string>("COMEnergy");
std::string prodTag = m_config->get<std::string>("prodTag");
std::string sumOfWeightsFile = gSystem->Getenv("ROOTCOREBIN");
sumOfWeightsFile += "/data/FrameworkSub_HH_bbtautau/yields.";
sumOfWeightsFile += ana_read;
sumOfWeightsFile += ".";
sumOfWeightsFile += prodTag;
sumOfWeightsFile += ".";
sumOfWeightsFile += comEnergy;
sumOfWeightsFile += ".txt";
m_sumOfWeightsProvider = new sumOfWeightsProvider(sumOfWeightsFile);
return EL::StatusCode::SUCCESS;
}
/*EL::StatusCode AnalysisReader_hhbbtt :: initializeOR2()
{
m_overlapRemoval2 = new OverlapRemoval_HH_bbtautau( *m_config );
EL_CHECK("AnalysisReader::initializeOR2()",m_overlapRemoval2->initialize());
return EL::StatusCode::SUCCESS;
}*/
EL::StatusCode AnalysisReader_hhbbtt::setObjectsForOR(const xAOD::ElectronContainer * electrons,
const xAOD::PhotonContainer * photons,
const xAOD::MuonContainer * muons,
const xAOD::TauJetContainer * taus,
const xAOD::JetContainer * jets,
const xAOD::JetContainer* fatjets,
const xAOD::DiTauJetContainer* ditaus)
{
if(electrons){
for(const xAOD::Electron * elec : *electrons){
Props::passPreSel.set(elec, Props::isHHLooseElectron.get(elec));
}
}
if(muons){
for(const xAOD::Muon * muon : *muons){
Props::passPreSel.set(muon, Props::isHHLooseMuon.get(muon));
}
}
if(jets){
for(const xAOD::Jet * jet : *jets){
Props::passPreSel.set(jet, Props::isVetoJet.get(jet));
}
}
if(taus){
for(const xAOD::TauJet * tau : *taus){
Props::passPreSel.set(tau, Props::passTauSelector.get(tau));
}
}
if (fatjets) {
for (const xAOD::Jet* jet : *fatjets) {
Props::passPreSel.set(jet,Props::isFatJet.get(jet));
}
}
if (ditaus) {
for (const xAOD::DiTauJet* ditau : *ditaus) {
Props::passPreSel.set(ditau,Props::isDiTauJet.get(ditau));
}
}
return EL::StatusCode::SUCCESS;
}
EL::StatusCode AnalysisReader_hhbbtt :: fill_bTaggerHists(const xAOD::Jet* jet)
{
// fills histograms per jet and jet flavour for a list of b-taggers
std::string flav = "Data";
if (m_isMC) {
int label = Props::TruthLabelID.get(jet);
flav = "L";
if (label == 4) flav = "C";
else if (label == 5) flav = "B";
}
float SV1_IP3D = Props::SV1_IP3D.get(jet);
float MV2c10 = Props::MV2c10.get(jet);
double BVar = BTagProps::tagWeight.get(jet);
if (m_isMC) {
double BEff = BTagProps::eff.get(jet);
m_histSvc->BookFillHist("eff_" + flav, 110, -0.1, 1.1, BEff, m_weight);
m_histSvc->BookFillHist("pT_eff_" + flav, 400, 0, 400, 110, 0.0, 1.1, jet->pt() / 1e3, BEff, m_weight);
m_histSvc->BookFillHist("eta_eff_" + flav, 100, -5, 5, 110, 0.0, 1.1, jet->eta(), BEff, m_weight);
}
m_histSvc->BookFillHist("btag_weight_" + flav, 110, -1.1, 1.1, BVar, m_weight);
m_histSvc->BookFillHist("SV1_IP3D_" + flav, 110, -30, 80, SV1_IP3D, m_weight);
m_histSvc->BookFillHist("MV2c10_" + flav, 110, -1.1, 1.1, MV2c10, m_weight);
return EL::StatusCode::SUCCESS;
}
void AnalysisReader_hhbbtt::compute_btagging (const std::vector<const xAOD::Jet*> &signalJets)
{
if (m_trackJets) {
m_bTagTool->setJetAuthor(m_trackJetReader->getContainerName());
for (auto jet : *m_trackJets) {
BTagProps::isTagged.set(jet, static_cast<decltype(BTagProps::isTagged.get(jet))>(m_bTagTool->isTagged(*jet)));
BTagProps::tagWeight.set(jet, Props::MV2c10.get(jet));
}
}
if (m_jets) {
m_bTagTool->setJetAuthor(m_jetReader->getContainerName());
for (auto jet : *m_jets) {
if(!m_use2DbTagCut) BTagProps::isTagged.set(jet, static_cast<decltype(BTagProps::isTagged.get(jet))>(m_bTagTool->isTagged(*jet)));
else BTagProps::isTagged.set(jet, false);
BTagProps::tagWeight.set(jet, Props::MV2c10.get(jet));
if (m_isMC && !m_use2DbTagCut) BTagProps::eff.set(jet, m_bTagTool->getEfficiency(*jet));
else BTagProps::eff.set(jet, -999.);
}
}
//Temporarily removed treatment of fat jets in lephad, but do not remove we might need it back
/*
if (m_fatJets) {
for (auto fatjet : *m_fatJets) {
using FatJetType = typename std::remove_pointer<decltype(fatjet)>::type;
static FatJetType::ConstAccessor<vector<ElementLink<DataVector<xAOD::IParticle>>>>
GhostAccessor ("GhostAntiKt2TrackJet");
if (Props::isFatJet.get(fatjet)) {
// determine number of b-tags in a fat jet
// number of tracks will be the track jets with closest DR with the ghost matched track jets
auto nTags = 0;
std::vector<const xAOD::Jet*> trackJetsInFatJet;
if (m_trackJets) {
// loop over the ghost associated track jets
for (auto gTrackParticle : GhostAccessor(*fatjet)) {
if (!gTrackParticle.isValid()) continue;
const auto &temp = **gTrackParticle;
auto gTrackJet = dynamic_cast<const xAOD::Jet*>(&temp);
auto minDR = 100.0;
const xAOD::Jet *minDRTrackJet = nullptr;
for (auto trackJet : *m_trackJets) {
auto Deta = trackJet->eta() - gTrackJet->eta(),
Dphi = trackJet->phi() - gTrackJet->phi(),
DR = sqrt(Deta * Deta + Dphi * Dphi);
if (minDR > DR) {
minDR = DR;
minDRTrackJet = trackJet;
}
}
if (minDRTrackJet) trackJetsInFatJet.push_back(minDRTrackJet);
}
}
for (auto trackJet : trackJetsInFatJet)
if (BTagProps::isTagged.get(trackJet)) ++nTags;
Props::nTrackJets.set(fatjet, trackJetsInFatJet.size());
Props::nBTags.set(fatjet, nTags);
// finished b-tagging criteria
// determine number of true b-jets in a fat jet with simple DR
auto nBJets = 0;
if (m_isMC) {
for (auto trackJet : trackJetsInFatJet) {
auto label = -999;
if (Props::HadronConeExclTruthLabelID.exists(trackJet)) label = Props::HadronConeExclTruthLabelID.get(trackJet);
else if (Props::TruthLabelID.exists(trackJet)) label = Props::TruthLabelID.get(trackJet);
if (label == 5) ++nBJets;
}
}
else nBJets = -1; // Data
Props::nTrueBJets.set(fatjet, nBJets);
// finished true b-jet association criteria
}
}
}//end if loop of m_fatjets
*/
} // compute_btagging
// temporarily removed fatjet_selection and implemented a different way to do it, but please do not permentantly remove
void AnalysisReader_hhbbtt::compute_TRF_tagging (const std::vector<const xAOD::Jet*>& signalJets)
{
bool ttag_track_jets=false;
if (m_trackJets) {
m_bTagTool->setJetAuthor(m_trackJetReader->getContainerName());
if(ttag_track_jets) m_bTagTool->truth_tag_jets(m_eventInfo->eventNumber(),*m_trackJets,m_config);
else{
for (auto jet : *m_trackJets) {
BTagProps::isTagged.set(jet, static_cast<decltype(BTagProps::isTagged.get(jet))>(m_bTagTool->isTagged(*jet)));
BTagProps::tagWeight.set(jet, Props::MV2c10.get(jet));
}
}
}
if (m_jets) {//we assume signal jets are taken from the larger jet container
m_bTagTool->setJetAuthor(m_jetReader->getContainerName());
m_bTagTool->truth_tag_jets(m_eventInfo->eventNumber(),signalJets,m_config);
}
if (m_fatJets) {
for (auto fatjet : *m_fatJets) {
Props::nTrackJets.set(fatjet, 0);
Props::nBTags.set(fatjet, 0);
if (m_isMC) Props::nTrueBJets.set(fatjet, 0);
else Props::nTrueBJets.set(fatjet, -1);
}
}
} // compute_TRF_tagging
/*
void AnalysisReader_hhbbtt::fatjet_selection ()
{
if (m_fatJets) {
for (auto fatjet : *m_fatJets) {
if (Props::isFatJet.get(fatjet)) {
// remove fatjet close to leptons with a simple DR cut
auto fatjeteta = fatjet->eta();
auto fatjetphi = fatjet->phi();
for (auto electron : *m_electrons) {
auto Deta = electron->eta() - fatjeteta,
Dphi = electron->phi() - fatjetphi,
DR = sqrt(Deta * Deta + Dphi * Dphi);
if (DR < 1.0) {
Props::isFatJet.set(fatjet, static_cast<int>(false));
break;
}
}
if (!Props::isFatJet.get(fatjet)) continue;
for (auto muon : *m_muons) {
auto Deta = muon->eta() - fatjeteta,
Dphi = muon->phi() - fatjetphi,
DR = sqrt(Deta * Deta + Dphi * Dphi);
if (DR < 1.0) {
Props::isFatJet.set(fatjet, static_cast<int>(false));
break;
}
}
// if (!Props::isFatJet.get(fatjet)) continue;
// finished lepton isolation criteria
}
}
}
} // fatjet_selection
*/
//the function below defines 1 btag and 2 btag regions based on how many btagged jets there are
void AnalysisReader_hhbbtt::tagjet_selection(
std::vector<const xAOD::Jet*> signalJets,
std::vector<const xAOD::Jet*> forwardJets,
std::vector<const xAOD::Jet*> &selectedJets,
int &tagcatExcl,
int &tagcatIncl)
{
string tagStrategy, tagAlgorithm;
m_config->getif<std::string>("tagStrategy", tagStrategy); // AllSignalJets,Leading2SignalJets,LeadingSignalJets
m_config->getif<std::string>("tagAlgorithm", tagAlgorithm); // FlavLabel,FlavTag
selectedJets.clear();
tagcatExcl = -1;
tagcatIncl = -1;
/////////////////////////////////////////////////////////////
// **B-Tagging Selection**
bool Lead1BTag = false;
bool Lead2BTag = false;
int Ind1BTag = -1;
int Ind2BTag = -1;
int nbtag = 0;
int jetidx = 0;
int nSignalJet = signalJets.size();
int nForwardJet = forwardJets.size();
const xAOD::Jet *Jet1;
const xAOD::Jet *Jet2;
const xAOD::Jet *Jet3;
if (m_isMC && tagAlgorithm == "FlavLabel") //use truth label to select b-jets (MC only!)
{
if (Props::TruthLabelID.get(signalJets.at(0)) == 5) Lead1BTag = true;
if (Props::TruthLabelID.get(signalJets.at(1)) == 5) Lead2BTag = true;
}
else // if (tagAlgorithm == "FlavTag") use b-tagging to select b-jets (the only option for data)
{
//truth tagging (MC only)
// if(m_isMC && m_doTruthTagging){
// if (BTagProps::isTruthTagged.get(signalJets.at(0)) == 1) Lead1BTag = true;
// if (BTagProps::isTruthTagged.get(signalJets.at(1)) == 1) Lead2BTag = true;
// }
//if direct tagging
// else{
if (BTagProps::isTagged.get(signalJets.at(0)) == 1) Lead1BTag = true; //isTagged property is set in compute_btagging function
if (BTagProps::isTagged.get(signalJets.at(1)) == 1) Lead2BTag = true;
//}
}
//set ind1btag to btagged jet with highest pt, ind1btag to btagged jet with 2nd highest pt
for (const xAOD::Jet *jet : signalJets)
{
if (m_isMC && tagAlgorithm == "FlavLabel") //use truth label to select b-jets (MC only!)
{
if (Props::TruthLabelID.get(jet) == 5)
{
nbtag++;
if (Ind1BTag < 0) Ind1BTag = jetidx;
else if (Ind2BTag < 0) Ind2BTag = jetidx;
}
}
else //if (tagAlgorithm == "FlavTag") use b-tagging to select b-jets (the only option for data)
{
//if truth tagging (MC only)
// if(m_isMC && m_doTruthTagging){
// if (BTagProps::isTruthTagged.get(jet) == 1)
// {
// nbtag++;
// if (Ind1BTag < 0) Ind1BTag = jetidx;
// else if (Ind2BTag < 0) Ind2BTag = jetidx;
// }
// }
//if direct tagging
// else{
if (BTagProps::isTagged.get(jet) == 1)
{
nbtag++;
if (Ind1BTag < 0) Ind1BTag = jetidx;
else if (Ind2BTag < 0) Ind2BTag = jetidx;
}
//}
}
jetidx++;
}
/////////////////////////////////////////////////////////////
// **Tag-Category Definition**
//define regions based on weather you want 0/1/2 btag categories in regions with 2 or more signal jets (first tagStrategy), or if you want 0/1/2 bag categories in regions with exactly 2 signal jets
//not sure the difference between tagcatExcl =0/1/2 when 0/1/2 btags, tagcatIncl is for what?
if ((tagStrategy == "AllSignalJets") || (tagStrategy == "LeadingSignalJets"))
{
if (signalJets.at(0)->pt() / 1000. > 45.)
{
tagcatIncl = 0;
if (nbtag == 0) tagcatExcl = 0;
Jet1 = signalJets.at(0);
Jet2 = signalJets.at(1);
if (nSignalJet >= 3) Jet3 = signalJets.at(2);
else if (nForwardJet >= 1) Jet3 = forwardJets.at(0);
}
if ((nbtag >= 1) && (signalJets.at(Ind1BTag)->pt() / 1000. > 45.))
{
tagcatIncl = 1;
if (nbtag == 1) tagcatExcl = 1;
// if(tagStrategy == "LeadingSignalJets") { if (!Lead1BTag) return EL::StatusCode::SUCCESS; }
if (tagStrategy == "LeadingSignalJets") if (!Lead1BTag) tagcatExcl = -1; Jet1 = signalJets.at(Ind1BTag);
if (Ind1BTag == 0) Jet2 = signalJets.at(1);
else Jet2 = signalJets.at(0);
if (nSignalJet >= 3)
{
if (Ind1BTag < 2) Jet3 = signalJets.at(2);
else Jet3 = signalJets.at(1);
}
else if (nForwardJet >= 1) Jet3 = forwardJets.at(0);
}
if ((nbtag >= 2) && (signalJets.at(Ind1BTag)->pt() / 1000. > 45.))
{
tagcatIncl = 2;
if (nbtag == 2) tagcatExcl = 2;
if (tagStrategy == "LeadingSignalJets") if (!Lead1BTag) tagcatExcl = -1;
Jet1 = signalJets.at(Ind1BTag);
Jet2 = signalJets.at(Ind2BTag);
int jetidx3 = 0;
if (nSignalJet >= 3) // may change with if/else to be consistent with 1tag
{
for (const xAOD::Jet *jet : signalJets)
{
if ((jetidx3 != Ind1BTag) && (jetidx3 != Ind2BTag)) { Jet3 = jet; break; }
jetidx3++;
}
}
else if (nForwardJet >= 1) Jet3 = forwardJets.at(0);
}
}
/////////////////////////////////////////////////////////////
if (tagStrategy == "Leading2SignalJets")
{
tagcatIncl = 0;
if ((Lead1BTag == false) && (Lead2BTag == false) && (signalJets.at(0)->pt() / 1000. > 45.)) tagcatExcl = 0;
if (((Lead1BTag == true) || (Lead2BTag == true)) && (signalJets.at(0)->pt() / 1000. > 45.)) tagcatIncl = 1;
if ((((Lead1BTag == true) && (Lead2BTag == false)) || ((Lead1BTag == false) && (Lead2BTag == true))) && (signalJets.at(0)->pt() / 1000. > 45.)) tagcatExcl = 1;
if ((Lead1BTag == true) && (Lead2BTag == true) && (signalJets.at(0)->pt() / 1000. > 45.)) { tagcatExcl = 2; tagcatIncl = 2; }
Jet1 = signalJets.at(0);
Jet2 = signalJets.at(1);
if (nSignalJet >= 3) Jet3 = signalJets.at(2);
else if (nForwardJet >= 1) Jet3 = forwardJets.at(0);
}
selectedJets.push_back(Jet1);
selectedJets.push_back(Jet2);
//set is tagged PROPERTY AGAIN (over wrtting is btag in compute btagging?) for leading /sublead signal jets chosen in taggins trategy loop
BTagProps::isTagged.set(Jet1, static_cast<decltype(BTagProps::isTagged.get(Jet1))>(m_bTagTool->isTagged(*Jet1)));
BTagProps::isTagged.set(Jet2, static_cast<decltype(BTagProps::isTagged.get(Jet2))>(m_bTagTool->isTagged(*Jet2)));
if ((nSignalJet >= 3) || (nForwardJet >= 1)) selectedJets.push_back(Jet3);
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
} // tagjet_selection
EL::StatusCode AnalysisReader_hhbbtt::fill_nJetHistos(std::vector<const xAOD::Jet*> jets, string jetType) {
int nJet = jets.size();
bool isSig = (jetType == "Sig");
m_histSvc->BookFillHist("N" + jetType + "Jets", 11, -0.5, 10.5, nJet, m_weight);
for (const xAOD::Jet *jet : jets) {
m_histSvc->BookFillHist("Pt" + jetType + "Jets", 100, 0, 100, jet->pt() / 1e3, m_weight);
m_histSvc->BookFillHist("Eta" + jetType + "Jets", 100, -5, 5, jet->eta(), m_weight);
}
if (isSig) {
for (const xAOD::Jet *jet : jets) fill_bTaggerHists(jet);
}
return EL::StatusCode::SUCCESS;
}
EL::StatusCode AnalysisReader_hhbbtt::setevent_flavour(std::vector<const xAOD::Jet*> selectedJets )
{
int jet0flav = -999;
int jet1flav = -999;
//if(Props::ConeTruthLabelID.exists(selectedJets.at(0))){ //in rel20
if (Props::HadronConeExclTruthLabelID.exists(selectedJets.at(0))) { // in rel20
//jet0flav = Props::ConeTruthLabelID.get(selectedJets.at(0));
//jet1flav = Props::ConeTruthLabelID.get(selectedJets.at(1));
jet0flav = Props::HadronConeExclTruthLabelID.get(selectedJets.at(0));
jet1flav = Props::HadronConeExclTruthLabelID.get(selectedJets.at(1));
}
if(jet0flav < 0 || jet1flav < 0){
Error("AnalysisReader_hhbbtt::setevent_flavour","Failed to retrieve jet flavour! Exiting.");
return EL::StatusCode::FAILURE;
}
m_histNameSvc -> set_eventFlavour(jet0flav, jet1flav);
return EL::StatusCode::SUCCESS;
}
/*float AnalysisReader_hhbbtt::computeBTagSFWeight (std::vector<const xAOD::Jet*> &signalJets)
{
using CP::CorrectionCode;
using CP::SystematicCode;
using CP::SystematicSet;
float weight = 1;
std::unordered_map<std::string, float> btageffweights;
auto systs = m_bTagTool->affectingSystematics();
// Set all weights to 1
for (auto var : systs) {
btageffweights[var.name()] = 1.0;
}
for (auto jet : signalJets) {
float sf(1.0);
auto GeV = 1e3;
// Code crashes without this!
if (fabs(jet->eta()) > 2.5) continue;
if (fabs(jet->pt()) < 20. * GeV) continue;
//std::cout << "Seg fault" << std::endl;
CorrectionCode result;
if (static_cast<bool>(BTagProps::isTagged.get(jet))) result = m_bTagTool->getBTaggingEfficiencyTool().getScaleFactor(*jet, sf);
else result = m_bTagTool->getBTaggingEfficiencyTool().getInefficiencyScaleFactor(*jet, sf);
weight *= sf;
int label(1000);
if (Props::HadronConeExclTruthLabelID.exists(jet)) label = Props::HadronConeExclTruthLabelID.get(jet);
else if (Props::TruthLabelID.exists(jet)) label = Props::TruthLabelID.get(jet);
if (result != CorrectionCode::Ok) Warning("computeBTagSFWeight", "Get efficiency failed (jet details): eta %f, pt %f, sf %f, MV2c10 %f, flavor %d", jet->eta(), jet->pt(), sf, Props::MV2c10.get(jet), label);
for (auto var : systs) {
SystematicSet set;
set.insert(var);
auto sresult = m_bTagTool->applySystematicVariation(set);
if (sresult != SystematicCode::Ok) {
// std::cout << var.name() << " apply systematic variation FAILED " << std::endl;
}
if (static_cast<bool>(BTagProps::isTagged.get(jet))) result = m_bTagTool->getBTaggingEfficiencyTool().getScaleFactor(*jet, sf);
else result = m_bTagTool->getBTaggingEfficiencyTool().getInefficiencyScaleFactor(*jet, sf);
if (result != CorrectionCode::Ok) {
// std::cout << var.name() << " getScaleFactor FAILED" << std::endl;
} else {
// std::cout << var.name() << " " <<m_hbbname[var.name()] << sf << std::endl;
btageffweights[var.name()] *= sf;
}
// Info("computeBTagSFWeight", "pT: %f, eta: %f, label: %d, SF: %f, var: %s", jet->pt(), jet->eta(), label, sf, var.name().c_str());
}
// don't forget to switch back off the systematics...
SystematicSet defaultSet;
auto dummyResult = m_bTagTool->applySystematicVariation(defaultSet);
if (dummyResult != SystematicCode::Ok) Warning("computeBTagSFWeight", "Problem disabling systematics setting!");
}
if (m_currentVar == "Nominal") {
for (auto pair : btageffweights)
m_weightSysts.push_back({pair.first, pair.second/weight});
}
// Info("computeBTagSFWeight", "event weight: %f", weight);
return weight;
} */
std::pair<int,int> AnalysisReader_hhbbtt :: HiggsTag(const xAOD::Jet *fatjet, std::string wp) {
// LASER: A simplified version of the Higgs tagger due to current limitations in CxAOD Framework
// Input:
// 1) const xAOD::Jet *fatjet [fatjet to tag]
// 2) std::string wp [working point]
// Output:
// 1) std::pair result [result.first = pass/fail tagger, result.second = number of btagged track jets]
// Result codes look like:
// -1: wrong configuration, kill everything
// -2: couldn't get associated track jets
// -3: less than 2 associated track jets
// -4: something went wrong in Laser's logic
// 0: a fatjet that did not pass the mass/substructure tagger cuts
// 1: a fatjet that did pass the mass/substructure tagger cuts
// NB: No muon-in-jet correction applied (due to aforementioned limitations)
std::pair<int,int> result;
// Step 0: check working point and define cut values
float lowmasscut; // low mass window cut
float highmasscut; // high mass window cut
float D2_a0, D2_a1, D2_a2, D2_a3, D2_a4; // D2 fit parameters (4th order polynomial)
if (wp == "loose") {
lowmasscut = 76.;
highmasscut = 146.;
}
else if (wp == "medium") {
lowmasscut = 93.;
highmasscut = 134.;
}
else if (wp == "tight") {
lowmasscut = 93.;
highmasscut = 134.;
D2_a0 = 11.3684217088;
D2_a1 = -0.0834101931325;
D2_a2 = 0.000244968552399;
D2_a3 = -3.09799473883e-07;
D2_a4 = 1.44703493877e-10;
}
else {
if(m_debug) std::cout << "ERROR!!! Provided working point is not defined! It must be either loose, medium, or tight!" << std::endl;
result.first = -1;
return result;
}
// Step 1: get the associated track jets
std::vector<const xAOD::Jet*> trkJets, goodTrkJets;
if (fatjet->getAssociatedObjects<xAOD::Jet>("GhostAntiKt2TrackJet", trkJets)) {
if(m_debug) std::cout << "Debug HiggsTagger: Step 1 in trk jets loos" << std::endl;
int ntrkjets = 0;
for (const xAOD::Jet *trkJ : trkJets) {
if (!trkJ) continue; // if the trackjet is not valid then skip it
if (!(trkJ->pt() / 1000. > 10. && fabs(trkJ->eta()) < 2.5)) continue;
goodTrkJets.push_back(trkJ);
ntrkjets++;
m_histSvc->BookFillHist("HiggsTagger_trkJets_pt", 400, 0, 2000, trkJ->pt()/1e3, m_weight);
m_histSvc->BookFillHist("HiggsTagger_trkJets_MV2c10", 200, -1, 1, Props::MV2c10.get(trkJ), m_weight);
m_histSvc->BookFillHist("HiggsTagger_trkJets_2d", 400, 0, 2000, 200, -1, 1, trkJ->pt()/1e3, Props::MV2c10.get(trkJ), 1.);
}
m_histSvc->BookFillHist("HiggsTagger_trkJets_n", 10, 0, 10, ntrkjets, m_weight);
}
else {
result.first = -2;
return result; // no associated track jets
}
// Step 2: count the number of btagged associated track jets
if (goodTrkJets.size() < 2) {
result.first = -3;
return result;
}
std::sort(goodTrkJets.begin(), goodTrkJets.end(), EventSelection::sort_pt);
const xAOD::Jet *trkJ_lead = goodTrkJets.at(0);
const xAOD::Jet *trkJ_sublead = goodTrkJets.at(1);
int nbtaggedtrkjets = 0;
if (Props::MV2c10.get(trkJ_lead) > m_trkBTagLimit) nbtaggedtrkjets++;
if (Props::MV2c10.get(trkJ_sublead) > m_trkBTagLimit) nbtaggedtrkjets++;
m_histSvc->BookFillHist("HiggsTagger_trkJets_nbtagged", 10, 0, 10, nbtaggedtrkjets, m_weight);
result.second = nbtaggedtrkjets; // how many btagged track jets are there
// Step 3: apply mass window cut
std::string btagregion;
if (result.second == 0) btagregion = "0btag"; // number of btagged track jets defines which region
if (result.second == 1) btagregion = "1btag";
if (result.second >= 2) btagregion = "2btag";
std::cout << "NI: Debug HiggsTagger: Step 3 result should not be negative" << result.second << "btagregion "<< btagregion << std::endl;
float fatjetmass = fatjet->m() / 1000.;
float fatjetD2 = Props::D2.get(fatjet);
float fatjetC2 = Props::C2.get(fatjet);
m_histSvc->BookFillHist("HiggsTagger_premasscut_m", 100, 0, 500, fatjetmass, m_weight);
m_histSvc->BookFillHist("HiggsTagger_premasscut_d2", 100, 0, 5, fatjetD2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_premasscut_c2", 20, 0, 1, fatjetC2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_"+btagregion+"_premasscut_m", 100, 0, 500, fatjetmass, m_weight);
m_histSvc->BookFillHist("HiggsTagger_"+btagregion+"_premasscut_d2", 100, 0, 5, fatjetD2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_"+btagregion+"_premasscut_c2", 20, 0, 1, fatjetC2, m_weight);
if (!(fatjetmass > lowmasscut && fatjetmass < highmasscut)) {
result.first = 0;
return result; // an unsuccessfully tagged fatjet, pass to the control region
}
m_histSvc->BookFillHist("HiggsTagger_postmasscut_d2", 100, 0, 5, fatjetD2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_postmasscut_c2", 20, 0, 1, fatjetC2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_"+btagregion+"_postmasscut_d2", 100, 0, 5, fatjetD2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_"+btagregion+"_postmasscut_c2", 20, 0, 1, fatjetC2, m_weight);
// Step 4: apply substructure cut if we are at the tight working point
if (wp != "tight") {
result.first = 1;
return result; // a succesfully tagged fatjet at the loose or medium working points
}
else {
float D2cut = D2_a0 + (D2_a1 * fatjet->pt() / 1000.) + (D2_a2 * pow(fatjet->pt() / 1000., 2)) + (D2_a3 * pow(fatjet->pt() / 1000., 3)) + (D2_a4 * pow(fatjet->pt()/ 1000., 4));
if (fatjetD2 > D2cut) {
result.first = 1;
m_histSvc->BookFillHist("HiggsTagger_postd2cut_c2", 20, 0, 1, fatjetC2, m_weight);
m_histSvc->BookFillHist("HiggsTagger_"+btagregion+"_postd2cut_c2", 20, 0, 1, fatjetC2, m_weight);
return result; // a successfully tagged fatjet at the tight working point
}
else {
result.first = 0;
return result; // an unsuccessfully tagged fatjet, pass to the control region
}
}
// If you got here, then something went wrong
result.first = -3;
return result; // something went wrong, start yelling
}//end of HiggsTag