-
Notifications
You must be signed in to change notification settings - Fork 3
/
analyzeTrees.C
2434 lines (2117 loc) · 119 KB
/
analyzeTrees.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <set>
#include "TH1.h"
#include "TF1.h"
#include "TTree.h"
#include "TFile.h"
#include "TNtupleD.h"
#include "TNtuple.h"
#include "TROOT.h"
#include "TChain.h"
#include "TMath.h"
//#include "DataFormats/HLTReco/interface/TriggerObject.h"
//These includes cause some complications in CMSSW_5_3_8_HI_patchX. Commented out for pp.
//If you want to recalculate the JECs on the fly again, just uncomment everything in the updateJEC blocks
//#include "CondFormats/JetMETObjects/interface/FactorizedJetCorrector.h"
//#include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
//#include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h"
using namespace std;
// ******* GLOBAL DECLARATIONS **********
const int QCDpthatBins = 5000; //2056
const int HFpthatBins = 6;
const int dataFiles = 4478;
//***************************************
// ** typedefs ******
//typedef std::vector<trigger::TriggerObject> trigO;
//******************
//**********************************************************
// Do the pthat weighting for the Heavy Flavor Jets
// This function is only useful when incorporating HF MC statistics into your analysis!
//**********************************************************
//(HFfile,infile,HFpthatBins,QCDpthatBins,'b',usePUsub)
double *heavyJetWeighting(std::string HFfile, std::string QCDfile, int HFnfiles, int QCDnfiles, char flavor, bool usePUsub){
const int nDivisions = 8;
double *HFweights = new double[nDivisions];
const int weightBlocks[nDivisions+1] = {15,30,50,80,120,170,220,280,2000};//370,460,540,2000};
TChain *chH = NULL;
TChain *chQCD = NULL;
if(usePUsub){
chH = new TChain("akPu3PFJetAnalyzer/t");
chQCD = new TChain("akPu3PFJetAnalyzer/t");
}
else{
chH = new TChain("ak3PFJetAnalyzer/t");
chQCD = new TChain("ak3PFJetAnalyzer/t");
}
std::ifstream instr(HFfile.c_str(), std::ifstream::in);
std::string filename;
for(int ifile=0; ifile<HFnfiles; ifile++){
instr >> filename;
chH->Add(filename.c_str());
}
std::ifstream instr2(QCDfile.c_str(), std::ifstream::in);
for(int ifile=0; ifile<QCDnfiles; ifile++){
instr2 >> filename;
chQCD->Add(filename.c_str());
}
int parton_flavor=0;
if(flavor=='b') parton_flavor=5;
if(flavor=='c') parton_flavor=4;
char* cutname = new char[200];
char* cutfull = new char[200];
TH1D *bjetEntr = new TH1D("bjetEntr","",1,0,2000);
TH1D *QCDjetEntr = new TH1D("QCDjetEntr","",1,0,2000);
TH1D *bjetEntrFULL = new TH1D("bjetEntrFULL","",1,0,2000);
TH1D *QCDjetEntrFULL = new TH1D("QCDjetEntrFULL","",1,0,2000);
if(parton_flavor==5 || parton_flavor==4){
for(int i=0; i<nDivisions; i++){
sprintf(cutname,"pthat>%d&&pthat<%d&&refpt>0&&abs(jteta)<2&&abs(refparton_flavorForB)==%d",weightBlocks[i],weightBlocks[i+1],parton_flavor);
sprintf(cutfull,"pthat>%d&&pthat<%d",weightBlocks[i],weightBlocks[i+1]);
cout << "jet cut: "<< cutname << endl;
cout << "evt cut: "<< cutfull << endl;
chQCD->Draw("jtpt>>QCDjetEntr",cutname);
chH->Draw("jtpt>>bjetEntr",cutname);
double qcd1 = (double)QCDjetEntr->Integral()/(double)chQCD->GetEntries(cutfull);
double h1 = (double)bjetEntr->Integral()/(double)chH->GetEntries(cutfull);
cout << "between pthat " << weightBlocks[i] << " and " << weightBlocks[i+1] << " has " << qcd1/h1 << " norm, or " << qcd1 << " qcd bjets and " << h1 << " hf jets" << endl;
if(qcd1!=qcd1 || h1!=h1) HFweights[i]=0; //check on NaN via IEEE recommended method
else{
cout << "QCD bjet per event, pthat " << i << ": " << qcd1 << endl;
cout << "HF bjet per event, pthat " << i << ": " << h1 << endl;
HFweights[i] = h1/qcd1;
}
bjetEntr->Reset();
QCDjetEntr->Reset();
}
}
delete bjetEntr;
delete QCDjetEntr;
return HFweights;
}
//**********************************************************
// Count the MC events to appropriately weight the pthat bins
//**********************************************************
int *countMCevents(std::string infile, int nFiles, std::string HFfile, bool usePUsub, int isMC){
TChain *ch = NULL;
if(usePUsub) ch = new TChain("akPu3PFJetAnalyzer/t");
else ch = new TChain("ak3PFJetAnalyzer/t");
std::ifstream instr(infile.c_str(), std::ifstream::in);
std::ifstream HFstr(HFfile.c_str(), std::ifstream::in);
std::string filename;
for(int ifile=0; ifile<nFiles; ifile++){
instr >> filename;
ch->Add(filename.c_str());
}
int *MCentries = new int[12];
//For first time users, you should uncomment the bit below and recalculate the MCentries.
//They are hardcoded here to save time since GetEntries on big TChains is time-consuming
//"official" pp @ 5.02 TeV at MIT
//t->GetEntries, full sample Nentries
/* MCentries[0] = 0;
MCentries[1] = 184697;
MCentries[2] = 187992;
MCentries[3] = 182080;
MCentries[4] = 192166;
MCentries[5] = 163634;
MCentries[6] = 176308;
MCentries[7] = 178740;
MCentries[8] = 207723;
MCentries[9] = 45210; //370 to 2k, //34908; 370 to 460
*/ // MCentries[10] = 7160;
//MCentries[11] = 3142;
//btagged pp @ 5.02 TeV at MIT
/*MCentries[0] = 0;
MCentries[1] = 0;
MCentries[2] = 887467;
MCentries[3] = 981984;
MCentries[4] = 972960;
MCentries[5] = 965903;
MCentries[6] = 900983;
MCentries[7] = 972206;
MCentries[8] = 1084966;
MCentries[9] = 949638; //370 to 460 //1233531; //370 to 2k
MCentries[10] = 283893;
//MCentries[10] = 883328;
//MCentries[11] = 1400565;
*/
//pA @ 5.02 TeV at MIT
/* MCentries[0] = 0;
MCentries[1] = 0;
MCentries[2] = 237013;
MCentries[3] = 310545;
MCentries[4] = 299517;
MCentries[5] = 217500;
MCentries[6] = 189313;
MCentries[7] = 284473;
MCentries[8] = 156224;
MCentries[9] = 33965; //370 to 2000, 26083; //370 to 460
//MCentries[10] = 5443;
//MCentries[11] = 2439;
*/
//Updated pA @ 5 TeV at MIT
/* MCentries[0] = 0;
MCentries[1] = 308267;
MCentries[2] = 255578;
MCentries[3] = 312609;
MCentries[4] = 299768;
MCentries[5] = 217531;
MCentries[6] = 189316;
MCentries[7] = 283472;
MCentries[8] = 189878; //155963;
MCentries[9] = 0;//33915; //370 to 2k
MCentries[10] = 0;
MCentries[11] = 0;
*/
//Updated pp at 5 TeV at MIT
/* MCentries[0] = 0;
MCentries[1] = 4422586;
MCentries[2] = 1156445;
MCentries[3] = 1012112;
MCentries[4] = 976514;
MCentries[5] = 966367;
MCentries[6] = 901062;
MCentries[7] = 972214;
MCentries[8] = 1084969;
MCentries[9] = 1233532;
*/
//official pA MC at Vandy
MCentries[0] = 0;
MCentries[1] = 524545;
MCentries[2] = 530193;
MCentries[3] = 553893;
MCentries[4] = 546277;
MCentries[5] = 542126;
MCentries[6] = 505112;
MCentries[7] = 544734;
MCentries[8] = 608834;
MCentries[9] = 532254;
MCentries[10] = 720672;
MCentries[11] = 0;
const int mcentrnbin = 11;
const double mcentrxbin[12] = {0,15,30,50,80,120,170,220,280,370,460,99999};
TH1D *mcentr = new TH1D("mcentr","",mcentrnbin, mcentrxbin);
//ch->Project("mcentr","pthat");
//for(int ibin=0; ibin<mcentrnbin; ibin++){
// MCentries[ibin] = mcentr->GetBinContent(ibin+1);
// }
/* MCentries[0] = 0;//ch->GetEntries("pthat<15");
MCentries[1] = ch->GetEntries("pthat>=15 && pthat<30");
MCentries[2] = ch->GetEntries("pthat>=30 && pthat<50");
MCentries[3] = ch->GetEntries("pthat>=50 && pthat<80");
MCentries[4] = ch->GetEntries("pthat>=80 && pthat<120");
MCentries[5] = ch->GetEntries("pthat>=120 && pthat<170");
MCentries[6] = ch->GetEntries("pthat>=170 && pthat<220");
MCentries[7] = ch->GetEntries("pthat>=220 && pthat<280");
MCentries[8] = ch->GetEntries("pthat>=280 && pthat<2000");
MCentries[9] = 0.;
MCentries[10]=0.;
MCentries[11]=0.;
//MCentries[9] = ch->GetEntries("pthat>=370 && pthat<460");
//MCentries[10] = ch->GetEntries("pthat>=460 && pthat<540");
//MCentries[11] = ch->GetEntries("pthat>=540 && pthat<2000");
*/
for(int i=0; i<mcentrnbin; i++){
cout << "QCD MCentries[" << i << "]: " << MCentries[i] << endl;
}
if(isMC>1){
TChain *HFch = NULL;
if(usePUsub) HFch = new TChain("akPu3PFJetAnalyzer/t");
else HFch = new TChain("ak3PFJetAnalyzer/t");
for(int ifile=0; ifile<HFpthatBins; ifile++){
HFstr >> filename;
HFch->Add(filename.c_str());
}
double *HFweight = NULL;
if(isMC==2) HFweight = heavyJetWeighting(HFfile,infile,HFpthatBins,QCDpthatBins,'b',usePUsub);
if(isMC==3) HFweight = heavyJetWeighting(HFfile,infile,HFpthatBins,QCDpthatBins,'c',usePUsub);
for(int i=0; i<11; i++){
cout << "HFweight[" << i << "]: " << HFweight[i] << endl;
}
double tempEntr[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
tempEntr[0] = HFch->GetEntries("pthat<15");
tempEntr[1] = HFch->GetEntries("pthat>=15 && pthat<30");
tempEntr[2] = HFch->GetEntries("pthat>=30 && pthat<50");
tempEntr[3] = HFch->GetEntries("pthat>=50 && pthat<80");
tempEntr[4] = HFch->GetEntries("pthat>=80 && pthat<120");
tempEntr[5] = HFch->GetEntries("pthat>=120 && pthat<170");
tempEntr[6] = HFch->GetEntries("pthat>=170 && pthat<220");
tempEntr[7] = HFch->GetEntries("pthat>=220 && pthat<280");
tempEntr[8] = HFch->GetEntries("pthat>=280 && pthat<370");
//tempEntr[9] = HFch->GetEntries("pthat>=370 && pthat<460");
//tempEntr[10] = HFch->GetEntries("pthat>=460 && pthat<540");
//tempEntr[11] = HFch->GetEntries("pthat>=540 && pthat<2000");
for(int i=1; i<12; i++){
cout << "HF entries[" << i << "]: " << tempEntr[i] << endl;
MCentries[i] += tempEntr[i]*HFweight[i-1];
}
for(int i=0; i<12; i++){
cout << "Effective MCentries[" << i << "]: " << MCentries[i] << endl;
}
}
return MCentries;
}
//**********************************************************
// Trigger-Combine the data in order to unfold properly later
//**********************************************************
//[0] = Jet20, [1] = Jet40, [2] = Jet60, [3] = Jet80, [4] = Jet100
double trigComb(bool *trg, int *pscl, double pt){
int combinationMethod = 6; // BE SURE TO CHANGE THE TRIGGER COMBINATION METHOD IF YOU DON'T LIKE THE ONE CHOSEN HERE BY DEFAULT!
double weight=0;
//HIN-12-017 (charged part RpA) combination method - solid but loses events that slip through the pt bins
if(combinationMethod==1){
if(trg[0] && pt>40 && pt<60) weight = pscl[0];
if(trg[1] && pt>60 && pt<75) weight = pscl[1];
if(trg[2] && pt>75 && pt<95) weight = pscl[2];
if(trg[3] && pt>95 && pt<120) weight = pscl[3];
if(trg[4] && pt>120) weight = 1.;
}
//Experimental method from STAR - works well but requires TRIGGER PT! NOT RECO PT!
//also will run into issues with double/int conversions!!
if(combinationMethod==2){
if(trg[0] && pt>=20 && pt<40) weight = 1./(1./pscl[0]);
if((trg[0] || trg[1]) && pt>=40 && pt<60) weight = 1./(1./pscl[0] + 1./pscl[1] - 1./(pscl[0]*pscl[1]));
if((trg[0] || trg[1] || trg[2]) && pt>=60 && pt<80) weight = 1./(1./pscl[0] + 1./pscl[1] + 1./pscl[2] - 1./(pscl[0]*pscl[1]) - 1./(pscl[0]*pscl[2]) - 1./(pscl[1]*pscl[2]) + 1./(pscl[0]*pscl[1]*pscl[2]));
if((trg[0] || trg[1] || trg[2] || trg[3]) && pt>=80 && pt<100) weight = 1./(1./pscl[0] + 1./pscl[1] + 1./pscl[2] + 1./pscl[3] - 1./(pscl[0]*pscl[1]) - 1./(pscl[0]*pscl[2]) - 1./(pscl[0]*pscl[3]) - 1./(pscl[1]*pscl[2]) - 1./(pscl[1]*pscl[3]) - 1./(pscl[2]*pscl[3]) + 1./(pscl[0]*pscl[1]*pscl[2]) + 1./(pscl[0]*pscl[1]*pscl[3]) + 1./(pscl[0]*pscl[2]*pscl[3]) + 1./(pscl[1]*pscl[2]*pscl[3]) - 1./(pscl[0]*pscl[1]*pscl[2]*pscl[3]));
if((trg[0] || trg[1] || trg[2] || trg[3] || trg[4]) && pt>=100) weight = 1.;
}
//Workaround method for HIN-12-003 (bjets). Only works with 3 triggers and tends to lose events and assumes Jet80 is unprescaled (false for pA). For cross-check only.
if(combinationMethod==3){
// if(triggerDecision[0] && !triggerDecision[1] && !triggerDecision[2] && !triggerDecision[3]) weight = 1./(1./pscl[0]); //Removing finnicky Jet20 sample
if(trg[1] && !trg[2] && !trg[3]) weight = pscl[1]; //1./(1./pscl[1]);
if(trg[2] && !trg[3]) weight = 1.; //1./(1./pscl[1] + 1./pscl[2] - (1./(pscl[1]*pscl[2])));
if(trg[3]) weight = 1.;
}
//Totally new experimental method - extend HIN-12-003 method to 5 triggers
if(combinationMethod==4){
if(trg[4]) weight = 1.;
if(trg[3] && !trg[4]) weight = 1.;
if(trg[2] && !trg[3] && !trg[4]) weight = 1.;
if(trg[1] && !trg[2] && !trg[3] && !trg[4]) weight = 1.;
if(trg[0] && !trg[1] && !trg[2] && !trg[3] && !trg[4]) weight = 1./(1./(double)pscl[0]);
}
//Combination fix because the triggers are stacked vertically on one another
//i.e. triggers are not completely independent!
if(combinationMethod==5){
if(trg[4] && pt>=100) weight = pscl[4];
if(!trg[4] && trg[3] && pt>=80 && pt<100) weight = pscl[3];
if(!trg[4] && !trg[3] && trg[2] && pt>=60 && pt<80) weight = pscl[2];
if(!trg[4] && !trg[3] && !trg[2] && trg[1] && pt>=40 && pt<60) weight = pscl[1];
if(!trg[4] && !trg[3] && !trg[2] && !trg[1] && trg[0] && pt>=20 && pt<40) weight = pscl[0];
}
if(combinationMethod==6){
if(trg[4] && pt>=100) weight = pscl[4];
if(trg[3] && pt>=80 && pt<100) weight = pscl[3];
if(trg[2] && pt>=60 && pt<80) weight = pscl[2];
if(trg[1] && pt>=40 && pt<60) weight = pscl[1];
if(trg[0] && pt>=20 && pt<40) weight = pscl[0];
}
return weight;
}
//**********************************************************
// "get" the trigger prescales by counting trigger overlap
//**********************************************************
double* getPscls(std::string infile, int nFiles, bool usePUsub){
TChain *dataCH = NULL;
if(usePUsub){
dataCH = new TChain("akPu3PFJetAnalyzer/t");
}
else dataCH = new TChain("ak3PFJetAnalyzer/t");
TChain *dataCH2 = new TChain("hltanalysis/HltTree");
std::ifstream instr(infile.c_str(), std::ifstream::in);
std::string filename;
if(nFiles>100) nFiles=100;
for(int ifile=0; ifile<nFiles; ifile++){
instr >> filename;
dataCH->Add(filename.c_str());
dataCH2->Add(filename.c_str());
}
dataCH->AddFriend(dataCH2, "hltanalysis/HltTree");
//Set up trigger combination prescales for data
double ov1, ov2, ov3, ov4, ov5;
ov1 = dataCH->GetEntries("HLT_PAJet20_NoJetID_v1 && HLT_PAJet100_NoJetID_v1");
ov2 = dataCH->GetEntries("HLT_PAJet40_NoJetID_v1 && HLT_PAJet100_NoJetID_v1");
ov3 = dataCH->GetEntries("HLT_PAJet60_NoJetID_v1 && HLT_PAJet100_NoJetID_v1");
ov4 = dataCH->GetEntries("HLT_PAJet80_NoJetID_v1 && HLT_PAJet100_NoJetID_v1");
ov5 = dataCH->GetEntries("HLT_PAJet100_NoJetID_v1");
double *pscls = new double[5];
pscls[0] = ov5/ov1;
pscls[1] = ov5/ov2;
pscls[2] = ov5/ov3;
pscls[3] = ov5/ov4;
pscls[4] = 1.;
cout << "ps20: "<< pscls[0] << endl;
cout << "ps40: " << pscls[1] << endl;
cout << "ps60: " << pscls[2] << endl;
cout << "ps80: "<< pscls[3] << endl;
cout << "ps100: "<< pscls[4] << endl;
return pscls;
}
//*****************************************************
// Do triggerPt Matching
// -i.e. ensure the jet you're looking at actually fired the trigger
//*****************************************************
double triggerMatch(int trgObjSize, double* trigPhi, double* trigEta, double *trigPt, double jtphi, double jteta, double jtpt, TH1D *dTrgEta, TH1D *dTrgPhi){
double triggerPt=0;
double triggerEta=-99;
double triggerPhi=-99;
double closestMatch=999999.;
for(int iObj=0; iObj<trgObjSize; iObj++){
if(abs(trigPhi[iObj]-jtphi)<0.2 && abs(trigEta[iObj]-jteta)<0.2 && abs(trigPt[iObj]-jtpt)/jtpt<1. && abs(trigPt[iObj]-TMath::Floor(trigPt[iObj]))>0.0001){
if(sqrt(pow((trigPhi[iObj]-jtphi),2)+pow((trigEta[iObj]-jteta),2))<closestMatch){
closestMatch = sqrt(pow((trigPhi[iObj]-jtphi),2)+pow((trigEta[iObj]-jteta),2));
triggerPt = trigPt[iObj];
triggerEta = trigEta[iObj];
triggerPhi = trigPhi[iObj];
}
}
}
if(triggerEta!=-99){
dTrgEta->Fill(jteta-triggerEta);
dTrgPhi->Fill(jtphi-triggerPhi);
}
return triggerPt;
}
//**********************************************************
// ~~~ MAIN PROGRAM ~~~
//**********************************************************
void analyzeTrees(const int startfile=0, const int endfile=1, int isRecopp=1, int ppPbPb=0, int isMuTrig=0, int isMC=0, int doNtuples=1, int doJets=1, int doTracks=1, int updateJEC=0, int cbin=-1, int useGSP=0, int jetTrig=0, bool ExpandedTree=false, bool usePUsub=1, bool useJetTrgAssociation=1, bool doMinBias=0, bool dopPb=1)
{
// isMC=0 --> Real data, ==1 --> QCD, ==2 --> bJet, ==3 --> cJet
Float_t minJetPt=20.;
double minRawPt=23.;
if (isMuTrig) minJetPt=30;
Float_t maxJetEta=2.5;
Float_t minMuPt=5;
// cbin = -1 --> 0-100%
// cbin = 0 --> 0-20%
// cbin = 1 --> 20-50%
// cbin =2 --> 50-100%
if(!ppPbPb) cbin=-1;
int useWeight=1;
if(isMC) updateJEC=0;
//Get vz weight histograms for MC if needed
TH1D *hMCvz[2], *hDatavz;
TFile *fMCvz, *fDatavz, *fBvz;
if(isMC){
fMCvz = new TFile("MCvzDistr.root");
hMCvz[0] = (TH1D*)(fMCvz->Get("hvz"))->Clone("hMCvz_0");
fDatavz = new TFile("DatavzDistro.root");
hDatavz = (TH1D*)(fDatavz->Get("hvzData"))->Clone("hDatavz");
fBvz = new TFile("BvzDistr.root");
hMCvz[1] = (TH1D*)(fBvz->Get("hvzB"))->Clone("hMCvz_1");
hMCvz[0]->Scale(1./hMCvz[0]->Integral());
hMCvz[1]->Scale(1./hMCvz[1]->Integral());
hDatavz->Scale(1./hDatavz->Integral());
}
TF1 *fVz = new TF1("fVz","[0]+[1]*x+[2]*TMath::Power(x,2)+[3]*TMath::Power(x,3)+[4]*TMath::Power(x,4)", -15., 15.);
//OLD private MC
//if(dopPb) fVz->SetParameters(1.60182e+00,1.08425e-03,-1.29156e-02,-7.24899e-06,2.80750e-05);
//else fVz->SetParameters(1.50159e+00,-4.34648e-03,-1.31039e-02,2.12382e-05,3.06402e-05);
//NEW official MC
if(dopPb) fVz->SetParameters(1.65968e+00, -3.35481e-03, -1.39913e-02, 1.20582e-05, 3.24727e-05);
else fVz->SetParameters(1.68907e+00, -3.82468e-03, -1.48634e-02, 1.76374e-05, 3.50409e-05);
TFile *f = new TFile("Casym_pPb_double_hcalbins_algo_akPu3PF_pt100_140_jet80_alphahigh_20_phicut250.root");
TFile *frev = new TFile("Casym_Pbp_double_hcalbins_algo_akPu3PF_pt100_140_jet80_alphahigh_20_phicut250.root");
TH1D *c_eta = (TH1D*)f->Get("C_asym");
TH1D *c_eta_rev = (TH1D*)frev->Get("C_asym");
TF1 *fcorr = new TF1("fcorr","1-[0]/pow(x,[1])",20,300);
if(usePUsub){ fcorr->SetParameter(0,0.3015); fcorr->SetParameter(1,0.8913); }
else{ fcorr->SetParameter(0,0.8648); fcorr->SetParameter(1,0.8167); }
//TFile *fC = new TFile("/net/hidsk0001/d00/scratch/kjung/dropbox/centReweight_pPbJet.root");
//TH1D *fCent = (TH1D*)fC->Get("CentReweightJet_All");
TF1 * fCen = new TF1("fCen","[0]*exp([1]+[2]*x+[3]*x*x+[4]*x*x*x+[5]*x*x*x*x+[6]*x*x*x*x*x)", 0., 100.);
//OLD private MC
//if(dopPb) fCen->SetParameters(8.68073e-03, 5.09356e+00, -1.33053e-02, 1.46904e-03, -6.99681e-05, 1.06721e-06, -5.21398e-09);
//else fCen->SetParameters(1.05408e-02, 5.27477e+00, -8.03382e-02, 3.51669e-03, -8.85332e-05, 1.08917e-06, -4.90091e-09);
//NEW official MC
if(dopPb) fCen->SetParameters(5.81628e-03, 4.88285e+00, 9.60958e-02, -5.16892e-03, 1.04572e-04, -9.89614e-07, 3.79293e-09);
else fCen->SetParameters(5.30157e-03, 4.76386e+00, 1.30991e-01, -6.38698e-03, 1.17033e-04, -9.69067e-07, 3.17267e-09);
cout << "Analyzing Trees! Assuming " << QCDpthatBins << " QCD pthat bins, and " << HFpthatBins << " B/C pthat bins." << endl;
if(usePUsub) cout << "Running on underlying event-subtracted jets!! (akPu3PF)" << endl;
else cout << "Running on jets with NO UE-SUBTRACTION! (ak3PF)" << endl;
if(useJetTrgAssociation) cout << "Using Jet-trigger association" << endl;
else cout << "WARNING! No Jet-Trigger association will be used - reverting to recoPt. Only use this with Trigger Combination method 1!" << endl;
if(dopPb && isMC) cout<< "dopPb flag set - assuming this is pPb MC" << endl;
else if(isMC) cout << "dopPb flag unset - assuming this is Pbp MC..." << endl;
int pthatbin[11] = {15,30,50,80,120,170,220,280,370,460,99999};
double w = 1.;
//double wght[10]={0.5335, 3.378E-02, 3.778E-03, 4.412E-04, 6.147E-05, 1.018E-05, 2.477E-06, 6.160E-07, 1.088E-07,0};//1.088E-07, 2.527E-08}; for pp - last at 370
double wght[11]={0.5335, 3.378E-02, 3.778E-03, 4.412E-04, 6.147E-05, 1.018E-05, 2.477E-06, 6.160E-07, 1.088E-07,2.527E-08,0}; //for pA - last at 280
//This is the old 2.76 TeV weighting!!
//double wght[8]={0.2034, 1.075E-02, 1.025E-03, 9.865E-05, 1.129E-05, 1.465E-06, 2.837E-07, 5.323E-08};
TFile *fin=NULL;
std::string infile;
std::string HFfile;
int *MCentr = NULL;
double *pscls = NULL;
//PbPb File load
if(ppPbPb){
if(isMC==0){
if(jetTrig==1)fin = new TFile("/data_CMS/cms/mnguyen/bTaggingOutput/PbPbData/pbpbDataJet80_hiRegitSVHighPurity_pt30by3_restrictMixTripletA_jpHICalibRepass/merged_bTagAnalyzers_all.root");
if(jetTrig==2)fin = new TFile("/data_CMS/cms/mnguyen/bTaggingOutput/PbPbData/pbpbDataJet65_hiRegitSVHighPurity_pt30by3_restrictMixTripletA_jpHICalibRepass/merged_bTagAnalyzers_all.root");
}
else if(isMC==1) fin = new TFile("/data_CMS/cms/mnguyen/bTaggingOutput/hydjetEmbedded/merged_bjetAnalyzers_hiReco_offPV_pt30by3_oldHydjet_restrictMixTripletA_ipHICalibCentWeight_weighted_qcd.root");
else if(isMC==2) fin = new TFile("/data_CMS/cms/mnguyen/bTaggingOutput/hydjetEmbedded/merged_bjetAnalyzers_hiReco_offPV_pt30by3_newHydjet_restrictMixTripletA_ipHICalibCentWeight_weighted_bJetPlusQCD.root");
else if(isMC==3)fin = new TFile("/data_CMS/cms/mnguyen/bTaggingOutput/hydjetEmbedded/merged_bjetAnalyzers_hiReco_offPV_pt30by3_newHydjet_restrictMixTripletA_ipHICalibCentWeight_weighted_cJetPlusQCD.root");
}
else{ //pp File Load
if(doMinBias){
infile = "wxie_MinBiasUPC_all.txt";
}
else if(!isMC){
infile = "HighPtForest_18thProd_Full.txt";//HalfDataList_july2014_forDebug.txt";
//infile = "JPRecalib_data_may14.txt";
//infile = "pPbRecalibFullList.txt";
}
else if(isMC){
//infile = "testJEC.txt";
if(dopPb) infile = "pPb_officialMC_Full_Dec2014.txt"; //pPbFullBTagMC_March2014.txt";
else infile = "pPb_officialMC_reverse_Full_Dec2014.txt";
//infile = "pPbMCBForestListMerged.txt";
//infile = "pPbMCBForestList.txt";
//infile = "Pythia_BTag_502TeV.txt";
//infile = "PythiaPP_502TeV_DogaNoBTag.txt";
////infile = "PythiaPP_502TeV_Fix2Sample.txt";
if(isMC==2){
HFfile = "pPbFullBTagMC_BGenList_Apr2014.txt";
}
else if(isMC==3){
HFfile = "pPbFullBTagMC_CGenList_Apr2014.txt";
}
else if(isMC>3){
cout << "I don't understand this MC number!" << endl;
exit(0);
}
}
}
cout << "infile: "<< infile << endl;
//Legacy code to get trigger prescales via trigger overlaps.
//if(!isMC && !ppPbPb){
//pscls = getPscls(infile,500,usePUsub);
//}
//duplicated PbPb runs in the HiForest
int dupRuns[6] = {181912,181913,181938,181950,181985,182124};
std::vector<int> usedEvents[6];
int nDup=0;
//Declaration of leaves types
Int_t evt;
Int_t run;
Int_t bin;
Int_t lumi;
Float_t hf;
Float_t hiHFplusEta4;
Float_t vz;
Int_t nref;
Float_t rawpt[1000];
Float_t jtpt[1000];
Float_t jteta[1000];
Float_t jty[1000];
Float_t jtphi[1000];
Float_t jtpu[1000];
Float_t discr_ssvHighEff[1000];
Float_t discr_ssvHighPur[1000];
//Float_t discr_csvMva[1000];
Float_t discr_csvSimple[1000];
// Float_t discr_muByIp3[1000];
Float_t discr_muByPt[1000];
Float_t discr_prob[1000];
Float_t discr_probb[1000];
Float_t discr_tcHighEff[1000];
Float_t discr_tcHighPur[1000];
Int_t nsvtx[1000];
Int_t svtxntrk[1000];
Float_t svtxdl[1000];
Float_t svtxdls[1000];
Float_t svtxm[1000];
Float_t svtxpt[1000];
Int_t nIPtrk[1000];
Int_t nselIPtrk[1000];
Int_t nIP;
Int_t ipJetIndex[10000];
Float_t ipPt[10000];
Float_t ipProb0[10000];
Float_t ipProb1[10000];
Float_t ip2d[10000];
Float_t ip2dSig[10000];
Float_t ip3d[10000];
Float_t ip3dSig[10000];
Float_t ipDist2Jet[10000];
Float_t ipDist2JetSig[10000];
Float_t ipClosest2Jet[10000];
//Float_t mue[1000];
Float_t mupt[1000];
Float_t muptPF[1000];
Float_t mueta[1000];
Float_t muphi[1000];
//Float_t mudr[1000];
Float_t muptrel[1000];
//Int_t muchg[1000];
Float_t pthat;
Int_t beamId1;
Int_t beamId2;
Float_t refpt[1000];
Float_t refeta[1000];
Float_t refy[1000];
Float_t refphi[1000];
Float_t refdphijt[1000];
Float_t refdrjt[1000];
Float_t refparton_pt[1000];
Int_t refparton_flavor[1000];
Int_t refparton_flavorForB[1000];
Bool_t refparton_isGSP[1000];
Int_t subid[1000];
Int_t HLT_PAJet20_NoJetID_v1;
Int_t HLT_PAJet40_NoJetID_v1;
Int_t HLT_PAJet60_NoJetID_v1;
Int_t HLT_PAJet80_NoJetID_v1;
Int_t HLT_PAJet100_NoJetID_v1;
Int_t HLT_PAJet120_NoJetID_v1;
Int_t HLT_PAZeroBiasPixel_SingleTrack_v1;
Int_t HLT_PAJet20_NoJetID_v1_Prescl;
Int_t HLT_PAJet40_NoJetID_v1_Prescl;
Int_t HLT_PAJet60_NoJetID_v1_Prescl;
Int_t HLT_PAJet80_NoJetID_v1_Prescl;
Int_t HLT_PAJet100_NoJetID_v1_Prescl;
Int_t HLT_PAJet120_NoJetID_v1_Prescl;
Int_t HLT_PAZeroBiasPixel_SingleTrack_v1_Prescl;
Int_t L1_ZeroBias_Prescl;
Int_t L1_SingleJet16_BptxAND_Prescl;
Int_t L1_SingleJet36_Prescl;
/*trigO *HLT_PAJet_NoJetID_v1_trigObject[6];
for(int i=0; i<6; i++){
HLT_PAJet_NoJetID_v1_trigObject[i] = new trigO;
} */
double triggerPt;
float maxTrgPt;
Int_t pVertexFilterCutGplusUpsPP;
Int_t pPAcollisionEventSelectionPA;
Int_t pHBHENoiseFilter;
Int_t pprimaryvertexFilter;
/*
Int_t ngen;
Int_t genmatchindex[1000];
Float_t genpt[1000];
Float_t geneta[1000];
Float_t geny[1000];
Float_t genphi[1000];
Float_t gendphijt[1000];
Float_t gendrjt[1000];
*/
float chargedMax[1000];
float photonMax[1000];
float neutralMax[1000];
float chargedSum[1000];
float photonSum[1000];
float neutralSum[1000];
float muSum[1000];
float eSum[1000];
Double_t weight, xSecWeight, centWeight, vzWeight;
int nHLTBit;
bool hltBit[12];
Int_t pvSel;
Int_t hbheNoiseSel;
Int_t spikeSel;
Int_t collSell;
TFile *fout=NULL;
if(ppPbPb){
if(cbin==-1){
if(jetTrig==0){
if(isMC==0) fout = new TFile("histos/PbPbdata_pt30by3_jpHICalibRepass_withDup_PU.root","recreate");
else if(isMC==1) fout = new TFile("histos/PbPbQCDMC_pt30by3_ipHICalibCentWeight_noTrig.root","recreate");
else if(isMC==2) fout = new TFile("histos/PbPbBMC_pt30by3_ipHICalibCentWeight_noTrig.root","recreate");
else if(isMC==3) fout = new TFile("histos/PbPbCMC_pt30by3_ipHICalibCentWeight_noTrig.root","recreate");
}
if(jetTrig==1){
if(isMC==0) fout = new TFile("histos/PbPbdata_pt30by3_jpHICalibRepass_withDup_PU.root","recreate");
else if(isMC==1) fout = new TFile("histos/PbPbQCDMC_pt30by3_ipHICalibCentWeight.root","recreate");
else if(isMC==2) fout = new TFile("histos/PbPbBMC_pt30by3_ipHICalibCentWeight.root","recreate");
else if(isMC==3) fout = new TFile("histos/PbPbCMC_pt30by3_ipHICalibCentWeight.root","recreate");
}
if(jetTrig==2){
if(isMC==0) fout = new TFile("histos/PbPbdata_pt30by3_jpHICalibRepass_withDup_PU_jet65.root","recreate");
else if(isMC==1) fout = new TFile("histos/PbPbQCDMC_pt30by3_ipHICalibCentWeight_jet65.root","recreate");
else if(isMC==2) fout = new TFile("histos/PbPbBMC_pt30by3_ipHICalibCentWeight_jet65.root","recreate");
else if(isMC==3) fout = new TFile("histos/PbPbCMC_pt30by3_ipHICalibCentWeight_jet65.root","recreate");
}
}
else{
if(isMC==0) fout = new TFile(Form("histos/PbPbdata_%d_pt30by3_jpHICalibRepass.root",cbin),"recreate");
else if(isMC==1) fout = new TFile(Form("histos/PbPbQCDMC_%d_pt30by3_ipHICalibCentWeight.root",cbin),"recreate");
else if(isMC==2) fout = new TFile(Form("histos/PbPbBMC_%d_pt30by3_ipHICalibCentWeight.root",cbin),"recreate");
else if(isMC==3) fout = new TFile(Form("histos/PbPbCMC_%d_pt30by3_ipHICalibCentWeight.root",cbin),"recreate");
}
}
else{
stringstream outfilestr;
outfilestr << endfile;
string fileappend = outfilestr.str();
string jetRecoType;
if(usePUsub) jetRecoType = "akPu3PF";
else jetRecoType = "ak3PF";
string datoutfile;
if(doMinBias) datoutfile = "pPbdata_ppreco_"+jetRecoType+"_MinBiasTrig_etashift_TrgCombMethod6_"+fileappend+".root";
else datoutfile = "pPbdata_ppreco_"+jetRecoType+"_jetTrig_etashift_fullIPrecalib_FinalTC_NoResCorr_FullReweight_v17Corr_noIPupperCut_"+fileappend+".root";
string QCDoutfile;
if(dopPb) QCDoutfile= "pPbMC_ppReco_"+jetRecoType+"_QCDjetTrig_officialMC_etashift_noTrgSelection_JetCleaned_MCWeightFinal_WithCentVzWeight_"+fileappend+".root";
else QCDoutfile= "pPbMC_ppReco_"+jetRecoType+"_QCDjetTrig_REVERSED_officialMC_etashift_noTrgSelection_JetCleaned_MCWeightFinal_WithCentVzWeight_"+fileappend+".root";
string Boutfile = "pPbMC_ppReco_"+jetRecoType+"_BjetTrig_etashift_noTrgSelection_MCWeightFinalWithSmoothedVzCentWeight_BGenJets"+fileappend+".root";
string Coutfile = "pPbMC_ppReco_"+jetRecoType+"_CjetTrig_etashift_noTrgSelection_MCWeightFinalWithSmoothedVzCentWeight_CGenJets_"+fileappend+".root";
if( isRecopp&& isMuTrig) { // pp reco, muon triggered
if(isMC)fout=new TFile("histos/ppMC_ppReco_muTrig_noIPupperCut.root","recreate");
else fout=new TFile("histos/ppdata_ppReco_muTrig_noIPupperCut.root","recreate");
}
else if (isRecopp && !isMuTrig) { // pp reco, jet triggered
if(isMC==1) fout=new TFile(QCDoutfile.c_str(),"recreate");
else if(isMC==2) fout=new TFile(Boutfile.c_str(),"recreate");
else if(isMC==3) fout=new TFile(Coutfile.c_str(),"recreate");
else fout=new TFile(datoutfile.c_str(),"recreate");
}
else if (!isRecopp&& isMuTrig) { // hi reco, muon triggered
if(isMC)fout=new TFile("histos/ppMC_hiReco_muTrig_noIPupperCut.root","recreate");
else fout=new TFile("histos/ppdata_hiReco_muTrig_noIPupperCut.root","recreate");
}
else if (!isRecopp&&!isMuTrig) { // hi reco, jet triggered
if(isMC)fout=new TFile("histos/ppMC_hiReco_jetTrig_addGSP_up.root","recreate");
else fout=new TFile("histos/ppdata_hiReco_jetTrig_regPFforJets.root","recreate");
}
}
TH1D *hbin = new TH1D("hbin","hbin",200,-0.5,199.5);
TH1D *hbinw = new TH1D("hbinw","hbinw",200,-0.5,199.5);
hbin->Sumw2(); hbinw->Sumw2();
TH1D *hvz = new TH1D("hvz","hvz",120,-15.,15.);
TH1D *hvzw = new TH1D("hvzw","hvzw",120,-15.,15.);
hvz->Sumw2(); hvzw->Sumw2();
TH1D *hjtpt = new TH1D("hjtpt","hjtpt",68,80,330);
TH1D *hjtptB = new TH1D("hjtptB","hjtptB",68,80,330);
TH1D *hjtptC = new TH1D("hjtptC","hjtptC",68,80,330);
TH1D *hjtptL = new TH1D("hjtptL","hjtptL",68,80,330);
TH1D *hjtptU = new TH1D("hjtptU","hjtptU",68,80,330);
hjtpt->Sumw2(); hjtptB->Sumw2(); hjtptC->Sumw2(); hjtptL->Sumw2(); hjtptU->Sumw2();
TH1D *hrawpt = new TH1D("hrawpt","hrawpt",68,80,330);
TH1D *hrawptB = new TH1D("hrawptB","hrawptB",68,80,330);
TH1D *hrawptC = new TH1D("hrawptC","hrawptC",68,80,330);
TH1D *hrawptL = new TH1D("hrawptL","hrawptL",68,80,330);
hrawpt->Sumw2(); hrawptB->Sumw2(); hrawptC->Sumw2(); hrawptL->Sumw2();
TH1D *hjteta = new TH1D("hjteta","hjteta",40,-2,2);
TH1D *hjtetaB = new TH1D("hjtetaB","hjtetaB",40,-2,2);
TH1D *hjtetaC = new TH1D("hjtetaC","hjtetaC",40,-2,2);
TH1D *hjtetaL = new TH1D("hjtetaL","hjtetaL",40,-2,2);
hjteta->Sumw2(); hjtetaB->Sumw2(); hjtetaC->Sumw2(); hjtetaL->Sumw2();
TH1D *hjtphi = new TH1D("hjtphi","hjtphi",40,-1.*acos(-1.),acos(-1.));
TH1D *hjtphiB = new TH1D("hjtphiB","hjtphiB",40,-1.*acos(-1.),acos(-1.));
TH1D *hjtphiC = new TH1D("hjtphiC","hjtphiC",40,-1.*acos(-1.),acos(-1.));
TH1D *hjtphiL = new TH1D("hjtphiL","hjtphiL",40,-1.*acos(-1.),acos(-1.));
hjtphi->Sumw2(); hjtphiB->Sumw2(); hjtphiC->Sumw2(); hjtphiL->Sumw2();
TH1D *hdiscr_csvSimple = new TH1D("hdiscr_csvSimple","hdiscr_csvSimple",25,0,1);
TH1D *hdiscr_csvSimpleB = new TH1D("hdiscr_csvSimpleB","hdiscr_csvSimpleB",25,0,1);
TH1D *hdiscr_csvSimpleC = new TH1D("hdiscr_csvSimpleC","hdiscr_csvSimpleC",25,0,1);
TH1D *hdiscr_csvSimpleL = new TH1D("hdiscr_csvSimpleL","hdiscr_csvSimpleL",25,0,1);
hdiscr_csvSimple->Sumw2(); hdiscr_csvSimpleB->Sumw2(); hdiscr_csvSimpleC->Sumw2(); hdiscr_csvSimpleL->Sumw2();
TH1D *hdiscr_prob = new TH1D("hdiscr_prob","hdiscr_prob",25,0,2.5);
TH1D *hdiscr_probB = new TH1D("hdiscr_probB","hdiscr_probB",25,0,2.5);
TH1D *hdiscr_probC = new TH1D("hdiscr_probC","hdiscr_probC",25,0,2.5);
TH1D *hdiscr_probL = new TH1D("hdiscr_probL","hdiscr_probL",25,0,2.5);
hdiscr_prob->Sumw2(); hdiscr_probB->Sumw2(); hdiscr_probC->Sumw2(); hdiscr_probL->Sumw2();
TH1D *hdiscr_ssvHighEff = new TH1D("hdiscr_ssvHighEff","hdiscr_ssvHighEff",25,1,6);
TH1D *hdiscr_ssvHighEffB = new TH1D("hdiscr_ssvHighEffB","hdiscr_ssvHighEffB",25,1,6);
TH1D *hdiscr_ssvHighEffC = new TH1D("hdiscr_ssvHighEffC","hdiscr_ssvHighEffC",25,1,6);
TH1D *hdiscr_ssvHighEffL = new TH1D("hdiscr_ssvHighEffL","hdiscr_ssvHighEffL",25,1,6);
hdiscr_ssvHighEff->Sumw2(); hdiscr_ssvHighEffB->Sumw2(); hdiscr_ssvHighEffC->Sumw2(); hdiscr_ssvHighEffL->Sumw2();
TH1D *hdiscr_ssvHighPur = new TH1D("hdiscr_ssvHighPur","hdiscr_ssvHighPur",25,1,6);
TH1D *hdiscr_ssvHighPurB = new TH1D("hdiscr_ssvHighPurB","hdiscr_ssvHighPurB",25,1,6);
TH1D *hdiscr_ssvHighPurC = new TH1D("hdiscr_ssvHighPurC","hdiscr_ssvHighPurC",25,1,6);
TH1D *hdiscr_ssvHighPurL = new TH1D("hdiscr_ssvHighPurL","hdiscr_ssvHighPurL",25,1,6);
hdiscr_ssvHighPur->Sumw2(); hdiscr_ssvHighPurB->Sumw2(); hdiscr_ssvHighPurC->Sumw2(); hdiscr_ssvHighPurL->Sumw2();
TH1D *hdiscr_tcHighEff = new TH1D("hdiscr_tcHighEff","hdiscr_tcHighEff",25,1,6);
TH1D *hdiscr_tcHighEffB = new TH1D("hdiscr_tcHighEffB","hdiscr_tcHighEffB",25,1,6);
TH1D *hdiscr_tcHighEffC = new TH1D("hdiscr_tcHighEffC","hdiscr_tcHighEffC",25,1,6);
TH1D *hdiscr_tcHighEffL = new TH1D("hdiscr_tcHighEffL","hdiscr_tcHighEffL",25,1,6);
hdiscr_tcHighEff->Sumw2(); hdiscr_tcHighEffB->Sumw2(); hdiscr_tcHighEffC->Sumw2(); hdiscr_tcHighEffL->Sumw2();
TH1D *hdiscr_tcHighPur = new TH1D("hdiscr_tcHighPur","hdiscr_tcHighPur",25,1,6);
TH1D *hdiscr_tcHighPurB = new TH1D("hdiscr_tcHighPurB","hdiscr_tcHighPurB",25,1,6);
TH1D *hdiscr_tcHighPurC = new TH1D("hdiscr_tcHighPurC","hdiscr_tcHighPurC",25,1,6);
TH1D *hdiscr_tcHighPurL = new TH1D("hdiscr_tcHighPurL","hdiscr_tcHighPurL",25,1,6);
hdiscr_tcHighPur->Sumw2(); hdiscr_tcHighPurB->Sumw2(); hdiscr_tcHighPurC->Sumw2(); hdiscr_tcHighPurL->Sumw2();
TH1D *hnsvtx = new TH1D("hnsvtx","hnsvtx",6,-0.5,5.5);
TH1D *hnsvtxB = new TH1D("hnsvtxB","hnsvtxB",6,-0.5,5.5);
TH1D *hnsvtxC = new TH1D("hnsvtxC","hnsvtxC",6,-0.5,5.5);
TH1D *hnsvtxL = new TH1D("hnsvtxL","hnsvtxL",6,-0.5,5.5);
hnsvtx->Sumw2(); hnsvtxB->Sumw2(); hnsvtxC->Sumw2(); hnsvtxL->Sumw2();
TH1D *hsvtxntrk = new TH1D("hsvtxntrk","hsvtxntrk",12,-0.5,11.5);
TH1D *hsvtxntrkB = new TH1D("hsvtxntrkB","hsvtxntrkB",12,-0.5,11.5);
TH1D *hsvtxntrkC = new TH1D("hsvtxntrkC","hsvtxntrkC",12,-0.5,11.5);
TH1D *hsvtxntrkL = new TH1D("hsvtxntrkL","hsvtxntrkL",12,-0.5,11.5);
hsvtxntrk->Sumw2(); hsvtxntrkB->Sumw2(); hsvtxntrkC->Sumw2(); hsvtxntrkL->Sumw2();
TH1D *hsvtxdl = new TH1D("hsvtxdl","hsvtxdl",20,0,10);
TH1D *hsvtxdlB = new TH1D("hsvtxdlB","hsvtxdlB",20,0,10);
TH1D *hsvtxdlC = new TH1D("hsvtxdlC","hsvtxdlC",20,0,10);
TH1D *hsvtxdlL = new TH1D("hsvtxdlL","hsvtxdlL",20,0,10);
hsvtxdl->Sumw2(); hsvtxdlB->Sumw2(); hsvtxdlC->Sumw2(); hsvtxdlL->Sumw2();
TH1D *hsvtxdls = new TH1D("hsvtxdls","hsvtxdls",40,0,80);
TH1D *hsvtxdlsB = new TH1D("hsvtxdlsB","hsvtxdlsB",40,0,80);
TH1D *hsvtxdlsC = new TH1D("hsvtxdlsC","hsvtxdlsC",40,0,80);
TH1D *hsvtxdlsL = new TH1D("hsvtxdlsL","hsvtxdlsL",40,0,80);
hsvtxdls->Sumw2(); hsvtxdlsB->Sumw2(); hsvtxdlsC->Sumw2(); hsvtxdlsL->Sumw2();
TH1D *hsvtxm = new TH1D("hsvtxm","hsvtxm",32,0,8);
TH1D *hsvtxmB = new TH1D("hsvtxmB","hsvtxmB",32,0,8);
TH1D *hsvtxmC = new TH1D("hsvtxmC","hsvtxmC",32,0,8);
TH1D *hsvtxmL = new TH1D("hsvtxmL","hsvtxmL",32,0,8);
hsvtxm->Sumw2(); hsvtxmB->Sumw2(); hsvtxmC->Sumw2(); hsvtxmL->Sumw2();
TH1D *hsvtxmSV3 = new TH1D("hsvtxmSV3","hsvtxmSV3",32,0,8);
TH1D *hsvtxmSV3B = new TH1D("hsvtxmSV3B","hsvtxmSV3B",32,0,8);
TH1D *hsvtxmSV3C = new TH1D("hsvtxmSV3C","hsvtxmSV3C",32,0,8);
TH1D *hsvtxmSV3L = new TH1D("hsvtxmSV3L","hsvtxmSV3L",32,0,8);
hsvtxmSV3->Sumw2(); hsvtxmSV3B->Sumw2(); hsvtxmSV3C->Sumw2(); hsvtxmSV3L->Sumw2();
TH1D *hsvtxpt = new TH1D("hsvtxpt","hsvtxpt",20,0,100);
TH1D *hsvtxptB = new TH1D("hsvtxptB","hsvtxptB",20,0,100);
TH1D *hsvtxptC = new TH1D("hsvtxptC","hsvtxptC",20,0,100);
TH1D *hsvtxptL = new TH1D("hsvtxptL","hsvtxptL",20,0,100);
hsvtxpt->Sumw2(); hsvtxptB->Sumw2(); hsvtxptC->Sumw2(); hsvtxptL->Sumw2();
TH1D *hsvtxptSV3 = new TH1D("hsvtxptSV3","hsvtxptSV3",20,0,100);
TH1D *hsvtxptSV3B = new TH1D("hsvtxptSV3B","hsvtxptSV3B",20,0,100);
TH1D *hsvtxptSV3C = new TH1D("hsvtxptSV3C","hsvtxptSV3C",20,0,100);
TH1D *hsvtxptSV3L = new TH1D("hsvtxptSV3L","hsvtxptSV3L",20,0,100);
hsvtxptSV3->Sumw2(); hsvtxptSV3B->Sumw2(); hsvtxptSV3C->Sumw2(); hsvtxptSV3L->Sumw2();
TH1D *hnIPtrk = new TH1D("hnIPtrk","hnIPtrk",100,0,100);
TH1D *hnIPtrkB = new TH1D("hnIPtrkB","hnIPtrkB",100,0,100);
TH1D *hnIPtrkC = new TH1D("hnIPtrkC","hnIPtrkC",100,0,100);
TH1D *hnIPtrkL = new TH1D("hnIPtrkL","hnIPtrkL",100,0,100);
hnIPtrk->Sumw2(); hnIPtrkB->Sumw2(); hnIPtrkC->Sumw2(); hnIPtrkL->Sumw2();
TH1D *hnselIPtrk = new TH1D("hnselIPtrk","hnselIPtrk",100,0,100);
TH1D *hnselIPtrkB = new TH1D("hnselIPtrkB","hnselIPtrkB",100,0,100);
TH1D *hnselIPtrkC = new TH1D("hnselIPtrkC","hnselIPtrkC",100,0,100);
TH1D *hnselIPtrkL = new TH1D("hnselIPtrkL","hnselIPtrkL",100,0,100);
hnselIPtrk->Sumw2(); hnselIPtrkB->Sumw2(); hnselIPtrkC->Sumw2(); hnselIPtrkL->Sumw2();
TH1D *hmuptrel = new TH1D("hmuptrel","hmuptrel",40,0,4);
TH1D *hmuptrelB = new TH1D("hmuptrelB","hmuptrelB",40,0,4);
TH1D *hmuptrelC = new TH1D("hmuptrelC","hmuptrelC",40,0,4);
TH1D *hmuptrelL = new TH1D("hmuptrelL","hmuptrelL",40,0,4);
hmuptrel->Sumw2(); hmuptrelB->Sumw2(); hmuptrelC->Sumw2(); hmuptrelL->Sumw2();
TH1D *hmuptrelSV2 = new TH1D("hmuptrelSV2","hmuptrelSV2",40,0,4);
TH1D *hmuptrelSV2B = new TH1D("hmuptrelSV2B","hmuptrelSV2B",40,0,4);
TH1D *hmuptrelSV2C = new TH1D("hmuptrelSV2C","hmuptrelSV2C",40,0,4);
TH1D *hmuptrelSV2L = new TH1D("hmuptrelSV2L","hmuptrelSV2L",40,0,4);
hmuptrelSV2->Sumw2(); hmuptrelSV2B->Sumw2(); hmuptrelSV2C->Sumw2(); hmuptrelSV2L->Sumw2();
TH1D *hmuptrelSV3 = new TH1D("hmuptrelSV3","hmuptrelSV3",40,0,4);
TH1D *hmuptrelSV3B = new TH1D("hmuptrelSV3B","hmuptrelSV3B",40,0,4);
TH1D *hmuptrelSV3C = new TH1D("hmuptrelSV3C","hmuptrelSV3C",40,0,4);
TH1D *hmuptrelSV3L = new TH1D("hmuptrelSV3L","hmuptrelSV3L",40,0,4);
hmuptrelSV3->Sumw2(); hmuptrelSV3B->Sumw2(); hmuptrelSV3C->Sumw2(); hmuptrelSV3L->Sumw2();
TH1D *hipPt = new TH1D("hipPt","hipPt",40,0,40);
TH1D *hipPtB = new TH1D("hipPtB","hipPtB",40,0,40);
TH1D *hipPtC = new TH1D("hipPtC","hipPtC",40,0,40);
TH1D *hipPtL = new TH1D("hipPtL","hipPtL",40,0,40);
hipPt->Sumw2(); hipPtB->Sumw2(); hipPtC->Sumw2(); hipPtL->Sumw2();
TH1D *hipProb0 = new TH1D("hipProb0","hipProb0",40,-1,1);
TH1D *hipProb0B = new TH1D("hipProb0B","hipProb0B",40,-1,1);
TH1D *hipProb0C = new TH1D("hipProb0C","hipProb0C",40,-1,1);
TH1D *hipProb0L = new TH1D("hipProb0L","hipProb0L",40,-1,1);
hipProb0->Sumw2(); hipProb0B->Sumw2(); hipProb0C->Sumw2(); hipProb0L->Sumw2();
TH1D *hipProb1 = new TH1D("hipProb1","hipProb1",40,-1,1);
TH1D *hipProb1B = new TH1D("hipProb1B","hipProb1B",40,-1,1);
TH1D *hipProb1C = new TH1D("hipProb1C","hipProb1C",40,-1,1);
TH1D *hipProb1L = new TH1D("hipProb1L","hipProb1L",40,-1,1);
hipProb1->Sumw2(); hipProb1B->Sumw2(); hipProb1C->Sumw2(); hipProb1L->Sumw2();
TH1D *hip2d = new TH1D("hip2d","hip2d",40,-0.1,0.1);
TH1D *hip2dB = new TH1D("hip2dB","hip2dB",40,-0.1,0.1);
TH1D *hip2dC = new TH1D("hip2dC","hip2dC",40,-0.1,0.1);
TH1D *hip2dL = new TH1D("hip2dL","hip2dL",40,-0.1,0.1);
hip2d->Sumw2(); hip2dB->Sumw2(); hip2dC->Sumw2(); hip2dL->Sumw2();
TH1D *hip2dSig = new TH1D("hip2dSig","hip2dSig",100,-35,65);
TH1D *hip2dSigB = new TH1D("hip2dSigB","hip2dSigB",100,-35,65);
TH1D *hip2dSigC = new TH1D("hip2dSigC","hip2dSigC",100,-35,65);
TH1D *hip2dSigL = new TH1D("hip2dSigL","hip2dSigL",100,-35,65);
hip2dSig->Sumw2(); hip2dSigB->Sumw2(); hip2dSigC->Sumw2(); hip2dSigL->Sumw2();
TH1D *hip2d1 = new TH1D("hip2d1","hip2d1",40,-0.1,0.1);
TH1D *hip2d1B = new TH1D("hip2d1B","hip2d1B",40,-0.1,0.1);
TH1D *hip2d1C = new TH1D("hip2d1C","hip2d1C",40,-0.1,0.1);
TH1D *hip2d1L = new TH1D("hip2d1L","hip2d1L",40,-0.1,0.1);
hip2d1->Sumw2(); hip2d1B->Sumw2(); hip2d1C->Sumw2(); hip2d1L->Sumw2();
TH1D *hip2dSig1 = new TH1D("hip2dSig1","hip2dSig1",100,-35,65);
TH1D *hip2dSig1B = new TH1D("hip2dSig1B","hip2dSig1B",100,-35,65);
TH1D *hip2dSig1C = new TH1D("hip2dSig1C","hip2dSig1C",100,-35,65);
TH1D *hip2dSig1L = new TH1D("hip2dSig1L","hip2dSig1L",100,-35,65);
hip2dSig1->Sumw2(); hip2dSig1B->Sumw2(); hip2dSig1C->Sumw2(); hip2dSig1L->Sumw2();
TH1D *hip2d2 = new TH1D("hip2d2","hip2d2",40,-0.1,0.1);
TH1D *hip2d2B = new TH1D("hip2d2B","hip2d2B",40,-0.1,0.1);
TH1D *hip2d2C = new TH1D("hip2d2C","hip2d2C",40,-0.1,0.1);
TH1D *hip2d2L = new TH1D("hip2d2L","hip2d2L",40,-0.1,0.1);
hip2d2->Sumw2(); hip2d2B->Sumw2(); hip2d2C->Sumw2(); hip2d2L->Sumw2();
TH1D *hip2dSig2 = new TH1D("hip2dSig2","hip2dSig2",100,-35,65);
TH1D *hip2dSig2B = new TH1D("hip2dSig2B","hip2dSig2B",100,-35,65);
TH1D *hip2dSig2C = new TH1D("hip2dSig2C","hip2dSig2C",100,-35,65);
TH1D *hip2dSig2L = new TH1D("hip2dSig2L","hip2dSig2L",100,-35,65);
hip2dSig2->Sumw2(); hip2dSig2B->Sumw2(); hip2dSig2C->Sumw2(); hip2dSig2L->Sumw2();
TH1D *hip2d3 = new TH1D("hip2d3","hip2d3",40,-0.1,0.1);
TH1D *hip2d3B = new TH1D("hip2d3B","hip2d3B",40,-0.1,0.1);
TH1D *hip2d3C = new TH1D("hip2d3C","hip2d3C",40,-0.1,0.1);
TH1D *hip2d3L = new TH1D("hip2d3L","hip2d3L",40,-0.1,0.1);
hip2d3->Sumw2(); hip2d3B->Sumw2(); hip2d3C->Sumw2(); hip2d3L->Sumw2();
TH1D *hip2dSig3 = new TH1D("hip2dSig3","hip2dSig3",100,-35,65);
TH1D *hip2dSig3B = new TH1D("hip2dSig3B","hip2dSig3B",100,-35,65);
TH1D *hip2dSig3C = new TH1D("hip2dSig3C","hip2dSig3C",100,-35,65);
TH1D *hip2dSig3L = new TH1D("hip2dSig3L","hip2dSig3L",100,-35,65);
hip2dSig3->Sumw2(); hip2dSig3B->Sumw2(); hip2dSig3C->Sumw2(); hip2dSig3L->Sumw2();
TH1D *hip3d = new TH1D("hip3d","hip3d",40,-0.1,0.1);
TH1D *hip3dB = new TH1D("hip3dB","hip3dB",40,-0.1,0.1);
TH1D *hip3dC = new TH1D("hip3dC","hip3dC",40,-0.1,0.1);
TH1D *hip3dL = new TH1D("hip3dL","hip3dL",40,-0.1,0.1);
hip3d->Sumw2(); hip3dB->Sumw2(); hip3dC->Sumw2(); hip3dL->Sumw2();
TH1D *hip3dSig = new TH1D("hip3dSig","hip3dSig",100,-35,65);
TH1D *hip3dSigB = new TH1D("hip3dSigB","hip3dSigB",100,-35,65);
TH1D *hip3dSigC = new TH1D("hip3dSigC","hip3dSigC",100,-35,65);
TH1D *hip3dSigL = new TH1D("hip3dSigL","hip3dSigL",100,-35,65);
hip3dSig->Sumw2(); hip3dSigB->Sumw2(); hip3dSigC->Sumw2(); hip3dSigL->Sumw2();
TH1D *hip3d1 = new TH1D("hip3d1","hip3d1",40,-0.1,0.1);
TH1D *hip3d1B = new TH1D("hip3d1B","hip3d1B",40,-0.1,0.1);
TH1D *hip3d1C = new TH1D("hip3d1C","hip3d1C",40,-0.1,0.1);
TH1D *hip3d1L = new TH1D("hip3d1L","hip3d1L",40,-0.1,0.1);
hip3d1->Sumw2(); hip3d1B->Sumw2(); hip3d1C->Sumw2(); hip3d1L->Sumw2();
TH1D *hip3dSig1 = new TH1D("hip3dSig1","hip3dSig1",100,-35,65);
TH1D *hip3dSig1B = new TH1D("hip3dSig1B","hip3dSig1B",100,-35,65);
TH1D *hip3dSig1C = new TH1D("hip3dSig1C","hip3dSig1C",100,-35,65);
TH1D *hip3dSig1L = new TH1D("hip3dSig1L","hip3dSig1L",100,-35,65);
hip3dSig1->Sumw2(); hip3dSig1B->Sumw2(); hip3dSig1C->Sumw2(); hip3dSig1L->Sumw2();
TH1D *hip3d2 = new TH1D("hip3d2","hip3d2",40,-0.1,0.1);
TH1D *hip3d2B = new TH1D("hip3d2B","hip3d2B",40,-0.1,0.1);