-
Notifications
You must be signed in to change notification settings - Fork 0
/
Functions.cc
1154 lines (1100 loc) · 45.8 KB
/
Functions.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <fstream>
#include "fastjet/ClusterSequence.hh"
#include "fastjet/tools/Filter.hh"
#include "fastjet/Selector.hh"
#include "fastjet/tools/MassDropTagger.hh"
//#include "fastjet/contrib/Nsubjettiness.hh"
//#include "fastjet/contrib/Njettiness.hh"
//#include "fastjet/contrib/NjettinessPlugin.hh"
#include "deltaphi.h"
#include <TCanvas.h>
#include <TFile.h>
#include <TArray.h>
#include <TH1D.h>
#include <TH1D.h>
#include <TLegend.h>
#include <TArray.h>
#include <TVector.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <TString.h>
#include <TObject.h>
#include <TMath.h>
#include "root_plot.h" //declare the histos
#include "cuts.h" // basic cuts
using namespace fastjet;
using namespace std;
//using namespace fastjet::contrib;
bool findVBFsimple(vector<PseudoJet> jets, vector<int> & vbftag, vector<int> & listNonTag);
/////////////////////////////////////////////////////////////////
void hello(){cout<<"\n\n\n HELLO!!!! \n\n"<<endl;}
/////////////////////////////////////////////////////////////////
void genhiggs(int counterh, vector<PseudoJet> higgses){
double hhmass = (higgses.at(0)+higgses.at(1)).m();
gen_higgs->Fill(hhmass);
}
/////////////////////////////////////////////////////////////////
bool analyse_2b2w(
vector<PseudoJet> jets, vector<int> fattag, vector<int> btag, vector<int> bmistag,vector<int> vbftag,
vector<PseudoJet> leptons, vector<PseudoJet> neutrinos){
PseudoJet H1,H2;
int nfat=0, nbtag=0, nmistag=0;
float Hmin = higgs_mass*(1-toleranceH1);
float Hmax = higgs_mass*(1+toleranceH1);
bool found = false;
PseudoJet Xres;
int cate;
// we first find the leptonic higgs -- do not consider more than 2 leptons
// do a isolation vector
vector<double> LepIso;
unsigned int minM =0;
unsigned int jsize = jets.size(), vbf1 = vbftag[0], vbf2 = vbftag[1];
std::vector< int > jetn1, jetn2; // to keep the pair
LepIso.push_back(leptons.at(0).delta_R(leptons.at(1)));
for(unsigned int i = 0;i<jsize;i++) {
LepIso.push_back(leptons.at(0).delta_R(jets.at(i)));
LepIso.push_back(leptons.at(1).delta_R(jets.at(i)));
} // close iso vector
int MinDRLep = TMath::LocMin(LepIso.size(), &LepIso[0]);
//if(MinDRLep<0) for(int i = 0;i<LepIso.size();i++)
//cout <<LepIso[MinDRLep]<< endl;
double MTnunu=(neutrinos.at(0)+neutrinos.at(1)).mperp();
if(1>0
&& LepIso[MinDRLep] > lepiso
&& leptons.at(0).pt()> ptlepton
&& leptons.at(1).pt()> ptlepton
&& leptons.at(0).eta()< etab
&& leptons.at(1).eta()< etab
&& MTnunu > 0
//
){
H1 = leptons.at(0)+leptons.at(1)+neutrinos.at(0)+neutrinos.at(1);
// deal with the jets -- separate analysis by number of fattags
for(unsigned int i=0;i<jsize;i++) { nbtag = nbtag + btag[i]; nmistag = nmistag + bmistag[i];}
if(jsize > 2 && fattag.size() >0) {
H2=jets.at(fattag[0]);
// quality requirements
//double massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
//double rapDiff = abs(H1.eta() - H2.eta());
Xres = H1 +H2;
// cout << " category "<<"1"<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
if(
(H2.m() > Hmin && H2.m() < Hmax)
&& (H1+H2).m() >MHH
&& MTnunu < MnunuMax
&& (leptons.at(0)+leptons.at(1)).m() < MeeMax
//&& abs(jets.at(jetn1[minM]).eta()+jets.at(jetn2[minM]).eta())<DetaH
){ found=true; cate =1; } // close quality
//cout << " category "<<cate<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
} // close 1 tag
if(jsize > 3 && !found){
// pair H2 the jets by the minimum invariant mass difference with H1
std::vector<double> a1;
double invmassB = H1.m();
for(unsigned int nj1=0; nj1< jsize; nj1++) if(nj1 != vbf1 && nj1 != vbf2)
for(unsigned int nj2=nj1+1; nj2< jsize; nj2++) if(nj2 != vbf1 && nj2 != vbf2) {
double invmassA = (jets.at(nj1)+jets.at(nj2)).m();
a1.push_back((invmassA-invmassB)*(invmassA-invmassB));
jetn1.push_back(nj1);jetn2.push_back(nj2); // we also what to keep the nj...
} // loop on jets
//Find the minumum value of the vector (iterator version)
minM = TMath::LocMin(a1.size(), &a1[0]);
H2=jets.at(jetn1[minM])+jets.at(jetn2[minM]);
Xres = H2+leptons.at(0)+leptons.at(1)+neutrinos.at(0)+neutrinos.at(1);
if(
(H2.m() > Hmin && H2.m() < Hmax)
&& (H1+H2).m() >MHH
&& MTnunu < MnunuMax
&& (leptons.at(0)+leptons.at(1)).m() < MeeMax
//&& rapDiff<DetaHH
&& abs(jets.at(jetn1[minM]).eta()+jets.at(jetn2[minM]).eta())<DetaH
){ found=true; cate=0;//Cat->Fill(0.,weight);
//if(Xres.m()<250)
//cout << " category "<<"0"<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
} // close quality
} // close if 2 tags
} else return found; // not found 2 leptons
//////////////////////////////////////
if(found==true){
///////////////////////////
// fill the histos
///////////////////////////
//cout<<"fat tag = " <<nfat <<" number of plots "<<basicHiggses.size()<<endl;
const int numvar1=16;
unsigned int numvar11=16;
if( 1>0
&& ((nbtag >cat && cate==0 ) ||
( nbtag >cat-1 && cate==1 ))
){
//cout << " category "<<"0"<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
Cat->Fill(cate,weight);
double monovar[numvar1] = {
H1.m(),H1.pt(),H1.eta(),H1.phi(), //4
H2.m(),H2.pt(),H2.eta(),H2.phi(), // 4
Xres.m(),Xres.pt(),Xres.eta(),Xres.phi(), // 4
nfat,nbtag,nmistag,abs(H1.eta() - H2.eta())
}; //25
for (unsigned int j=0; j<numvar11; j++) basicHiggses[j]->Fill(monovar[j],weight); // weight
///////////////////////////
// fill the jet histos
///////////////////////////
const int numvar2=10;
unsigned int numvar22=10;
PseudoJet vbfmass = jets.at(vbf1) +jets.at(vbf2);
double Deta = abs(jets.at(vbf1).eta() -jets.at(vbf2).eta());
//cout<<"plots vbf "<<basicvbf.size()<<endl;
double monovarvbf[numvar2] = {
jets.at(vbf1).pt(),jets.at(vbf1).eta(), //2
jets.at(vbf2).pt(),jets.at(vbf2).eta(), //2
vbfmass.m(),vbfmass.pt(),Deta, // 2
nfat,nbtag,nmistag
}; //25
for (unsigned int j=0; j<numvar22; j++) basicvbf[j]->Fill(monovarvbf[j],weight); // weight
/////////////////////////////////
// fill leptons histos
////////////////////////////////
//basicLeptons
const int numvar3=12;
unsigned int numvar33=12;
double detalep; detalep = abs((leptons.at(0).eta() - leptons.at(1).eta()));
double drlep=-1; drlep = LepIso[0];
double detabb =-1 ,drbb=-1;
if(cate ==0)if (jets.at(jetn2[minM]).m()>0 ) {
drbb=jets.at(jetn1[minM]).delta_R(jets.at(jetn2[minM]));//
detabb=abs(jets.at(jetn1[minM]).eta()-jets.at(jetn2[minM]).eta());
}
cout<<"plots vbf "<<basicLeptons.size()<<" "<<MTnunu<<endl;
//double met = MET;
double monovarlep[numvar3] = {
leptons.at(0).pt(),leptons.at(0).eta(), //2
leptons.at(1).pt(),leptons.at(1).eta(), //2
(leptons.at(0)+leptons.at(1)).m(),(leptons.at(0)+leptons.at(1)).pt(),detalep , // 2
(H2+leptons.at(0)+leptons.at(1)).m(), detabb,drlep,MTnunu
}; //25
for (unsigned int j=0; j<numvar33; j++) basicLeptons[j]->Fill(monovarlep[j],weight); // weight
} // close if correct btag
btagselected->Fill(nbtag,weight);
} // close if fill
// histos -- met and Mee Ptee
//} // close if the leptons pass the cuts
return found; // close if 2 tags
}//close WWbb
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
bool analyse_4b(
vector<PseudoJet> jets, vector<int> fattag, vector<int> btag, vector<int> bmistag,
vector<int> vbftag, int Xmass){
// pair the jets that was not VBF tagged
bool found = false;
PseudoJet Xres;
// now we separate analysis
// number of fattags
int nfat=0, nbtag=0, nmistag=0;
double massDiff;
int minM,minM2,cate=-2;
// do a vector with btagged jets and fat btagged jets
vector<int> bjets, fatbjets, misbjets, misfatbjets, listNonTag; // list non fat b jets
vector<double> bweights; double final_weight;
unsigned int jsize = jets.size(), fsize = fattag.size(), vbf1 = vbftag[0], vbf2 = vbftag[1];
for(unsigned int i=0;i<jsize;i++) {
nbtag = nbtag + btag[i]; nmistag = nmistag + bmistag[i];
if(btag[i]>0) { // think on mistag later
int teste=0;
for(unsigned int j=0;j<fsize;j++) {
unsigned int ff = fattag[j]; if(ff==i) {
fatbjets.push_back(i);teste=1;
if(btag[i]==2) bweights.push_back(subjet2b); // calculate distances to decide
if(btag[i]==1) bweights.push_back(fatjet2b);
}}
if(teste==0) {bjets.push_back(i); bweights.push_back(normalb);}
} else {listNonTag.push_back(i); bweights.push_back(1);}
}
// change the analysis to take only b--tagged
nfat = fattag.size();// nfat + fattag[i];
PseudoJet H1,H2;
float Hmin1 = higgs_mass*(1-toleranceH2);
float Hmax1 = higgs_mass*(1+toleranceH1);
float Hmin2 = higgs_mass*(1-toleranceH2);
float Hmax2 = higgs_mass*(1+toleranceH2);
double drbb =-1, drbb2 =-1;
std::vector<double> a1,a2;
std::vector< int > jetn1, jetn2,jetn3, jetn4; // to keep the pairs resolved
std::vector<double> a3;
std::vector< int > jetn11, jetn21; // to keep the pairs 1 tag
if(jsize > 3 && nfat >1) { // if 2 tag
//std::cout<<"2 tag! "<<std::endl;
H1=jets.at(fattag[0]);
H2=jets.at(fattag[1]);
// quality requirements
massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
double rapDiff = abs(H1.eta() - H2.eta());
Xres = H1 +H2;
if(1>0
&& H1.m() > minMH && H2.m() > minMH
&& H1.m() > Hmin1 && H1.m() < Hmax1
&& H2.m() > Hmin2 && H2.m() < Hmax2
&& H1.pt() > H1_ptmin && H2.pt() > H2_ptmin
&& Xres.pt() > HH_ptmin
&& (H1+H2).m() >MHH
&& Xres.m() < Xmass*(1.+toleranceX)
&& Xres.m() > Xmass*(1.-toleranceX)
&& rapDiff<DetaHH
){ found=true;
cate=2;
final_weight = bweights[fattag[0]]*bweights[fattag[0]];
//cout << " category "<<cate<<" mass "<<Xres.m()<<endl;
//if(Xres.m()<250) cout << " category "<<2<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
}
} // close 2 tag
else if(nfat >0 && jsize > 4 && found==false) { // if 1 tag
//std::cout<<"1 tag! "<<std::endl;
if(nfat>1) {cout<<"ops! "<<endl;}
//int nj; for(nj=0; nj< jets.size(); nj++) if(fattag[nj]==1) {
H1=jets.at(fattag[0]);//}
// pair H2 the jets by the minimum invariant mass difference with H1
double invmassB = H1.m();
unsigned int fat1 = fattag[0];
for(unsigned int nj1=0; nj1< jsize; nj1++) if(nj1 != vbf1 && nj1 != vbf2 && nj1!=fat1)
for(unsigned int nj2=nj1+1; nj2< jsize; nj2++) if(nj2 != vbf1 && nj2 != vbf2 && nj2!=fat1) {
//std::cout<<nj1<<nj2<<" "<<nj3<<nj4<<std::endl;
double invmassA = (jets.at(nj1)+jets.at(nj2)).m();
a3.push_back((invmassA-invmassB)*(invmassA-invmassB));
jetn11.push_back(nj1);jetn21.push_back(nj2); // we also what to keep the nj...
} // loop on jets
//int minM;
//Find the minumum value of the vector (iterator version)
minM = TMath::LocMin(a3.size(), &a3[0]);
//std::cout<<"hi, the jets pairs are !!!! "<<jetn1[minM]<<jetn2[minM]<<" "
//<<fattag[0]<<std::endl;
H2=jets.at(jetn11[minM])+jets.at(jetn21[minM]);
// quality requirements
massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
Xres = H1 +H2;
double rapDiff = abs(H1.eta() - H2.eta());
if( //massDiff < tolerance && //rapDiff < deltaEtaHH &&
1>0
&& H1.m() > minMH && H2.m() > minMH
&& H1.m() > Hmin1 && H1.m() < Hmax1
&& H2.m() > Hmin2 && H2.m() < Hmax2
&& H1.pt() > H1_ptmin && H2.pt() > H2_ptmin
&& (H1+H2).m() >MHH
&& Xres.pt() > HH_ptmin
&& Xres.m()< Xmass*(1+toleranceX)
&& Xres.m()> Xmass*(1-toleranceX)
&& rapDiff<DetaHH
//&& abs(jets.at(jetn1[minM]).eta()+jets.at(jetn2[minM]).eta())<DetaH
){ found=true;
//if(Xres.m()<250)
cate=1;
final_weight = bweights[fattag[0]]*bweights[jetn11[minM]]*bweights[jetn21[minM]];
} // close quality
} // close if 1 tag
else if(jsize > 5 && found==false) { // resolved
// pair the jets by the minimum invariant mass difference
//std::cout<<"resolved! "<<std::endl;
for(unsigned int nj1=0; nj1< jsize; nj1++)
for(unsigned int nj2=0; nj2< jsize; nj2++)
for(unsigned int nj3=0; nj3< jsize; nj3++)
for(unsigned int nj4=0; nj4< jsize; nj4++)
{
if( 1>0
&& nj1 != vbf1 && nj1 != vbf2
&& nj2 != vbf1 && nj2 != vbf2
&& nj3 != vbf1 && nj3 != vbf2
&& nj4 != vbf1 && nj4 != vbf2
&& nj1 !=nj2 && nj1 !=nj3 && nj1 !=nj4
&& nj2 !=nj3 && nj2 !=nj4
&& nj1 !=nj4
){
double invmassA = (jets.at(nj1)+jets.at(nj2)).m();
double invmassB = (jets.at(nj3)+jets.at(nj4)).m();
//if(invmassA< 50 || invmassB<50) a2.push_back(100000000); else
a2.push_back((invmassA-invmassB)*(invmassA-invmassB));
jetn1.push_back(nj1);jetn2.push_back(nj2); // we also what to keep the nj...
jetn3.push_back(nj3);jetn4.push_back(nj4);
}// close if not btagged
} // loop on jets
//Find the minumum value of the vector (iterator version)
minM2 = TMath::LocMin(a2.size(), &a2[0]);
//std::cout<<"hi, the jets pairs are !!!! "<<jetn1[minM]<<jetn2[minM]<<" "
//<<jetn3[minM]<<jetn4[minM]<<std::endl;
H1=jets.at(jetn1[minM2])+jets.at(jetn2[minM2]);
H2=jets.at(jetn3[minM2])+jets.at(jetn4[minM2]);
// quality requirements
massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
double rapDiff = abs(H1.eta() - H2.eta());
Xres = H1 +H2;
if(
//massDiff < tolerance && //rapDiff < deltaEtaHH &&
1>0
&& H1.m() > minMH && H2.m() > minMH
&& H1.m() > Hmin1 && H1.m() < Hmax1
&& H2.m() > Hmin2 && H2.m() < Hmax2
&& H1.pt() > H1_ptmin && H2.pt() > H2_ptmin
&& (H1+H2).m() >MHH
&& Xres.pt() > HH_ptmin
&& Xres.m()< Xmass*(1.+toleranceX)
&& Xres.m()> Xmass*(1.-toleranceX)
&& rapDiff<DetaHH
//&& H2.m() > 15
){ //std::cout<<"getting there"<<std::endl;
found=true;
cate=0;
final_weight = bweights[jetn1[minM]]*bweights[jetn2[minM]]*bweights[jetn3[minM]]*bweights[jetn4[minM]];
} // close quality
}
//////////////////////////////////////
//if(massDiff > 0.1 && nbtag>3) cout << "failed , btags = "<<H1.m()<<" "<<H2.m()<<" "<<cate<<endl;
//cout << "Mass hyp = "<<Xmass<<endl;
if(found){
///////////////////////////
// fill the histos
///////////////////////////
//cout<<"fat tag = " <<nfat <<" number of plots "<<basicHiggses.size()<<endl;
const int numvar1=16;
unsigned int numvar11=16;
if(
(nbtag >cat && cate==0 ) //|| // && (H1.m()< 50 || H2.m()<50)
//(nbtag >cat-1 && cate==1) ||
//(nbtag >cat-2 && cate==2)
){
//if(H1.m()>130) cout << " category "<<cate<<" mass "<<Xres.m()<<" nbtag "<<nbtag<<endl;
Cat->Fill(cate,weight);
// cout << " category "<<cate<<" mass "<<Xres.m()<<endl;
double monovar[numvar1] = {
H1.m(),H1.pt(),H1.eta(),H1.phi(), //4
H2.m(),H2.pt(),H2.eta(),H2.phi(), // 4
Xres.m(),Xres.pt(),Xres.eta(),Xres.phi(), // 4
nfat,nbtag,nmistag,abs(H1.eta() - H2.eta())
}; //25
for (unsigned int j=0; j<numvar11; j++) basicHiggses[j]->Fill(monovar[j],final_weight); // weight
///////////////////////////
// fill the jet histos
///////////////////////////
const int numvar2=10;
unsigned int numvar22=10;
PseudoJet vbfmass = jets.at(vbf1) +jets.at(vbf2);
double Deta = abs(jets.at(vbf1).eta() -jets.at(vbf2).eta());
//cout<<"plots vbf "<<basicvbf.size()<<endl;
double monovarvbf[numvar2] = {
jets.at(vbf1).pt(),jets.at(vbf1).eta(), //2
jets.at(vbf2).pt(),jets.at(vbf2).eta(), //2
vbfmass.m(),vbfmass.pt(),Deta, // 2
nfat,nbtag,nmistag
}; //25
for (unsigned int j=0; j<numvar22; j++) basicvbf[j]->Fill(monovarvbf[j],final_weight); // weight
/////////////////////////////////
// fill leptons histos with 0
////////////////////////////////
//basicLeptons
const int numvar3=12;
unsigned int numvar33=12;
if(minM2 >0) {
drbb=jets.at(jetn1[minM2]).delta_R(jets.at(jetn2[minM2]));//
drbb2=jets.at(jetn3[minM2]).delta_R(jets.at(jetn4[minM2]));
} else if(minM >0) {drbb=jets.at(jetn11[minM]).delta_R(jets.at(jetn21[minM])); drbb2=0;}
double monovarlep[numvar3] = {0,0,0,0,0,0,0,0,0,drbb,drbb2,0}; //25
for (unsigned int j=0; j<numvar33; j++) basicLeptons[j]->Fill(monovarlep[j],weight); // weight
} // close if correct btag
btagselected->Fill(nbtag,weight);
} // close if fill
//else cout << " category "<<nfat<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
return found; // close if 2 tags
} // close 4b analysis
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
bool analyse_4b_prior(
vector<PseudoJet> jets, vector<int> fattag, vector<int> btag, vector<int> bmistag,
vector<int> vbftag, int Xmass){
// pair the jets using btag
bool found = false, foundvbf =false;
PseudoJet Xres;
// now we separate analysis
// number of fattags
int nfat=0, nbtag=0, nmistag=0;
double massDiff;
int minM,minM2,cate=-2;
// do a vector with btagged jets and fat btagged jets
vector<int> bjets; // list non fat b jets
vector<int> fatbjets;
vector<int> listNonTag; // list the non tagged
unsigned int jsize = jets.size(), fsize = fattag.size();
for(unsigned int i=0;i<jsize;i++) {
nbtag = nbtag + btag[i]; nmistag = nmistag + bmistag[i];
if(1>0
&& btag[i]>0 || (btag[i]==0 && bmistag[i] >0)
) { // think on weight later
int teste=0;
for(unsigned int j=0;j<fsize;j++) {
unsigned int ff = fattag[j];
if(ff==i) {fatbjets.push_back(i);teste=1;}
}
if(teste==0) bjets.push_back(i);
} else listNonTag.push_back(i);
} unsigned int lsize = listNonTag.size(), fbsize = fatbjets.size(), bsize = bjets.size();
//nbfat = fatbjets.size();// nfat + fattag[i];
PseudoJet H1,H2;
float Hmin1 = higgs_mass*(1-toleranceH1);
float Hmax1 = higgs_mass*(1+toleranceH1);
float Hmin2 = higgs_mass*(1-toleranceH2);
float Hmax2 = higgs_mass*(1+toleranceH2);
double drbb =-1, drbb2 =-1;
std::vector<double> a1,a2;
std::vector< int > jetn1, jetn2,jetn3, jetn4; // to keep the pairs resolved
std::vector<double> a3;
std::vector< int > jetn11, jetn21; // to keep the pairs 1 tag
//////////////////////////////////////////////////////////////
if(fbsize > 1) { // if 2 tag
//std::cout<<"2 tag! "<<std::endl;
H1=jets.at(fatbjets[0]);
H2=jets.at(fatbjets[0]);
// quality requirements
massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
double rapDiff = abs(H1.eta() - H2.eta());
Xres = H1 +H2;
if( //massDiff1 < tolerance
//&& massDiff2 < tolerance //rapDiff < deltaEtaHH &&
1>0
&& H1.m() > minMH && H2.m() > minMH
&& H1.m() > Hmin1 && H1.m() < Hmax1
&& H2.m() > Hmin2 && H2.m() < Hmax2
&& H1.pt() > H1_ptmin && H2.pt() > H2_ptmin
&& Xres.pt() > HH_ptmin
&& (H1+H2).m() >MHH
&& Xres.m() < Xmass*(1.+toleranceX)
&& Xres.m() > Xmass*(1.-toleranceX)
&& rapDiff<DetaHH
){
found=true; cate=2;
// then fill the WBF from the non tagged
if(lsize>1) foundvbf = findVBFsimple(jets, vbftag, listNonTag);
}
//cout << " category "<<cate<<" mass "<<Xres.m()<<endl;
//if(Xres.m()<250) cout << " category "<<2<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
} // close 2 tag
//////////////////////////////////////////////////////////////////////////
if(found==false && fbsize > 0 && bsize>1) { // if 1 tag
//std::cout<<"1 tag! "<<std::endl;
// if(nfat>1) {cout<<"ops! "<<endl;}
//int nj; for(nj=0; nj< jets.size(); nj++) if(fattag[nj]==1) {
H1=jets.at(fatbjets[0]);
// pair H2 the jets by the minimum invariant mass difference with H1
double invmassB = 125;// H1.m();
if(bsize==2) {H2=jets.at(bjets[0])+jets.at(bjets[1]);}
else if (bsize>2) {
for(unsigned int nj1=0; nj1< bsize; nj1++) if(bjets[nj1]!=fatbjets[0])
for(unsigned int nj2=nj1+1; nj2< bsize; nj2++) if( bjets[nj2]!=fatbjets[0] && bjets[nj2]!=bjets[nj1]) {
//std::cout<<nj1<<nj2<<" "<<nj3<<nj4<<std::endl;
double invmassA = (jets.at(bjets[nj1])+jets.at(bjets[nj2])).m();
a3.push_back((invmassA-invmassB)*(invmassA-invmassB));
jetn11.push_back(bjets[nj1]);jetn21.push_back(bjets[nj2]);
// we also what to keep the nj...
} // loop on jets
//int minM;
//Find the minumum value of the vector (iterator version)
minM = TMath::LocMin(a3.size(), &a3[0]);
//std::cout<<"hi, the jets pairs are !!!! "<<jetn1[minM]<<jetn2[minM]<<" "
//<<fattag[0]<<std::endl;
H2=jets.at(jetn11[minM])+jets.at(jetn21[minM]);
// quality requirements
// massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
} // close if >2 btag
Xres = H1 +H2;
double rapDiff = abs(H1.eta() - H2.eta());
if( //massDiff < tolerance && //rapDiff < deltaEtaHH &&
1>0
&& H1.m() > minMH && H2.m() > minMH
&& H1.m() > Hmin1 && H1.m() < Hmax1
&& H2.m() > Hmin2 && H2.m() < Hmax2
&& H1.pt() > H1_ptmin && H2.pt() > H2_ptmin
//&& (H1+H2).m() >MHH
&& Xres.pt() > HH_ptmin
&& Xres.m()< Xmass*(1+toleranceX)
&& Xres.m()> Xmass*(1-toleranceX)
&& rapDiff<DetaHH
// && abs(jets.at(jetn1[minM]).eta()+jets.at(jetn2[minM]).eta())<DetaH
){ found=true;
//if(Xres.m()<250)
cate=1;
//if(H2.m() > 110 && H2.m() < 130) cout<<"ops! "<<bjets.size()<<" "<<jets.size()<<" fatjet "<<fattag.size()<<" fatbjet "<<fatbjets.size() <<endl;
if(listNonTag.size()>1) foundvbf = findVBFsimple(jets, vbftag, listNonTag);
} // close quality
// then fill the WBF from the non tagged
//vector<int> listNonTag; // list the non tagged
//for(int nj1=0; nj1< jets.size(); nj1++)
// if(nj1 != fattag[0] || nj1 != jetn11[minM] || nj1 != jetn21[minM]) listNonTag.push_back(nj1);
// if not fat tagged keep
} // close if 1 tag
//////////////////////////////////////////////////////////////////////
if(jsize > 5 && found==false) { // resolved
// pair the jets by the minimum invariant mass difference
//std::cout<<"resolved! "<<std::endl; //cout<<"ops! "<<bjets.size()<<endl;
if (bsize>3) {
for(unsigned int nj1=0; nj1< bsize; nj1++)
for(unsigned int nj2=0; nj2< bsize; nj2++)
for(unsigned int nj3=0; nj3< bsize; nj3++)
for(unsigned int nj4=0; nj4< bsize; nj4++) {
if( 1>0
&& nj1 !=nj2 && nj1 !=nj3 && nj1 !=nj4
&& nj2 !=nj3 && nj2 !=nj4
&& nj1 !=nj4
){
double invmassA = (jets.at(bjets[nj1])+jets.at(bjets[nj2])).m();
double invmassB = (jets.at(bjets[nj3])+jets.at(bjets[nj4])).m();
a2.push_back((invmassA-invmassB)*(invmassA-invmassB));
jetn1.push_back(bjets[nj1]);jetn2.push_back(bjets[nj2]); // we also what to keep the nj...
jetn3.push_back(bjets[nj3]);jetn4.push_back(bjets[nj4]);
} }// loop on jets
//Find the minumum value of the vector (iterator version)
minM2 = TMath::LocMin(a2.size(), &a2[0]);
//std::cout<<"hi, the jets pairs are !!!! "<<jetn1[minM]<<jetn2[minM]<<" "
//<<jetn3[minM]<<jetn4[minM]<<std::endl;
H1=jets.at(jetn1[minM2])+jets.at(jetn2[minM2]);
H2=jets.at(jetn3[minM2])+jets.at(jetn4[minM2]);
// quality requirements
massDiff = abs(2*(H1.m() - H2.m())/(H1.m() + H2.m()));
double rapDiff = abs(H1.eta() - H2.eta());
Xres = H1 +H2;
if(
//massDiff < tolerance && //rapDiff < deltaEtaHH &&
1>0
&& H1.m() > minMH && H2.m() > minMH
&& H1.m() > Hmin1 && H1.m() < Hmax1
&& H2.m() > Hmin2 && H2.m() < Hmax2
&& H1.pt() > H1_ptmin && H2.pt() > H2_ptmin
&& (H1+H2).m() >MHH
&& Xres.pt() > HH_ptmin
&& Xres.m()< Xmass*(1.+toleranceX)
&& Xres.m()> Xmass*(1.-toleranceX)
&& rapDiff<DetaHH
//&& H2.m() > 15
){ //std::cout<<"getting there"<<std::endl;
found=true;
cate=0;
if(listNonTag.size()>1) foundvbf = findVBFsimple(jets, vbftag, listNonTag);
} // close quality
// then fill the WBF from the non tagged
//vector<int> listNonTag; // list the non tagged
//for(int nj1=0; nj1< jets.size(); nj1++)
// if(nj1 != jetn1[minM] || nj1 != jetn2[minM] || nj1 != jetn3[minM] || nj1 != jetn4[minM])
// listNonTag.push_back(nj1); // if not fat tagged keep
} //if not 4 btag
}
//////////////////////////////////////
//if(massDiff > 0.1 && nbtag>3) cout << "failed , btags = "<<H1.m()<<" "<<H2.m()<<" "<<cate<<endl;
//cout << "Mass hyp = "<<Xmass<<endl;
if(found && foundvbf){
///////////////////////////
// fill the histos
///////////////////////////
//cout<<"fat tag = " <<nfat <<" number of plots "<<basicHiggses.size()<<endl;
const int numvar1=16;
if(
(cate==0 ) ||
(cate==1 ) ||
(cate==2 )
){
//if(H1.m()>130) cout << " category "<<cate<<" mass "<<Xres.m()<<" nbtag "<<nbtag<<endl;
Cat->Fill(cate,weight);
//cout << " category "<<cate<<"higgses mass "<<H1.m()<<" "<<H2.m()<<endl;
double monovar[numvar1] = {
H1.m(),H1.pt(),H1.eta(),H1.phi(), //4
H2.m(),H2.pt(),H2.eta(),H2.phi(), // 4
Xres.m(),Xres.pt(),Xres.eta(),Xres.phi(), // 4
nfat,nbtag,nmistag,abs(H1.eta() - H2.eta())
}; //25
unsigned int bh = basicHiggses.size(), bl = basicLeptons.size(), bv = 10; // basicvbf.size();
for (unsigned int j=0; j<bh; j++) basicHiggses[j]->Fill(monovar[j],weight); // weight
///////////////////////////
// fill the jet histos
///////////////////////////
const int numvar2=10;
PseudoJet vbfmass = jets.at(vbftag[0]) +jets.at(vbftag[1]);
double Deta = abs(jets.at(vbftag[0]).eta() -jets.at(vbftag[1]).eta());
//cout<<"plots vbf "<<basicvbf.size()<<endl;
double monovarvbf[numvar2] = {
jets.at(vbftag[0]).pt(),jets.at(vbftag[0]).eta(), //2
jets.at(vbftag[1]).pt(),jets.at(vbftag[1]).eta(), //2
vbfmass.m(),vbfmass.pt(),Deta, // 2
nfat,nbtag,nmistag
}; //25
for (unsigned int j=0; j<bv; j++) basicvbf[j]->Fill(monovarvbf[j],weight); // weight
/////////////////////////////////
// fill leptons histos with 0
////////////////////////////////
//basicLeptons
const int numvar3=12;
if(minM2 >0) {
drbb=jets.at(jetn1[minM2]).delta_R(jets.at(jetn2[minM2]));//
drbb2=jets.at(jetn3[minM2]).delta_R(jets.at(jetn4[minM2]));
} else if(minM >0) {drbb=jets.at(jetn11[minM]).delta_R(jets.at(jetn21[minM])); drbb2=0;}
double monovarlep[numvar3] = {0,0,0,0,0,0,0,0,0,drbb,drbb2,0}; //25
for (unsigned int j=0; j<bl; j++) basicLeptons[j]->Fill(monovarlep[j],weight); // weight
} // close if correct btag
btagselected->Fill(nbtag,weight);
} // close if fill
//else cout << " category "<<nfat<<" mass "<<Xres.m()<<" btags "<<nbtag <<endl;
return found; // close if 2 tags
} // close 4b analysis prior higgs reco
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
bool findVBFsimple(vector<PseudoJet> jets, vector<int> & vbftag, vector<int> & listNonTag){
// find the hightest inv mass pair among jets
std::vector<double> a1;
std::vector< int > jetn1, jetn2; // to keep the pairs
for(unsigned int nj1=0; nj1< listNonTag.size(); nj1++)
for(unsigned int nj2=nj1+1; nj2< listNonTag.size(); nj2++) { // we also what to keep the nj...
double invmass = (jets.at(listNonTag[nj1])+jets.at(listNonTag[nj2])).m();
a1.push_back(invmass); jetn1.push_back(listNonTag[nj1]);jetn2.push_back(listNonTag[nj2]);
} // loop on jets
//
int i1; i1 = TMath::LocMax(a1.size(), &a1[0]); // max inv mass
vbftag.push_back(jetn1[i1]); vbftag.push_back(jetn2[i1]); // save the pair number
double etaVBF = abs(jets.at(vbftag[0]).eta()-jets.at(vbftag[1]).eta());
double MJJ = (jets.at(vbftag[0])+jets.at(vbftag[1])).m();
if( 1>0
&& MJJ > Mjj && etaVBF > DeltayVBF
&& jets.at(vbftag[0]).delta_R(jets.at(vbftag[1])) > DeltaRVBF
&& (jets.at(vbftag[0])+jets.at(vbftag[1])).pt() > PTjj
&& jets.at(vbftag[0]).pt()>jet1_ptminvbf
&& jets.at(vbftag[1]).pt()>jet2_ptminvbf
&& jets.at(vbftag[0]).eta() < etaj
&& jets.at(vbftag[1]).eta() < etaj
){ // apply the VBF cuts
// std::cout<<"hi VBF jets really are !!!! "<<vbftag[0]<<" "<<vbftag[1]<<std::endl;
// cout << " dijet mass "<<(jets.at(vbftag[0])+jets.at(vbftag[1])).m() <<endl;
// cout << " dijet btag "<<btag[vbftag[0]]<<btag[vbftag[1]] <<endl;
return true;
} else return false; // close VBF cuts
} // close VBF selection
/////////////////////////////////////////////////////////////////
bool findVBF(vector<PseudoJet> jets, vector<int> fattag, vector<int> btag, vector<int> bmistag, vector<int> & vbftag){
// highest invariant mass among the non-tagged
vector<int> listNonTag; // list the non tagged
unsigned int jsize = jets.size();
for(unsigned int nj1=0; nj1< jsize; nj1++) {
//cout<<"fat tagged = " <<fattag[nj1]<<" b-quarks mistagged =
//" <<bmistag[nj1] <<" b-quark = " <<btag[nj1] <<endl;
if(1>0
// && fattag[nj1]==0
&& btag[nj1] ==0 // if not b tagged see
//&& bmistag[nj1]==0 // if not b mis tagged see
) {
int found=0;
//for(int nj2=0; nj2< fattag.size(); nj2++)
// {if(fattag[nj2]==nj1){found=1; break;}}
if(found==0) listNonTag.push_back(nj1); // if not fat tagged keep
}
}
unsigned int nsize = listNonTag.size(); // cout<<"enter vbf! "<<nsize<<endl;
if(nsize>1){ // find the hightest inv mass pair
int nfat=0, nbtag=0, nmistag=0;
for(unsigned int i=0;i<nsize;i++)
{//nfat = nfat + fattag[listNonTag[i]];
nbtag = nbtag + btag[listNonTag[i]]; nmistag = nmistag + bmistag[listNonTag[i]];}
std::vector<double> a1;
std::vector< int > jetn1, jetn2; // to keep the pairs
for(unsigned int nj1=0; nj1< nsize; nj1++)
for(unsigned int nj2=nj1+1; nj2< nsize; nj2++) { // we also what to keep the nj...
double invmass = (jets.at(listNonTag[nj1])+jets.at(listNonTag[nj2])).m();
a1.push_back(invmass); jetn1.push_back(listNonTag[nj1]);jetn2.push_back(listNonTag[nj2]);
} // loop on jets
//
int i1; i1 = TMath::LocMax(a1.size(), &a1[0]); // max inv mass
vbftag.push_back(jetn1[i1]); vbftag.push_back(jetn2[i1]); // save the pair number
double etaVBF = abs(jets.at(vbftag[0]).eta()-jets.at(vbftag[1]).eta());
double MJJ = (jets.at(vbftag[0])+jets.at(vbftag[1])).m();
if( 1>0
&& MJJ > Mjj && etaVBF > DeltayVBF
&& jets.at(vbftag[0]).delta_R(jets.at(vbftag[1])) > DeltaRVBF
&& (jets.at(vbftag[0])+jets.at(vbftag[1])).pt() > PTjj
&& jets.at(vbftag[0]).pt()>jet1_ptminvbf
&& jets.at(vbftag[1]).pt()>jet2_ptminvbf
&& jets.at(vbftag[0]).eta() < etaj
&& jets.at(vbftag[1]).eta() < etaj
){ // apply the VBF cuts
// std::cout<<"hi VBF jets really are !!!! "<<vbftag[0]<<" "<<vbftag[1]<<std::endl;
// cout << " dijet mass "<<(jets.at(vbftag[0])+jets.at(vbftag[1])).m() <<endl;
// cout << " dijet btag "<<btag[vbftag[0]]<<btag[vbftag[1]] <<endl;
return true;
} else return false; // close VBF cuts
} else { //cout<<"not enought vbf ! "<<listNonTag.size()<<endl;
return false;}// close if listnontag>1
} // close VBF selection
/////////////////////////////////////////////////////////////////
void isbtagged(vector<PseudoJet> jets, vector<int> & btag, vector<int> & bmistag);
/////////////////////////////
int recojets(vector<PseudoJet> particles,vector<PseudoJet> & jets_akt, vector<int> & btag, vector<int> & bmistag, vector<int> & fattag){
JetDefinition akt(antikt_algorithm, RR);
ClusterSequence cs_akt(particles, akt);
//vector<PseudoJet> jets_akt;
Selector jet_selector = SelectorPtMin(jet_ptmin) && SelectorAbsRapMax(rapmax);
if(shower){
// first we do akt jets from particles
jets_akt = sorted_by_pt(jet_selector(cs_akt.inclusive_jets()));
}
else{
double const ptmin=0.0; // if parton jet pt min zero
Selector jet_selector_parton = SelectorPtMin(ptmin);
jets_akt = sorted_by_pt(jet_selector_parton(cs_akt.inclusive_jets()));
}
unsigned int njets = jets_akt.size();
//cout<<njets<<endl;
Njets_passing_kLooseID->Fill(njets,weight);
isbtagged(jets_akt, btag, bmistag); // check wheather the b(c)jet is b--(mis)tagable
///////////////////// check tag
JetDefinition CA10(cambridge_algorithm, Rsb);
// Filter definition to improve mass resolution
Filter filter(JetDefinition(cambridge_algorithm, Rfilt), SelectorNHardest(n_subjet));
PseudoJet tagged_jet;
for (unsigned int i = 0; i < njets; i++) { // to each akt jet
// first recluster with some large CA (needed for mass-drop)
ClusterSequence cs_tmp(jets_akt[i].constituents(), CA10);
// next get hardest jet
PseudoJet ca_jet = sorted_by_pt(cs_tmp.inclusive_jets())[0]; // find the cores
// now run mass drop tagger
MassDropTagger md_tagger(mu, ycut); // define the cut on mass drop
// mu: ratio in between mass of cores, symetric splitting
tagged_jet = md_tagger(ca_jet);
if(tagged_jet.m()>10) {
PseudoJet filtered_jet = filter(jets_akt.at(i)); // filter to tag
if(filtered_jet.m()>Mfat) fattag.push_back(i); //see = 1; else see = 0; // no fat tag
} //else see = 0;
} // close find mass drop
//jets = jets_akt;
//////////////////////////// see n-subjetiness
/* for (int i = 0; i < jets_akt.size(); i++) { // to each akt jet
// want the 31 and 21, by now the basic usage of 21
double beta = 1.0; // beta
UnnormalizedMeasure measureSpec1(beta);
OnePass_WTA_KT_Axes axisMode1;
//Njettiness::AxesMode axisMode;
//axisMode = Njettiness::onepass_kt_axes;
NsubjettinessRatio nSubRatio21(2, 1, axisMode1, measureSpec1);
double tau21 = nSubRatio21(jets_akt[i]);
} // to each kt jet */
return njets;
} // close cluster jets
////////////////////////////////////////////////////////////////////////////////////////////////
void isbtagged(vector<PseudoJet> jets, vector<int> & btag, vector<int> & bmistag){
unsigned int jsize = jets.size();
for (unsigned int i=0; i<jsize; i++) { // check wheter jet have inside a b's are taggable
int see=0,see2=0;
vector<PseudoJet> constitu=jets.at(i).constituents();
unsigned int csize = constitu.size();
for (unsigned int j=0; j<csize; j++) {
//cout<<"constituents flavour "<<constitu.at(j).user_index()<<endl;
if((constitu.at(j).user_index() == 5 || constitu.at(j).user_index() == -5) // work !!
&& constitu.at(j).pt() > bjetpt
&& constitu.at(j).eta() < etab
) {see++;}//btag.push_back(1);} else btag.push_back(0);
if( abs(constitu.at(j).user_index()) == 4 // work !!
&& constitu.at(j).pt() > bjetpt
&& constitu.at(j).eta() < etab
) {see2++;}// bmistag.push_back(1);} bmistag.push_back(0);
} // close constituents
//bmistag.push_back(see2);
btag.push_back(see); //else btag.push_back(0); // count all tag/jet
// if(see>0) btag.push_back(1); else btag.push_back(0); // count only one tag/jet
if(see2>0) bmistag.push_back(1); else bmistag.push_back(0); // count only one tag/jet
//cout<<"b-quarks mistagged = " <<bmistag[i] <<" b-quark = " <<btag[i] <<endl;
} // close for each jet
} // close isbtagged
/////////////////////////////////////////////////////////////////////////
// save the histos
int save_hist(int nmass, bool resonant,bool bkg, bool fourb){
const char* Mass;
if(resonant && !bkg) {
if(fourb) Mass = Form("spin0/shower/Control_shower_%d.root",nmass);
if(!fourb) Mass = Form("bulk_graviton_mad_WWbb/Control_shower_%d.root",nmass);
//Mass = Form("histos/Madgraph0_0137/Control_shower_%d.root",nmass);
}
else if(!bkg && fourb) Mass = Form("nonresonant/Control_shower_%d.root",nmass);
else if(!bkg && !fourb) Mass = Form("nonresWWbb/Control_shower_%d.root",nmass);
else Mass = Form("4bsbkg/Control_shower_%d.root",nmass);
TFile f1(Mass, "recreate");
f1.cd();
Njets_passing_kLooseID->Write();
Cat->Write();
btagselected->Write();
gen_higgs->Write();
unsigned int bl = basicLeptons.size(), bh = basicHiggses.size(), bv = 10;// basicvbf.size();
for (unsigned int j=0; j<bl; j++){basicLeptons[j]->Write();} //
for (unsigned int j=0; j<bh; j++){basicHiggses[j]->Write();} //
for (unsigned int i=0; i<bv; i++) {basicvbf[i]->Write();}
f1.Close();
//
Njets_passing_kLooseID->Reset();
Cat->Reset();
gen_higgs->Reset();
btagselected->Reset();
// basicLeptons->Reset();
// basicHiggses->Reset();
// basicvbf->Reset();
for (unsigned int i=0; i<bl; i++) basicLeptons[i]->Reset();
for (unsigned int i=0; i<bh; i++) basicHiggses[i]->Reset();
for (unsigned int i=0; i<bv; i++) basicvbf[i]->Reset();
return 0;
}
///////////////////////////////////////////////////////////////////////////
// declare the histos
int decla(int mass){
const char* label="i";
Njets_passing_kLooseID = new TH1D("njets_passing_kLooseID_ct4",
label,
13, -0.5, 12.5);
Njets_passing_kLooseID->GetYaxis()->SetTitle("");
Njets_passing_kLooseID->GetXaxis()->SetTitle("Njets after showering");
gen_higgs = new TH1D("gen_higgs",
label,
90, 50, 1550);
gen_higgs->GetYaxis()->SetTitle("");
gen_higgs->GetXaxis()->SetTitle("gen Mhh");
btagselected = new TH1D("btagselected",
label,
13, -0.5, 12.5);
btagselected->GetYaxis()->SetTitle("");
btagselected->GetXaxis()->SetTitle("b-tagable b's on selected events");
//
TH1D *H1hist = new TH1D("H1hist",
label,
90, -10, 385);
//H1hist->GetYaxis()->SetTitle("Events .");
H1hist->GetXaxis()->SetTitle("M_{H1} (GeV)");
basicHiggses.push_back (H1hist);
TH1D *H1histpt = new TH1D("H1histpt",
label,
20, 0, 300);
H1histpt->GetYaxis()->SetTitle("Events/ 2 GeV");
H1histpt->GetXaxis()->SetTitle("H1 P_T (GeV)");
basicHiggses.push_back (H1histpt);
TH1D *H1histeta = new TH1D("H1histeta",
label,
30, -6, 6);
H1histeta->GetYaxis()->SetTitle("Events/ 2 GeV");
H1histeta->GetXaxis()->SetTitle("#eta_{H1} (GeV)");
basicHiggses.push_back (H1histeta);
TH1D *H1histphi = new TH1D("H1histphi",
label,
30, 0, 5);
H1histphi->GetYaxis()->SetTitle("Events/ 2 GeV");
H1histphi->GetXaxis()->SetTitle("#phi_{H1} (GeV)");
basicHiggses.push_back (H1histphi);
//
TH1D *H2hist = new TH1D("H2hist",
label,
90, -10, 385);
H2hist->GetYaxis()->SetTitle("Events/ 2 GeV");
H2hist->GetXaxis()->SetTitle("M_{H2} (GeV)");
basicHiggses.push_back (H2hist);
TH1D *H2histpt = new TH1D("H2histpt",
label,
20, 0, 300);
H2histpt->GetYaxis()->SetTitle("Events/ 2 GeV");
H2histpt->GetXaxis()->SetTitle("H2 P_T (GeV)");
basicHiggses.push_back (H2histpt);
TH1D *H2histeta = new TH1D("H2histeta",
label,
30, -6, 6);
H2histeta->GetYaxis()->SetTitle("Events/ 2 GeV");
H2histeta->GetXaxis()->SetTitle("#eta_{H2} (GeV)");
basicHiggses.push_back (H2histeta);
TH1D *H2histphi = new TH1D("H2histphi",
label,
30, 0, 5);
H2histphi->GetYaxis()->SetTitle("Events/ 2 GeV");
H2histphi->GetXaxis()->SetTitle("#phi_{H2} (GeV)");
basicHiggses.push_back (H2histphi);
//
TH1D *RRadMass = new TH1D("RadMass_ct4",
label,
80, 50, 1100);
RRadMass->GetXaxis()->SetTitle("M_{ HH } (GeV)");
basicHiggses.push_back (RRadMass);
TH1D *Radion_pt = new TH1D("radion_pt_ct4",
label,
80, 0, 800);
Radion_pt->GetYaxis()->SetTitle("");
Radion_pt->GetXaxis()->SetTitle("Pt_{HH} (GeV)");
basicHiggses.push_back (Radion_pt);
TH1D *Radion_eta = new TH1D("radion_eta_ct4",
label,
35, -9 , 9);
Radion_eta->GetYaxis()->SetTitle("");
Radion_eta->GetXaxis()->SetTitle("#eta_{HH }");
basicHiggses.push_back (Radion_eta);
//
TH1D *Radion_phi = new TH1D("radion_phi_ct4",
label,
25, 0, 7.14);
Radion_phi->GetYaxis()->SetTitle("");
Radion_phi->GetXaxis()->SetTitle("#phi_{HH}");
basicHiggses.push_back (Radion_phi);
//
TH1D *Nfattag = new TH1D("fattag_ct4",
label,
6, -1.5, 4.5);
Nfattag->GetYaxis()->SetTitle("");
Nfattag->GetXaxis()->SetTitle("Number of fat tags");
basicHiggses.push_back (Nfattag);
TH1D *Nbtag = new TH1D("btag_ct4",
label,
9, -1.5, 7.5);
Nbtag->GetYaxis()->SetTitle("");
Nbtag->GetXaxis()->SetTitle("Number b-jets");
basicHiggses.push_back (Nbtag);
TH1D *Nbmistag = new TH1D("bmistag_ct4",
label,
7, -1.5, 5.5);
Nbmistag->GetYaxis()->SetTitle("");
Nbmistag->GetXaxis()->SetTitle("Number mistagged b jets's");
basicHiggses.push_back (Nbmistag);
TH1D *DetaHH = new TH1D("detahh_ct4",
label,
30, -1.5, 10.5);
DetaHH->GetYaxis()->SetTitle("");
DetaHH->GetXaxis()->SetTitle("#Delta #eta_{HH}");
basicHiggses.push_back (DetaHH);
Cat = new TH1D("cat_ct4",
label,
7, -1.5, 5.5);
Cat->GetYaxis()->SetTitle("");
Cat->GetXaxis()->SetTitle("Tag category");
//basicHiggses.push_back (Cat);
/////////////////////////////////////////////////////////////////////
TH1D *j1histpt = new TH1D("j1histpt",
label,
80, 20, 2000);
j1histpt->GetYaxis()->SetTitle("Events/ 2 GeV");
j1histpt->GetXaxis()->SetTitle("vbf j1 P_T (GeV)");
basicvbf[0]= j1histpt;
TH1D *j1histeta = new TH1D("j1histeta",
label,
32, -6, 6);