-
Notifications
You must be signed in to change notification settings - Fork 0
/
HcalAna.cc
1562 lines (1114 loc) · 52.3 KB
/
HcalAna.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 <TLegend.h>
#include <TDirectory.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TGraph.h>
#include <TMultiGraph.h>
#include <TGraphErrors.h>
#include <math.h>
#include <cmath>
#include <map>
#include "Math/GenVector/VectorUtil.h"
//#include "hDraw.h"
#include "HcalAna.h"
HcalAna::HcalAna(string datacardfile, int u, int y, int t)
{
Input = new AnaInput(datacardfile);
Input->GetParameters("PlotType", &plotType);
Input->GetParameters("Path", &hfolder);
Input->GetParameters("ProcessEvents", &ProcessEvents);
Input->GetParameters("TheData", &datafileName);
//Input->GetParameters("HistoName", &hfName ) ;
Input->GetParameters("MuonCuts", &mucuts);
Input->GetParameters("JetCuts", &jcuts);
cout << "getting parameter" << endl;
Input->GetParameters("parameter1", ¶meter1);
Input->GetParameters("parameter2", ¶meter2);
Input->GetParameters("parameter3", ¶meter3);
Input->GetParameters("sparameter1", &sparameter1);
Input->GetParameters("sparameter2", &sparameter2);
Input->GetParameters("sparameter3", &sparameter3);
Input->GetParameters("parameterh1", ¶meterh1);
Input->GetParameters("parameterh2", ¶meterh2);
Input->GetParameters("parameterh3", ¶meterh3);
Input->GetParameters("sparameterh1", &sparameterh1);
Input->GetParameters("sparameterh2", &sparameterh2);
Input->GetParameters("sparameterh3", &sparameterh3);
Input->GetParameters("nparameter1", &nparameter1);
Input->GetParameters("nparameter2", &nparameter2);
Input->GetParameters("nparameter3", &nparameter3);
Input->GetParameters("snparameter1", &snparameter1);
Input->GetParameters("snparameter2", &snparameter2);
Input->GetParameters("snparameter3", &snparameter3);
Input->GetParameters("nparameterh1", &nparameterh1);
Input->GetParameters("nparameterh2", &nparameterh2);
Input->GetParameters("nparameterh3", &nparameterh3);
Input->GetParameters("snparameterh1", &snparameterh1);
Input->GetParameters("snparameterh2", &snparameterh2);
Input->GetParameters("snparameterh3", &snparameterh3);
Input->GetParameters("histonum", &hisn);
Input->GetParameters("classification", &rec);
Input->GetParameters("type", &type);
Input->GetParameters("innercone", &asub);
Input->GetParameters("maxdr", &drval);
maxdr = drval;
string clever(8, '0');
sprintf(&clever[0], "_dr_%f", drval);
if(sparameter1[0] == 4) rec = 1;
if(asub == 0) sub = "";
cout << "asub is " << asub << endl;
if(asub == 1)
{
sub = "_sub" + clever;
cout << "sub is " << sub << endl;
}
if(asub == 2) sub = "_subd" + clever;
if(asub == 3) sub = "_subu" + clever;
if(rec == 1) ofile = "reco" + sub;
else ofile = "gen" + sub;
string typ1, typ2;
if(parameter1[0] == 1) typ1 = "wdecay";
if(parameter1[0] == 2) typ1 = "jet";
if(parameter1[0] == 3) typ1 = "total";
if(parameter1[0] == 4) typ1 = "rec";
if(sparameter1[0] == 1) typ2 = "wdecay";
if(sparameter1[0] == 2) typ2 = "jet";
if(sparameter1[0] == 3) typ2 = "total";
if(sparameter1[0] == 4) typ2 = "rec";
ofile = ofile + typ1 + "vrs" + typ2;
if(type == 13) ifile = "muons";
if(type == 11) ifile = "electron";
isreco = (rec == 1);
if(u >= 0)parameter1[1] = u;
if(y >= 0)parameter2[1] = y;
if(t >= 0)parameter3[1] = t;
///Hey file name hopefully
//////more lazy work
snparameterh1[1] = snparameter1[1] = nparameterh1[1] = nparameter1[1];
snparameterh2[1] = snparameter2[1] = nparameterh2[1] = nparameter2[1];
snparameterh3[1] = snparameter3[1] = nparameterh3[1] = nparameter3[1];
sparameterh1[1] = sparameter1[1] = parameterh1[1] = parameter1[1];
sparameterh2[1] = sparameter2[1] = parameterh2[1] = parameter2[1];
sparameterh3[1] = sparameter3[1] = parameterh3[1] = parameter3[1];
nparameterh1[0] = nparameter1[0] = parameterh1[0] = parameter1[0];
snparameterh1[0] = snparameter1[0] = sparameterh1[0] = sparameter1[0];
parameter3[0] = parameter2[0] = parameter1[0];
sparameter3[0] = sparameter2[0] = sparameter1[0];
parameterh3[0] = parameterh2[0] = parameterh1[0];
sparameterh3[0] = sparameterh2[0] = sparameterh1[0];
nparameter3[0] = nparameter2[0] = nparameter1[0];
snparameter3[0] = snparameter2[0] = snparameter1[0];
nparameterh3[0] = nparameterh2[0] = nparameterh1[0];
snparameterh3[0] = snparameterh2[0] = snparameterh1[0];
///////////////// LAZY AS WAY OF GETTING OUT OF WORK
if(parameter1[1] == 0) parameter1[0] = 0;
if(parameter2[1] == 0) parameter2[0] = 0;
if(parameter3[1] == 0) parameter3[0] = 0;
if(sparameter1[1] == 0) sparameter1[0] = 0;
if(sparameter2[1] == 0) sparameter2[0] = 0;
if(sparameter3[1] == 0) sparameter3[0] = 0;
if(parameterh1[1] == 0) parameterh1[0] = 0;
if(parameterh2[1] == 0) parameterh2[0] = 0;
if(parameterh3[1] == 0) parameterh3[0] = 0;
if(sparameterh1[1] == 0) sparameterh1[0] = 0;
if(sparameterh2[1] == 0) sparameterh2[0] = 0;
if(sparameterh3[1] == 0) sparameterh3[0] = 0;
if(nparameter1[1] == 0) nparameter1[0] = 0;
if(nparameter2[1] == 0) nparameter2[0] = 0;
if(nparameter3[1] == 0) nparameter3[0] = 0;
if(snparameter1[1] == 0) snparameter1[0] = 0;
if(snparameter2[1] == 0) snparameter2[0] = 0;
if(snparameter3[1] == 0) snparameter3[0] = 0;
if(nparameterh1[1] == 0) nparameterh1[0] = 0;
if(nparameterh2[1] == 0) nparameterh2[0] = 0;
if(nparameterh3[1] == 0) nparameterh3[0] = 0;
if(snparameterh1[1] == 0) snparameterh1[0] = 0;
if(snparameterh2[1] == 0) snparameterh2[0] = 0;
if(snparameterh3[1] == 0) snparameterh3[0] = 0;
////////////
cout << "parameter1[0] " << parameter1[0] << endl;
cout << "parameterh1[1] " << parameterh1[1] << endl;
cout << "parameter2[0] " << parameter2[0] << endl;
cout << "parameterh2[1] " << parameterh2[1] << endl;
cout << "parameter3[0] " << parameter3[0] << endl;
cout << "parameterh3[1] " << parameterh3[1] << endl;
Input->GetParameters("comp1", &comp1);
Input->GetParameters("comp2", &comp2);
comp.push_back(comp1);
// Set the address for the branches
tr = Input->GetTree(datafileName, "HcalUpgrade");
cout << datafileName << std::endl;
tr->SetBranchAddress("lepPx", lepPx);
tr->SetBranchAddress("lepPy", lepPy);
tr->SetBranchAddress("lepPz", lepPz);
tr->SetBranchAddress("lepE", lepE);
tr->SetBranchAddress("nJets", &nJets); //so number of jets
tr->SetBranchAddress("jetE", jetE);
tr->SetBranchAddress("jetPx", jetPx);
tr->SetBranchAddress("jetPy", jetPy);
tr->SetBranchAddress("jetPz", jetPz);
tr->SetBranchAddress("nGen", &nGen); //find number of events byprodects that are detected
tr->SetBranchAddress("pdgId", &bid); //baby ID
tr->SetBranchAddress("momId", &mom); //moms ID
tr->SetBranchAddress("genPx", bPx); //babies shit
tr->SetBranchAddress("genPy", bPy);
tr->SetBranchAddress("genPz", bPz);
tr->SetBranchAddress("genE", bE);
tr->SetBranchAddress("gen_hcalE", gen_hcalE);
tr->SetBranchAddress("gen_hcaldR", gen_hcaldR);
//So this should be the isolation shit reality muons
if(isreco)
{
tr->SetBranchAddress("lepIso1", iso.getArrayPtr(1));
tr->SetBranchAddress("lepIso2", iso.getArrayPtr(2));
tr->SetBranchAddress("lepIso3", iso.getArrayPtr(3));
tr->SetBranchAddress("lepIso4", iso.getArrayPtr(4));
tr->SetBranchAddress("lepIso5", iso.getArrayPtr(5));
tr->SetBranchAddress("lepIhit1", isoh.getArrayPtr(1));
tr->SetBranchAddress("lepIhit2", isoh.getArrayPtr(2));
tr->SetBranchAddress("lepIhit3", isoh.getArrayPtr(3));
tr->SetBranchAddress("lepIhit4", isoh.getArrayPtr(4));
tr->SetBranchAddress("lepIhit5", isoh.getArrayPtr(5));
} else
{
tr->SetBranchAddress("genIso1", iso.getArrayPtr(1)); //energy
tr->SetBranchAddress("genIso2", iso.getArrayPtr(2));
tr->SetBranchAddress("genIso3", iso.getArrayPtr(3));
tr->SetBranchAddress("genIso4", iso.getArrayPtr(4));
tr->SetBranchAddress("genIso5", iso.getArrayPtr(5));
//number of hits for reals
tr->SetBranchAddress("genIhit1", isoh.getArrayPtr(1));
tr->SetBranchAddress("genIhit2", isoh.getArrayPtr(2));
tr->SetBranchAddress("genIhit3", isoh.getArrayPtr(3));
tr->SetBranchAddress("genIhit4", isoh.getArrayPtr(4));
tr->SetBranchAddress("genIhit5", isoh.getArrayPtr(5));
}
tr->SetBranchAddress("genE", genE);
//iso due to reconstructed
//tr->SetBranchAddress("muIso1", riso1);
tr->SetBranchAddress("nLeptons", &nlep);
tr->SetBranchAddress("lepE", lepE);
/////////////////////
///////////////
// Input->GetParameters("aroundwego", &aro);
// grabdata(datacardfile);
if(u > 0)aro = 1;
else aro = 0;
if(aro == 1) ofile = "all_" + ofile;
sprintf(hfName, "%d%d%d_%d%d%d", parameter1[1], parameter2[1], parameter3[1], nparameter1[1], nparameter2[1], nparameter3[1]);
if(aro == 1) comp2 = string(hfName);
comp.push_back(comp2);
string parx("null");
// Read the ntuple tree
}
HcalAna::~HcalAna()
{
delete Input;
}
float eta(float x, float y, float z)
{
float theta, feta, tht; //tht- tan of half of theta feta is final eta
theta = atan(fabs(sqrt(y * y + x * x) / z));
tht = tan(theta / 2);
feta = -log(tht);
return feta;
}
// analysis template
void HcalAna::Analysis()
{
if(parameter1[0] == 0)parameter1[1] = 0;
if(parameter2[0] == 0)parameter2[1] = 0;
if(parameter3[0] == 0)parameter3[1] = 0;
if(nparameter1[0] == 0)nparameter1[1] = 0;
if(nparameter2[0] == 0)nparameter2[1] = 0;
if(nparameter3[0] == 0)nparameter3[1] = 0;
sprintf(hfName, "%d%d%d_%d%d%d", parameter1[1], parameter2[1], parameter3[1], nparameter1[1], nparameter2[1], nparameter3[1]);
// Prepare file and folder for histograms
cout << "so here should have other shit " << ofile << endl;
gSystem->mkdir(ofile.c_str());
gSystem->mkdir((ofile + "/" + ifile).c_str());
hfolder = "SLHC_" + string(hfName);
gSystem->mkdir((ofile + "/" + ifile + "/" + hfolder).c_str());
// create histogram files
TString Path_fName = ofile + "/" + ifile + "/" + hfolder + "/" + hfName + ".root"; //probably dont need to worry about
cout << Path_fName << endl << endl;
theFile = new TFile(Path_fName, "RECREATE");
theFile->cd();
jets_directory = theFile->mkdir("Jets", "Jets");
w_directory = theFile->mkdir("wbos", "wbos");
t_directory = theFile->mkdir("gtot", "gtot");
rec_directory = theFile->mkdir("reconstructed", "reconstructed");
compare_directory = theFile->mkdir("compare", "compare");
// booking histograms
//histos["h_nMu"] = new TH1D("h_nMu", " number of reco Muons ", 9, 0., 9. ) ;
//t_directory->cd();
g_realte = new TH1D("g_realte", "the eta of the generated particels of the total", 50, -.8, .8); // eta of total
h_lepPt = new TH1D("h_lepPt", " muon Pt ", 50, 30, 400);
h_nJets = new TH1D("h_nJets", "should be total number of generated oer event", 15, 0, 15); // again added by me should make new histograms
//h_Jets = new TH1D("h_Jets ", " highest energy of a jet per event", 50, 0, 5000 );
g_isolt1 = new TH1D("g_isolt1", "the look of the iso due to muons of the first layer", 50, 0, 300); //jet
g_isolt12 = new TH1D("g_isolt12", "the look of the iso due to muons of the first and second layer", 50, 0, 300);
g_isolt123 = new TH1D("g_isolt123", "the look of the iso due to muons of all three layers", 50, 0, 300);
g_isolth1 = new TH1D("g_isolth1", "the number of hits in the isolated regeon around the muon on the first layer", 50, 0, 50); //w decay hits
g_isolth12 = new TH1D("g_isolth12", "he number of hits in the isolated regeon around the muon on the first and second layers", 50, 0, 50);
g_isolth123 = new TH1D("g_isolth123", "the number of hits in the isolated regeon around the muon on the three layers", 50, 0, 50);
g_realtp = new TH1D("g_realtp", "the pt of the real of the total", 50, 0, 500); //momentum of total
jets_directory->cd();
h_gjets = new TH1D("gjets", "number of muons created by jets", 5, 0, 5);
g_isolj1 = new TH1D("g_isolj1", "the energy deposted on the first layer for the isolated muons", 50, 0, 300); //deposted stuff isolated g mean denerated
g_isolj12 = new TH1D("g_isolj12", "the energy deposted on the first and second layer for the isolated muons", 50, 0, 300);
g_isolj123 = new TH1D("g_isolj123", "the energy deposted on the all three layers for the isolated muons", 50, 0, 100);
h_JetsPt = new TH1D("h_JetsPt ", " highest momentum of a jet per event", 50, 30, 400);
g_realje = new TH1D("g_realje", "the eta of the muon due to a jet", 50, -.8, .8); //eta of jets
g_realjp = new TH1D("g_realjp", "the pt of the of the jet", 50, 0, 500); //momentum of jets
g_isoljh1 = new TH1D("g_isoljh1", "the number of hits in the isolated regeon around the muon on the first layer due to jets", 60, 0, 60); //number of hits
g_isoljh12 = new TH1D("g_isoljh12", "the number of hits in the isolated regeon around the muon on the first and second layers due to jets", 60, 0, 60);
g_isoljh123 = new TH1D("g_isoljh123", "the number of hits in the isolated regeon around the muon on the three layers due to jets", 60, 0, 60);
rec_directory->cd();
h_nMu = new TH1D("h_nMu", " number of reco Muons ", 9, 0., 9.);
r_isol1 = new TH1D("r_isol1", "the engery deposted iso of the reconstructed muon on the first layer", 50, 0, 300); //reconstructed iso
r_isol12 = new TH1D("r_isol12", "the engery deposted iso of the reconstructed muon on the first and second layer", 50, 0, 300);
r_isol123 = new TH1D("r_isol123", "the engery deposted iso of the reconstructed muon on the all three layers", 50, 0, 300);
r_isolh1 = new TH1D("r_isolh1", "the number of hits around the isolated muon on the first layer", 60, 0, 60); //reconstructed iso hits
r_isolh12 = new TH1D("r_isolh12", "the number of hits around the isolated muon on the first and second layer", 60, 0, 60);
r_isolh123 = new TH1D("r_isolh123", "the number of hits around the isolated muon on all three layers", 60, 0, 60);
w_directory->cd();
//w
g_realwp = new TH1D("g_realwp", " the pt of the due to w", 50, 0, 500); //momentum of w decayed muons
g_realwe = new TH1D("g_realwe", " the eta of the zero crash due to w", 50, -.8, .8); //eta of w boson
g_isolw1 = new TH1D("g_isolw1", "the look of the iso muons energy depost due to w decay on the first layer", 50, 0, 100); //w decay iso deposit
g_isolw12 = new TH1D("g_isolw12", "the look of the iso muons energy deposit caused by w decay on the first and second layer", 50, 0, 300);
g_isolw123 = new TH1D("g_isolw123", "the look of the iso muons energy depost from w decays on all three layers", 50, 0, 100);
h_gwz = new TH1D("gwz", "number of muons created by w decay", 5, 0, 5); //number of generated by w decay
g_isolwh1 = new TH1D("g_isolwh1", "the number of hits in the isolated regeon around the muon on the first layer due to w", 50, 0, 50); //w decay hits
g_isolwh12 = new TH1D("g_isolwh12", "he number of hits in the isolated regeon around the muon on the first and second layers due to w", 50, 0, 50);
g_isolwh123 = new TH1D("g_isolwh123", "the number of hits in the isolated regeon around the muon on the three layers due to w", 50, 0, 50);
//hey don't forget you need this if you are using multiple efficiancies at the same time
compare_directory -> cd();
for(int i = 0; i < 6; i++)
{
char mesh1_name[5];
char mesh2_name[5];
char meshh1_name[5];
char meshh2_name[5];
sprintf(mesh1_name, "mesh1%d", i);
sprintf(mesh2_name, "mesh2%d", i);
sprintf(meshh1_name, "meshh1%d", i);
sprintf(meshh2_name, "meshh2%d", i);
if(parameter1[3] == 1)
{
mesh1.push_back(new TH1D(mesh1_name, "so this is whatever you chose to add together deposit energy", 400, 0, 200));
}
if(sparameter1[3] == 1)
{
mesh2.push_back(new TH1D(mesh2_name, "so this is whatever you chose to add together deposit energy", 400, 0, 200));
}
meshh1.push_back(new TH1D(meshh1_name, "so this is whate.00001ver you chose to add together deposit hits", 50, 0, 50));
meshh2.push_back(new TH1D(meshh2_name, "so this is whatever you chose to add together deposit hits", 50, 0, 50));
}
float pjets = 0;
int count;
int totalN = tr->GetEntries();
cout << " Total Number of entries : " << totalN << endl;
// for(int x=1; x<=5; x++)
//{
for(int i = 0; i < totalN; i++) //particular event
{
for(int h = 0; h < 20; h++)
{
test[h] = 0;
}
pjets = 0;
count = 0;
//cout<<endl<<"leaf we are on"<<i<<endl;
if(ProcessEvents > 0 && i >= (ProcessEvents)) break;
// Get the entry from the ntuple
tr->GetEntry(i);
//So here is supposed to look at the generated shit
int evngwz = 0; //event Group from w
int evngnz = 0; // event group not from w
float mesht1 = 0; //so this gives us the total deposted enenergy by the particle
float mesht2 = 0;
float meshht1 = 0; //so this gives us the total deposted enenergy by the particle
float meshht2 = 0;
//cout<<" =============================== "<<endl ;
for(int k = 0; k < nGen; k++)//DUMBASS THIS DOES REALality nGen
{
for(int p = 0; p < (isreco ? nlep : 1); p++)
{
if(!isreco) p = k;
if(test[p] == 1) continue;
mesht1 = 0; //so this gives us the total deposted enenergy by the particle
mesht2 = 0;
meshht1 = 0; //so this gives us the total hits
meshht2 = 0;
TLorentzVector gP4;
gP4.SetPxPyPzE(bPx[k], bPy[k], bPz[k], bE[k]);
TLorentzVector rP4;
rP4.SetPxPyPzE(lepPx[p], lepPy[p], lepPz[p], lepE[p]);
//regedr=sqrt((rP4.Eta()-gP4.Eta())*(rP4.Eta()-gP4.Eta())+(rP4.Theta()-gP4.Theta())*(rP4.Theta()-gP4.Theta()));
// regedr=DeltaR(gP4,rP4);
if(rec == 1) regedr = gP4.DeltaR(rP4);
else regedr = 0;
//printf("Gen (%d) Reco (%d) -> dR = %.5f ", k, p, regedr ) ;
if(abs(bid[k]) == type && abs(mom[k]) == 24 && gP4.Pt() > mucuts[0]&& (isreco ? ((regedr) < .1) : true) && fabs(gP4.Eta()) < mucuts[2])//sees if it comes from a w boson
{
/* if(gisoh1[k][0]+gisoh1[k][1]+gisoh1[k][2]==0)
{
g_crashwe->Fill(gP4.Eta());
g_crashwp->Fill(gP4.Pt());
}
*/
g_realwe->Fill(gP4.Eta());
g_realwp->Fill(gP4.Pt());
massTableofDoom(1, p, mesht1, mesht2, meshht1, meshht2);
////new
}
if(abs(bid[k]) == type && abs(mom[k]) != 24 && gP4.Pt() > mucuts[0]&&(isreco ? (regedr < .1) : true) && eta(bPx[k], bPy[k], bPz[k]) < mucuts[2])// sees if it is a muon form a jet
{
/*if(gisoh1[k][0]+gisoh1[k][1]+gisoh1[k][2]==0) delete me ones this is working
{
g_crashje->Fill(gP4.Eta());
g_crashjp->Fill(gP4.Pt());
}*/
g_realje->Fill(gP4.Eta());
g_realjp->Fill(gP4.Pt());
g_isolj1->Fill(iso(1, k, 0)); // energy
g_isolj12->Fill(iso(1, k, 0) + iso(1, k, 1));
g_isolj123->Fill(iso(1, k, 0) + iso(1, k, 1) + iso(1, k, 2));
g_isoljh1->Fill(isoh(1, k, 0)); //hits
g_isoljh12->Fill(isoh(1, k, 0) + isoh(1, k, 1));
g_isoljh123->Fill(isoh(1, k, 0) + isoh(1, k, 1) + isoh(1, k, 2));
evngnz++;
massTableofDoom(2, p, mesht1, mesht2, meshht1, meshht2);
}
if(abs(bid[k]) == type && gP4.Pt() > mucuts[0] && eta(bPx[k], bPy[k], bPz[k]) < mucuts[2]&&(isreco ? (regedr < .1) : true))
{
//THIS IS TOTAL
//
massTableofDoom(3, p, mesht1, mesht2, meshht1, meshht2);
test[p] = 1;
if(abs(bid[k]) == type && gP4.Pt() > mucuts[0] && gP4.Eta() < mucuts[2]&&(isreco ? regedr < .001 : true))
{
if((parameter1[0] == 1 && abs(mom[k]) == 24) || (parameter1[0] == 2 && abs(mom[k]) != 24) || (parameter1[0] == 3))
{
if(parameter1[3] == 2)
{
mesh1.at(hisn)->Fill(mesht1 / gP4.Pt());
}
if(parameter1[3] == 1)
{
mesh1.at(hisn)->Fill(mesht1 + .00001);
}
}
if((sparameter1[0] == 1 && abs(mom[k]) == 24) || (sparameter1[0] == 2 && abs(mom[k]) != 24) || (sparameter1[0] == 3))
{
if(sparameter1[3] == 2)
{
mesh2.at(hisn)->Fill(mesht2 / gP4.Pt());
}
if(sparameter1[3] == 1)
{
mesh2.at(hisn)->Fill(mesht2 + .0000001);
}
}
if((parameterh1[0] == 1 && abs(mom[k]) == 24) || (parameterh1[0] == 2 && abs(mom[k]) != 24) || (parameterh1[0] == 3))
{
//this should be a graph of hits
if(parameterh1[3] == 2)
{
meshh1.at(hisn)->Fill(meshht1 / lepE[p]);
}
if(parameterh1[3] == 1)
{
meshh1.at(hisn)->Fill(meshht1);
}
}
if((sparameterh1[0] == 1 && abs(mom[k]) == 24) || (sparameterh1[0] == 2 && abs(mom[k]) != 24) || (sparameterh1[0] == 3))
{
if(sparameterh1[3] == 2)
{
meshh2.at(hisn)->Fill(meshht2 / lepE[p]);
}
if(sparameterh1[3] == 1)
{ // if (meshht2<1) cout<<"huh this aint right"<<endl;
meshh2.at(hisn)->Fill(meshht2);
}
}
}
}
}
}
//so this should be used to count number of
///////////////////////////////
for(int p = 0; p < (isreco ? nlep : 0); p++)
{
TLorentzVector rP4;
rP4.SetPxPyPzE(lepPx[p], lepPy[p], lepPz[p], lepE[p]);
TLorentzVector gP4;
gP4.SetPxPyPzE(bPx[p], bPy[p], bPz[p], bE[p]);
if(rP4.Pt() > mucuts[0] && eta(lepPx[p], lepPy[p], lepPz[p]) < mucuts[2])
{
massTableofDoom(4, p, mesht1, mesht2, meshht1, meshht2);
if(sparameter1[0] == 4 && test[p] != 1)
{
if(sparameter1[3] == 1)mesh2.at(hisn)->Fill(mesht2 + .0000001);
if(sparameter1[3] == 2)mesh2.at(hisn)->Fill(mesht2 / rP4.Pt() + .0000001);
meshh2.at(hisn)->Fill(meshht2);
}
}
}
/////////////////
/////////////////////////
//cout<<"number of baby "<<test<<endl;
//int a=evngwz+evngnz;
h_gwz->Fill(evngwz);
h_gjets->Fill(evngnz);
//h_nJets->Fill(a);//DELETE ME this is total number of real particles
//cout<<"number of seen muons "<<count<<endl;
h_nMu->Fill(count);
mesht1 = 0;
mesht2 = 0;
} // end of event looping
// record file in histogram format
theFile->cd();
HistoWrite("", theFile);
// cout<<"so we are off by="<<offby<<endl<<"total number of reco muons="<<tnum<<endl<<"total number of gen="<<tgen<<endl;
cout << " historams written ! " << endl;
theFile->Close();
mesh1.clear();
mesh2.clear();
meshh1.clear();
meshh2.clear();
}
// ****************************************
// * Draw Histograms *
// ****************************************
void HcalAna::DrawHistogram()
{
OpenHistogram();
cout << "crash yet?" << endl;
Draw_H1(mesh1, "first comparisons you wanted to make", mesh2, "second comparisons you wanted to make");
//Draw_H1( mesh2, "second comparisons you wanted to make");
Draw_H2(meshh1, "first hit comparisons you wanted to make ", meshh2, "second comparisons you wanted to make hits");
// Draw_H2( meshh2, "second comparisons you wanted to make");
theFile->Close();
}
void HcalAna::Draw_H1(vector <TH1D*> h1, string plotname, vector <TH1D*> h2 /* = NULL */, string splotname /*""*/)
{
double beg = 0, end = 0;
cout << "Draw_H1 start\n";
TGraph * effi[2];
for(int k = 0; k < 2; k++)
{
cout << "Make " << k << " plot\n";
effi[k] = new TGraph(10);
hfolder = ofile + "/" + ifile + "/SLHC_" + comp.at(k) + "/";
TCanvas* c1 = new TCanvas("c1", "", 800, 700);
c1->SetFillColor(10);
c1->SetFillColor(10);
////c1->SetLogy();
gStyle->SetOptStat("eoumi");
gStyle->SetOptStat("");
h1.at(k)->SetLineColor(2);
c1->SetLogy();
string typ1, typ2, dr1(1, 0), dr2(1, 0), lay1(1, 0), lay2(1, 0), lay3(1, 0), slay1(1, 0), slay2(1, 0), slay3(1, 0);
if(parameter1[0] == 1) typ1 = "wdecay";
if(parameter1[0] == 2) typ1 = "jet";
if(parameter1[0] == 3) typ1 = "total";
if(parameter1[0] == 4) typ1 = "rec";
if(sparameter1[0] == 1) typ2 = "wdecay";
if(sparameter1[0] == 2) typ2 = "jet";
if(sparameter1[0] == 3) typ2 = "total";
if(sparameter1[0] == 4) typ2 = "rec";
if(parameter1[0] != 0)sprintf(&dr1.at(0), "%d", parameter1[1]);
if(sparameter1[0] != 0)sprintf(&dr2.at(0), "%d", sparameter1[1]);
//int x=1+parameter1[2];
if(parameter1[0] != 0)sprintf(&lay1.at(0), "%d", (1 + parameter1[2]));
if(parameter2[0] != 0)sprintf(&lay2.at(0), "%d", (1 + parameter2[2]));
if(parameter3[0] != 0)sprintf(&lay3.at(0), "%d", (1 + parameter3[2]));
if(sparameter1[0] != 0)sprintf(&slay1.at(0), "%d", (1 + sparameter1[2]));
if(sparameter2[0] != 0)sprintf(&slay2.at(0), "%d", (1 + sparameter2[2]));
if(sparameter3[0] != 0)sprintf(&slay3.at(0), "%d", (1 + sparameter3[2]));
// dr1=parameter1[1];
if(h2.at(k) != NULL)
{
float max1 = h1.at(k)->GetAt(h1.at(k)->GetMaximumBin());
float max2 = h2.at(k)->GetAt(h2.at(k)->GetMaximumBin());
h1.at(k)->SetMaximum(1.1 * max(max1, max2));
h1.at(k)->Draw();
h2.at(k)->SetLineColor(8);
h2.at(k)->Draw("same");
TLegend* leg = new TLegend(0.6, 0.7, 0.9, 0.9); // lets make a legend to tell everything apart
leg->SetHeader("energy deposted");
leg-> SetFillColor(kWhite);
leg-> SetShadowColor(kWhite);
leg->AddEntry(h1.at(k), (typ1 + " dr of " + comp.at(k)).c_str(), "l");
leg->AddEntry(h2.at(k), (typ2 + " dr of " + comp.at(k)).c_str(), "l");
leg->Draw();
double maxb[20], mins[20], effb[20], blocks[20];
maxb[0] = 1;
mins[0] = .8;
double maxb2, mins2;
maxb2 = maxb[0];
mins2 = mins[0];
effb[0] = 1;
blocks[0] = 1; //slight misnomer this is how much of the noise gets through
//TGraph* effi = new TGraph(10,mins,blocks);
for(int i = 0; i < 10; i++)
{
efficiency(h1.at(k), h2.at(k), maxb[i], mins[i], effb[i], blocks[i]);
//( TH1D* h1 , string plotname, TH1D* h2 , string splotname, double maxb, double mins, double *effb, double *blocks )
mins2 = .02 + mins2;
maxb2 = maxb2 - .02;
effi[k]->SetPoint(i, mins[i], blocks[i]);
mins[i + 1] = mins2;
maxb[i + 1] = maxb2;
}
beg = mins[0];
end = mins[9];
// first attempt at getting this bloody thing to graph
TCanvas *c2 = new TCanvas("c2", "sooooooooo working? no?", 200, 10, 700, 500);
//Int_t n = 20;
effi[k]->SetName("efficiency");
effi[k]->SetTitle("efficiency");
effi[k]->GetXaxis()->SetTitle("efficiency");
effi[k]->GetYaxis()->SetTitle("Noise");
effi[k]->Draw("AC*");
c2->Update();
TString plotname2 = hfolder + plotname + "effic" + "." + plotType;
cout << "plotname2:" << plotname2 << endl;
c2->Print(plotname2);
delete c2;
} else h1.at(k)->Draw();
c1->SetLogy();
c1->Update();
TString plotname1 = hfolder + plotname + splotname + "." + plotType;
c1->Print(plotname1);
delete c1;
}
effi[0]->SetMarkerColor(2);
effi[1]->SetMarkerColor(3);
gStyle->SetOptFit();
TCanvas *c3 = new TCanvas("c3", "multigraph", 700, 500);
TMultiGraph *mg = new TMultiGraph("compo", "combo");
c3->SetFillColor(10);
c3->SetFillColor(10);
mg->Add(effi[0]);
mg->Add(effi[1]);
mg->Draw("AP");
mg->GetXaxis()->SetTitle("efficiency");
mg->GetYaxis()->SetTitle("backround servival");
// Change the axis limits
//c3->BuildLegend();
////////
TLegend* leg = new TLegend(0.15, .7, 0.35, .9); // lets make a legend to tell everything apart
leg-> SetFillColor(kWhite);
leg-> SetShadowColor(kWhite);
//leg->AddEntry(h1.at(0),(typ1 + " dr of " + dr1 + " layers " + lay1 + lay2 + lay3 ).c_str(), "l");
leg->AddEntry(effi[0], (comp1.c_str()), "p");
leg->AddEntry(effi[1], (comp2.c_str()), "p");
leg->Draw();
c3->Update();
gSystem->mkdir((ofile + "/" + ifile + "/compare"+comp1).c_str());
TString plotname3 = ofile + "/" + ifile + "/compare"+comp1+"/" + comp1 + sub + "_" + comp2 + sub + "." + plotType;
c3->Print(plotname3);
/////////
string helpplease = ofile + "/" + ifile + "/compare"+comp1+"/" + comp1 + sub + "_t" + comp2 + sub + ".root";
TFile * gt = new TFile(helpplease.c_str(), "RECREATE");
gt->cd();
mg->Write();
delete c3;
TCanvas *c4 = new TCanvas("c4", "effratio", 700, 500);
TF1 * fit0 = new TF1("expfit0", "[0]+exp([1]+x*[2])");
effi[0]->Fit(fit0, "NQ");
TF1 * fit1 = new TF1("expfit1", "[0]+exp([1]+x*[2])");
effi[1]->Fit(fit1, "NQ");
TF1 * ratio = new TF1("ratio", "([0]+exp([1]+x*[2]))/([3]+exp([4]+x*[5]))", beg, end);
for(int i = 0; i < 3; i++)
ratio->SetParameter(i, fit0->GetParameter(i));
for(int i = 0; i < 3; i++)
ratio->SetParameter(i + 3, fit1->GetParameter(i));
gt->cd();
string tit = comp1 + "/" + comp2 + "_ratio";
ratio->SetTitle(tit.c_str());
ratio->GetXaxis()->SetTitle("efficiency");
ratio->Write();
c4->cd();
ratio->Draw();
if(aro == 1) gSystem->mkdir((ofile + "/" + ifile + "/better" + comp1).c_str());
if(aro != 1)
{
TString plotname4 = ofile + "/" + ifile + "/compare"+comp1+"/ratio" + comp1 + sub + "_" + comp2 + sub + "." + plotType;
c4->Print(plotname4);
}
if((ratio->Integral(beg, end)>(end - beg)) && aro == 1)
{
TString plotname4 = ofile + "/" + ifile + "/better" + comp1 + "/" + comp1 + sub + "_" + comp2 + sub + "." + plotType;
c4->Print(plotname4);
}
delete c4;
}
void HcalAna::Draw_H2(vector <TH1D*> h1, string plotname, vector <TH1D*> h2 /* = NULL */, string splotname /*""*/)
{
double beg = .8, end = 1;
TGraph * effi[2];
for(int k = 0; k < 2; k++)
{
effi[k] = new TGraph(10);
hfolder = ofile + "/" + ifile + "/SLHC_" + comp.at(k) + "/";
TCanvas* c1 = new TCanvas("c1", "", 800, 700);
c1->SetFillColor(10);
c1->SetFillColor(10);
gStyle->SetOptStat("eoumi");
gStyle->SetOptStat("");
//h1->GetXaxis()->SetTitle( "x title" );
//h1->GetYaxis()->SetTitle( "y title" );
h1.at(k)->SetLineColor(2);
c1->cd();
c1->SetLogy();
string typ1, typ2, dr1(1, 0), dr2(1, 0), lay1(1, 0), lay2(1, 0), lay3(1, 0), slay1(1, 0), slay2(1, 0), slay3(1, 0);
if(parameterh1[0] == 1) typ1 = "wdecay";
if(parameterh1[0] == 2) typ1 = "jet";
if(parameterh1[0] == 3) typ1 = "total";
if(parameterh1[0] == 4) typ1 = "rec";
if(sparameterh1[0] == 1) typ2 = "wdecay";
if(sparameterh1[0] == 2) typ2 = "jet";
if(sparameterh1[0] == 3) typ2 = "total";
if(sparameterh1[0] == 4) typ2 = "rec";
if(parameterh1[0] != 0)sprintf(&dr1.at(0), "%d", parameterh1[1]);
if(sparameterh1[0] != 0)sprintf(&dr2.at(0), "%d", sparameterh1[1]);
//int x=1+parameter1[2];
if(parameterh1[0] != 0)sprintf(&lay1.at(0), "%d", (1 + parameterh1[2]));
if(parameterh2[0] != 0)sprintf(&lay2.at(0), "%d", (1 + parameterh2[2]));
if(parameterh3[0] != 0)sprintf(&lay3.at(0), "%d", (1 + parameterh3[2]));
if(sparameterh1[0] != 0)sprintf(&slay1.at(0), "%d", (1 + sparameterh1[2]));
if(sparameterh2[0] != 0)sprintf(&slay2.at(0), "%d", (1 + sparameterh2[2]));
if(sparameterh3[0] != 0)sprintf(&slay3.at(0), "%d", (1 + sparameterh3[2]));
// dr1=parameter1[1];
if(h2.at(0) != NULL)
{