-
Notifications
You must be signed in to change notification settings - Fork 6
/
validate.C
3940 lines (3532 loc) · 161 KB
/
validate.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
// copied from Jean--Roch Vlimant
#include "TTree.h"
#include "TChain.h"
#include "TCanvas.h"
#include "TString.h"
#include "TFile.h"
#include "TROOT.h"
#include "TH1F.h"
#include "TGaxis.h"
#include "TStyle.h"
#include <iostream>
#include <fstream>
#include "TLegend.h"
#include "TPaveText.h"
#include "TCut.h"
#include "TSQLResult.h"
#include "TSQLRow.h"
#include <cmath>
bool detailed = true;
bool detailed1 = false;//higher level of detail
bool RemoveIdentical = true;
bool cleanEmpties = true;
TTree * Events=0;
TTree * refEvents=0;
int Nmax=0;
TString recoS="RECO";
TString refrecoS="RECO";
void print( TString step){
// gROOT->ProcessLine(".! mkdir -p "+step);
const TSeqCollection* l=gROOT->GetListOfCanvases();
for (int i=0 ; i!=l->GetSize();++i){
// TString n=step+"/"+step+l->At(i)->GetName()+".gif";
// TString n=step+"/"+step+l->At(i)->GetName()+".png";
TString n=step+l->At(i)->GetName()+".png";
l->At(i)->Print(n);
//TString n2=step+"/"+step+l->At(i)->GetName()+".eps";
//l->At(i)->Print(n2);
}
}
// Underscores have a special meaning: most common use for steps with an underscore
// is for the last pattern to mean the used workflow.
// The workflow names so far had no underscores, but some can match the selection pattern.
// To disambiguate:
// append an underscore during pattern matching to steps with underscores present
bool stepContainsNU(const TString& s, TString v){
if (!v.Contains("_")){
if (s.Contains("_")){
return s.Contains(v+"_");
} else {
return s.Contains(v);
}
} else {
return s.Contains(v);
}
}
bool checkBranchAND(const TString& b, bool verboseFalse = false){
bool res = Events->GetBranch(b) != nullptr && refEvents->GetBranch(b) != nullptr;
if (!res && verboseFalse) std::cout<<"Branch "<<b.Data()<<" is not found in one of the inputs. Skip."<<std::endl;
return res;
}
bool checkBranchOR(const TString& b, bool verboseFalse = false){
bool res = Events->GetBranch(b) != nullptr || refEvents->GetBranch(b) != nullptr;
if (!res && verboseFalse) std::cout<<"Branch "<<b.Data()<<" is not found in either of the inputs. Skip."<<std::endl;
return res;
}
struct PlotStats {
int status;
double countDiff;
double ksProb;
int new_entries;
int ref_entries;
double new_mean;
double ref_mean;
double new_rms;
double ref_rms;
double new_xmax;
double ref_xmax;
double new_xmin;
double ref_xmin;
PlotStats() : status(-1),
countDiff(0.), ksProb(0),
new_entries(0), ref_entries(0),
new_mean(0.), ref_mean(0.), new_rms(0.), ref_rms(0.),
new_xmax(0.), ref_xmax(0.), new_xmin(0.), ref_xmin(0.)
{}
};
PlotStats plotvar(TString v,TString cut="", bool tryCatch = false){
PlotStats res;
std::cout<<"plotting variable: "<<v<<std::endl;
TCut selection(cut);
static int count=0;
if (cut!="") count++;
TString limit = "";
if (v.Contains("pt()") && !v.Contains("log") )
{
limit = v+"<";
limit+=1000;
}
TString vn=v;
vn.ReplaceAll(".","_");
vn.ReplaceAll("(","");
vn.ReplaceAll(")","");
vn.ReplaceAll("@","AT");
vn.ReplaceAll("[","_");
vn.ReplaceAll("]","_");
vn.ReplaceAll(">","GT");
vn.ReplaceAll("<","LT");
vn.ReplaceAll("$","");
vn.ReplaceAll("&","N");
vn.ReplaceAll("*\"","_");
vn.ReplaceAll("\"!=\"\"","_");
if (limit!="")
selection *= limit;
TString cn="c_"+vn;
if (cut!="") cn+=count;
TCanvas * c = new TCanvas(cn,"plot of "+v);
c->SetGrid();
c->SetTopMargin(0.12);
c->SetLeftMargin(0.06);
c->SetRightMargin(0.01);
c->SetBottomMargin(0.06);
TH1F * refplot=0;
TString refvn=vn;
vn.ReplaceAll(recoS,refrecoS);
TString refv=v;
refv.ReplaceAll(recoS,refrecoS);
TString refselectionS(selection.GetTitle());
refselectionS.ReplaceAll(recoS,refrecoS);
TCut refselection(refselectionS);
if (refv!=v)
std::cout<<" changing reference variable to:"<<refv<<std::endl;
gStyle->SetTitleX(0.5);
gStyle->SetTitleY(1);
gStyle->SetTitleW(1);
gStyle->SetTitleH(0.06);
TGaxis::SetExponentOffset(-0.052,-0.060,"x");
TGaxis::SetExponentOffset(-0.052,0.010,"y");
res.ref_entries = -1;
res.new_entries = -1;
res.ref_mean = -1e12;
res.new_mean = -1e12;
if (refEvents!=0){
TString reffn=refvn+"_refplot";
if (cut!="") reffn+=count;
if(tryCatch){
try {
refEvents->Draw(refv+">>"+reffn,
refselection,
"",
Nmax);
} catch (...) {std::cout<<"Exception caught for refEvents"<<std::endl; delete c; res.status = -9; return res;}
} else {
refEvents->Draw(refv+">>"+reffn,
refselection,
"",
Nmax);
}
refplot = (TH1F*)gROOT->Get(reffn);
if (refplot){
refplot->SetLineColor(1);
res.ref_entries = refplot->GetEntries();
res.ref_mean = refplot->GetMean();//something inside the histo makes it to make more sense
res.ref_rms = refplot->GetRMS();
res.ref_xmin = refplot->GetXaxis()->GetXmin();
res.ref_xmax = refplot->GetXaxis()->GetXmax();
}
else {std::cout<<"Comparison died "<<std::endl; if (cleanEmpties) delete c; res.status = -1; return res;}
} else {
std::cout<<"cannot do things for "<<refv<<std::endl;
res.status = -1; return res;
}
TString fn=vn+"_plot";
if (cut!="") fn+=count;
TH1F * plot = new TH1F(fn,refplot->GetTitle(),
refplot->GetNbinsX(),
refplot->GetXaxis()->GetXmin(),
refplot->GetXaxis()->GetXmax());
plot->SetLineColor(2);
if (Events!=0){
if (tryCatch){
try {
Events->Draw(v+">>"+fn,
selection,
"",
Nmax);
} catch (...) { std::cout<<"Exception caught for Events"<<std::endl; delete c; res.status = -9; return res;}
} else {
Events->Draw(v+">>"+fn,
selection,
"",
Nmax);
}
res.new_entries = plot->GetEntries();
res.new_mean = plot->GetMean();
res.new_rms = plot->GetRMS();
//unclear if it can really ever be different from ref_xmin or ref_xmax
res.new_xmin = plot->GetXaxis()->GetXmin();
res.new_xmax = plot->GetXaxis()->GetXmax();
if ( plot->GetXaxis()->GetXmax() != refplot->GetXaxis()->GetXmax()){
std::cout<<"ERROR: DRAW RANGE IS INCONSISTENT !!!"<<std::endl;
}
}
res.countDiff=0;
if (refplot && plot) {
refplot->Draw("he");
refplot->SetMinimum(-0.05*refplot->GetMaximum() );
plot->Draw("same he");
TString dn=vn+"_diff";
if (cut!="") dn+=count;
TH1F * diff = new TH1F(dn,refplot->GetTitle(),
refplot->GetNbinsX(),
refplot->GetXaxis()->GetXmin(),
refplot->GetXaxis()->GetXmax());
diff->Add(plot);
diff->Add(refplot,-1.);
double max = std::max(refplot->GetMaximum() , plot->GetMaximum());
double min = std::min(refplot->GetMinimum() , plot->GetMinimum());
min = std::min(diff->GetMinimum(), min);
refplot->SetMaximum(max + 0.05*std::abs(max));
refplot->SetMinimum(min - 0.05*std::abs(min));
diff->SetMarkerColor(4);
diff->SetLineColor(4);
diff->SetMarkerStyle(7);
diff->Draw("same p e");
for (int ib=1;ib<=diff->GetNbinsX();++ib){
res.countDiff+=std::abs(diff->GetBinContent(ib));
}
res.ksProb = refplot->KolmogorovTest(plot);
TString outtext;
outtext.Form("Ref: %i, New: %i, De: %6.4g, Diff: %g, 1-KS: %6.4g",res.ref_entries,res.new_entries,
res.ref_entries>0? (res.new_entries-res.ref_entries)/double(res.ref_entries):0, res.countDiff,1-res.ksProb);
TPaveText * pt = new TPaveText(0.05,0.89,0.71,0.93,"NDC");
pt->AddText(outtext);
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->Draw();
TLegend * leg = new TLegend(0.72,0.89,0.99,0.93);
leg->SetNColumns(3);
leg->AddEntry(refplot,"Ref.","l");
leg->AddEntry(plot,"New","l");
leg->AddEntry(diff,"New - Ref.","p");
leg->Draw();
}else{
std::cout<<"cannot do things for "<<v<<std::endl;
res.status = -1; return res;
}
if (res.countDiff!=0)
{
std::cout<<v<<" has "<< res.countDiff <<" differences"<<std::endl;
}
else
{
if (RemoveIdentical){
// std::cout<<"remove identical"<<std::endl;
delete c;
}
}
return res;
}
int maxSize(const PlotStats& res){
int ref_max = res.ref_rms == 0 ? res.ref_mean : res.ref_xmax;
int new_max = res.new_rms == 0 ? res.new_mean : res.new_xmax;
return std::max(ref_max, new_max);
}
PlotStats jet(TString type, TString algo, TString var, bool log10Var = false, bool trycatch = false, bool notafunction = false){
TString v = type+"_"+algo+(algo.Contains("_")? "_" : "__")+recoS+".obj."+var+(notafunction? "" : "()");
if (log10Var) v = "log10(" + v + ")";
return plotvar(v, "", trycatch);
}
void jets(TString type,TString algo){
TString bObj = type+"_"+algo+(algo.Contains("_")? "_" : "__")+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
jet(type,algo,"energy", true);
jet(type,algo,"et", true);
jet(type,algo,"eta");
jet(type,algo,"phi");
jet(type,algo,"emEnergyFraction", false, true);//the last "true" is to catch cases of unfilled specific
jet(type,algo,"neutralHadronEnergy", false, true);
jet(type,algo,"chargedHadronEnergyFraction", false, true);
jet(type,algo,"neutralHadronEnergyFraction", false, true);
jet(type,algo,"photonEnergyFraction", false, true);
jet(type,algo,"electronEnergyFraction", false, true);
jet(type,algo,"muonEnergyFraction", false, true);
jet(type,algo,"hoEnergyFraction", false, true);
jet(type,algo,"HFHadronEnergyFraction", false, true);
jet(type,algo,"HFEMEnergyFraction", false, true);
if (type == "patJets"){
PlotStats res = jet(type, algo, "[email protected]");
TString jetBName = type+"_"+algo+(algo.Contains("_")? "_" : "__")+recoS;
for (int i = 0; i< maxSize(res); ++i){
plotvar(jetBName+Form(".obj[].userFloats_[%d]",i), "", true);
}
res = jet(type, algo, "[email protected]");
for (int i = 0; i< maxSize(res); ++i){
plotvar(jetBName+Form(".obj[].userInts_[%d]",i), "", true);
}
jet(type, algo, "[email protected]");
res = jet(type, algo, "[email protected]");
for (int i = 0; i< maxSize(res); ++i){
plotvar("min(2,max(-2,"+jetBName+Form(".obj[].pairDiscriVector_[%d].second))",i), "", true);
}
if (algo.Contains("AK8")){//many discriminants are valid only for high pt
for (int i = 0; i< maxSize(res); ++i){
plotvar("min(2,max(-2,"+jetBName+Form(".obj[].pairDiscriVector_[%d].second))",i), jetBName+".obj[].pt()>200", true);
}
}
jet(type, algo, "[email protected]");
jet(type, algo, "currentJECSet_", false, false, true);
jet(type, algo, "currentJECLevel_", false, false, true);
}
}
void caloTowers(TString br, bool addHEP17 = false){
TString bObj = "CaloTowersSorted_"+br+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
TString tObj = bObj+".obj";
plotvar(tObj+"@.size()");
plotvar("log10("+tObj+".energy())");
plotvar("log10("+tObj+".emEnergy())");
plotvar("log10("+tObj+".hadEnergy())");
plotvar("log10("+tObj+".massSqr())/2.");
plotvar(tObj+".eta()");
plotvar(tObj+".phi()");
if (addHEP17){
plotvar("log10("+tObj+".energy())", tObj+".eta()>1.5&&"+tObj+".eta()<3&&"+tObj+".phi()<-0.435&&"+tObj+".phi()>-0.960");
plotvar("log10("+tObj+".emEnergy())", tObj+".eta()>1.5&&"+tObj+".eta()<3&&"+tObj+".phi()<-0.435&&"+tObj+".phi()>-0.960");
plotvar("log10("+tObj+".hadEnergy())", tObj+".eta()>1.5&&"+tObj+".eta()<3&&"+tObj+".phi()<-0.435&&"+tObj+".phi()>-0.960");
plotvar("log10("+tObj+".massSqr())/2.", tObj+".eta()>1.5&&"+tObj+".eta()<3&&"+tObj+".phi()<-0.435&&"+tObj+".phi()>-0.960");
plotvar(tObj+".eta()", tObj+".eta()>1.5&&"+tObj+".eta()<3&&"+tObj+".phi()<-0.435&&"+tObj+".phi()>-0.960");
plotvar(tObj+".phi()", tObj+".eta()>1.5&&"+tObj+".eta()<3&&"+tObj+".phi()<-0.435&&"+tObj+".phi()>-0.960");
}
plotvar("Sum$("+tObj+".energy()>0)");
plotvar("log10("+tObj+".energy())", tObj+".energy()>0");
plotvar("log10("+tObj+".emEnergy())", tObj+".energy()>0");
plotvar("log10("+tObj+".hadEnergy())", tObj+".energy()>0");
plotvar("log10("+tObj+".massSqr())/2.", tObj+".energy()>0");
plotvar(tObj+".eta()", tObj+".energy()>0");
plotvar(tObj+".phi()", tObj+".energy()>0");
}
void secondaryVertexTagInfoVars(TString br){
TString bObj = br+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
plotvar(bObj+".nSelectedTracks()");
plotvar(bObj+".nVertexTracks()");
plotvar(bObj+".nVertices()");
plotvar(bObj+".nVertexCandidates()");
plotvar(bObj+".m_svData.dist1d.value()");
plotvar(bObj+".m_svData.dist1d.error()");
plotvar(bObj+".m_svData.dist2d.value()");
plotvar(bObj+".m_svData.dist2d.error()");
plotvar(bObj+".m_trackData.first");
plotvar(bObj+".m_trackData.second.svStatus");
}
void impactParameterTagInfoVars(TString br){
TString bObj = br+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
plotvar(bObj+".m_axis.theta()");
plotvar(bObj+".m_axis.phi()");
plotvar(bObj+"[email protected]()");
plotvar(bObj+".m_data.ip2d.value()");
plotvar(bObj+".m_data.ip2d.error()");
plotvar(bObj+".m_data.distanceToJetAxis.value()");
plotvar(bObj+".m_data.distanceToGhostTrack.value()");
plotvar(bObj+".m_data.ghostTrackWeight");
plotvar(bObj+".m_prob2d");
plotvar(bObj+".m_prob3d");
}
void vertexVars(TString br){
TString bObj = br+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
plotvar(bObj+".x()");
plotvar(bObj+".y()");
plotvar(bObj+".z()");
plotvar(bObj+".t()");
plotvar("log10("+bObj+".xError())");
plotvar("log10("+bObj+".yError())");
plotvar("log10("+bObj+".zError())");
plotvar("log10("+bObj+".tError())");
plotvar(bObj+".chi2()");
plotvar(bObj+".tracksSize()");
}
void jetTagVar(TString mName){
TString br = "recoJetedmRefToBaseProdTofloatsAssociationVector_" + mName;
TString bObj = br+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+".@data_.size()");
plotvar(bObj+".data_");
plotvar(bObj+".data_", bObj+".data_>=0");
}
void calomet(TString algo, TString var, bool doLog10 = false){
TString v;
if (doLog10) v ="log10(recoCaloMETs_"+algo+"__"+recoS+".obj."+var+"())";
else v ="recoCaloMETs_"+algo+"__"+recoS+".obj."+var+"()";
plotvar(v);
}
void caloMetVars(TString cName){
TString bObj = "recoCaloMETs_"+cName+"__"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
calomet(cName,"et", true);
calomet(cName,"eta");
calomet(cName,"phi");
calomet(cName,"metSignificance");
}
PlotStats met(TString var, TString cName = "tcMet_", TString tName = "recoMETs_", bool log10Var = false, bool trycatch = false, bool notafunction=false){
TString v = tName+cName+"_"+recoS+".obj."+var+(notafunction? "" : "()");
if (log10Var) v = "log10(" + v + ")";
return plotvar(v, "", trycatch);
}
void metVars(TString cName = "tcMet_", TString tName = "recoMETs_") {
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
met("pt",cName,tName);
met("px",cName,tName);
met("py",cName,tName);
met("eta",cName,tName);
met("phi",cName,tName);
met("sumEt",cName,tName);
met("significance",cName,tName);
}
void patMetVars(TString cName){
const TString tName = "patMETs_";
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
metVars(cName, tName);
PlotStats res = met("[email protected]", cName, tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[0].userFloats_[%d]",i), "", true);
}
res = met("[email protected]", cName, tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[0].userInts_[%d]",i), "", true);
}
met("[email protected]", cName, tName);
met("pfMET_[0].NeutralEMFraction", cName, tName, false, true, true);
met("pfMET_[0].NeutralHadFraction", cName, tName, false, true, true);
met("pfMET_[0].ChargedEMFraction", cName, tName, false, true, true);
met("pfMET_[0].ChargedHadFraction", cName, tName, false, true, true);
met("pfMET_[0].MuonFraction", cName, tName, false, true, true);
met("pfMET_[0].Type6Fraction", cName, tName, false, true, true);
met("pfMET_[0].Type7Fraction", cName, tName, false, true, true);
met("metSumPtUnclustered", cName, tName, true, true, false);
res = met("[email protected]", cName, tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[0].uncertainties_[%d].dpx()",i), tName+cName+"_"+recoS+Form(".obj[0][email protected]()>%d",i), true);
plotvar(tName+cName+"_"+recoS+Form(".obj[0].uncertainties_[%d].dsumEt()",i), tName+cName+"_"+recoS+Form(".obj[0][email protected]()>%d",i), true);
}
res = met("[email protected]", cName, tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[0].corrections_[%d].dpx()",i), tName+cName+"_"+recoS+Form(".obj[0][email protected]()>%d",i), true);
plotvar(tName+cName+"_"+recoS+Form(".obj[0].corrections_[%d].dsumEt()",i), tName+cName+"_"+recoS+Form(".obj[0][email protected]()>%d",i), true);
}
}
PlotStats tau(TString var, TString cName = "hpsPFTauProducer_", TString tName = "recoPFTaus_",
bool log10Var = false, bool trycatch = false, bool notafunction = false){
TString v=notafunction ? tName+cName+"_"+recoS+".obj."+var:
tName+cName+"_"+recoS+".obj."+var+"()";
if (log10Var) v = "log10(" + v + ")";
return plotvar(v, "", trycatch);
}
void tauVars(TString cName = "hpsPFTauProducer_", TString tName = "recoPFTaus_"){
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
tau("energy",cName,tName);
tau("et",cName,tName);
tau("eta",cName,tName);
tau("phi",cName,tName);
if (tName!="patTaus_") tau("emFraction",cName,tName);//crashes now for patTaus
if (tName == "patTaus_"){
tau("dxy", cName, tName);
tau("dxy_error", cName, tName);
tau("ip3d", cName, tName);
tau("ip3d_error", cName, tName);
tau("ecalEnergy", cName, tName);
tau("hcalEnergy", cName, tName);
tau("leadingTrackNormChi2", cName, tName);
tau("ecalEnergyLeadChargedHadrCand", cName, tName);
tau("hcalEnergyLeadChargedHadrCand", cName, tName);
tau("etaAtEcalEntrance", cName, tName);
tau("etaAtEcalEntranceLeadChargedCand", cName, tName);
tau("ptLeadChargedCand", cName, tName);
tau("emFraction_MVA", cName, tName);
PlotStats res = tau("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].userFloats_[%d]",i), "", true);
}
res = tau("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].userInts_[%d]",i), "", true);
}
tau("[email protected]", cName,tName);
res = tau("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].isolations_[%d]",i), "", true);
}
res = tau("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].tauIDs_[%d].second",i), "", true);
}
}
}
PlotStats photon(TString var, TString cName = "photons_", TString tName = "recoPhotons_", bool notafunction=false){
TString v= notafunction ? tName+cName+"_"+recoS+".obj."+var :
tName+cName+"_"+recoS+".obj."+var+"()" ;
return plotvar(v);
}
void photonVars(TString cName = "photons_", TString tName = "recoPhotons_"){
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
photon("energy", cName,tName);
photon("et", cName,tName);
if (detailed) photon("px", cName,tName);
if (detailed) photon("py", cName,tName);
if (detailed) photon("pz", cName,tName);
photon("eta", cName,tName);
photon("phi", cName,tName);
photon("hadronicDepth1OverEm", cName,tName);
photon("hadronicDepth2OverEm", cName,tName);
photon("hadronicOverEmValid", cName,tName);
photon("hadTowDepth1OverEm", cName,tName);
photon("hadTowDepth2OverEm", cName,tName);
photon("hadTowOverEmValid", cName,tName);
photon("hadronicOverEm", cName,tName);
photon("hadronicOverEm(1)", cName,tName, true);
photon("hadronicOverEm(3)", cName,tName, true);
photon("e1x5", cName,tName);
photon("e2x5", cName,tName);
photon("e3x3", cName,tName);
photon("e5x5", cName,tName);
photon("full5x5_e1x5", cName,tName);
photon("full5x5_e2x5Max", cName,tName);
photon("full5x5_e5x5", cName,tName);
photon("maxEnergyXtal", cName,tName);
photon("sigmaEtaEta", cName,tName);
photon("sigmaIetaIeta", cName,tName);
photon("r1x5", cName,tName);
photon("r2x5", cName,tName);
// photon("r9", cName,tName);
photon("mipChi2", cName,tName);
photon("mipNhitCone", cName,tName);
photon("hcalTowerSumEtConeDR04", cName,tName);
photon("hcalTowerSumEtConeDR04(1)", cName,tName, true);
photon("hcalTowerSumEtConeDR04(3)", cName,tName, true);
photon("ecalRecHitSumEtConeDR03", cName,tName);
photon("hcalTowerSumEtConeDR03", cName,tName);
photon("hcalTowerSumEtConeDR03(1)", cName,tName, true);
photon("hcalTowerSumEtConeDR03(3)", cName,tName, true);
photon("hcalDepth1TowerSumEtConeDR03", cName,tName);
photon("trkSumPtSolidConeDR03", cName,tName);
photon("trkSumPtHollowConeDR03", cName,tName);
photon("chargedHadronIso", cName,tName);
photon("chargedHadronWorstVtxIso", cName,tName);
photon("chargedHadronPFPVIso", cName,tName);
photon("neutralHadronIso", cName,tName);
photon("photonIso", cName,tName);
photon("sumChargedParticlePt", cName,tName);
photon("sumNeutralHadronEtHighThreshold", cName,tName);
photon("sumPhotonEtHighThreshold", cName,tName);
photon("sumPUPt", cName,tName);
photon("ecalPFClusterIso", cName,tName);
photon("hcalPFClusterIso", cName,tName);
photon("nClusterOutsideMustache", cName,tName);
photon("etOutsideMustache", cName,tName);
photon("pfMVA", cName,tName);
photon("pfDNN", cName,tName);
photon("haloTaggerMVAVal", cName,tName);
photon("showerShapeVariables().effSigmaRR",cName,tName, true);
photon("showerShapeVariables().sigmaIetaIphi",cName,tName, true);
photon("showerShapeVariables().sigmaIphiIphi",cName,tName, true);
photon("showerShapeVariables().e2nd",cName,tName, true);
photon("showerShapeVariables().eTop",cName,tName, true);
photon("showerShapeVariables().eLeft",cName,tName, true);
photon("showerShapeVariables().eRight",cName,tName, true);
photon("showerShapeVariables().eBottom",cName,tName, true);
photon("showerShapeVariables().e1x3",cName,tName, true);
photon("showerShapeVariables().e2x2",cName,tName, true);
photon("showerShapeVariables().e2x5Max",cName,tName, true);
photon("showerShapeVariables().e2x5Left",cName,tName, true);
photon("showerShapeVariables().e2x5Right",cName,tName, true);
photon("showerShapeVariables().e2x5Top",cName,tName, true);
photon("showerShapeVariables().e2x5Bottom",cName,tName, true);
photon("showerShapeVariables().smMajor",cName,tName, true);
photon("energyCorrections().scEcalEnergy", cName,tName, true);
photon("energyCorrections().scEcalEnergyError", cName,tName, true);
photon("energyCorrections().phoEcalEnergy", cName,tName, true);
photon("energyCorrections().phoEcalEnergyError", cName,tName, true);
photon("energyCorrections().regression1Energy", cName,tName, true);
photon("energyCorrections().regression1EnergyError", cName,tName, true);
photon("energyCorrections().regression2Energy", cName,tName, true);
photon("energyCorrections().regression2EnergyError", cName,tName, true);
photon("energyCorrections().candidateP4type", cName,tName, true);
photon("caloPosition().rho", cName,tName);
photon("caloPosition().phi", cName,tName);
photon("caloPosition().eta", cName,tName);
if (tName == "patPhotons_"){
photon("puppiChargedHadronIso", cName,tName);
photon("puppiNeutralHadronIso", cName,tName);
photon("puppiPhotonIso", cName,tName);
PlotStats res = photon("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].userFloats_[%d]",i), "", true);
}
res = photon("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].userInts_[%d]",i), "", true);
}
photon("[email protected]", cName,tName);
res = photon("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].isolations_[%d]",i), "", true);
}
res = photon("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].photonIDs_[%d].second",i), "", true);
}
}
}
PlotStats conversion(TString var, TString cName = "conversions_", TString tName = "recoConversions_", bool notafunction=false){
TString v=notafunction ? tName+cName+"_"+recoS+".obj."+var:
tName+cName+"_"+recoS+".obj."+var+"()";
return plotvar(v);
}
void conversionVars(TString cName = "conversions_", TString tName = "recoConversions_"){
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
//conversion("EoverP", cName,tName); //seg fault !!!
conversion("algo", cName,tName);
conversion("nTracks", cName,tName);
conversion("pairMomentum().x", cName,tName);
conversion("pairMomentum().y", cName,tName);
conversion("pairMomentum().z", cName,tName);
conversion("MVAout", cName,tName);
}
PlotStats electron(TString var, TString cName = "gsfElectrons_", TString tName = "recoGsfElectrons_", bool notafunction=false){
TString v=notafunction ? tName+cName+"_"+recoS+".obj."+var:
tName+cName+"_"+recoS+".obj."+var+"()";
return plotvar(v);
}
void electronVars(TString cName = "gsfElectrons_", TString tName = "recoGsfElectrons_"){
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
electron("pt", cName, tName);
if (detailed) electron("px", cName, tName);
if (detailed) electron("py", cName, tName);
if (detailed) electron("pz", cName, tName);
electron("eta", cName, tName);
electron("phi", cName, tName);
electron("e1x5", cName, tName);
electron("e5x5", cName, tName);
electron("e2x5Max", cName, tName);
electron("full5x5_e1x5", cName, tName);
electron("full5x5_e5x5", cName, tName);
electron("full5x5_e2x5Max", cName, tName);
electron("ecalEnergy", cName, tName);
if (detailed) electron("hcalOverEcal", cName, tName);
if (detailed) electron("hcalOverEcal(1)", cName, tName, true);
if (detailed) electron("hcalOverEcal(2)", cName, tName, true);
if (detailed) electron("hcalOverEcal(4)", cName, tName, true);
electron("energy", cName, tName);
if (detailed) electron("fbrem", cName, tName);
electron("classification", cName, tName);
electron("scPixCharge", cName, tName);
electron("isGsfCtfScPixChargeConsistent", cName, tName);
electron("isGsfScPixChargeConsistent", cName, tName);
electron("isGsfCtfChargeConsistent", cName, tName);
// electron("superCluster().index", cName, tName);
// electron("gsfTrack().index", cName, tName);
// electron("closestTrack().index", cName, tName);
electron("eSuperClusterOverP", cName, tName);
electron("eSeedClusterOverPout", cName, tName);
electron("deltaEtaEleClusterTrackAtCalo", cName, tName);
electron("deltaPhiEleClusterTrackAtCalo", cName, tName);
electron("sigmaEtaEta", cName, tName);
electron("sigmaIetaIeta", cName, tName);
electron("sigmaIphiIphi", cName, tName);
electron("r9", cName, tName);
electron("hcalDepth1OverEcal", cName, tName);
electron("hcalDepth2OverEcal", cName, tName);
electron("hcalOverEcalBc", cName, tName);
electron("hcalOverEcalBc(1)", cName, tName, true);
electron("hcalOverEcalBc(2)", cName, tName, true);
electron("hcalOverEcalBc(4)", cName, tName, true);
electron("hcalOverEcalValid", cName, tName);
electron("eLeft", cName, tName);
electron("eTop", cName, tName);
electron("full5x5_sigmaEtaEta", cName, tName);
electron("full5x5_sigmaIetaIeta", cName, tName);
electron("full5x5_sigmaIphiIphi", cName, tName);
electron("full5x5_r9", cName, tName);
electron("full5x5_hcalDepth1OverEcal", cName, tName);
electron("full5x5_hcalDepth2OverEcal", cName, tName);
electron("full5x5_hcalOverEcal", cName, tName);
electron("full5x5_hcalOverEcal(1)", cName, tName, true);
electron("full5x5_hcalOverEcal(3)", cName, tName, true);
electron("full5x5_hcalOverEcalBc", cName, tName);
electron("full5x5_hcalOverEcalBc(1)", cName, tName, true);
electron("full5x5_hcalOverEcalBc(3)", cName, tName, true);
electron("full5x5_hcalOverEcalValid", cName, tName);
electron("full5x5_e2x5Left", cName, tName);
electron("full5x5_eLeft", cName, tName);
electron("full5x5_e2x5Top", cName, tName);
electron("full5x5_eTop", cName, tName);
electron("nSaturatedXtals", cName, tName);
electron("dr03TkSumPt", cName, tName);
electron("dr03TkSumPtHEEP", cName, tName);
electron("dr03EcalRecHitSumEt", cName, tName);
electron("dr03HcalDepth1TowerSumEt", cName, tName);
electron("dr03HcalTowerSumEt", cName, tName);
electron("dr03HcalTowerSumEt(1)", cName, tName, true);
electron("dr03HcalTowerSumEt(3)", cName, tName, true);
electron("dr03HcalDepth1TowerSumEtBc", cName, tName);
electron("dr03HcalTowerSumEtBc", cName, tName);
electron("dr03HcalTowerSumEtBc(1)", cName, tName, true);
electron("dr03HcalTowerSumEtBc(3)", cName, tName, true);
electron("convDist", cName, tName);
electron("convRadius", cName, tName);
electron("convVtxFitProb", cName, tName);
electron("pfIsolationVariables().chargedHadronIso", cName, tName, true);
electron("pfIsolationVariables().neutralHadronIso", cName, tName, true);
electron("pfIsolationVariables().photonIso", cName, tName, true);
electron("pfIsolationVariables().sumChargedHadronPt", cName, tName, true);
electron("pfIsolationVariables().sumNeutralHadronEt", cName, tName, true);
electron("pfIsolationVariables().sumPhotonEt", cName, tName, true);
electron("pfIsolationVariables().sumChargedParticlePt", cName, tName, true);
electron("pfIsolationVariables().sumNeutralHadronEtHighThreshold", cName, tName, true);
electron("pfIsolationVariables().sumPhotonEtHighThreshold", cName, tName, true);
electron("pfIsolationVariables().sumPUPt", cName, tName, true);
electron("pfIsolationVariables().sumEcalClusterEt", cName, tName, true);
electron("pfIsolationVariables().sumHcalClusterEt", cName, tName, true);
electron("mvaInput().earlyBrem", cName, tName, true);
electron("mvaOutput().mva", cName, tName, true);
electron("mvaOutput().mva_Isolated", cName, tName, true);
electron("mvaOutput().mva_e_pi", cName, tName, true);
electron("mvaOutput().dnn_e_sigIsolated", cName, tName, true);
electron("mvaOutput().dnn_e_sigNonIsolated", cName, tName, true);
electron("mvaOutput().dnn_e_bkgNonIsolated", cName, tName, true);
electron("mvaOutput().dnn_e_bkgTau", cName, tName, true);
electron("mvaOutput().dnn_e_bkgPhoton", cName, tName, true);
electron("correctedEcalEnergy", cName, tName);
electron("correctedEcalEnergyError", cName, tName);
electron("trackMomentumError", cName, tName);
electron("ecalEnergyError", cName, tName);
electron("caloEnergy", cName, tName);
electron("pixelMatchSubdetector1", cName, tName);
electron("pixelMatchSubdetecto", cName, tName);
electron("pixelMatchDPhi1", cName, tName);
electron("pixelMatchDPhi2", cName, tName);
electron("pixelMatchDRz1", cName, tName);
electron("pixelMatchDRz2", cName, tName);
electron("showerShape().sigmaIetaIphi", cName,tName, true);
electron("showerShape().eMax", cName,tName, true);
electron("showerShape().e2nd", cName,tName, true);
electron("showerShape().eTop", cName,tName, true);
electron("showerShape().eLeft", cName,tName, true);
electron("showerShape().eRight", cName,tName, true);
electron("showerShape().eBottom", cName,tName, true);
if (tName == "patElectrons_"){
electron("puppiChargedHadronIso", cName,tName);
electron("puppiNeutralHadronIso", cName,tName);
electron("puppiPhotonIso", cName,tName);
electron("puppiNoLeptonsChargedHadronIso", cName,tName);
electron("puppiNoLeptonsNeutralHadronIso", cName,tName);
electron("puppiNoLeptonsPhotonIso", cName,tName);
electron("miniPFIsolation().chargedHadronIso", cName,tName);
electron("miniPFIsolation().neutralHadronIso", cName,tName);
electron("miniPFIsolation().photonIso", cName,tName);
electron("miniPFIsolation().puChargedHadronIso", cName,tName);
electron("dB(pat::Electron::PV2D)", cName,tName, true);
electron("dB(pat::Electron::BS2D)", cName,tName, true);
electron("dB(pat::Electron::PV3D)", cName,tName, true);
electron("dB(pat::Electron::PVDZ)", cName,tName, true);
PlotStats res = electron("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].userFloats_[%d]",i), "", true);
}
res = electron("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].userInts_[%d]",i), "", true);
}
electron("[email protected]", cName,tName);
res = electron("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].isolations_[%d]",i), "", true);
}
res = electron("[email protected]", cName,tName);
for (int i = 0; i< maxSize(res); ++i){
plotvar(tName+cName+"_"+recoS+Form(".obj[].electronIDs_[%d].second",i), "", true);
}
}
}
PlotStats gsfTracks(TString var, bool doLog10 = false, TString cName = "electronGsfTracks_", TString tName = "recoGsfTracks_", bool notafunction=false){
TString v=notafunction ? tName+cName+"_"+recoS+".obj."+var:
tName+cName+"_"+recoS+".obj."+var+"()";
if (doLog10) v = "log10("+v+")";
return plotvar(v);
}
void gsfTrackVars(TString cName = "electronGsfTracks_", TString tName = "recoGsfTracks_"){
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
gsfTracks("pt", true, cName, tName);
gsfTracks("p", true, cName, tName);
gsfTracks("eta", false, cName, tName);
gsfTracks("phi", false, cName, tName);
if (detailed) gsfTracks("found", false, cName, tName);
gsfTracks("chi2", false, cName, tName);
gsfTracks("normalizedChi2", false, cName, tName);
if (detailed) gsfTracks("dz", false, cName, tName);
gsfTracks("dxy", false, cName, tName);
if (detailed) gsfTracks("ndof", false, cName, tName);
gsfTracks("qoverp", false, cName, tName);
if (detailed) gsfTracks("px", false, cName, tName);
if (detailed) gsfTracks("py", false, cName, tName);
if (detailed) gsfTracks("pz", false, cName, tName);
gsfTracks("t0", false, cName, tName);
gsfTracks("beta", false, cName, tName);
gsfTracks("covt0t0", true, cName, tName);
gsfTracks("covBetaBeta", true, cName, tName);
}
void globalMuons(TString var){
TString v="recoTracks_globalMuons__"+recoS+".obj."+var+"()";
plotvar(v);
}
void staMuons(TString var){
TString v="recoTracks_standAloneMuons_UpdatedAtVtx_"+recoS+".obj."+var+"()";
plotvar(v);
}
PlotStats muonVar(TString var, TString cName = "muons_", TString tName = "recoMuons_", bool notafunction = false){
TString v= notafunction ? tName+cName+"_"+recoS+".obj."+var :
tName+cName+"_"+recoS+".obj."+var+"()" ;
return plotvar(v);
}
void muonVars(TString cName = "muons_", TString tName = "recoMuons_"){
TString bObj = tName+cName+"_"+recoS+".obj";
if (! checkBranchOR(bObj, true)) return;
plotvar(bObj+"@.size()");
muonVar("innerTrack().index",cName,tName);
muonVar("track().index",cName,tName);
muonVar("outerTrack().index",cName,tName);
muonVar("globalTrack().index",cName,tName);
muonVar("pt",cName,tName);
plotvar("log10("+tName+cName+"_"+recoS+".obj.pt())");
muonVar("eta",cName,tName);
muonVar("phi",cName,tName);
muonVar("calEnergy().towerS9",cName,tName, true);
muonVar("calEnergy().emS9",cName,tName, true);
muonVar("calEnergy().hadS9",cName,tName, true);
muonVar("calEnergy().hoS9",cName,tName, true);
muonVar("calEnergy().ecal_time",cName,tName, true);
muonVar("calEnergy().hcal_time",cName,tName, true);
muonVar("calEnergy()[email protected]()",cName,tName, true);
plotvar("log10("+tName+cName+"_"+recoS+".obj.calEnergy().crossedHadRecHits.energy)");
plotvar("min(200,max(-100,"+tName+cName+"_"+recoS+".obj.calEnergy().crossedHadRecHits.time))");
muonVar("calEnergy().crossedHadRecHits.detId.ietaAbs()",cName,tName, true);
muonVar("combinedQuality().trkKink",cName,tName, true);
muonVar("combinedQuality().glbKink",cName,tName, true);
muonVar("combinedQuality().localDistance",cName,tName, true);
muonVar("combinedQuality().updatedSta",cName,tName, true);
muonVar("time().nDof",cName,tName, true);
muonVar("time().timeAtIpInOut",cName,tName, true);
muonVar("time().timeAtIpInOutErr",cName,tName, true);
muonVar("rpcTime().nDof",cName,tName, true);
muonVar("rpcTime().timeAtIpInOut",cName,tName, true);
muonVar("rpcTime().timeAtIpInOutErr",cName,tName, true);
muonVar("caloCompatibility",cName,tName);
muonVar("isolationR03().sumPt",cName,tName, true);
muonVar("isolationR03().emEt",cName,tName, true);
muonVar("isolationR03().hadEt",cName,tName, true);
muonVar("isolationR03().hoEt",cName,tName, true);
muonVar("isolationR03().trackerVetoPt",cName,tName, true);
muonVar("isolationR03().emVetoEt",cName,tName, true);
muonVar("isolationR03().hadVetoEt",cName,tName, true);
muonVar("isolationR05().sumPt",cName,tName, true);
muonVar("isolationR05().emEt",cName,tName, true);
muonVar("isolationR05().hadEt",cName,tName, true);
muonVar("isolationR05().hoEt",cName,tName, true);
muonVar("isolationR05().trackerVetoPt",cName,tName, true);
muonVar("isolationR05().emVetoEt",cName,tName, true);
muonVar("isolationR05().hadVetoEt",cName,tName, true);
muonVar("pfIsolationR03().sumChargedHadronPt",cName,tName, true);
muonVar("pfIsolationR03().sumChargedParticlePt",cName,tName, true);
muonVar("pfIsolationR03().sumNeutralHadronEt",cName,tName, true);
muonVar("pfIsolationR03().sumPhotonEt",cName,tName, true);