-
Notifications
You must be signed in to change notification settings - Fork 4
/
GamHistosFill.C
3070 lines (2778 loc) · 120 KB
/
GamHistosFill.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
#define GamHistosFill_cxx
#include "GamHistosFill.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include "TH1D.h"
#include "TProfile.h"
#include "TProfile2D.h"
#include "TLorentzVector.h"
#include "TStopwatch.h"
#include <iostream>
using namespace std;
//using namespace GamHistosFill;
#include "parsePileUpJSON.C"
bool _gh_debug = false;
bool _gh_debug100 = false;
bool doGamjet = true;
bool doGamjet2 = true;
bool smearJets = false;
// Error counters
int cntErrDR(0);
// Classes to structure sets of histograms and profiles
struct BasicHistos {
TH1D *hn;
TH1D *hxsec;
TProfile *prpt;
TProfile *prbal;
TProfile *prdb;
TProfile *prmpf;
TProfile *prmpf1;
TProfile *prmpfn;
TProfile *prmpfu;
TProfile *prho;
TProfile *pdjes;
TProfile *pjes;
TProfile *pres;
};
class gamjetHistos {
public:
TH1D *hpt13, *hpt13a, *hpt13j;
TProfile *pptg, *pptj;
TProfile *pres, *pjsf, *pm0, *pm2, *pmn, *pmu;
// Resolution
TProfile *pm0x, *pm2x;
// Extra FRS studies
TProfile *pmnu, *pmnx, *pmux, *pmnux;
// Composition
TProfile *prho, *pchf, *pnef, *pnhf;
// Alternative pT bins
TProfile *presa, *pm0a, *pm2a, *pmna, *pmua;
TProfile *presj, *pm0j, *pm2j, *pmnj, *pmuj;
};
class gamjetHistos2 {
public:
// Basic information about the trigger
//string trg;
//int trgpt;
//double ptmin, ptmax, absetamin, absetamax;
TH2D *h2pteta;
TProfile2D *p2res, *p2m0, *p2m2, *p2mn, *p2mu;
TProfile2D *p2m0x, *p2m2x;
// Extra for FSR studies
TProfile2D *p2mnu, *p2mnx, *p2mux, *p2mnux;
//TH2D *h2ptetatc, *h2ptetapf;
//TProfile2D *p2restc, *p2m0tc, *p2m2tc, *p2mntc, *p2mutc; // pT,tag (central)
//TProfile2D *p2respf, *p2m0pf, *p2m2pf, *p2mnpf, *p2mupf; // pT,probe (forward)
// Smearing controls
TProfile2D *p2jsf;//, *p2jsftc, *p2jsfpf;
};
// Helper function to retrieve FactorizedJetCorrector
FactorizedJetCorrector *getFJC(string l1="", string l2="", string res="",
string path="") {
// Set default jet algo
if (l1!="" && !(TString(l1.c_str()).Contains("_AK")))
l1 += "_AK4PFchs";
if (l2!="" && !(TString(l2.c_str()).Contains("_AK")))
l2 += "_AK4PFchs";
if (res!="" && !(TString(res.c_str()).Contains("_AK")))
res += "_AK4PFchs";
// Set default path
if (path=="") path = "CondFormats/JetMETObjects/data";
const char *cd = path.c_str();
const char *cl1 = l1.c_str();
const char *cl2 = l2.c_str();
const char *cres = res.c_str();
string s("");
vector<JetCorrectorParameters> v;
if (l1!=""){
s = Form("%s/%s.txt",cd,cl1);
cout << s << endl << flush;
JetCorrectorParameters *pl1 = new JetCorrectorParameters(s);
v.push_back(*pl1);
}
if (l2!="") {
s = Form("%s/%s.txt",cd,cl2);
cout << s << endl << flush;
JetCorrectorParameters *pl2 = new JetCorrectorParameters(s);
v.push_back(*pl2);
}
if (res!="") {
s = Form("%s/%s.txt",cd,cres);
cout << s << endl << flush;
JetCorrectorParameters *pres = new JetCorrectorParameters(s);
v.push_back(*pres);
}
FactorizedJetCorrector *jec = new FactorizedJetCorrector(v);
return jec;
} // getJFC
void GamHistosFill::Loop()
{
// In a ROOT session, you can do:
// root> .L GamHistosFill.C
// root> GamHistosFill t
// root> t.GetEntry(12); // Fill t data members with entry number 12
// root> t.Show(); // Show values of entry 12
// root> t.Show(16); // Read and show values of entry 16
// root> t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
//Not working in v6.26.06 as is
//ROOT.EnableImplicitMT(); // From Nico on Skype, to parallelize processing
TStopwatch fulltime, laptime;
fulltime.Start();
TDatime bgn;
int nlap(0);
int _ntot(0), _nevents(0), _nbadevents_json(0), _nbadevents_trigger(0);
int _nbadevents_veto(0);
if (true) { // ProcessFast
fChain->SetBranchStatus("*",0); // disable all branches
// Baseline triggers with very high prescale except Photon200
if (is18) {// || is22 || is23) {
fChain->SetBranchStatus("HLT_Photon20",1);
}
if (is16) {
if (!isMC) fChain->SetBranchStatus("HLT_Photon22",1);
if (!isMC) fChain->SetBranchStatus("HLT_Photon30",1);
if (!isMC) fChain->SetBranchStatus("HLT_Photon36",1);
}
if (is17 || is18 || is22 || is23 || is24) {
fChain->SetBranchStatus("HLT_Photon33",1);
fChain->SetBranchStatus("HLT_Photon200",1);
//fChain->SetBranchStatus("HLT_Photon500",1);
//fChain->SetBranchStatus("HLT_Photon600",1);
}
fChain->SetBranchStatus("HLT_Photon50",1);
fChain->SetBranchStatus("HLT_Photon75",1);
fChain->SetBranchStatus("HLT_Photon90",1);
fChain->SetBranchStatus("HLT_Photon120",1);
fChain->SetBranchStatus("HLT_Photon175",1);
// Presumably backup triggers for unprescaled Photon175 or Photon200
if (is16 && !isMC) fChain->SetBranchStatus("HLT_Photon165_HE10",1);
if (is16 && !isMC) fChain->SetBranchStatus("HLT_Photon250_NoHE",1);
fChain->SetBranchStatus("HLT_Photon300_NoHE",1);
// Triggers to recover pT=105-230 GeV range. Efficient, low prescale
// Not active in some of 2018 data (~10%)?
if (is18) {
fChain->SetBranchStatus("HLT_Photon100EB_TightID_TightIso",1); // ok
fChain->SetBranchStatus("HLT_Photon110EB_TightID_TightIso",1); // best
fChain->SetBranchStatus("HLT_Photon120EB_TightID_TightIso",1); // backup
}
if (isRun3) {
fChain->SetBranchStatus("HLT_Photon30EB_TightID_TightIso",1);
fChain->SetBranchStatus("HLT_Photon110EB_TightID_TightIso",1);
fChain->SetBranchStatus("HLT_Photon100EBHE10",1);
}
if (is24) {
fChain->SetBranchStatus("HLT_Photon50EB_TightID_TightIso",1);
fChain->SetBranchStatus("HLT_Photon55EB_TightID_TightIso",1);
fChain->SetBranchStatus("HLT_Photon75EB_TightID_TightIso",1);
fChain->SetBranchStatus("HLT_Photon90EB_TightID_TightIso",1);
}
// Triggers to recover 60-105 GeV range. However, inefficient up to high pT
// Possibly medium HLT cuts not fully consistent with tight ID?
if (is16 && !isMC) {
fChain->SetBranchStatus("HLT_Photon22_R9Id90_HE10_IsoM",1);
fChain->SetBranchStatus("HLT_Photon30_R9Id90_HE10_IsoM",1);
fChain->SetBranchStatus("HLT_Photon36_R9Id90_HE10_IsoM",1);
}
fChain->SetBranchStatus("HLT_Photon50_R9Id90_HE10_IsoM",1);
fChain->SetBranchStatus("HLT_Photon75_R9Id90_HE10_IsoM",1);
fChain->SetBranchStatus("HLT_Photon90_R9Id90_HE10_IsoM",1);
fChain->SetBranchStatus("HLT_Photon120_R9Id90_HE10_IsoM",1);
fChain->SetBranchStatus("HLT_Photon165_R9Id90_HE10_IsoM",1);
// Triggers to recover 30-60 GeV range. Efficient above 30 GeV
if (is17 || is18 || is22 || is23 || is24) {
fChain->SetBranchStatus("HLT_Photon20_HoverELoose",1);
fChain->SetBranchStatus("HLT_Photon30_HoverELoose",1);
}
if (is17 && !isMC) {
fChain->SetBranchStatus("HLT_Photon40_HoverELoose",1);
fChain->SetBranchStatus("HLT_Photon50_HoverELoose",1);
fChain->SetBranchStatus("HLT_Photon60_HoverELoose",1);
}
// JSON filtering, PU reweighing
if (isMC) fChain->SetBranchStatus("Pileup_nTrueInt");
fChain->SetBranchStatus("run",1);
if (!isMC) fChain->SetBranchStatus("luminosityBlock",1);
if (!isMC && debugFiles) fChain->SetBranchStatus("event",1);
if (isRun3) {
// Same cut as for dijet sample
//fChain->SetBranchStatus("Flag_METFilters",1);
// https://twiki.cern.ch/twiki/bin/viewauth/CMS/MissingETOptionalFiltersRun2#Run_3_recommendations
fChain->SetBranchStatus("Flag_goodVertices");
fChain->SetBranchStatus("Flag_globalSuperTightHalo2016Filter");
fChain->SetBranchStatus("Flag_EcalDeadCellTriggerPrimitiveFilter");
fChain->SetBranchStatus("Flag_BadPFMuonFilter");
fChain->SetBranchStatus("Flag_BadPFMuonDzFilter");
fChain->SetBranchStatus("Flag_hfNoisyHitsFilter");
fChain->SetBranchStatus("Flag_eeBadScFilter");
fChain->SetBranchStatus("Flag_ecalBadCalibFilter");
}
else {
// Event filters listing from Sami:
// twiki.cern.ch/twiki/bin/viewauth/CMS/MissingETOptionalFiltersRun2
// #2018_2017_data_and_MC_UL
fChain->SetBranchStatus("Flag_goodVertices",1);
fChain->SetBranchStatus("Flag_globalSuperTightHalo2016Filter",1);
fChain->SetBranchStatus("Flag_HBHENoiseFilter",1);
fChain->SetBranchStatus("Flag_HBHENoiseIsoFilter",1);
fChain->SetBranchStatus("Flag_EcalDeadCellTriggerPrimitiveFilter",1);
fChain->SetBranchStatus("Flag_BadPFMuonFilter",1);
//fChain->SetBranchStatus("Flag_BadPFMuonDzFilter",1); // not in nAOD?
//inputList.("Flag_BadPFMuonDzFilter",1); // new in UL, but part of above?
//inputList.("Flag_BadChargedCandidateFilter",0); // not recommended
//inputList.("Flag_globalTightHalo2016Filter",0); // obsolete?
//inputList.("Flag_CSCTightHaloFilter",0); // obsolete?
if (!is16) {
fChain->SetBranchStatus("Flag_ecalBadCalibFilter",1);//new (add for Sami)
}
//if dataset.isData:
//if (!isMC) {
fChain->SetBranchStatus("Flag_eeBadScFilter",1); // MC added 7 July 2021
//}
}
// MC weights
if (isMC) fChain->SetBranchStatus("genWeight",1);
if (isMC) fChain->SetBranchStatus("nPSWeight",1);
if (isMC) fChain->SetBranchStatus("PSWeight",1);
//if (isMC && !isRun3) fChain->SetBranchStatus("nPSWeight",1);
//if (isMC && !isRun3) fChain->SetBranchStatus("PSWeight",1);
if (!isRun3)
fChain->SetBranchStatus("fixedGridRhoFastjetAll",1);
if (isRun3)
fChain->SetBranchStatus("Rho_fixedGridRhoFastjetAll",1);
//fChain->SetBranchStatus("Rho_fixedGridRhoAll",1);
fChain->SetBranchStatus("PV_npvs",1);
fChain->SetBranchStatus("PV_npvsGood",1);
if (isRun2) {
fChain->SetBranchStatus("ChsMET_pt",1);
fChain->SetBranchStatus("ChsMET_phi",1);
}
if (isRun3) {
fChain->SetBranchStatus("RawPuppiMET_pt",1);
fChain->SetBranchStatus("RawPuppiMET_phi",1);
}
fChain->SetBranchStatus("nPhoton",1);
fChain->SetBranchStatus("Photon_pt",1);
fChain->SetBranchStatus("Photon_eta",1);
fChain->SetBranchStatus("Photon_phi",1);
if (!(is22||is23||is24)) fChain->SetBranchStatus("Photon_mass",1);
fChain->SetBranchStatus("Photon_hoe",1);
if (is17 && isMC && isQCD)
fChain->SetBranchStatus("Photon_cutBasedBitmap",1);
else
fChain->SetBranchStatus("Photon_cutBased",1);
fChain->SetBranchStatus("Photon_jetIdx",1);
fChain->SetBranchStatus("Photon_seedGain",1);
if (b_Photon_eCorr)
fChain->SetBranchStatus("Photon_eCorr",1); // not in 2016
fChain->SetBranchStatus("Photon_energyErr",1);
fChain->SetBranchStatus("Photon_r9",1);
fChain->SetBranchStatus("nJet",1);
fChain->SetBranchStatus("Jet_pt",1);
fChain->SetBranchStatus("Jet_eta",1);
fChain->SetBranchStatus("Jet_phi",1);
fChain->SetBranchStatus("Jet_mass",1);
fChain->SetBranchStatus("Jet_rawFactor",1);
fChain->SetBranchStatus("Jet_area",1);
fChain->SetBranchStatus("Jet_jetId",1);
// PF composition
fChain->SetBranchStatus("Jet_chHEF",1);
fChain->SetBranchStatus("Jet_neHEF",1);
fChain->SetBranchStatus("Jet_neEmEF",1);
fChain->SetBranchStatus("Jet_chEmEF",1);
fChain->SetBranchStatus("Jet_muEF",1);
//if (!isRun3) fChain->SetBranchStatus("Jet_chFPV0EF",1);
if (isMC) fChain->SetBranchStatus("Jet_genJetIdx",1);
if (!isRun3) fChain->SetBranchStatus("Jet_btagDeepB",1);
if (!isRun3) fChain->SetBranchStatus("Jet_btagDeepC",1);
if (!isRun3) fChain->SetBranchStatus("Jet_qgl",1);
//
if (isRun3) fChain->SetBranchStatus("Jet_btagDeepFlavB",1);
if (isRun3) fChain->SetBranchStatus("Jet_btagDeepFlavCvB",1);
if (isRun3) fChain->SetBranchStatus("Jet_btagDeepFlavCvL",1);
if (isRun3) fChain->SetBranchStatus("Jet_btagDeepFlavQG",1);
//if (isMC && isRun3) {
if (isMG) {
fChain->SetBranchStatus("LHE_HT",1);
cout << "Running over MadGraph HT bins" << endl;
}
/*
fChain->SetBranchStatus("nLHEPart",1);
fChain->SetBranchStatus("LHEPart_pt",1);
fChain->SetBranchStatus("LHEPart_eta",1);
fChain->SetBranchStatus("LHEPart_phi",1);
fChain->SetBranchStatus("Jet_mass",1);
fChain->SetBranchStatus("LHEPart_status",1);
fChain->SetBranchStatus("LHEPart_pdgId",1);
*/
// Photon pT correlates with Generator_binvar (pThat) in P8 PtFlat,
// and with LHEPart_pt[2] (parton photon) in MadGraph HT samples, but
// MadGraph has plenty of uncorrelated soft and hard photons as well
if (isMC) {
if (!isQCD) {
fChain->SetBranchStatus("nGenIsolatedPhoton",1);
fChain->SetBranchStatus("GenIsolatedPhoton_pt",1);
fChain->SetBranchStatus("GenIsolatedPhoton_eta",1);
fChain->SetBranchStatus("GenIsolatedPhoton_phi",1);
fChain->SetBranchStatus("GenIsolatedPhoton_mass",1);
}
else
nGenIsolatedPhoton = 0;
}
if (isMC) {
fChain->SetBranchStatus("nGenJet",1);
fChain->SetBranchStatus("GenJet_pt",1);
fChain->SetBranchStatus("GenJet_eta",1);
fChain->SetBranchStatus("GenJet_phi",1);
fChain->SetBranchStatus("GenJet_mass",1);
fChain->SetBranchStatus("GenJet_partonFlavour",1);
}
}
// Select appropriate L1RC for type-I MET L1L2L3-RC calculation
FactorizedJetCorrector *jecl1rc(0), *jec(0);
string& ds = dataset;
if (ds=="2016B") jecl1rc = getFJC("Summer19UL16APV_RunBCD_V7_DATA_L1RC");
if (ds=="2016C") jecl1rc = getFJC("Summer19UL16APV_RunBCD_V7_DATA_L1RC");
if (ds=="2016D") jecl1rc = getFJC("Summer19UL16APV_RunBCD_V7_DATA_L1RC");
if (ds=="2016BCD") jecl1rc = getFJC("Summer19UL16APV_RunBCD_V7_DATA_L1RC");
if (ds=="2016E") jecl1rc = getFJC("Summer19UL16APV_RunEF_V7_DATA_L1RC");
if (ds=="2016F") jecl1rc = getFJC("Summer19UL16APV_RunEF_V7_DATA_L1RC");
if (ds=="2016EF") jecl1rc = getFJC("Summer19UL16APV_RunEF_V7_DATA_L1RC");
//if (ds=="2016BCDEF")jecl1rc=getFJC("Summer19UL16APV_RunBCDEF_V7_DATA_L1RC");
if (ds=="2016FG") jecl1rc = getFJC("Summer19UL16_RunFGH_V7_DATA_L1RC");
if (ds=="2016H") jecl1rc = getFJC("Summer19UL16_RunFGH_V7_DATA_L1RC");
if (ds=="2016FGH") jecl1rc = getFJC("Summer19UL16_RunFGH_V7_DATA_L1RC");
if (ds=="2017B") jecl1rc = getFJC("Summer19UL17_RunB_V5_DATA_L1RC");
if (ds=="2017C") jecl1rc = getFJC("Summer19UL17_RunC_V5_DATA_L1RC");
if (ds=="2017D") jecl1rc = getFJC("Summer19UL17_RunD_V5_DATA_L1RC");
if (ds=="2017E") jecl1rc = getFJC("Summer19UL17_RunE_V5_DATA_L1RC");
if (ds=="2017F") jecl1rc = getFJC("Summer19UL17_RunF_V5_DATA_L1RC");
//if (ds=="2017BCDEF")jecl1rc=getFJC("Summer19UL17_RunBCDEF_V5_DATA_L1RC");
if (ds=="2018A") jecl1rc = getFJC("Summer19UL18_RunA_V5_DATA_L1RC");
if (ds=="2018B") jecl1rc = getFJC("Summer19UL18_RunB_V5_DATA_L1RC");
if (ds=="2018C") jecl1rc = getFJC("Summer19UL18_RunC_V5_DATA_L1RC");
if (ds=="2018D") jecl1rc = getFJC("Summer19UL18_RunD_V5_DATA_L1RC");
if (ds=="2018A1") jecl1rc = getFJC("Summer19UL18_RunA_V5_DATA_L1RC");
if (ds=="2018A2") jecl1rc = getFJC("Summer19UL18_RunA_V5_DATA_L1RC");
if (ds=="2018D1") jecl1rc = getFJC("Summer19UL18_RunD_V5_DATA_L1RC");
if (ds=="2018D2") jecl1rc = getFJC("Summer19UL18_RunD_V5_DATA_L1RC");
if (ds=="2018D3") jecl1rc = getFJC("Summer19UL18_RunD_V5_DATA_L1RC");
if (ds=="2018D4") jecl1rc = getFJC("Summer19UL18_RunD_V5_DATA_L1RC");
//if (ds=="2018ABCD")jecl1rc=getFJC("Summer19UL18_RunABCD_V5_DATA_L1RC");
if (isRun3) {
//if (isMC)
//jecl1rc = getFJC("Winter23Prompt23_V2_MC_L1RC_AK4PFchs");
//else
//jecl1rc = getFJC("Winter23Prompt23_RunC_V2_DATA_L1RC_AK4PFchs");
jecl1rc = 0;
}
if (ds=="2016P8") jecl1rc = getFJC("Summer19UL16_V7_MC_L1RC");
if (ds=="2016APVP8") jecl1rc = getFJC("Summer19UL16APV_V7_MC_L1RC");
if (ds=="2017P8") jecl1rc = getFJC("Summer19UL17_V5_MC_L1RC");
if (ds=="2018P8") jecl1rc = getFJC("Summer19UL18_V5_MC_L1RC");
//
if (ds=="2016QCD") jecl1rc = getFJC("Summer19UL16_V7_MC_L1RC");
if (ds=="2016APVQCD") jecl1rc = getFJC("Summer19UL16APV_V7_MC_L1RC");
if (ds=="2017QCD") jecl1rc = getFJC("Summer19UL17_V5_MC_L1RC");
if (ds=="2018QCD") jecl1rc = getFJC("Summer19UL18_V5_MC_L1RC");
assert(jecl1rc || isRun3);
// FactorizedJetCorrector for redoing JEC on the fly.
//2022
if (ds=="2022C") {
jec = getFJC("", "Summer22Run3_V1_MC_L2Relative_AK4PUPPI",
//"Run22CD-22Sep2023_DATA_L2L3Residual_AK4PFPuppi");
"Summer22-22Sep2023_Run2022CD_V3_DATA_L2L3Residual_AK4PFPuppi");
}
if (ds=="2022D") {
jec = getFJC("", "Summer22Run3_V1_MC_L2Relative_AK4PUPPI",
//"Run22CD-22Sep2023_DATA_L2L3Residual_AK4PFPuppi");
"Summer22-22Sep2023_Run2022CD_V3_DATA_L2L3Residual_AK4PFPuppi");
}
if (ds=="2022E") {
jec = getFJC("", "Summer22EEVetoRun3_V1_MC_L2Relative_AK4PUPPI",
//"Run22E-22Sep2023_DATA_L2L3Residual_AK4PFPuppi");
"Summer22EE-22Sep2023_Run2022E_V3_DATA_L2L3Residual_AK4PFPuppi");
}
if (ds=="2022F") {
jec = getFJC("", "Summer22EEVetoRun3_V1_MC_L2Relative_AK4PUPPI",
//"Run22F-Prompt_DATA_L2L3Residual_AK4PFPuppi");
"Summer22EEPrompt22_Run2022F_V3_DATA_L2L3Residual_AK4PFPuppi");
}
if (ds=="2022G") {
jec = getFJC("", "Summer22EEVetoRun3_V1_MC_L2Relative_AK4PUPPI",
//"Run22G-Prompt_DATA_L2L3Residual_AK4PFPuppi");
"Summer22EEPrompt22_Run2022G_V3_DATA_L2L3Residual_AK4PFPuppi");
}
//22/23 MC
if (ds=="2022P8" || ds=="2022QCD") {
jec = getFJC("", "Summer22Run3_V1_MC_L2Relative_AK4PUPPI","");
}
if (ds=="2022EEP8" || ds=="2022EEQCD") {
jec = getFJC("", "Summer22EEVetoRun3_V1_MC_L2Relative_AK4PUPPI", "");
}
if (dataset=="Summer23") {
jec = getFJC("", "Winter23Prompt23_V2_MC_L2Relative_AK4PFPuppi", "");
assert(false); // not yet available
}
//2023
if (ds=="2023B" || ds=="2023Cv123") {
jec = getFJC("", "Summer22Run3_V1_MC_L2Relative_AK4PUPPI",
//"Run23C123-Prompt_DATA_L2L3Residual_AK4PFPuppi");
"Summer22Prompt23_Run2023Cv123_V3_DATA_L2L3Residual_AK4PFPUPPI");
}
if (ds=="2023Cv4") {
jec = getFJC("", "Summer22Run3_V1_MC_L2Relative_AK4PUPPI",
//"Run23C4-Prompt_DATA_L2L3Residual_AK4PFPuppi");
"Summer22Prompt23_Run2023Cv4_V3_DATA_L2L3Residual_AK4PFPUPPI");
}
if (ds=="2023D") {
//jec = getFJC("", "Summer22Run3_V1_MC_L2Relative_AK4PUPPI",
// "Summer22Prompt23_Run2023D_V3_DATA_L2L3Residual_AK4PFPUPPI");
jec = getFJC("", "Summer23BPixPrompt23_V1_MC_L2Relative_AK4PFPuppi",
"Summer23BPixPrompt23_RunD_V1_DATA_L2L3Residual_AK4PFPuppi");
}
// 2024
if (ds=="2024B") {
jec = getFJC("", "Summer23BPixPrompt23_V1_MC_L2Relative_AK4PFPuppi",
"Summer23BPixPrompt23_RunD_V1_DATA_L2L3Residual_AK4PFPuppi");
}
assert(jec);
string sera("");
if (ds=="2016APVP8" || ds=="2016APVQCD") sera = "2016APV";
if (ds=="2016P8" || ds=="2016QCD") sera = "2016FGH";
if (ds=="2017P8" || ds=="2017QCD") sera = "2017";
if (ds=="2018P8" || ds=="2018QCD") sera = "2018";
if (ds=="2022P8" || ds=="2022QCD") sera = "2022";
if (ds=="2022EEP8" || ds=="2022EEQCD") sera = "2022EE";
if (ds=="2023P8" || ds=="2023QCD") sera = "2023";
//
if (ds=="2016B"||ds=="2016C"||ds=="2016D"||ds=="2016BCD"||
ds=="2016E"||ds=="2016F"||ds=="2016EF"||ds=="2016BCDEF") sera = "2016APV";
if (ds=="2016FG"||ds=="2016H"||ds=="2016FGH") sera = "2016FGH";
if (ds=="2017B"||ds=="2017C"||ds=="2017D"||ds=="2017E"||ds=="2017F"||
ds=="2017BCDEF") sera = "2017";
if (ds=="2018A"||ds=="2018A1"||ds=="2018A2"||ds=="2018B"||ds=="2018C"||
ds=="2018D"||ds=="2018D1"||ds=="2018D2"||ds=="2018D3"||ds=="2018D4")
sera = "2018";
//
if (ds=="2022P8" || ds=="2022QCD") sera = "2022";
if (ds=="2022EEP8" || ds=="2022EEQCD") sera = "2022EE";
if (ds=="2022C" || ds=="2022D") sera ="2022";
if (ds=="2022E" || ds=="2022F" || ds=="2022G") sera = "2022EE";
if (ds=="2023B" || ds=="2023Cv123" || ds=="2023Cv4" || ds=="2023D")
sera = "2023";
if (ds=="2024B")
sera = "2024";
assert(sera!="");
// Load JSON files
if (TString(ds.c_str()).Contains("2016"))
LoadJSON("files/Cert_271036-284044_13TeV_Legacy2016_Collisions16_JSON.txt");
if (TString(ds.c_str()).Contains("2017"))
LoadJSON("files/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt");
if (TString(ds.c_str()).Contains("2018"))
LoadJSON("files/Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt");
if (TString(ds.c_str()).Contains("2022"))
LoadJSON("files/Cert_Collisions2022_355100_362760_Golden.json");
if (TString(ds.c_str()).Contains("2023"))
LoadJSON("files/Cert_Collisions2023_366442_370790_Golden.json");
if (TString(ds.c_str()).Contains("2024"))
LoadJSON("files/Collisions24_13p6TeV_378981_379154_DCSOnly_TkPx.json");
// Load pileup JSON
parsePileUpJSON("files/pileup_ASCII_UL16-UL18.txt");
// Load pileup profiles
LoadPU();
// Load veto maps
// JECDatabase/jet_veto_maps/Summer19UL16_V0/hotjets-UL16.root
// JECDatabase/jet_veto_maps/Summer19UL17_V2/hotjets-UL17_v2.root
// JECDatabase/jet_veto_maps/Summer19UL18_V1/hotjets-UL18.root
TFile *fjv(0);
if (TString(ds.c_str()).Contains("2016"))
fjv = new TFile("files/hotjets-UL16.root","READ");
if (TString(ds.c_str()).Contains("2017"))
fjv = new TFile("files/hotjets-UL17_v2.root","READ");
if (TString(ds.c_str()).Contains("2018"))
fjv = new TFile("files/hotjets-UL18.root","READ");
if (TString(ds.c_str()).Contains("2022")) {
if (TString(ds.c_str()).Contains("2022C") ||
TString(ds.c_str()).Contains("2022D") ||
TString(ds.c_str()).Contains("2022P8") ||
TString(ds.c_str()).Contains("2022QCD"))
fjv = new TFile("files/jetveto2022CD.root","READ");
if (TString(ds.c_str()).Contains("2022E") || // incl. EEP8
TString(ds.c_str()).Contains("2022F") ||
TString(ds.c_str()).Contains("2022G") ||
TString(ds.c_str()).Contains("2022EEP8") ||
TString(ds.c_str()).Contains("2022EEQCD") )
fjv = new TFile("files/jetveto2022EFG.root","READ");
}
if (TString(ds.c_str()).Contains("2023")) {
if (TString(ds.c_str()).Contains("2023B") ||
TString(ds.c_str()).Contains("2023C"))
fjv = new TFile("files/jetveto2023BC.root","READ");
if (TString(ds.c_str()).Contains("2023D"))
fjv = new TFile("files/jetveto2023D.root","READ");
}
if (TString(ds.c_str()).Contains("2024")) {
if (TString(ds.c_str()).Contains("2024B"))
fjv = new TFile("files/jetveto2023D.root","READ"); // placeholder
}
if (!fjv) cout << "Jetvetomap file not found for " << ds << endl << flush;
assert(fjv);
// Veto lists for different years (NB: extra MC map for UL16):
// h2hot_ul16_plus_hbm2_hbp12_qie11 + h2hot_mc (for UL16)
// h2hot_ul17_plus_hep17_plus_hbpw89 (UL17)
// h2hot_ul18_plus_hem1516_and_hbp2m1 (UL18)
TH2D *h2jv = 0;
if (TString(ds.c_str()).Contains("2016")) {
h2jv = (TH2D*)fjv->Get("h2hot_ul16_plus_hbm2_hbp12_qie11");
assert(h2jv);
TH2D *h2mc = (TH2D*)fjv->Get("h2hot_mc");
assert(h2mc);
h2jv->Add(h2mc);
}
if (TString(ds.c_str()).Contains("2017"))
h2jv = (TH2D*)fjv->Get("h2hot_ul17_plus_hep17_plus_hbpw89");
if (TString(ds.c_str()).Contains("2018"))
h2jv = (TH2D*)fjv->Get("h2hot_ul18_plus_hem1516_and_hbp2m1");
if (TString(ds.c_str()).Contains("2022") ||
TString(ds.c_str()).Contains("2023") ||
TString(ds.c_str()).Contains("2024"))
h2jv = (TH2D*)fjv->Get("jetvetomap");
if (!h2jv) cout << "Jetvetomap histo not found for " << ds << endl << flush;
assert(h2jv);
// Setup B and C tagging thresholds according to Z+jet settings (Sami)
double bthr(0.7527), cthr(0.3985), frac(0.5);
if (TString(ds.c_str()).Contains("2016")) {
//btagDeepB->set("2016",0.2217,0.6321,0.8953);
//btagDeepC->set("2016",-0.48,-0.1,-0.1+frac*(0.69+0.1));
//bthr = 0.8953; // tight
bthr = 0.6321; // medium
cthr = -0.1+frac*(0.69+0.1);
}
if (TString(ds.c_str()).Contains("2017")) {
//btagDeepB->set("2017",0.1522,0.4941,0.8001);
//btagDeepC->set("2017",0.05,0.15,0.15+frac*(0.8-0.15));
//bthr = 0.8001; // tight
bthr = 0.4941; // medium
cthr = 0.15+frac*(0.8-0.15);
}
if (TString(ds.c_str()).Contains("2018")) {
//btagDeepB->set("2018",0.1241,0.4184,0.7527);
//btagDeepC->set("2018",0.04,0.137,0.137+frac*(0.66-0.137));
//bthr = 0.7527; // tight
bthr = 0.4184; // medium
cthr = 0.137+frac*(0.66-0.137);
}
if (TString(ds.c_str()).Contains("22") ||
TString(ds.c_str()).Contains("23")) {
// Copy of 2018
bthr = 0.4184;
cthr = 0.137+frac*(0.66-0.137);
}
// Create histograms. Copy format from existing files from Lyon
// Keep only histograms actually used by global fit (reprocess.C)
TDirectory *curdir = gDirectory;
TFile *fout = new TFile(Form("rootfiles/GamHistosFill_%s_%s_%s.root",
isMC ? "mc" : "data",
dataset.c_str(), version.c_str()),
"RECREATE");
assert(fout && !fout->IsZombie());
// Original gamma+jet binning
// old bin trigger edges (20,30,60,85,*95*,105,130,230)
//double vx[] = {15, 20, 25, 30, 35, 40, 50, 60, 70, 85, 105, 130, 175, 230,
// 300, 400, 500, 600, 700, 850, 1000, 1200, 1450, 1750};
// 22-23 binning
double vx[] = {15, 20, 25, 30, 35, 40, 50, 60, 75, 90, 110, 130, 175, 230,
300, 400, 500, 600, 700, 850, 1000, 1200, 1450, 1750,
2100, 2500, 3000};
const int nx = sizeof(vx)/sizeof(vx[0])-1;
// L2L3Res eta binning
double vy[] = {-5.191, -3.839, -3.489, -3.139, -2.964, -2.853, -2.650,
-2.500, -2.322, -2.172, -1.930, -1.653, -1.479, -1.305,
-1.044, -0.783, -0.522, -0.261, 0.000, 0.261, 0.522, 0.783,
1.044, 1.305, 1.479, 1.653, 1.930, 2.172, 2.322, 2.500,
2.650, 2.853, 2.964, 3.139, 3.489, 3.839, 5.191};
const int ny = sizeof(vy)/sizeof(vy[0])-1;
string dir = (isMC ? "MC" : "DATA");
vector<pair<double,double> > etas;
etas.push_back(make_pair<double,double>(0,1.305));
etas.push_back(make_pair<double,double>(0,2.500));
vector<double> alphas;
alphas.push_back(1.00);
alphas.push_back(0.30);
alphas.push_back(0.20);
alphas.push_back(0.15);
alphas.push_back(0.10);
alphas.push_back(0.50);
// Setup HT bin weighting and monitoring
TH1D *hxsec(0), *hnevt(0), *hsumw(0), *hLHE_HT(0), *hHT(0);
//double vht_gam[] = {0, 25, 50, 100, 200, 300, 500, 700, 1000, 1500, 2000, 6500};
double vht_gam[] = {0, 40, 70, 100, 200, 400, 600, 6500}; // G-4Jets
const int nht_gam = sizeof(vht_gam)/sizeof(vht_gam[0])-1;
int nMG_gam(0);
double wMG_gam(0);
if (isMG && !isQCD) {
hxsec = new TH1D("hxsec",";H_{T} (GeV);pb",nht_gam,vht_gam);
hnevt = new TH1D("hnevt",";H_{T} (GeV);N_{evt}",nht_gam,vht_gam);
hsumw = new TH1D("hsumw",";H_{T} (GeV);Sum(weights)",nht_gam,vht_gam);
hLHE_HT = new TH1D("hLHE_HT",";H_{T} (GeV);N_{evt} (unweighted)",
nht_gam,vht_gam);
hHT = new TH1D("hHT",";H_{T} (GeV);N_{evt} (weighted)",2485,15,2500);
// Reference number of events, retrieved manuallay with
// TChain c("Events"); c.AddFile("<path to files>/*.root"); c.GetEntries();
// Also re-calculated this code before event loop when needed
//int vnevt[nht] = {0, 0, 11197186, 23002929, 17512439, 16405924, 14359110,
// 13473185, 4365993, 2944561, 1836165};
int vnevt[7] = {1, 6862, 7213, 5825, 6575, 3185, 2815}; // 2022EEP8 (local)
double vsumw[7] = {0, 5.277e+08, 3.126e+08, 2.698e+08, 7.937e+07, 4.976e+06, 1.596e+06}; // 2022EEP8 (local)
for (int i = 0; i != nht_gam; ++i) {
hnevt->SetBinContent(i+1, vnevt[i]);
nMG_gam += vnevt[i];
hsumw->SetBinContent(i+1, vsumw[i]);
wMG_gam += vsumw[i];
}
cout << "Loaded (local) MadGraph event numbers ("
<< nMG_gam << ", sumw=" << wMG_gam << ")" << endl << flush;
// xsec from jetphys/settings.h_template
//double vxsec[nht] = {0, 0, 246300000.*23700000./28060000., 23700000,
// 1547000, 322600, 29980, 6334, 1088, 99.11, 20.23};
// pT^-4
//double vxsec[nht] = {0, 1, 1.07e-1, 2.56e-2, 1.60e-3, 1.00e-4, 1.98e-5};
// pT^-3
//double vxsec[nht] = {0, 1, 1.86e-1, 6.40e-2, 8.00e-3, 1.00e-3, 2.97e-4};
// pT^-2
//double vxsec[nht] = {0, 1, 3.27e-1, 1.60e-1, 4.00e-2, 1.00e-2, 4.44e-3};
// pT^-2 + fine tuning on hHT histogram (a*pT^b fits at boundary)
//double k70 = 5056./3181.;
//double k100 = 1475./831.3 * k70;
//double k200 = 106.8/124.3 * k100;
//double k400 = 9.339/21.11 * k200;
//double k600 = 3.622/5.122 * k400;
//double vxsec[nht] = {0, 1, k70*3.27e-1, k100*1.60e-1, k200*4.00e-2,
// k400*1.00e-2, k600*4.44e-3};
//double vxsec[7] = {0, 2.727, 1.417, 1.23, 0.2643, 0.02923, 0.009177}; // 2022EEP8 hand-adjusted, including vxsec[i] *= 4./1.467; for above
// Values from Laurent Thomas, 20 Sep 2023, based on
// https://twiki.cern.ch/twiki/bin/viewauth/CMS/HowToGenXSecAnalyzer#Running_the_GenXSecAnalyzer_on_a
double vxsec[nht_gam] = {0, 1.524e+04, 8.111e+03, 7.327e+03, 1.541e+03,
1.676e+02, 5.439e+01}; // xsec in pb
cout << Form("double vxsec[%d] = {",nht_gam);
for (int i = 0; i != nht_gam; ++i) {
//vxsec[i] *= 1.7893701e-4; // match 4to70 to 2.727 for 2022C test file
hxsec->SetBinContent(i+1, vxsec[i]);
cout << Form("%s%1.4g",i==0 ? "" : ", ", vxsec[i]);
}
cout << "}; // 2022EEP8 hand-adjusted" << endl << flush;
}
// Setup HT bin weighting and monitoring for QCD
double vht_qcd2[] =
{0, 25, 50, 100, 200, 300, 500, 700, 1000, 1500, 2000, 6500};
const int nht_qcd2 = sizeof(vht_qcd2)/sizeof(vht_qcd2[0])-1;
double vht_qcd3[] =
{0, 40, 70, 100, 200, 400, 600, 800, 1000, 1200, 1500, 2000, 6800};
const int nht_qcd3 = sizeof(vht_qcd3)/sizeof(vht_qcd3[0])-1;
const double *vht_qcd = (isRun3 ? &vht_qcd3[0] : &vht_qcd2[0]);
const int nht_qcd = (isRun3 ? nht_qcd3 : nht_qcd2);
int nMG_qcd(0);
double wMG_qcd(0);
if (isMG && isQCD) {
hxsec = new TH1D("hxsec",";H_{T} (GeV);pb",nht_qcd,vht_qcd);
hnevt = new TH1D("hnevt",";H_{T} (GeV);N_{evt}",nht_qcd,vht_qcd);
hsumw = new TH1D("hsumw",";H_{T} (GeV);Sum of weights",nht_qcd,vht_qcd);
hLHE_HT = new TH1D("hLHE_HT",";H_{T} (GeV);N_{evt} (unweighted)",
nht_qcd,vht_qcd);
//hLHE_HTw = new TH1D("hLHE_HTw",";H_{T} (GeV);N_{evt} (weighted)",
// nht_qcd,vht_qcd);
hHT = new TH1D("hHT",";H_{T} (GeV);N_{evt} (weighted)",2485,15,2500);
// Reference number of events, retrieved manuallay with
// TChain c("Events"); c.AddFile("<path to files>/*.root"); c.GetEntries();
// Also re-calculated this code before event loop when needed
int vnevt2[nht_qcd2] =
{0, 0, 11197186, 23002929, 17512439, 16405924, 14359110,
13473185, 4365993, 2944561, 1836165};
//int vnevt3[nht3] = {0, 9929, 26573, 16411, 10495, 8260, 7929, 10082, 14390, 6548, 6250}; // Summer22MG, local files
int vnevt3[nht_qcd3] =
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // Summer22MG, local files
int vnwgt3[nht_qcd3] =
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // Summer22MG, local files
const int *vnevt = (isRun3 ? &vnevt3[0] : &vnevt2[0]);
const int *vnwgt = (isRun3 ? &vnwgt3[0] : &vnevt2[0]);
for (int i = 0; i != nht_qcd; ++i) {
hnevt->SetBinContent(i+1, vnevt[i]);
hsumw->SetBinContent(i+1, vnwgt[i]);
nMG_qcd += vnevt[i];
wMG_qcd += vnwgt[i];
}
cout << "Loaded Hefaistos MadGraph event numbers ("
<< nMG_qcd << ")" << endl << flush;
// xsec from jetphys/settings.h_template
double vxsec2[nht_qcd2] =
{0, 0, 246300000.*23700000./28060000., 23700000,
1547000, 322600, 29980, 6334, 1088, 99.11, 20.23};
// Run3 xsec from Mikel Mendizabal, MatterMost 16 Oct 2023
double vxsec3[nht_qcd3] =
{0, 3.136e+08,
5.883e+07, //5.807e+07 * 3478241.4 / 5305581.5, // HT 70to100
2.520e+07, 1.936e+06, 9.728e+04,
1.323e+04, //3.044e+04, //HT 60to800
3.027e+03, 8.883e+02, 3.834e+02, 1.253e+02, 2.629e+01};
const double *vxsec = (isRun3 ? &vxsec3[0] : &vxsec2[0]);
for (int i = 0; i != nht_qcd; ++i) {
hxsec->SetBinContent(i+1, vxsec[i]);
}
} // isMG && isQCD
const double *vht = (isMG ? (isQCD ? &vht_qcd[0] : &vht_gam[0]) : 0);
const int nht = (isMG ? (isQCD ? nht_qcd : nht_gam) : 0);
int nMG = (isMG ? (isQCD ? nMG_qcd : nMG_gam) : 0);
const int wMG = (isMG ? (isQCD ? wMG_qcd : wMG_gam) : 0);
// PF composition plots stored in a separate directory
fout->mkdir("pf");
fout->cd("pf");
TH2D *h2pteta = new TH2D("h2pteta","",nx,vx,ny,vy);
TProfile *pabseta = new TProfile("pabseta","",nx,vx);
// 1D composition and response
TProfile *pdb = new TProfile("pdb","",nx,vx);
TProfile *pmpf = new TProfile("pmpf","",nx,vx);
TProfile *pchf = new TProfile("pchf","",nx,vx);
TProfile *pnhf = new TProfile("pnhf","",nx,vx);
TProfile *pnef = new TProfile("pnef","",nx,vx);
TProfile *pcef = new TProfile("pcef","",nx,vx);
TProfile *pmuf = new TProfile("pmuf","",nx,vx);
TProfile *ppuf = new TProfile("ppuf","",nx,vx);
// for (int i = 0; i != 72; ++i) cout << Form("%1.3f, ",-TMath::Pi()+i*TMath::TwoPi()/72.); cout << endl;
const int nphi = 72;
const double vphi[nphi+1] =
{-3.142, -3.054, -2.967, -2.880, -2.793, -2.705, -2.618, -2.531, -2.443,
-2.356, -2.269, -2.182, -2.094, -2.007, -1.920, -1.833, -1.745, -1.658,
-1.571, -1.484, -1.396, -1.309, -1.222, -1.134, -1.047, -0.960, -0.873,
-0.785, -0.698, -0.611, -0.524, -0.436, -0.349, -0.262, -0.175, -0.087,
0.000, 0.087, 0.175, 0.262, 0.349, 0.436, 0.524, 0.611, 0.698, 0.785,
0.873, 0.960, 1.047, 1.134, 1.222, 1.309, 1.396, 1.484, 1.571, 1.658,
1.745, 1.833, 1.920, 2.007, 2.094, 2.182, 2.269, 2.356, 2.443, 2.531,
2.618, 2.705, 2.793, 2.880, 2.967, 3.054,3.142};
// 2D composition and response
TProfile2D *p2db = new TProfile2D("p2db","",ny,vy,nphi,vphi);
TProfile2D *p2mpf = new TProfile2D("p2mpf","",ny,vy,nphi,vphi);
TProfile2D *p2chf = new TProfile2D("p2chf","",ny,vy,nphi,vphi);
TProfile2D *p2nhf = new TProfile2D("p2nhf","",ny,vy,nphi,vphi);
TProfile2D *p2nef = new TProfile2D("p2nef","",ny,vy,nphi,vphi);
TProfile2D *p2cef = new TProfile2D("p2cef","",ny,vy,nphi,vphi);
TProfile2D *p2muf = new TProfile2D("p2muf","",ny,vy,nphi,vphi);
TProfile2D *p2puf = new TProfile2D("p2puf","",ny,vy,nphi,vphi);
// Run control plots stored in a separate directory
fout->mkdir("runs");
fout->cd("runs");
// Time stability of xsec
TH1D *pr30n = new TH1D("pr30n",";Run;N_{events};",26000,355000.5,381000.5);
TH1D *pr50n = new TH1D("pr50n",";Run;N_{events};",26000,355000.5,381000.5);
TH1D *pr110n = new TH1D("pr110n",";Run;N_{events};",26000,355000.5,381000.5);
TH1D *pr230n = new TH1D("pr230n",";Run;N_{events};",26000,355000.5,381000.5);
TH1D *prg1n = new TH1D("prg1n",";Run;N_{events};",26000,355000.5,381000.5);
// Time stability of JEC
TProfile *pr30b = new TProfile("pr30b",";Run;BAL;",26000,355000.5,381000.5);
TProfile *pr50b = new TProfile("pr50b",";Run;BAL;",26000,355000.5,381000.5);
TProfile *pr110b = new TProfile("pr110b",";Run;BAL;",26000,355000.5,381000.5);
TProfile *pr230b = new TProfile("pr230b",";Run;BAL;",26000,355000.5,381000.5);
TProfile *prg1b = new TProfile("prg1b",";Run;BAL;",26000,355000.5,381000.5);
TProfile *pr30m = new TProfile("pr30m",";Run;MPF;",26000,355000.5,381000.5);
TProfile *pr50m = new TProfile("pr50m",";Run;MPF;",26000,355000.5,381000.5);
TProfile *pr110m = new TProfile("pr110m",";Run;MPF;",26000,355000.5,381000.5);
TProfile *pr230m = new TProfile("pr230m",";Run;MPF;",26000,355000.5,381000.5);
TProfile *prg1m = new TProfile("prg1m",";Run;MPF;",26000,355000.5,381000.5);
// Time stability of PF composition
TProfile *pr30chf = new TProfile("pr30chf",";Run;CHF;",26000,355000.5,381000.5);
TProfile *pr50chf = new TProfile("pr50chf",";Run;CHF;",26000,355000.5,381000.5);
TProfile *pr110chf = new TProfile("pr110chf",";Run;CHF;",26000,355000.5,381000.5);
TProfile *pr230chf = new TProfile("pr230chf",";Run;CHF;",26000,355000.5,381000.5);
TProfile *prg1chf = new TProfile("prg1chf",";Run;CHF;",26000,355000.5,381000.5);
//
TProfile *pr30nhf = new TProfile("pr30nhf",";Run;NHF;",26000,355000.5,381000.5);
TProfile *pr50nhf = new TProfile("pr50nhf",";Run;NHF;",26000,355000.5,381000.5);
TProfile *pr110nhf = new TProfile("pr110nhf",";Run;NHF;",26000,355000.5,381000.5);
TProfile *pr230nhf = new TProfile("pr230nhf",";Run;NHF;",26000,355000.5,381000.5);
TProfile *prg1nhf = new TProfile("prg1nhf",";Run;NHF;",26000,355000.5,381000.5);
//
TProfile *pr30nef = new TProfile("pr30nef",";Run;NHF;",26000,355000.5,381000.5);
TProfile *pr50nef = new TProfile("pr50nef",";Run;NHF;",26000,355000.5,381000.5);
TProfile *pr110nef = new TProfile("pr110nef",";Run;NHF;",26000,355000.5,381000.5);
TProfile *pr230nef = new TProfile("pr230nef",";Run;NHF;",26000,355000.5,381000.5);
TProfile *prg1nef = new TProfile("prg1nef",";Run;NHF;",26000,355000.5,381000.5);
// Control plots stored in a separate directory
fout->mkdir("control");
fout->cd("control");
// Cut flow controls
TProfile *pcutflow1 = new TProfile("pcutflow1",";Cut;Pass",20,-0.5,19.5);
TProfile *pcutflow2 = new TProfile("pcutflow2",";Cut;Pass",20,-0.5,19.5);
TProfile *pcutflow3 = new TProfile("pcutflow3",";Cut;Pass",20,-0.5,19.5);
const int nc = 18;
string cuts[nc] = {"pass_trig", "pass_ngam", "pass_njet", "pass_gameta",
"pass_dphi", "pass_jetid", "pass_veto", "pass_leak",
"pass_basic", "pass_bal", "pass_mpf", "pass_basic_ext",
"pass_jeteta", "pass_alpha100", "pass_all", "pass_gen"};
for (int i = 0; i != nc; ++i) {
pcutflow1->GetXaxis()->SetBinLabel(i+1, cuts[i].c_str());
pcutflow2->GetXaxis()->SetBinLabel(i+1, cuts[i].c_str());
pcutflow3->GetXaxis()->SetBinLabel(i+1, cuts[i].c_str());
}
// Follow up on problematic cuts
TH1D *hdphi = new TH1D("hdphi",";#Delta#phi;N_{events}",
126,-TMath::TwoPi(),TMath::TwoPi());
TH1D *hdr = new TH1D("hdr",";#DeltaR;N_{events}",100,0,10);
// 1D plots for mu per trigger
//hmusmc,20,30,50,75,90,100,110,200
TH1D *hmus = new TH1D("hmus","",100,0,100);
TH1D *hmusmc = new TH1D("hmusmc","",100,0,100);
TH1D *hmus20 = new TH1D("hmus20","",100,0,100);
TH1D *hmus30 = new TH1D("hmus30","",100,0,100);
TH1D *hmus50 = new TH1D("hmus50","",100,0,100);
TH1D *hmus75 = new TH1D("hmus75","",100,0,100);
TH1D *hmus90 = new TH1D("hmus90","",100,0,100);
TH1D *hmus100 = new TH1D("hmus100","",100,0,100);
TH1D *hmus110 = new TH1D("hmus110","",100,0,100);
TH1D *hmus200 = new TH1D("hmus200","",100,0,100);
// 2D plots for mu vs photon pT
TH2D *h2mus = new TH2D("h2mus","",nx,vx,100,0,100);
// Plots of npvgood, npvall vs mu
TProfile *pmuvsmu = new TProfile("pmuvsmu","",100,0,100);
TProfile *prhovsmu = new TProfile("prhovsmu","",100,0,100);
TProfile *pnpvgoodvsmu = new TProfile("pnpvgoodvsmu","",100,0,100);
TProfile *pnpvallvsmu = new TProfile("pnpvallvsmu","",100,0,100);
// Plots of photon corr, err, hoe, r9, vs mu
TProfile *pgainvsmu = new TProfile("pgainvsmu","",100,0,100);
TProfile *pcorrvsmu = new TProfile("pcorrvsmu","",100,0,100);
TProfile *perrvsmu = new TProfile("perrvsmu","",100,0,100);
TProfile *phoevsmu = new TProfile("phoevsmu","",100,0,100);
TProfile *pr9vsmu = new TProfile("pr9vsmu","",100,0,100);
// ...and vs pT
TProfile *pmuvspt = new TProfile("pmuvspt","",nx,vx);
TProfile *prhovspt = new TProfile("prhovspt","",nx,vx);
TProfile *pnpvgoodvspt = new TProfile("pnpvgoodvspt","",nx,vx);
TProfile *pnpvallvspt = new TProfile("pnpvallvspt","",nx,vx);
// ..and vs pT
TProfile *pgain1vspt = new TProfile("pgain1vspt","",nx,vx);
TProfile *pgain6vspt = new TProfile("pgain6vspt","",nx,vx);
TProfile *pgain12vspt = new TProfile("pgain12vspt","",nx,vx);
TProfile *pgainvspt = new TProfile("pgainvspt","",nx,vx);
TProfile *pcorrvspt = new TProfile("pcorrvspt","",nx,vx);
TProfile *perrvspt = new TProfile("perrvspt","",nx,vx);
TH2D *h2hoevspt = new TH2D("h2hoevspt","",nx,vx,125,0,0.025);
TProfile *phoevspt = new TProfile("phoevspt","",nx,vx);
TH2D *h2r9vspt = new TH2D("h2r9vspt","",nx,vx,150,0.90,1.05);
TProfile *pr9vspt = new TProfile("pr9vspt","",nx,vx);
// 2D plots for jet response
TH2D *h2bal = new TH2D("h2bal","",nx,vx,200,0,4);
TH2D *h2mpf = new TH2D("h2mpf","",nx,vx,300,-2,4);
TH2D *h2balc = new TH2D("h2balc","",nx,vx,200,0,4);
TH2D *h2mpfc = new TH2D("h2mpfc","",nx,vx,300,-2,4);
TH2D *h2balc2 = new TH2D("h2balc2","",nx,vx,200,0,4);
TH2D *h2mpfc2 = new TH2D("h2mpfc2","",nx,vx,300,-2,4);
// 2D and profile for photon-jet pT
TH2D *h2phoj = new TH2D("h2phoj","",nx,vx,240,-0.1,0.5);
TProfile *pphoj = new TProfile("pphoj","",nx,vx);
// Extras without zero suppression and for gain paths
TH2D *h2phoj0 = new TH2D("h2phoj0","",nx,vx,140,-0.2,0.5);
TProfile *pphoj0 = new TProfile("pphoj0","",nx,vx);
TH2D *h2phoj1 = new TH2D("h2phoj1","",nx,vx,140,-0.2,0.5);
TProfile *pphoj1 = new TProfile("pphoj1","",nx,vx);
TH2D *h2phoj6 = new TH2D("h2phoj6","",nx,vx,140,-0.2,0.5);
TProfile *pphoj6 = new TProfile("pphoj6","",nx,vx);
TH2D *h2phoj12 = new TH2D("h2phoj12","",nx,vx,140,-0.2,0.5);
TProfile *pphoj12 = new TProfile("pphoj12","",nx,vx);
// Plots for photon properties (more in MC)
TH2D *h2gametaphi = new TH2D("h2gametaphi","",30,-1.305,+1.305,
72,-TMath::Pi(),TMath::Pi());
//TH2D *h2gametaphi2 = new TH2D("h2gametaphi2","",150,-1.305,+1.305,