forked from h2gglobe/h2gglobe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneralFunctions.cc
executable file
·5083 lines (4357 loc) · 231 KB
/
GeneralFunctions.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 "LoopAll.h"
#include "Sorters.h"
#include "TRandom3.h"
#define GFDEBUG 0
float LoopAll::pfTkIsoWithVertex(int phoindex, int vtxInd, float dRmax, float dRvetoBarrel, float dRvetoEndcap,
float ptMin, float dzMax, float dxyMax, int pfToUse) {
float dRveto;
if (pho_isEB[phoindex])
dRveto = dRvetoBarrel;
else
dRveto = dRvetoEndcap;
TLorentzVector photonDirectionWrtVtx = get_pho_p4(phoindex, vtxInd, 0);
float sum = 0;
// Loop over the PFCandidates
for(unsigned i=0; i<pfcand_n; i++) {
//require that PFCandidate is a charged hadron
if (pfcand_pdgid[i] == pfToUse) {
TLorentzVector* pfc = (TLorentzVector*)pfcand_p4->At(i);
if (pfc->Pt() < ptMin)
continue;
TVector3* vtx = (TVector3*)vtx_std_xyz->At(vtxInd);
TVector3* pfCandVtx = (TVector3*)pfcand_posvtx->At(i);
float dz = fabs(pfCandVtx->Z() - vtx->Z());
if (dz > dzMax)
continue;
double dxy = (-(pfCandVtx->X() - vtx->X())*pfc->Py() + (pfCandVtx->Y() - vtx->Y())*pfc->Px()) / pfc->Pt();
if(fabs(dxy) > dxyMax)
continue;
float dR = photonDirectionWrtVtx.DeltaR(*pfc);
if(dR > dRmax || dR < dRveto)
continue;
sum += pfc->Pt();
}
}
return sum;
}
float LoopAll::pfEcalIso(int phoindex, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel,
float etaStripEndcap, float thrBarrel, float thrEndcaps, int pfToUse) {
float dRVeto, etaStrip, thr;
if (pho_isEB[phoindex]) {
dRVeto = dRVetoBarrel;
etaStrip = etaStripBarrel;
thr = thrBarrel;
} else {
dRVeto = dRVetoEndcap;
etaStrip = etaStripEndcap;
thr = thrEndcaps;
}
float sum = 0;
for(unsigned i=0; i<pfcand_n; i++) {
if (pfcand_pdgid[i] == pfToUse) {
// FIXME questo non so come implementarlo...
//if(pfc.superClusterRef().isNonnull() && localPho->superCluster().isNonnull()) {
//if (pfc.superClusterRef() == localPho->superCluster())
// continue;
//}
TVector3* pfvtx = (TVector3*)pfcand_posvtx->At(i);
TVector3* phoEcalPos = (TVector3*)sc_xyz->At(pho_scind[phoindex]);
TVector3 photonDirectionWrtVtx = TVector3(phoEcalPos->X() - pfvtx->X(),
phoEcalPos->Y() - pfvtx->Y(),
phoEcalPos->Z() - pfvtx->Z());
TLorentzVector* pfc = (TLorentzVector*)pfcand_p4->At(i);
if( pfc->Pt() < thr )
continue;
float dEta = fabs(photonDirectionWrtVtx.Eta() - pfc->Eta());
float dR = photonDirectionWrtVtx.DeltaR(pfc->Vect());
if (dEta < etaStrip)
continue;
if(dR > dRmax || dR < dRVeto)
continue;
sum += pfc->Pt();
}
}
return sum;
}
void LoopAll::SetAllMVA() {
tmvaReaderID_UCSD = new TMVA::Reader("!Color:Silent");
tmvaReaderID_UCSD->AddVariable("sieie", &tmva_id_ucsd_sieie);
tmvaReaderID_UCSD->AddVariable("goodpf_iso", &tmva_id_ucsd_goodpf_iso);
tmvaReaderID_UCSD->AddVariable("badpf_iso", &tmva_id_ucsd_badpf_iso);
tmvaReaderID_UCSD->AddVariable("drtotk", &tmva_id_ucsd_drtotk);
tmvaReaderID_UCSD->AddVariable("hoe", &tmva_id_ucsd_hoe);
tmvaReaderID_UCSD->AddVariable("tkisopf", &tmva_id_ucsd_tkisopf);
tmvaReaderID_UCSD->AddVariable("r9", &tmva_id_ucsd_r9);
tmvaReaderID_UCSD->AddVariable("ptom", &tmva_id_ucsd_ptom);
tmvaReaderID_UCSD->AddVariable("eta", &tmva_id_ucsd_eta);
tmvaReaderID_UCSD->AddSpectator("isLeading", &tmva_id_ucsd_isLeading);
// tmvaReaderID_UCSD->BookMVA("Gradient", "ID_UCSD.weights.xml");
tmvaReaderID_MIT_Barrel = new TMVA::Reader("!Color:Silent");
tmvaReaderID_MIT_Barrel->AddVariable("HoE", &tmva_id_mit_hoe);
tmvaReaderID_MIT_Barrel->AddVariable("covIEtaIEta", &tmva_id_mit_sieie);
tmvaReaderID_MIT_Barrel->AddVariable("tIso1abs", &tmva_id_mit_tiso1);
tmvaReaderID_MIT_Barrel->AddVariable("tIso3abs", &tmva_id_mit_tiso3);
tmvaReaderID_MIT_Barrel->AddVariable("tIso2abs", &tmva_id_mit_tiso2);
tmvaReaderID_MIT_Barrel->AddVariable("R9", &tmva_id_mit_r9);
tmvaReaderID_MIT_Barrel->AddVariable("absIsoEcal", &tmva_id_mit_ecal);
tmvaReaderID_MIT_Barrel->AddVariable("absIsoHcal", &tmva_id_mit_hcal);
// tmvaReaderID_MIT_Barrel->AddVariable("RelE5x5", &tmva_id_mit_e5x5);
// tmvaReaderID_MIT_Barrel->AddVariable("EtaWidth", &tmva_id_mit_etawidth);
// tmvaReaderID_MIT_Barrel->AddVariable("PhiWidth", &tmva_id_mit_phiwidth);
// tmvaReaderID_MIT_Barrel->AddVariable("CoviEtaiPhi", &tmva_id_mit_sieip);
// tmvaReaderID_MIT_Barrel->AddVariable("CoviPhiiPhi", &tmva_id_mit_sipip);
tmvaReaderID_MIT_Barrel->AddVariable("NVertexes", &tmva_id_mit_nvtx);
tmvaReaderID_MIT_Barrel->AddVariable("ScEta", &tmva_id_mit_sceta);
tmvaReaderID_MIT_Barrel->AddVariable("EtaWidth", &tmva_id_mit_etawidth);
tmvaReaderID_MIT_Barrel->AddVariable("PhiWidth", &tmva_id_mit_phiwidth);
tmvaReaderID_MIT_Endcap = new TMVA::Reader("!Color:Silent");
tmvaReaderID_MIT_Endcap->AddVariable("HoE", &tmva_id_mit_hoe);
tmvaReaderID_MIT_Endcap->AddVariable("covIEtaIEta", &tmva_id_mit_sieie);
tmvaReaderID_MIT_Endcap->AddVariable("tIso1abs", &tmva_id_mit_tiso1);
tmvaReaderID_MIT_Endcap->AddVariable("tIso3abs", &tmva_id_mit_tiso3);
tmvaReaderID_MIT_Endcap->AddVariable("tIso2abs", &tmva_id_mit_tiso2);
tmvaReaderID_MIT_Endcap->AddVariable("R9", &tmva_id_mit_r9);
tmvaReaderID_MIT_Endcap->AddVariable("absIsoEcal", &tmva_id_mit_ecal);
tmvaReaderID_MIT_Endcap->AddVariable("absIsoHcal", &tmva_id_mit_hcal);
// tmvaReaderID_MIT_Endcap->AddVariable("RelE5x5", &tmva_id_mit_e5x5);
// tmvaReaderID_MIT_Endcap->AddVariable("EtaWidth", &tmva_id_mit_etawidth);
// tmvaReaderID_MIT_Endcap->AddVariable("PhiWidth", &tmva_id_mit_phiwidth);
// tmvaReaderID_MIT_Endcap->AddVariable("CoviEtaiPhi", &tmva_id_mit_sieip);
// tmvaReaderID_MIT_Endcap->AddVariable("CoviPhiiPhi", &tmva_id_mit_sipip);
tmvaReaderID_MIT_Endcap->AddVariable("NVertexes", &tmva_id_mit_nvtx);
tmvaReaderID_MIT_Endcap->AddVariable("ScEta", &tmva_id_mit_sceta);
tmvaReaderID_MIT_Endcap->AddVariable("EtaWidth", &tmva_id_mit_etawidth);
tmvaReaderID_MIT_Endcap->AddVariable("PhiWidth", &tmva_id_mit_phiwidth);
tmva_dipho_MIT_buf.resize(10,0.);
tmva_dipho_MIT_dmom = &tmva_dipho_MIT_buf[0];
tmva_dipho_MIT_dmom_wrong_vtx= &tmva_dipho_MIT_buf[1];
tmva_dipho_MIT_vtxprob= &tmva_dipho_MIT_buf[2];
tmva_dipho_MIT_ptom1= &tmva_dipho_MIT_buf[3];
tmva_dipho_MIT_ptom2= &tmva_dipho_MIT_buf[4];
tmva_dipho_MIT_eta1= &tmva_dipho_MIT_buf[5];
tmva_dipho_MIT_eta2= &tmva_dipho_MIT_buf[6];
tmva_dipho_MIT_dphi= &tmva_dipho_MIT_buf[7];
tmva_dipho_MIT_ph1mva= &tmva_dipho_MIT_buf[8];
tmva_dipho_MIT_ph2mva= &tmva_dipho_MIT_buf[9];
if( funcReader_dipho_MIT != 0 ) {
tmvaReader_dipho_MIT = 0;
//// masserr,masserrwrong,vtxprob,pt1,pt2,eta1,eta2,dphi,idmva1,idmva2
funcReader_dipho_MIT->bookVariable("masserr", tmva_dipho_MIT_dmom);
funcReader_dipho_MIT->bookVariable("masserrwrongvtx", tmva_dipho_MIT_dmom_wrong_vtx);
funcReader_dipho_MIT->bookVariable("vtxprob", tmva_dipho_MIT_vtxprob);
funcReader_dipho_MIT->bookVariable("pt1", tmva_dipho_MIT_ptom1);
funcReader_dipho_MIT->bookVariable("pt2", tmva_dipho_MIT_ptom2);
funcReader_dipho_MIT->bookVariable("eta1", tmva_dipho_MIT_eta1);
funcReader_dipho_MIT->bookVariable("eta2", tmva_dipho_MIT_eta2);
funcReader_dipho_MIT->bookVariable("dphi", tmva_dipho_MIT_dphi);
funcReader_dipho_MIT->bookVariable("idmva1", tmva_dipho_MIT_ph1mva);
funcReader_dipho_MIT->bookVariable("idmva2", tmva_dipho_MIT_ph2mva);
} else {
tmvaReader_dipho_MIT = new TMVA::Reader("!Color:Silent");
tmvaReader_dipho_MIT->AddVariable("masserrsmeared/mass", tmva_dipho_MIT_dmom);
tmvaReader_dipho_MIT->AddVariable("masserrsmearedwrongvtx/mass", tmva_dipho_MIT_dmom_wrong_vtx);
tmvaReader_dipho_MIT->AddVariable("vtxprob", tmva_dipho_MIT_vtxprob);
tmvaReader_dipho_MIT->AddVariable("ph1.pt/mass", tmva_dipho_MIT_ptom1);
tmvaReader_dipho_MIT->AddVariable("ph2.pt/mass", tmva_dipho_MIT_ptom2);
tmvaReader_dipho_MIT->AddVariable("ph1.eta", tmva_dipho_MIT_eta1);
tmvaReader_dipho_MIT->AddVariable("ph2.eta", tmva_dipho_MIT_eta2);
tmvaReader_dipho_MIT->AddVariable("TMath::Cos(ph1.phi-ph2.phi)", tmva_dipho_MIT_dphi);
tmvaReader_dipho_MIT->AddVariable("ph1.idmva", tmva_dipho_MIT_ph1mva);
tmvaReader_dipho_MIT->AddVariable("ph2.idmva", tmva_dipho_MIT_ph2mva);
}
tmvaReaderID_Single_Barrel = new TMVA::Reader("!Color:Silent");
tmvaReaderID_Single_Barrel->AddVariable("ph.r9", &tmva_photonid_r9 );
tmvaReaderID_Single_Barrel->AddVariable("ph.sigietaieta", &tmva_photonid_sieie );
tmvaReaderID_Single_Barrel->AddVariable("ph.scetawidth", &tmva_photonid_etawidth );
tmvaReaderID_Single_Barrel->AddVariable("ph.scphiwidth", &tmva_photonid_phiwidth );
tmvaReaderID_Single_Barrel->AddVariable("ph.idmva_CoviEtaiPhi", &tmva_photonid_sieip );
tmvaReaderID_Single_Barrel->AddVariable("ph.idmva_s4ratio", &tmva_photonid_s4ratio );
tmvaReaderID_Single_Barrel->AddVariable("ph.idmva_GammaIso", &tmva_photonid_pfphotoniso03 );
tmvaReaderID_Single_Barrel->AddVariable("ph.idmva_ChargedIso_selvtx", &tmva_photonid_pfchargedisogood03 );
tmvaReaderID_Single_Barrel->AddVariable("ph.idmva_ChargedIso_worstvtx", &tmva_photonid_pfchargedisobad03 );
tmvaReaderID_Single_Barrel->AddVariable("ph.sceta", &tmva_photonid_sceta );
tmvaReaderID_Single_Barrel->AddVariable("rho", &tmva_photonid_eventrho );
tmvaReaderID_Single_Endcap = new TMVA::Reader("!Color:Silent");
tmvaReaderID_Single_Endcap->AddVariable("ph.r9", &tmva_photonid_r9 );
tmvaReaderID_Single_Endcap->AddVariable("ph.sigietaieta", &tmva_photonid_sieie );
tmvaReaderID_Single_Endcap->AddVariable("ph.scetawidth", &tmva_photonid_etawidth );
tmvaReaderID_Single_Endcap->AddVariable("ph.scphiwidth", &tmva_photonid_phiwidth );
tmvaReaderID_Single_Endcap->AddVariable("ph.idmva_CoviEtaiPhi", &tmva_photonid_sieip );
tmvaReaderID_Single_Endcap->AddVariable("ph.idmva_s4ratio", &tmva_photonid_s4ratio );
tmvaReaderID_Single_Endcap->AddVariable("ph.idmva_GammaIso", &tmva_photonid_pfphotoniso03 );
tmvaReaderID_Single_Endcap->AddVariable("ph.idmva_ChargedIso_selvtx", &tmva_photonid_pfchargedisogood03 );
tmvaReaderID_Single_Endcap->AddVariable("ph.idmva_ChargedIso_worstvtx", &tmva_photonid_pfchargedisobad03 );
tmvaReaderID_Single_Endcap->AddVariable("ph.sceta", &tmva_photonid_sceta );
tmvaReaderID_Single_Endcap->AddVariable("rho", &tmva_photonid_eventrho );
tmvaReaderID_Single_Endcap->AddVariable("ph.idmva_PsEffWidthSigmaRR", &tmva_photonid_ESEffSigmaRR );
tmvaReaderID_2013_Barrel = new TMVA::Reader("!Color:Silent");
tmvaReaderID_2013_Barrel->AddVariable("ph.scrawe", &tmva_photonid_scrawe );
tmvaReaderID_2013_Barrel->AddVariable("ph.r9", &tmva_photonid_r9 );
tmvaReaderID_2013_Barrel->AddVariable("ph.sigietaieta", &tmva_photonid_sieie );
tmvaReaderID_2013_Barrel->AddVariable("ph.scetawidth", &tmva_photonid_etawidth );
tmvaReaderID_2013_Barrel->AddVariable("ph.scphiwidth", &tmva_photonid_phiwidth );
tmvaReaderID_2013_Barrel->AddVariable("ph.idmva_CoviEtaiPhi", &tmva_photonid_sieip );
tmvaReaderID_2013_Barrel->AddVariable("ph.idmva_s4ratio", &tmva_photonid_s4ratio );
tmvaReaderID_2013_Barrel->AddVariable("ph.idmva_GammaIso", &tmva_photonid_pfphotoniso03 );
tmvaReaderID_2013_Barrel->AddVariable("ph.idmva_ChargedIso_selvtx", &tmva_photonid_pfchargedisogood03 );
tmvaReaderID_2013_Barrel->AddVariable("ph.idmva_ChargedIso_worstvtx", &tmva_photonid_pfchargedisobad03 );
tmvaReaderID_2013_Barrel->AddVariable("ph.sceta", &tmva_photonid_sceta );
tmvaReaderID_2013_Barrel->AddVariable("rho", &tmva_photonid_eventrho );
tmvaReaderID_2013_Endcap = new TMVA::Reader("!Color:Silent");
tmvaReaderID_2013_Endcap->AddVariable("ph.scrawe", &tmva_photonid_scrawe );
tmvaReaderID_2013_Endcap->AddVariable("ph.r9", &tmva_photonid_r9 );
tmvaReaderID_2013_Endcap->AddVariable("ph.sigietaieta", &tmva_photonid_sieie );
tmvaReaderID_2013_Endcap->AddVariable("ph.scetawidth", &tmva_photonid_etawidth );
tmvaReaderID_2013_Endcap->AddVariable("ph.scphiwidth", &tmva_photonid_phiwidth );
tmvaReaderID_2013_Endcap->AddVariable("ph.idmva_CoviEtaiPhi", &tmva_photonid_sieip );
tmvaReaderID_2013_Endcap->AddVariable("ph.idmva_s4ratio", &tmva_photonid_s4ratio );
tmvaReaderID_2013_Endcap->AddVariable("ph.idmva_GammaIso", &tmva_photonid_pfphotoniso03 );
tmvaReaderID_2013_Endcap->AddVariable("ph.idmva_ChargedIso_selvtx", &tmva_photonid_pfchargedisogood03 );
tmvaReaderID_2013_Endcap->AddVariable("ph.idmva_ChargedIso_worstvtx", &tmva_photonid_pfchargedisobad03 );
tmvaReaderID_2013_Endcap->AddVariable("ph.sceta", &tmva_photonid_sceta );
tmvaReaderID_2013_Endcap->AddVariable("rho", &tmva_photonid_eventrho );
tmvaReaderID_2013_Endcap->AddVariable("ph.idmva_PsEffWidthSigmaRR", &tmva_photonid_ESEffSigmaRR );
tmvaReaderID_2013_7TeV_MIT_Barrel = new TMVA::Reader("!Color:Silent");
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.scrawe", &tmva_photonid_scrawe );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.r9", &tmva_photonid_r9 );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.sigietaieta", &tmva_photonid_sieie );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.scetawidth", &tmva_photonid_etawidth );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.scphiwidth", &tmva_photonid_phiwidth );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.idmva_CoviEtaiPhi", &tmva_photonid_sieip );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.idmva_s4ratio", &tmva_photonid_s4ratio );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.idmva_GammaIso", &tmva_photonid_pfphotoniso03 );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.idmva_ChargedIso_selvtx", &tmva_photonid_pfchargedisogood03 );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.idmva_ChargedIso_worstvtx", &tmva_photonid_pfchargedisobad03 );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("ph.sceta", &tmva_photonid_sceta );
tmvaReaderID_2013_7TeV_MIT_Barrel->AddVariable("rho", &tmva_photonid_eventrho );
tmvaReaderID_2013_7TeV_MIT_Endcap = new TMVA::Reader("!Color:Silent");
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.scrawe", &tmva_photonid_scrawe );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.r9", &tmva_photonid_r9 );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.sigietaieta", &tmva_photonid_sieie );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.scetawidth", &tmva_photonid_etawidth );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.scphiwidth", &tmva_photonid_phiwidth );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.idmva_CoviEtaiPhi", &tmva_photonid_sieip );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.idmva_s4ratio", &tmva_photonid_s4ratio );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.idmva_GammaIso", &tmva_photonid_pfphotoniso03 );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.idmva_ChargedIso_selvtx", &tmva_photonid_pfchargedisogood03 );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.idmva_ChargedIso_worstvtx", &tmva_photonid_pfchargedisobad03 );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.sceta", &tmva_photonid_sceta );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("rho", &tmva_photonid_eventrho );
tmvaReaderID_2013_7TeV_MIT_Endcap->AddVariable("ph.idmva_PsEffWidthSigmaRR", &tmva_photonid_ESEffSigmaRR );
}
Float_t LoopAll::photonIDMVA2013(Int_t iPhoton, Int_t vtx, TLorentzVector &p4, const char* type) {
Float_t mva = 999.;
double pfchargedisobad03=0.;
for(int ivtx=0; ivtx<vtx_std_n; ivtx++) {
pfchargedisobad03=(*pho_pfiso_mycharged03)[iPhoton][ivtx]>pfchargedisobad03?(*pho_pfiso_mycharged03)[iPhoton][ivtx]:pfchargedisobad03;
}
tmva_photonid_pfchargedisogood03 = (*pho_pfiso_mycharged03)[iPhoton][vtx];
tmva_photonid_pfchargedisobad03 = pfchargedisobad03;
tmva_photonid_pfphotoniso03 = pho_pfiso_myphoton03[iPhoton];
tmva_photonid_pfneutraliso03 = pho_pfiso_myneutral03[iPhoton];
tmva_photonid_sieie = pho_sieie[iPhoton];
tmva_photonid_sieip = pho_sieip[iPhoton];
tmva_photonid_etawidth = pho_etawidth[iPhoton];
int scind=pho_scind[iPhoton];
tmva_photonid_scrawe = sc_raw[scind];
tmva_photonid_phiwidth = sc_sphi[scind]; //pho_etawidth[iPhoton]*pho_brem[iPhoton]; //sc_sphi[pho_scind[ipho]]
tmva_photonid_r9 = pho_r9[iPhoton];
tmva_photonid_lambdaratio = pho_lambdaratio[iPhoton];
// tmva_photonid_s4ratio = pho_e2x2[iPhoton]/pho_e5x5[iPhoton];
tmva_photonid_s4ratio = pho_s4ratio[iPhoton];
tmva_photonid_eventrho = rho_algo1;
tmva_photonid_sceta = ((TVector3*)sc_xyz->At(pho_scind[iPhoton]))->Eta();
tmva_photonid_ESEffSigmaRR = pho_ESEffSigmaRR[iPhoton];
if (pho_isEB[iPhoton]) {
mva = tmvaReaderID_2013_Barrel->EvaluateMVA("AdaBoost");
} else {
mva = tmvaReaderID_2013_Endcap->EvaluateMVA("AdaBoost");
}
return mva;
}
Float_t LoopAll::photonIDMVA2013_7TeV(Int_t iPhoton, Int_t vtx, TLorentzVector &p4, const char* type) {
Float_t mva = 999.;
double pfchargedisobad03=0.;
for(int ivtx=0; ivtx<vtx_std_n; ivtx++) {
pfchargedisobad03=(*pho_pfiso_mycharged03)[iPhoton][ivtx]>pfchargedisobad03?(*pho_pfiso_mycharged03)[iPhoton][ivtx]:pfchargedisobad03;
}
tmva_photonid_pfchargedisogood03 = (*pho_pfiso_mycharged03)[iPhoton][vtx];
tmva_photonid_pfchargedisobad03 = pfchargedisobad03;
tmva_photonid_pfphotoniso03 = pho_pfiso_myphoton03[iPhoton];
tmva_photonid_pfneutraliso03 = pho_pfiso_myneutral03[iPhoton];
tmva_photonid_sieie = pho_sieie[iPhoton];
tmva_photonid_sieip = pho_sieip[iPhoton];
tmva_photonid_etawidth = pho_etawidth[iPhoton];
int scind=pho_scind[iPhoton];
tmva_photonid_scrawe = sc_raw[scind];
tmva_photonid_phiwidth = sc_sphi[scind]; //pho_etawidth[iPhoton]*pho_brem[iPhoton]; //sc_sphi[pho_scind[ipho]]
tmva_photonid_r9 = pho_r9[iPhoton];
tmva_photonid_lambdaratio = pho_lambdaratio[iPhoton];
tmva_photonid_s4ratio = pho_s4ratio[iPhoton];
tmva_photonid_eventrho = rho_algo1;
tmva_photonid_sceta = ((TVector3*)sc_xyz->At(pho_scind[iPhoton]))->Eta();
tmva_photonid_ESEffSigmaRR = pho_ESEffSigmaRR[iPhoton];
//std::cout << tmva_photonid_pfchargedisogood03 << " " << tmva_photonid_pfchargedisobad03 << " "
// << tmva_photonid_pfphotoniso03 << " "<< tmva_photonid_sieie << " " << tmva_photonid_sieip << " "
// << tmva_photonid_etawidth << " " << tmva_photonid_scrawe << " " << tmva_photonid_phiwidth << " "
// << tmva_photonid_lambdaratio << " " << tmva_photonid_s4ratio << " " << tmva_photonid_eventrho << " "
// << tmva_photonid_ESEffSigmaRR << std::endl;
if (pho_isEB[iPhoton]) {
mva = tmvaReaderID_2013_7TeV_MIT_Barrel->EvaluateMVA("AdaBoost");
} else {
mva = tmvaReaderID_2013_7TeV_MIT_Endcap->EvaluateMVA("AdaBoost");
}
return mva;
}
Float_t LoopAll::photonIDMVA2012(Int_t iPhoton, Int_t vtx, TLorentzVector &p4, const char* type) {
Float_t mva = 999.;
double pfchargedisobad03=0.;
for(int ivtx=0; ivtx<vtx_std_n; ivtx++) {
pfchargedisobad03=(*pho_pfiso_mycharged03)[iPhoton][ivtx]>pfchargedisobad03?(*pho_pfiso_mycharged03)[iPhoton][ivtx]:pfchargedisobad03;
}
tmva_photonid_pfchargedisogood03 = (*pho_pfiso_mycharged03)[iPhoton][vtx];
tmva_photonid_pfchargedisobad03 = pfchargedisobad03;
tmva_photonid_pfphotoniso03 = pho_pfiso_myphoton03[iPhoton];
tmva_photonid_pfneutraliso03 = pho_pfiso_myneutral03[iPhoton];
tmva_photonid_sieie = pho_sieie[iPhoton];
tmva_photonid_sieip = pho_sieip[iPhoton];
tmva_photonid_etawidth = pho_etawidth[iPhoton];
int scind=pho_scind[iPhoton];
tmva_photonid_phiwidth = sc_sphi[scind]; //pho_etawidth[iPhoton]*pho_brem[iPhoton]; //sc_sphi[pho_scind[ipho]]
tmva_photonid_r9 = pho_r9[iPhoton];
tmva_photonid_lambdaratio = pho_lambdaratio[iPhoton];
// tmva_photonid_s4ratio = pho_e2x2[iPhoton]/pho_e5x5[iPhoton];
tmva_photonid_s4ratio = pho_s4ratio[iPhoton];
tmva_photonid_eventrho = rho_algo1;
tmva_photonid_sceta = ((TVector3*)sc_xyz->At(pho_scind[iPhoton]))->Eta();
tmva_photonid_ESEffSigmaRR = pho_ESEffSigmaRR[iPhoton];
if (pho_isEB[iPhoton]) {
mva = tmvaReaderID_Single_Barrel->EvaluateMVA("AdaBoost");
}
else {
mva = tmvaReaderID_Single_Endcap->EvaluateMVA("AdaBoost");
}
return mva;
}
Float_t LoopAll::photonIDMVA(Int_t iPhoton, Int_t vtx, TLorentzVector &p4, const char* type) {
if( pho_idmva_cached && pho_idmva[iPhoton][vtx] > -2 ) {
return pho_idmva[iPhoton][vtx];
}
TString t(type);
if( t == "MIT" ) {
return photonIDMVA2013(iPhoton,vtx,p4,"MIT");
} else if( t == "Moriond2013" ) {
return photonIDMVA2012(iPhoton,vtx,p4,"MIT");
} else if( t == "Old7TeV" ) {
return photonIDMVA2011(iPhoton,vtx,p4,"MIT");
} else if( t == "2013_7TeV") {
return photonIDMVA2013_7TeV(iPhoton, vtx, p4, "MIT");
} else {
std::cerr << "Uknown BDT type " << t << std::endl;
assert(0);
}
}
Float_t LoopAll::photonIDMVA2011(Int_t iPhoton, Int_t vtx, TLorentzVector &p4, const char* type) {
Float_t mva = 999.;
float photonEt = p4.Et();
if (type == "UCSD") {
Int_t cat = PhotonCategory(iPhoton);
Float_t isomax=-99;
Int_t badind=0;
for(int iv=0; iv<vtx_std_n; iv++) {
if((*pho_pfiso_mycharged04)[iPhoton][iv]>isomax) {
badind=iv;
isomax=(*pho_pfiso_mycharged04)[iPhoton][iv];
}
}
float rhofacpf[6] = {0.075, 0.082, 0.143, 0.050, 0.091, 0.106};
float rhofacbadpf[6] = {0.141, 0.149, 0.208, 0.135, 0.162, 0.165};
float rhofac = rhofacpf[cat];
float rhofacbad = rhofacbadpf[cat];
Float_t tmva_id_ucsd_pt = photonEt;
tmva_id_ucsd_badpf_iso = ((*pho_pfiso_mycharged04)[iPhoton][badind]+pho_pfiso_myphoton04[iPhoton]-rho*rhofacbad)*50/tmva_id_ucsd_pt;
tmva_id_ucsd_goodpf_iso = ((*pho_pfiso_mycharged03)[iPhoton][vtx]+pho_pfiso_myphoton03[iPhoton]-rho*rhofac)*50/tmva_id_ucsd_pt;
tmva_id_ucsd_tkisopf = (*pho_pfiso_mycharged03)[iPhoton][vtx]*50/tmva_id_ucsd_pt;
tmva_id_ucsd_sieie = pho_sieie[iPhoton];
tmva_id_ucsd_drtotk = pho_drtotk_25_99[iPhoton];
tmva_id_ucsd_hoe = pho_hoe[iPhoton];
tmva_id_ucsd_r9 = pho_r9[iPhoton];
tmva_id_ucsd_eta = fabs(p4.Eta());
tmva_id_ucsd_isLeading = -1.; // not used just a spectator in the original definition
mva = tmvaReaderID_UCSD->EvaluateMVA("Gradient");
} else {
tmva_id_mit_hoe = pho_hoe[iPhoton];
tmva_id_mit_sieie = pho_sieie[iPhoton];
float rhofacbad=0.52, rhofac=0.17;
Float_t raw = sc_raw[pho_scind[iPhoton]];
float pho_tkiso_goodvtx = (*pho_tkiso_recvtx_030_002_0000_10_01)[iPhoton][vtx];
float pho_tkiso_badvtx = pho_tkiso_badvtx_040_002_0000_10_01[iPhoton];
tmva_id_mit_tiso1 = (pho_tkiso_goodvtx + pho_ecalsumetconedr03[iPhoton] + pho_hcalsumetconedr04[iPhoton] - rho*rhofac);
tmva_id_mit_tiso2 = (pho_tkiso_badvtx + pho_ecalsumetconedr04[iPhoton] + pho_hcalsumetconedr04[iPhoton] - rho*rhofacbad);
tmva_id_mit_tiso3 = pho_tkiso_goodvtx;
tmva_id_mit_r9 = pho_r9[iPhoton];
tmva_id_mit_ecal = pho_ecalsumetconedr03[iPhoton]-rho*rhofac;
tmva_id_mit_hcal = pho_hcalsumetconedr04[iPhoton]-rho*rhofac;
tmva_id_mit_e5x5 = pho_e5x5[iPhoton]/raw;
tmva_id_mit_etawidth = sc_seta[pho_scind[iPhoton]];
tmva_id_mit_phiwidth = sc_sphi[pho_scind[iPhoton]];
tmva_id_mit_sieip = pho_sieip[iPhoton];
tmva_id_mit_sipip = TMath::Sqrt(pho_sipip[iPhoton]);
tmva_id_mit_nvtx = vtx_std_n;
tmva_id_mit_preshower = sc_pre[pho_scind[iPhoton]]/raw;
tmva_id_mit_sceta = ((TVector3*)sc_xyz->At(pho_scind[iPhoton]))->Eta();
if (pho_isEB[iPhoton])
mva = tmvaReaderID_MIT_Barrel->EvaluateMVA("AdaBoost");
else
mva = tmvaReaderID_MIT_Endcap->EvaluateMVA("AdaBoost");
}
return mva;
}
Float_t LoopAll::diphotonMVA(Int_t diphoton_id, Int_t leadingPho, Int_t subleadingPho, Int_t vtx, float vtxProb, TLorentzVector &leadP4, TLorentzVector &subleadP4, float sigmaMrv, float sigmaMwv, float sigmaMeonly, const char* idType, const char* bdtType, float photonID_1,float photonID_2) {
// Ok need to re-write the diphoton-mva part since the systematics won't work unless we can change the Et of the photons
// all we have to do is to pass in the ->Et of the two photons also rather than take them from the four-vector branches
Float_t mva = 99.;
TLorentzVector Higgs = leadP4+subleadP4;
float leadPt = leadP4.Pt();
float subleadPt = subleadP4.Pt();
float mass = Higgs.M();
float diphopt = Higgs.Pt();
if (idType == "UCSD") {
tmva_dipho_UCSD_leadr9 = pho_r9[leadingPho];
tmva_dipho_UCSD_subleadr9 = pho_r9[subleadingPho];
tmva_dipho_UCSD_leadeta = fabs(leadP4.Eta());
tmva_dipho_UCSD_subleadeta = fabs(subleadP4.Eta());
// tmva_dipho_UCSD_leadptomass = leadPt/mass;
tmva_dipho_UCSD_subleadptomass = subleadPt/mass;
tmva_dipho_UCSD_diphoptom = diphopt/mass;
tmva_dipho_UCSD_sumptom = (leadPt+subleadPt)/mass;
tmva_dipho_UCSD_subleadmva = photonIDMVA2011(subleadingPho, vtx,leadP4, "UCSD");
tmva_dipho_UCSD_leadmva = photonIDMVA2011(leadingPho, vtx,subleadP4, "UCSD");
// tmva_dipho_UCSD_dmom = sigmaMrv;
tmva_dipho_UCSD_dmom = sigmaMeonly;
mva = tmvaReader_dipho_UCSD->EvaluateMVA("Gradient");
} else {
*tmva_dipho_MIT_dmom = sigmaMrv;
*tmva_dipho_MIT_dmom_wrong_vtx = sigmaMwv;
*tmva_dipho_MIT_vtxprob = vtxProb;
*tmva_dipho_MIT_ptom1 = leadPt/mass;
*tmva_dipho_MIT_ptom2 = subleadPt/mass;
*tmva_dipho_MIT_eta1 = leadP4.Eta();
*tmva_dipho_MIT_eta2 = subleadP4.Eta();
*tmva_dipho_MIT_dphi = TMath::Cos(leadP4.Phi() - subleadP4.Phi());
if (photonID_1 < -1. && photonID_2 < -1.) {
*tmva_dipho_MIT_ph1mva = photonIDMVA(leadingPho,vtx, leadP4, bdtType);
*tmva_dipho_MIT_ph2mva = photonIDMVA(subleadingPho,vtx, subleadP4, bdtType);
} else {
*tmva_dipho_MIT_ph1mva = photonID_1;
*tmva_dipho_MIT_ph2mva = photonID_2;
}
//std::cout << *tmva_dipho_MIT_dmom << " " << *tmva_dipho_MIT_dmom_wrong_vtx << " " << *tmva_dipho_MIT_vtxprob
// << *tmva_dipho_MIT_ptom1 << " " << *tmva_dipho_MIT_ptom2 << " " << *tmva_dipho_MIT_eta1 << " " << *tmva_dipho_MIT_dphi
// << *tmva_dipho_MIT_ph1mva << " " << *tmva_dipho_MIT_ph2mva << std::endl;
tmva_dipho_MIT_cache[diphoton_id] = tmva_dipho_MIT_buf;
mva = ( funcReader_dipho_MIT != 0 ? funcReader_dipho_MIT->eval() : tmvaReader_dipho_MIT->EvaluateMVA("Gradient") );
//std::cout << mva << std::endl;
}
return mva;
}
float LoopAll::getDmOverDz(Int_t pho1, Int_t pho2, Float_t* smeared) {
TVector3* vtx_plus = new TVector3(0, 0, 0.5);
TVector3* vtx_minus = new TVector3(0, 0, -0.5);
TLorentzVector lead_plus = get_pho_p4(pho1, vtx_plus, smeared);
TLorentzVector sublead_plus = get_pho_p4(pho2, vtx_minus, smeared);
TLorentzVector diphoton_plus = lead_plus + sublead_plus;
TLorentzVector lead_minus = get_pho_p4(pho1, vtx_minus, smeared);
TLorentzVector sublead_minus = get_pho_p4(pho2, vtx_minus, smeared);
TLorentzVector diphoton_minus = lead_minus + sublead_minus;
float result = diphoton_plus.M() - diphoton_minus.M();
return result;
}
Float_t LoopAll::deltaMassVtx(Int_t pho1, Int_t pho2, Float_t dz) {
TVector3* pos1 = (TVector3*)sc_xyz->At(pho_scind[pho1]);
TVector3* pos2 = (TVector3*)sc_xyz->At(pho_scind[pho2]);
Float_t r1 = pos1->Mag();
Float_t r2 = pos2->Mag();
Float_t sech1 = sin(pos1->Theta());
Float_t tanh1 = cos(pos1->Theta());
Float_t sech2 = sin(pos2->Theta());
Float_t tanh2 = cos(pos2->Theta());
Float_t cos12 = cos(pos1->Phi() - pos2->Phi());
Float_t rad1 = sech1*(sech1*tanh2-tanh1*sech2*cos12)/(1-tanh1*tanh2-sech1*sech2*cos12);
Float_t rad2 = sech2*(sech2*tanh1-tanh2*sech1*cos12)/(1-tanh2*tanh1-sech2*sech1*cos12);
return dz * 0.5*fabs(rad1/r1+rad2/r2);
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
void LoopAll::GlobeCtIsol(int mode, TLorentzVector* p4, float ptCut, float drCutMin, float drCutMax, Int_t & nIsol, Float_t & ptIsol, Float_t & angle1, Float_t & angle2, Float_t & angle3) {
nIsol=0;
ptIsol=0.;
angle1=10.;
angle2=10.;
angle3=10.;
//must put a track selection
for (int i=0; i<ct_n; i++) {
TLorentzVector * tempp4= (TLorentzVector *) ct_p4->At(i);
if(tempp4->Et()<ptCut) continue;
double dr=p4->DeltaR(*tempp4);
if(dr<drCutMin) continue;
if(dr<angle1) {
angle3=angle2;
angle2=angle1;
angle1=dr;
}
else if (dr<angle2) {
angle3=angle2;
angle2=dr;
}
else if (dr<angle3) {
angle3=dr;
}
if(dr>drCutMax) continue;
nIsol++;
ptIsol+=tempp4->Et();
}
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
int LoopAll::GlobeMatchIsl(TLorentzVector* p4, Float_t & deltaR) {
deltaR=10.;
int imatch=-1;
for (int i=0; i<sc_islbar_n; i++) {
TLorentzVector * tempp4= (TLorentzVector *) sc_islbar_p4->At(i);
double dr=p4->DeltaR(*tempp4);
if(dr<deltaR) {
deltaR=dr;
imatch=i;
}
}
if(imatch==-1) {
cout<<"ERROR GlobeMatchIsl found no match!!!! "<<endl;
}
else if(deltaR>0.3) {
cout<<"Strange, GlobeMatchIsl deltaR="<<deltaR<<" etapho "<<p4->Eta()<<endl;
}
return imatch;
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
#include "eIDCuts.h"
std::pair<bool, bool> LoopAll::ElectronId(int index, eIDLevel type) {
std::pair<bool, bool> isoIDResult(true, true);
//TLorentzVector* p4 = (TLorentzVector*)sc_p4->At(el_std_scind[index]);
TLorentzVector* p4 = (TLorentzVector*)el_std_sc->At(index);
float eta = fabs(p4->Eta());
int eb = 0, bin = 0;
float see = 0;
if (p4->Et() < 20.)
bin = 2;
else if (p4->Et() > 30.)
bin = 0;
else
bin =1;
//#ifndef CMSSW3
//if (eta < 1.479) {
//see = sc_sieie[el_std_scind[index]];
//eb = 0;
//} else {
//eb = 1;
//see = bc_sieie[sc_bcseedind[el_std_scind[index]]];
//}
//#else
if (eta < 1.479) {
see = el_std_sieiesc[index];
eb = 0;
} else {
eb = 1;
see = el_std_sieie[index];
}
//#endif
float eseedopincor = el_std_eseedopin[index] + el_std_fbrem[index];
if(el_std_fbrem[index]<0)
eseedopincor = el_std_eseedopin[index];
//#ifndef CMSSW3
//float sip = sipCalculator(index);
//#else
float sip = fabs(el_std_ip_gsf[index]);
//#endif
int cat = ElectronClassification(index);
float corr_tk_iso = el_std_tkiso03[ index];
float corr_ecal_iso = el_std_ecaliso04[index];
float corr_hcal_iso = el_std_hcaliso04[index];
corr_tk_iso = corr_tk_iso *pow(40/p4->Et(), 2);
corr_ecal_iso = corr_ecal_iso*pow(40/p4->Et(), 2);
corr_hcal_iso = corr_hcal_iso*pow(40/p4->Et(), 2);
if ((corr_tk_iso > cutisotk[bin][type][cat]) ||
(corr_ecal_iso > cutisoecal[bin][type][cat]) ||
(corr_hcal_iso > cutisohcal[bin][type][cat]))
isoIDResult.first = false;
if (el_std_fbrem[index] < -2) {
isoIDResult.second = false;
return isoIDResult;
}
if (el_std_hoe[index] > cuthoe[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
if (see > cutsee[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
if (fabs(el_std_dphiin[index]) > cutdphi[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
if (fabs(el_std_detain[index]) > cutdeta[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
if (eseedopincor < cuteopin[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
if (sip > cutip[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
if (el_std_hp_expin[index] > cutmishits[bin][type][cat]) {
isoIDResult.second = false;
return isoIDResult;
}
return isoIDResult;
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
int LoopAll::ElectronClassification(int index) {
TLorentzVector* p4 = (TLorentzVector*) el_std_sc->At(index);
int cat = -1;
float eta = fabs(p4->Eta());
if (eta < 1.479) { // BARREL
if(el_std_fbrem[index]<0.12)
cat=1;
else if (el_std_eopin[index] < 1.2 && el_std_eopin[index] > 0.9)
cat=0;
else
cat=2;
} else { // ENDCAP
if(el_std_fbrem[index]<0.2)
cat=4;
else if (el_std_eopin[index] < 1.22 && el_std_eopin[index] > 0.82)
cat=3;
else
cat=5;
}
return cat;
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
Float_t LoopAll::sipCalculator(int index) {
Float_t ip = 0;
if (el_std_tkind[index] != -1) {
TLorentzVector* tk = (TLorentzVector*)tk_p4->At(el_std_tkind[index]);
TVector3* my_tk_pos = (TVector3*)tk_vtx_pos->At(el_std_tkind[index]);
// FIXME to handle the case of multiple vertices
if (vtx_std_n != 0) {
TVector3* my_vtx_pos = (TVector3*)vtx_std_xyz->At(0);
// this is d0 "corrected" for the vertex...
ip = fabs((-(my_tk_pos->X()-my_vtx_pos->X())*tk->Y()+(my_tk_pos->Y()-my_vtx_pos->Y()) * tk->X())/tk->Pt());
} else {
ip = fabs((-(my_tk_pos->X())*tk->Y()+(my_tk_pos->Y()) * tk->X())/tk->Pt());
}
}
return ip;
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
void LoopAll::eIDInfo(Int_t index, Int_t& iso_result, Int_t& id_result, Int_t eIDMaxLevel) {
iso_result = 0;
id_result = 0;
// FIXME add GetEntry functions
for(Int_t i=0; i<eIDMaxLevel; ++i) {
std::pair<bool, bool> result = ElectronId(index, LoopAll::eIDLevel(i));
if (result.first)
iso_result = i;
if (result.second)
id_result = i;
}
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
// Vertex Analysis
// ---------------------------------------------------------------------------------------------------------------------------------------------
class GlobeVertexInfo : public VertexInfoAdapter
{
public:
GlobeVertexInfo(LoopAll &);
virtual int nvtx() const { return lo_.vtx_std_n; };
virtual int ntracks() const { return lo_.tk_p4->GetEntries(); } // return lo_.tk_n; };
virtual bool hasVtxTracks() const { return true; }
virtual const unsigned short * vtxTracks(int ii) const { return &(*lo_.vtx_std_tkind)[ii][0]; };
virtual int vtxNTracks(int ii) const { return lo_.vtx_std_ntks[ii]; };
virtual const float * vtxTkWeights(int ii) const { return &(*lo_.vtx_std_tkweight)[ii][0]; };
virtual float tkpx(int ii) const { return ((TLorentzVector*)lo_.tk_p4->At(ii))->Px(); };
virtual float tkpy(int ii) const { return ((TLorentzVector*)lo_.tk_p4->At(ii))->Py(); };
virtual float tkpz(int ii) const { return ((TLorentzVector*)lo_.tk_p4->At(ii))->Pz(); };
virtual float tkPtErr(int ii) const { return lo_.tk_pterr[ii]; };
virtual int tkVtxId(int ii) const { return -1; };
virtual float tkWeight(int ii, int jj) const { return (*lo_.vtx_std_tkweight)[jj][ii]; };
virtual float vtxx(int ii) const { return ((TVector3*)lo_.vtx_std_xyz->At(ii))->X(); };
virtual float vtxy(int ii) const { return ((TVector3*)lo_.vtx_std_xyz->At(ii))->Y(); };
virtual float vtxz(int ii) const { return ((TVector3*)lo_.vtx_std_xyz->At(ii))->Z(); };
virtual float tkd0(int ii, int jj) const { return 0.; }; // FIXME
virtual float tkd0Err(int ii, int jj) const { return 1.; }; // FIXME
virtual float tkdz(int ii, int jj) const { return 0.; }; // FIXME
virtual float tkdzErr(int ii, int jj) const { return 1.; }; // FIXME
virtual bool tkIsHighPurity(int ii) const { return ( lo_.tk_quality[ii] & (1<<2) ) >> 2; };
virtual ~GlobeVertexInfo();
private:
LoopAll & lo_;
};
// ---------------------------------------------------------------------------------------------------------------------------------------------
GlobeVertexInfo::GlobeVertexInfo(LoopAll & lo) : lo_(lo) {};
// ---------------------------------------------------------------------------------------------------------------------------------------------
GlobeVertexInfo::~GlobeVertexInfo() {};
// ---------------------------------------------------------------------------------------------------------------------------------------------
void LoopAll::vertexAnalysis(HggVertexAnalyzer & vtxAna, PhotonInfo pho1, PhotonInfo pho2)
{
GlobeVertexInfo vinfo(*this);
// PhotonInfo
// pho1(p1,*((TVector3*)pho_calopos->At(p1)),((TLorentzVector*)pho_p4->At(p1))->Energy()),
// pho2(p2,*((TVector3*)pho_calopos->At(p2)),((TLorentzVector*)pho_p4->At(p2))->Energy());
vtxAna.analyze(vinfo,pho1,pho2);
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
PhotonInfo LoopAll::fillPhotonInfos(int p1, int useAllConvs, float * energy)
{
int iConv1 = useAllConvs>0 ? matchPhotonToConversion(p1,useAllConvs) : -1;
if ( iConv1 >= 0) {
// conversions infos
return PhotonInfo(p1,
// *((TVector3*)pho_calopos->At(p1)),
*((TVector3*)sc_xyz->At(pho_scind[p1])),
*((TVector3*) bs_xyz->At(0)),
*((TVector3*) conv_vtx->At(iConv1)),
conv_ntracks[iConv1] == 1 ? *((TVector3*) conv_singleleg_momentum->At(iConv1)) : *((TVector3*) conv_refitted_momentum->At(iConv1)),
energy == 0 ? ((TLorentzVector*)pho_p4->At(p1))->Energy() : energy[p1],
pho_isEB[p1],
conv_ntracks[iConv1],
conv_validvtx[iConv1],
conv_chi2_probability[iConv1],
conv_eoverp[iConv1]
);
}
//// else {
//// return PhotonInfo(p1,*((TVector3*)pho_calopos->At(p1)),((TLorentzVector*)pho_p4->At(p1))->Energy());
//// }
return PhotonInfo(p1,
// *((TVector3*)pho_calopos->At(p1)),
*((TVector3*)sc_xyz->At(pho_scind[p1])),
*((TVector3*) bs_xyz->At(0)),
*((TVector3*) pho_conv_vtx->At(p1)),
*((TVector3*) pho_conv_refitted_momentum->At(p1)),
energy == 0 ? ((TLorentzVector*)pho_p4->At(p1))->Energy() : energy[p1],
pho_isEB[p1],
0,
0,
0,
pho_conv_eoverp[p1]
);
}
// ---------------------------------------------------------------------------------------------------------------------------------------------
std::vector<int> LoopAll::vertexSelection(HggVertexAnalyzer & vtxAna, HggVertexFromConversions & vtxAnaFromConv,
PhotonInfo & pho1, PhotonInfo & pho2, std::vector<std::string> & vtxVarNames,
bool useMva, TMVA::Reader * tmvaReader, std::string tmvaMethod)
{
int p1 = pho1.id(), p2 = pho2.id();
// assert( p1 == vtxAna.pho1() && p2 == vtxAna.pho2() );
vtxAna.setPairID(p1,p2);
if( useMva ) { return vtxAna.rank(*tmvaReader,tmvaMethod); }
// preselect vertices : all vertices
std::vector<int> preselAll;
for(int i=0; i<vtx_std_n ; i++) {
preselAll.push_back(i);
}
float zconv = 0;
float dzconv = 0;
std::vector<int> preselConv;
if ( (pho1.isAConversion() || pho2.isAConversion() ) ) {
// at least one of the photons is identified as a conversion
if (pho1.isAConversion() && !pho2.isAConversion() ){
zconv = vtxAnaFromConv.vtxZ(pho1);
dzconv = vtxAnaFromConv.vtxdZ(pho1);
}
if (pho2.isAConversion() && !pho1.isAConversion()){
zconv = vtxAnaFromConv.vtxZ(pho2);
dzconv = vtxAnaFromConv.vtxdZ(pho2);
}
if ( pho1.isAConversion() && pho2.isAConversion()){
float z1 = vtxAnaFromConv.vtxZ(pho1);
float dz1 = vtxAnaFromConv.vtxdZ(pho1);
float z2 = vtxAnaFromConv.vtxZ(pho2);
float dz2 = vtxAnaFromConv.vtxdZ(pho2);
zconv = (z1/dz1/dz1 + z2/dz2/dz2)/(1./dz1/dz1 + 1./dz2/dz2 ); // weighted average
dzconv = sqrt( 1./(1./dz1/dz1 + 1./dz2/dz2)) ;
}
// preselect vertices : only vertices in a window zconv +/- dzconv
for(int i=0; i < vtx_std_n; i++) {
TVector3 * vtxpos= (TVector3 *) vtx_std_xyz->At(i);
if ( fabs(zconv - vtxpos->Z() ) < dzconv )
preselConv.push_back(i);
}
} // end if at least one photon is a conversion
std::vector<int> rankprodAll = useMva ? vtxAna.rank(*tmvaReader,tmvaMethod) : vtxAna.rankprod(vtxVarNames);
int iClosestConv = -1;
float dminconv = 9999999;
TLorentzVector dipho = get_pho_p4( p1, 0 ) + get_pho_p4( p2, 0 ) ;
int nbest ;
if ( dipho.Pt() < 30 ) nbest = 5;
else nbest = 3;
if (rankprodAll.size() < nbest ) nbest = rankprodAll.size();
for (int ii = 0; ii < nbest; ii++ ){
TVector3 * vtxpos= (TVector3 *) vtx_std_xyz->At(rankprodAll[ii]);
if ( fabs( vtxpos->Z()-zconv ) < dzconv && fabs(vtxpos->Z() - zconv ) < dminconv){
iClosestConv = rankprodAll[ii];
dminconv = fabs(vtxpos->Z()-zconv );
}
}
std::vector<int> rankprod;
rankprod.clear();
if (iClosestConv!=-1 ) rankprod.push_back(iClosestConv);
//for (int kk = 0; kk < nbest; kk++ ){
for (int kk = 0; kk < rankprodAll.size(); kk++ ){
if ( iClosestConv == rankprodAll[kk] ) continue;