-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelectronSelections.cc
2076 lines (1709 loc) · 80.8 KB
/
electronSelections.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
/////////////////////////
// Electron Selections //
/////////////////////////
// ROOT includes
#include "Math/VectorUtil.h"
// CMS2 includes
#include "electronSelections.h"
#include "eventSelections.h"
#include "MITConversionUtilities.h"
#include "muonSelections.h"
#include "trackSelections.h"
//#include "ssSelections.h"
using namespace tas;
using namespace wp2012;
bool pass_electronSelectionCompareMask( const cuts_t cuts_passed, const cuts_t selectionType ) {
if ((cuts_passed & selectionType) == selectionType) return true;
return false;
}
bool pass_electronSelection( const unsigned int index, const cuts_t selectionType, bool applyAlignmentCorrection, bool removedEtaCutInEndcap, bool useGsfTrack) {
checkElectronSelections();
cuts_t cuts_passed = electronSelection(index, applyAlignmentCorrection, removedEtaCutInEndcap, useGsfTrack);
if ( (cuts_passed & selectionType) == selectionType ) return true;
return false;
}
cuts_t electronSelection( const unsigned int index, bool applyAlignmentCorrection, bool removedEtaCutInEndcap, bool useGsfTrack) {
// keep track of which cuts passed
cuts_t cuts_passed = 0;
///////////////
// Isolation //
///////////////
// relative isolation non truncated
if( electronIsolation_rel_v1(index, true ) < 0.10) cuts_passed |= (1ll<<ELEISO_RELNT010); // Relative Isolation
if( electronIsolation_rel_v1(index, true ) < 0.15) cuts_passed |= (1ll<<ELEISO_RELNT015); //
if( electronIsolation_rel_v1(index, true ) < 0.40) cuts_passed |= (1ll<<ELEISO_RELNT040); //
if( electronIsolation_rel_v1(index, false) < 0.20) cuts_passed |= (1ll<<ELEISO_TRK_RELNT020); // Tracker Relative Isolation
if( electronIsolation_ECAL_rel_v1(index) < 0.20) cuts_passed |= (1ll<<ELEISO_ECAL_RELNT020); // ECAL Relative Isolation
if( electronIsolation_HCAL_rel_v1(index) < 0.20) cuts_passed |= (1ll<<ELEISO_HCAL_RELNT020); // HCAL Relative Isolation
if (electronIsolation_ECAL_rel_v1(index, false) < 0.20) cuts_passed |= (1ll<<ELEISO_ECAL_RELNT020_NPS); // ECAL Relative Isolation, no ped sub in EB
if( electronIsolation_ECAL_rel(index) < 0.20) cuts_passed |= (1ll<<ELEISO_ECAL_REL020); // ECAL Relative Isolation (truncated)
if( electronIsolation_HCAL_rel(index) < 0.20) cuts_passed |= (1ll<<ELEISO_HCAL_REL020); // HCAL Relative Isolation (truncated)
if (electronIsolation_cor_rel_v1(index, true) < 0.10) cuts_passed |= (1ll<<ELEISO_COR_RELNT010);
//relative isolation truncated
if (electronIsolation_rel_FastJet(index, true) < 0.05) cuts_passed |= (1ll<<ELEISO_FASTJET_REL005); // ADDED
if (electronIsolation_rel_FastJet(index, true) < 0.10) cuts_passed |= (1ll<<ELEISO_FASTJET_REL010); // ADDED
if (electronIsolation_rel_FastJet(index, true) < 0.15) cuts_passed |= (1ll<<ELEISO_FASTJET_REL015); // ADDED
//relative isolation truncated
if (electronIsolation_rel(index, true) < 0.10) cuts_passed |= (1ll<<ELEISO_REL010);
if (electronIsolation_rel(index, true) < 0.15) cuts_passed |= (1ll<<ELEISO_REL015);
if (electronIsolation_rel(index, true) < 0.40) cuts_passed |= (1ll<<ELEISO_REL040);
if (electronIsolation_rel(index, true) < 1.00) cuts_passed |= (1ll<<ELEISO_REL100);
if (electronIsolation_rel_ww(index, true) < 0.10) cuts_passed |= (1ll<<ELEISO_REL010_WW);
if (electronIsolation_rel_ww(index, true) < 0.40) cuts_passed |= (1ll<<ELEISO_REL040_WW);
if (electronIsolation_rel_ww(index, true) < 1.00) cuts_passed |= (1ll<<ELEISO_REL100_WW);
//pf iso
float pfiso = electronIsoValuePF(index,0);
if (fabs(cms2.els_p4()[index].eta()) < 1.479){
if (pfiso<0.15) cuts_passed |= (1ll<<ELEISO_SMURFV4);
if (pfiso<0.13) cuts_passed |= (1ll<<ELEISO_SMURFV5);
} else if (pfiso<0.09) {
cuts_passed |= (1ll<<ELEISO_SMURFV4);
cuts_passed |= (1ll<<ELEISO_SMURFV5);
}
////////
// d0 //
////////
if (fabs(cms2.els_d0corr()[index]) < 0.02) cuts_passed |= (1ll<<ELEIP_200);
if (fabs(cms2.els_d0corr()[index]) < 0.04) cuts_passed |= (1ll<<ELEIP_400);
if (fabs(electron_d0PV(index)) < 0.02) cuts_passed |= (1ll<<ELEIP_PV_200);
if (fabs(electron_d0PV_wwV1(index)) < 0.02 && fabs(electron_dzPV_wwV1(index)) < 1.0 ) cuts_passed |= (1ll<<ELEIP_PV_wwV1);
if (fabs(electron_d0PV_smurfV3(index)) < 0.02 && fabs(electron_dzPV_smurfV3(index)) < 0.2 ) cuts_passed |= (1ll<<ELEIP_PV_SMURFV3);
if (fabs(electron_dzPV_smurfV3(index)) < 0.1 ) cuts_passed |= (1ll<<ELEIP_PV_DZ_1MM);
if (fabs(electron_d0PV_smurfV3(index)) < 0.04 && fabs(electron_dzPV_smurfV3(index)) < 1.0 ) cuts_passed |= (1ll<<ELEIP_PV_OSV2);
if (fabs(electron_d0PV_smurfV3(index)) < 0.20 && fabs(electron_dzPV_smurfV3(index)) < 1.0 ) cuts_passed |= (1ll<<ELEIP_PV_OSV2_FO);
int vtxidx = firstGoodVertex();
if (vtxidx >= 0) {
if (useGsfTrack) {
if (fabs(gsftrks_d0_pv(cms2.els_gsftrkidx()[index], vtxidx).first) < 0.02)
cuts_passed |= (1ll<<ELEIP_SS200);
}
else if (cms2.els_trkidx()[index] >= 0) {
if (fabs(trks_d0_pv(cms2.els_trkidx()[index], vtxidx).first) < 0.02)
cuts_passed |= (1ll<<ELEIP_SS200);
}
}
else if (fabs(cms2.els_d0corr()[index]) < 0.02)
cuts_passed |= (1ll<<ELEIP_SS200);
////////////////////
// Identification //
////////////////////
// SMURF ID
if (electronId_smurf_v1(index)) cuts_passed |= (1ll<<ELEID_SMURFV1_EXTRA);
if (electronId_smurf_v2(index)) cuts_passed |= (1ll<<ELEID_SMURFV2_EXTRA);
if (electronId_smurf_v3(index)) cuts_passed |= (1ll<<ELEID_SMURFV3_EXTRA);
if (electronId_smurf_v1ss(index)) cuts_passed |= (1ll<<ELEID_SMURFV1SS_EXTRA);
if (electronId_smurf_v2ss(index)) cuts_passed |= (1ll<<ELEID_SMURFV2SS_EXTRA);
// 2012 ID
// electronIdComponent_t answer_loose_2012 = electronId_WP2012(index, LOOSE);
// if ((answer_loose_2012 & PassWP2012CutsNoIso) == PassWP2012CutsNoIso) cuts_passed |= (1ll<<ELEID_WP2012_LOOSE_NOISO);
// if ((answer_loose_2012 & PassWP2012CutsNoIsoNoIP) == PassWP2012CutsNoIsoNoIP) cuts_passed |= (1ll<<ELEID_WP2012_LOOSE_NOISO_NOIP);
electronIdComponent_t answer_med_2012 = electronId_WP2012(index, MEDIUM);
if ((answer_med_2012 & PassWP2012CutsNoIso) == PassWP2012CutsNoIso) cuts_passed |= (1ll<<ELEID_WP2012_MEDIUM_NOISO);
if ((answer_med_2012 & PassWP2012CutsNoIsoNoIP) == PassWP2012CutsNoIsoNoIP) cuts_passed |= (1ll<<ELEID_WP2012_MEDIUM_NOISO_NOIP);
electronIdComponent_t answer_loose_2012 = electronId_WP2012(index, LOOSE);
if ((answer_loose_2012 & PassWP2012CutsNoIso) == PassWP2012CutsNoIso) cuts_passed |= (1ll<<ELEID_WP2012_LOOSE_NOISO);
// VBTF ID
electronIdComponent_t answer_vbtf = 0;
// VBTF95 (optimised in 35X)
answer_vbtf = electronId_VBTF(index, VBTF_35X_95, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_95);
// VBTF90 (optimised in 35X)
answer_vbtf = electronId_VBTF(index, VBTF_35X_90, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_90);
// VBTF80 (optimised in 35X)
answer_vbtf = electronId_VBTF(index, VBTF_35X_80, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_80);
// VBTF70 (optimised in 35X)
// answer_vbtf = electronId_VBTF(index, VBTF_35Xr2_70, applyAlignmentCorrection, removedEtaCutInEndcap);
// if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_70);
// VBTF85 no H/E in endcap
answer_vbtf = electronId_VBTF(index, VBTF_85_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_85_NOHOEEND);
// VBTF85
answer_vbtf = electronId_VBTF(index, VBTF_85 , applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_85);
// VBTF80 no H/E in endcap
answer_vbtf = electronId_VBTF(index, VBTF_80_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_80_NOHOEEND);
// VBTF70 no H/E in endcap
answer_vbtf = electronId_VBTF(index, VBTF_70_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_70_NOHOEEND);
// VBTF90 with H/E and dPhiIn tuned to match HLT
answer_vbtf = electronId_VBTF(index, VBTF_90_HLT, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_90_HLT);
// VBTF90 with H/E and dPhiIn tuned to match HLT (CaloIdT+TrkIdVL)
answer_vbtf = electronId_VBTF(index, VBTF_90_HLT_CALOIDT_TRKIDVL, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_90_HLT_CALOIDT_TRKIDVL);
// VBTF95 no H/E in endcap
answer_vbtf = electronId_VBTF(index, VBTF_95_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_95_NOHOEEND);
// CIC ID
// MEDIUM (V03 optimisation)
electronIdComponent_t answer_cic = electronId_CIC(index, 3, CIC_MEDIUM, applyAlignmentCorrection, removedEtaCutInEndcap);
if ((answer_cic & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_CIC_V03_MEDIUM);
//////////////////////////
// Conversion Rejection //
//////////////////////////
if (!isFromConversionPartnerTrack(index)) cuts_passed |= (1ll<<ELENOTCONV_DISTDCOT002);
if (!isFromConversionPartnerTrack_v2(index)) cuts_passed |= (1ll<<ELENOTCONV_DISTDCOT002_OLD);
if (!isFromConversionHitPattern(index)) cuts_passed |= (1ll<<ELENOTCONV_HITPATTERN);
if (cms2.els_exp_innerlayers().at(index) == 0) cuts_passed |= (1ll<<ELENOTCONV_HITPATTERN_0MHITS);
if(!isFromConversionMIT(index)) cuts_passed |= (1ll<<ELENOTCONV_MIT);
/////////////////
// Fiduciality //
/////////////////
if ((cms2.els_type()[index] & (1ll<<ISECALDRIVEN))) cuts_passed |= (1ll<<ELESEED_ECAL);
if (fabs(cms2.els_p4()[index].eta()) < 2.5) cuts_passed |= (1ll<<ELEETA_250);
if (fabs(cms2.els_p4()[index].eta()) < 2.4) cuts_passed |= (1ll<<ELEETA_240);
if (electronId_noMuon(index)) cuts_passed |= (1ll<<ELENOMUON_010);
if (electronId_noMuon_SS(index)) cuts_passed |= (1ll<<ELENOMUON_010_SS);
////////
// Pt //
////////
if( cms2.els_p4()[index].pt() > 10.0 ) cuts_passed |= (1ll<<ELEPT_010);
// Veto electron in transition region
if( fabs(cms2.els_etaSC()[index]) < 1.4442 || fabs(cms2.els_etaSC()[index]) > 1.566 ) cuts_passed |= (1ll<<ELE_NOT_TRANSITION);
/////////////////
// Charge Flip //
/////////////////
if (!isChargeFlip3agree(index)) cuts_passed |= (1ll<<ELECHARGE_NOTFLIP3AGREE);
// return which selections passed
return cuts_passed;
}
///////////////
// Muon Veto //
//////////////
bool electronId_noMuon( const unsigned int index ) {
if ( cms2.els_closestMuon().at(index) != -1) return false;
return true;
}
bool electronId_noMuon_SS( const unsigned int index ) {
int idx = cms2.els_closestMuon().at(index);
if (idx < 0) return true;
if (muonId(idx, NominalSSv5)) return false;
return true;
}
////////////////////
// Identification //
////////////////////
// SMURF
bool electronId_smurf_v1(const unsigned int index)
{
if (cms2.els_p4()[index].pt() > 20.0) return true;
if (cms2.els_fbrem()[index] > 0.15) return true;
if (fabs(cms2.els_etaSC()[index]) < 1.) {
if (cms2.els_eOverPIn()[index] > 0.95 && fabs(cms2.els_dPhiIn()[index]*cms2.els_charge()[index]) < 0.006) return true;
}
return false;
}
bool electronId_smurf_v2(const unsigned int index)
{
if (cms2.els_p4()[index].pt() > 20.0) return true;
if (cms2.els_fbrem()[index] > 0.15) return true;
if (fabs(cms2.els_etaSC()[index]) < 1.) {
if (cms2.els_eOverPIn()[index] > 0.95) return true;
}
return false;
}
bool electronId_smurf_v3(const unsigned int index)
{
if (fabs(cms2.els_etaSC()[index]) > 1.479 && cms2.els_hOverE()[index] > 0.1) return false;
if (cms2.els_p4()[index].pt() > 20.0) return true;
electronIdComponent_t answer_vbtf = 0;
answer_vbtf = electronId_VBTF(index, VBTF_70_NOHOEEND, false, false);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) {
if (cms2.els_fbrem()[index] > 0.15) return true;
if (fabs(cms2.els_etaSC()[index]) < 1.) {
if (cms2.els_eOverPIn()[index] > 0.95) return true;
}
}
return false;
}
bool electronId_smurf_v1ss(const unsigned int index)
{
if (cms2.els_p4()[index].pt() > 20.0) return true;
electronIdComponent_t answer_vbtf = 0;
answer_vbtf = electronId_VBTF(index, VBTF_80_NOHOEEND, false, false);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) {
if (cms2.els_fbrem()[index] > 0.15) return true;
if (fabs(cms2.els_etaSC()[index]) < 1.) {
if (cms2.els_eOverPIn()[index] > 0.95) return true;
}
}
return false;
}
bool electronId_smurf_v2ss(const unsigned int index)
{
if (cms2.els_p4()[index].pt() > 20.0) return true;
electronIdComponent_t answer_vbtf = 0;
answer_vbtf = electronId_VBTF(index, VBTF_80_NOHOEEND, false, false);
if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) {
if (fabs(cms2.els_etaSC()[index]) > 1.479)
if (cms2.els_hOverE()[index] < 0.15) return true;
if (cms2.els_fbrem()[index] > 0.15) return true;
if (fabs(cms2.els_etaSC()[index]) < 1.) {
if (cms2.els_eOverPIn()[index] > 0.95) return true;
}
}
return false;
}
// CIC
electronIdComponent_t electronId_CIC(const unsigned int index, const unsigned int version, const cic_tightness tightness, bool applyAlignementCorrection, bool removedEtaCutInEndcap)
{
// check that a valid version number was supplied
if (version != 2 && version != 3 && version != 4 && version != 6) {
std::cout << "[electronId_CIC] Error! Version must be 2, 3, 4 or 6 - fail" << std::endl;
return 0;
}
//
// get the variables that are going to be cut on
//
double scTheta = (2*atan(exp(-1*cms2.els_etaSC()[index])));
double scEt = cms2.els_eSC()[index]*sin(scTheta);
double scEta = cms2.els_etaSC()[index];
double eSeedOverPin = cms2.els_eSeedOverPIn()[index];
double fBrem = cms2.els_fbrem()[index];
double hOverE = cms2.els_hOverE()[index];
double sigmaee = cms2.els_sigmaIEtaIEta()[index];
int mishits = cms2.els_exp_innerlayers()[index];
double dist = (cms2.els_conv_dist()[index] == -9999.? 9999:cms2.els_conv_dist()[index]);
double dcot = (cms2.els_conv_dcot()[index] == -9999.? 9999:cms2.els_conv_dcot()[index]);
float dcotdistcomb = ((0.04 - std::max(dist, dcot)) > 0?(0.04 - std::max(dist, dcot)):0);
double tkIso = cms2.els_tkIso()[index];
double ecalIso = cms2.els_ecalIso04()[index];
double hcalIso = cms2.els_hcalIso04()[index];
double ip = fabs(cms2.els_d0()[index]);
if (cms2.vtxs_sumpt().size() > 0) {
const float vx = cms2.vtxs_position()[0].x();
const float vy = cms2.vtxs_position()[0].y();
const float px = cms2.els_trk_p4()[index].px();
const float py = cms2.els_trk_p4()[index].py();
ip = fabs(-1*cms2.els_d0()[index] + (vx*py - vy*px) / cms2.els_trk_p4()[index].pt());
}
//
// get corrected dEtaIn and dPhiIn
//
float deltaEtaIn = cms2.els_dEtaIn()[index];
float deltaPhiIn = cms2.els_dPhiIn()[index];
if (applyAlignementCorrection) electronCorrection_pos(index, deltaEtaIn, deltaPhiIn);
// find the catagory for this electron
unsigned int cat = eidClassify(version, index);
// determine if in EB or EE
int eb;
if (cms2.els_fiduciality()[index] & (1<<ISEB)) eb = 0;
else eb = 1;
// Version V02
if (version == 2) {
// set the parameters for the chosen tightness
std::vector<double> cutdeta;
std::vector<double> cutdphi;
std::vector<double> cuteopin;
std::vector<double> cutet;
std::vector<double> cuthoe;
std::vector<double> cutip;
std::vector<double> cutisoecal;
std::vector<double> cutisohcal;
std::vector<double> cutisotk;
std::vector<double> cutmishits;
std::vector<double> cutsee;
eidGetCIC_V02(tightness, cutdeta, cutdphi, cuteopin, cutet, cuthoe,
cutip, cutisoecal, cutisohcal, cutisotk, cutmishits, cutsee);
unsigned int result = 0;
int bin = 0;
if (scEt < 20.)
bin = 2;
else if (scEt > 30.)
bin = 0;
else
bin = 1;
if (fBrem > 0)
eSeedOverPin = eSeedOverPin + fBrem;
if (bin != 2) {
tkIso = tkIso*pow(40./scEt, 2);
ecalIso = ecalIso*pow(40./scEt, 2);
hcalIso = hcalIso*pow(40./scEt, 2);
}
if ((tkIso < cutisotk[cat+3*eb+bin*6]) &&
(ecalIso < cutisoecal[cat+3*eb+bin*6]) &&
(hcalIso < cutisohcal[cat+3*eb+bin*6]))
result |= (1<<ELEID_ISO);
if (fBrem < -2)
return result;
bool passdEtaCut = fabs(deltaEtaIn) < cutdeta[cat+3*eb+bin*6];
if(removedEtaCutInEndcap && eb == 1) passdEtaCut = true;
if (hOverE < cuthoe[cat+3*eb+bin*6] &&
sigmaee < cutsee[cat+3*eb+bin*6] &&
fabs(deltaPhiIn) < cutdphi[cat+3*eb+bin*6] &&
passdEtaCut &&
eSeedOverPin > cuteopin[cat+3*eb+bin*6])
result |= (1<<ELEID_ID);
if (ip < cutip[cat+3*eb+bin*6])
result |= (1<<ELEID_IP);
if (mishits < cutmishits[cat+3*eb+bin*6])
result |= (1<<ELEID_CONV);
return result;
}
// version V03, V04 or V05
if (version == 3 || version == 4 || version == 5) {
//
// set the parameters for the chosen tightness
//
std::vector<double> cutdcotdist;
std::vector<double> cutdetain;
std::vector<double> cutdphiin;
std::vector<double> cuteseedopcor;
std::vector<double> cutet;
std::vector<double> cutfmishits;
std::vector<double> cuthoe;
std::vector<double> cutip_gsf;
std::vector<double> cutiso_sum;
std::vector<double> cutiso_sumoet;
std::vector<double> cutsee;
// V03 uses Et binning
bool wantBinning = true;
if (version == 3) {
eidGetCIC_V03(tightness, cutdcotdist, cutdetain, cutdphiin, cuteseedopcor, cutet,
cutfmishits, cuthoe, cutip_gsf, cutiso_sum, cutiso_sumoet, cutsee);
}
if (version == 4) {
eidGetCIC_V04(tightness, cutdcotdist, cutdetain, cutdphiin, cuteseedopcor, cutet,
cutfmishits, cuthoe, cutip_gsf, cutiso_sum, cutiso_sumoet, cutsee);
// V04 does not use Et binning
wantBinning = false;
}
// this is certainly true for V03
// but not sure the meaning of V04,05
unsigned int result = 0;
int bin = 0;
if (wantBinning) {
if (scEt < 20.)
bin = 2;
else if (scEt > 30.)
bin = 0;
else
bin = 1;
}
if (fBrem > 0)
eSeedOverPin = eSeedOverPin + fBrem;
float iso_sum = tkIso + ecalIso + hcalIso;
float iso_sum_corrected = iso_sum*pow(40./scEt, 2);
if ((iso_sum < cutiso_sum[cat+bin*9]) &&
(iso_sum_corrected < cutiso_sumoet[cat+bin*9]))
result |= (1<<ELEID_ISO);
if (fBrem > -2) {
if ((hOverE < cuthoe[cat+bin*9]) and
(sigmaee < cutsee[cat+bin*9]) and
(fabs(deltaPhiIn) < cutdphiin[cat+bin*9]) and
(fabs(deltaEtaIn) < cutdetain[cat+bin*9]) and
(eSeedOverPin > cuteseedopcor[cat+bin*9]) and
(scEt > cutet[cat+bin*9]))
result |= (1<<ELEID_ID);
}
if (ip < cutip_gsf[cat+bin*9])
result |= (1<<ELEID_IP);
if ((mishits < cutfmishits[cat+bin*9]) and
(dcotdistcomb < cutdcotdist[cat+bin*9]))
result |= (1<<ELEID_CONV);
return result;
}
if (version == 6) {
std::vector<double> cutIsoSum;
std::vector<double> cutIsoSumCorr;
std::vector<double> cuthoe;
std::vector<double> cutsee;
std::vector<double> cutdphi;
std::vector<double> cutdeta;
std::vector<double> cuteopin;
std::vector<double> cutmishits;
std::vector<double> cutdcotdist;
std::vector<double> cutip;
std::vector<double> cutIsoSumCorrl;
std::vector<double> cuthoel;
std::vector<double> cutseel;
std::vector<double> cutdphil;
std::vector<double> cutdetal;
std::vector<double> cutipl;
eidGetCIC_V06(tightness, cutIsoSum, cutIsoSumCorr, cuthoe, cutsee, cutdphi,
cutdeta, cuteopin, cutmishits, cutdcotdist, cutip, cutIsoSumCorrl,
cuthoel, cutseel, cutdphil, cutdetal, cutipl);
int result = 0;
const int ncuts = 10;
std::vector<bool> cut_results(ncuts, false);
float iso_sum = tkIso + ecalIso + hcalIso;
if(fabs(scEta)>1.5)
iso_sum += (fabs(scEta)-1.5)*1.09;
float iso_sumoet = iso_sum*(40./scEt);
float eseedopincor = eSeedOverPin + fBrem;
if(fBrem < 0) eseedopincor = eSeedOverPin;
for (int cut=0; cut<ncuts; cut++) {
switch (cut) {
case 0:
cut_results[cut] = eidComputeCut(fabs(deltaEtaIn), scEt, cutdetal[cat], cutdeta[cat]);
break;
case 1:
cut_results[cut] = eidComputeCut(fabs(deltaPhiIn), scEt, cutdphil[cat], cutdphi[cat]);
break;
case 2:
cut_results[cut] = (eseedopincor > cuteopin[cat]);
break;
case 3:
cut_results[cut] = eidComputeCut(hOverE, scEt, cuthoel[cat], cuthoe[cat]);
break;
case 4:
cut_results[cut] = eidComputeCut(sigmaee, scEt, cutseel[cat], cutsee[cat]);
break;
case 5:
cut_results[cut] = eidComputeCut(iso_sumoet, scEt, cutIsoSumCorrl[cat], cutIsoSumCorr[cat]);
break;
case 6:
cut_results[cut] = (iso_sum < cutIsoSum[cat]);
break;
case 7:
cut_results[cut] = eidComputeCut(fabs(ip), scEt, cutipl[cat], cutip[cat]);
break;
case 8:
cut_results[cut] = (mishits < cutmishits[cat]);
break;
case 9:
cut_results[cut] = (dcotdistcomb < cutdcotdist[cat]);
break;
}
}
// ID part
if (cut_results[0] & cut_results[1] & cut_results[2] & cut_results[3] & cut_results[4]) result |= (1<<ELEID_ID);
// ISO part
if (cut_results[5] & cut_results[6]) result |= (1<<ELEID_ISO);
// IP part
if (cut_results[7]) result |= (1<<ELEID_IP);
// Conversion part
if (cut_results[8] and cut_results[9]) result |= (1<<ELEID_CONV);
return result;
}
std::cout << "[electronId_CIC] Error! got to the end and didn't apply any cuts - fail" << std::endl;
return 0;
}
unsigned int eidClassify(const unsigned int version, const unsigned int index) {
// variables used for classification
double eta = fabs(cms2.els_etaSC()[index]);
double eOverP = cms2.els_eOverPIn()[index];
double fBrem = cms2.els_fbrem()[index];
bool isEB = (cms2.els_fiduciality()[index] & (1<<ISEB));
bool isEE = (cms2.els_fiduciality()[index] & (1<<ISEE));
bool ecalDriven = (cms2.els_type()[index] & (1<<ISECALDRIVEN));
bool trackerDriven = (cms2.els_type()[index] & (1<<ISTRACKERDRIVEN));
int cat = -1;
//
// version V00 or V01
//
if (version == 0 || version == 1) {
if((isEB && fBrem<0.06) || (isEE && fBrem<0.1))
cat=1;
else if (eOverP < 1.2 && eOverP > 0.8)
cat=0;
else
cat=2;
return cat;
}
// version V02
if (version == 2) {
if (isEB) { // BARREL
if(fBrem < 0.12)
cat=1;
else if (eOverP < 1.2 && eOverP > 0.9)
cat=0;
else
cat=2;
} else { // ENDCAP
if(fBrem < 0.2)
cat=1;
else if (eOverP < 1.22 && eOverP > 0.82)
cat=0;
else
cat=2;
}
return cat;
}
//
// version V03, V04 or V05
// took this from V00-03-07-02 of
// ElectronIdentification/src/CutBasedElectronID.cc
// NOTE - DLE - now adding version 6
// this means newCategories is switched on
//
if (version == 3 || version == 4 || version == 5 || version == 6) {
// this is certainly true for V03 and V04
// not sure about V05
bool newCategories = false;
if (version == 6) newCategories = true;
if (isEB) {
if ((fBrem >= 0.12) && (eOverP > 0.9) && (eOverP < 1.2))
cat = 0;
else if (((eta > .445 && eta < .45 ) ||
(eta > .79 && eta < .81 ) ||
(eta > 1.137 && eta < 1.157 ) ||
(eta > 1.47285 && eta < 1.4744)) && newCategories)
cat = 6;
else if (trackerDriven && !ecalDriven && newCategories)
cat = 8;
else if (fBrem < 0.12)
cat = 1;
else
cat = 2;
} else {
if ((fBrem >= 0.2) && (eOverP > 0.82) && (eOverP < 1.22))
cat = 3;
else if (eta > 1.5 && eta < 1.58 && newCategories)
cat = 7;
else if (trackerDriven && !ecalDriven && newCategories)
cat = 8;
else if (fBrem < 0.2)
cat = 4;
else
cat = 5;
}
return cat;
}
return cat;
}
bool eidComputeCut(double x, double et, double cut_min, double cut_max, bool gtn)
{
float et_min = 10;
float et_max = 40;
bool accept = false;
float cut = cut_max; // the cut at et=40 GeV
if(et < et_max) {
cut = cut_min + (1/et_min - 1/et)*(cut_max - cut_min)/(1/et_min - 1/et_max);
}
if(et < et_min) {
cut = cut_min;
}
if(gtn) { // useful for e/p cut which is gt
accept = (x >= cut);
}
else {
accept = (x <= cut);
}
//std::cout << x << " " << cut_min << " " << cut << " " << cut_max << " " << et << " " << accept << std::endl;
return accept;
}
// WP2012
electronIdComponent_t electronId_WP2012(const unsigned int index, const wp2012_tightness tightness)
{
// set return value
unsigned int mask = 0;
// cut values
std::vector<double> dEtaInThresholds;
std::vector<double> dPhiInThresholds;
std::vector<double> sigmaIEtaIEtaThresholds;
std::vector<double> hoeThresholds;
std::vector<double> ooemoopThresholds;
std::vector<double> d0VtxThresholds;
std::vector<double> dzVtxThresholds;
std::vector<bool> vtxFitThresholds;
std::vector<int> mHitsThresholds;
std::vector<double> isoHiThresholds;
std::vector<double> isoLoThresholds;
// set cut values
eidGetWP2012(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds, sigmaIEtaIEtaThresholds,
ooemoopThresholds, d0VtxThresholds, dzVtxThresholds, vtxFitThresholds, mHitsThresholds,
isoHiThresholds, isoLoThresholds);
// useful kinematic variables
unsigned int det = ((cms2.els_fiduciality()[index] & (1<<ISEB)) == (1<<ISEB)) ? 0 : 1;
float etaAbs = fabs(cms2.els_etaSC()[index]);
float pt = cms2.els_p4()[index].pt();
// get effective area
float AEff = 0.;
if (etaAbs <= 1.0) AEff = 0.10;
else if (etaAbs > 1.0 && etaAbs <= 1.479) AEff = 0.12;
else if (etaAbs > 1.479 && etaAbs <= 2.0) AEff = 0.085;
else if (etaAbs > 2.0 && etaAbs <= 2.2) AEff = 0.11;
else if (etaAbs > 2.2 && etaAbs <= 2.3) AEff = 0.12;
else if (etaAbs > 2.3 && etaAbs <= 2.4) AEff = 0.12;
else if (etaAbs > 2.4) AEff = 0.13;
// pf iso
// calculate from the ntuple for now...
float pfiso_ch = cms2.els_iso03_pf2012_ch().at(index);
float pfiso_em = cms2.els_iso03_pf2012_em().at(index);
float pfiso_nh = cms2.els_iso03_pf2012_nh().at(index);
// rho
float rhoPrime = std::max(cms2.evt_kt6pf_foregiso_rho(), float(0.0));
float pfiso_n = std::max(pfiso_em + pfiso_nh - rhoPrime * AEff, float(0.0));
float pfiso = (pfiso_ch + pfiso_n) / pt;
// |1/E - 1/p|
float ooemoop = fabs( (1.0/cms2.els_ecalEnergy()[index]) - (cms2.els_eOverPIn()[index]/cms2.els_ecalEnergy()[index]) );
// MIT conversion vtx fit
bool vtxFitConversion = isMITConversion(index, 0, 1e-6, 2.0, true, false);
// d0
float d0vtx = electron_d0PV_smurfV3(index);
float dzvtx = electron_dzPV_smurfV3(index);
// test cuts
if (fabs(cms2.els_dEtaIn()[index]) < dEtaInThresholds[det]) mask |= wp2012::DETAIN;
if (fabs(cms2.els_dPhiIn()[index]) < dPhiInThresholds[det]) mask |= wp2012::DPHIIN;
if (cms2.els_sigmaIEtaIEta()[index] < sigmaIEtaIEtaThresholds[det]) mask |= wp2012::SIGMAIETAIETA;
if (cms2.els_hOverE()[index] < hoeThresholds[det]) mask |= wp2012::HOE;
if (ooemoop < ooemoopThresholds[det]) mask |= wp2012::OOEMOOP;
if (fabs(d0vtx) < d0VtxThresholds[det]) mask |= wp2012::D0VTX;
if (fabs(dzvtx) < dzVtxThresholds[det]) mask |= wp2012::DZVTX;
if (!vtxFitThresholds[det] || !vtxFitConversion) mask |= wp2012::VTXFIT;
if (cms2.els_exp_innerlayers()[index] <= mHitsThresholds[det]) mask |= wp2012::MHITS;
if (pt >= 20.0 && pfiso < isoHiThresholds[det]) mask |= wp2012::ISO;
if (pt < 20.0 && pfiso < isoLoThresholds[det]) mask |= wp2012::ISO;
// return the mask
return mask;
}
// WP2012: same as above function but with updated electron isolation branches, and calculate dz using GSF track and 1st good vertex
electronIdComponent_t electronId_WP2012_v2(const unsigned int index, const wp2012_tightness tightness, bool useOldIsolation)
{
// set return value
unsigned int mask = 0;
// cut values
std::vector<double> dEtaInThresholds;
std::vector<double> dPhiInThresholds;
std::vector<double> sigmaIEtaIEtaThresholds;
std::vector<double> hoeThresholds;
std::vector<double> ooemoopThresholds;
std::vector<double> d0VtxThresholds;
std::vector<double> dzVtxThresholds;
std::vector<bool> vtxFitThresholds;
std::vector<int> mHitsThresholds;
std::vector<double> isoHiThresholds;
std::vector<double> isoLoThresholds;
// set cut values
eidGetWP2012(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds, sigmaIEtaIEtaThresholds,
ooemoopThresholds, d0VtxThresholds, dzVtxThresholds, vtxFitThresholds, mHitsThresholds,
isoHiThresholds, isoLoThresholds);
// useful kinematic variables
unsigned int det = ((cms2.els_fiduciality()[index] & (1<<ISEB)) == (1<<ISEB)) ? 0 : 1;
float etaAbs = fabs(cms2.els_etaSC()[index]);
float pt = cms2.els_p4()[index].pt();
// get effective area
float AEff = 0.;
if (etaAbs <= 1.0) AEff = 0.10;
else if (etaAbs > 1.0 && etaAbs <= 1.479) AEff = 0.12;
else if (etaAbs > 1.479 && etaAbs <= 2.0) AEff = 0.085;
else if (etaAbs > 2.0 && etaAbs <= 2.2) AEff = 0.11;
else if (etaAbs > 2.2 && etaAbs <= 2.3) AEff = 0.12;
else if (etaAbs > 2.3 && etaAbs <= 2.4) AEff = 0.12;
else if (etaAbs > 2.4) AEff = 0.13;
// pf iso
// calculate from the ntuple for now...
float pfiso_ch = 0.0;
float pfiso_em = 0.0;
float pfiso_nh = 0.0;
if( useOldIsolation ){
pfiso_ch = cms2.els_iso03_pf2012_ch().at(index);
pfiso_em = cms2.els_iso03_pf2012_em().at(index);
pfiso_nh = cms2.els_iso03_pf2012_nh().at(index);
}
else{
pfiso_ch = cms2.els_iso03_pf2012ext_ch().at(index);
pfiso_em = cms2.els_iso03_pf2012ext_em().at(index);
pfiso_nh = cms2.els_iso03_pf2012ext_nh().at(index);
}
// rho
float rhoPrime = std::max(cms2.evt_kt6pf_foregiso_rho(), float(0.0));
float pfiso_n = std::max(pfiso_em + pfiso_nh - rhoPrime * AEff, float(0.0));
float pfiso = (pfiso_ch + pfiso_n) / pt;
// |1/E - 1/p|
float ooemoop = fabs( (1.0/cms2.els_ecalEnergy()[index]) - (cms2.els_eOverPIn()[index]/cms2.els_ecalEnergy()[index]) );
// MIT conversion vtx fit
bool vtxFitConversion = isMITConversion(index, 0, 1e-6, 2.0, true, false);
int elgsftkid = cms2.els_gsftrkidx().at(index);
int eltkid = cms2.els_trkidx().at(index);
int ivtx = firstGoodVertex();
// sanity check
if( elgsftkid < 0 ){
std::cout << __FILE__ << " " << __LINE__ << std::endl;
std::cout << "WARNING! found electron without valid GSF track index" << std::endl;
std::cout << cms2.evt_dataset().at(0) << " " << cms2.evt_run() << " " << cms2.evt_lumiBlock() << " " << cms2.evt_event() << std::endl;
std::cout << "Electron pT eta phi " << Form("%.1f %.1f %.1f",cms2.els_p4().at(index).pt(),cms2.els_p4().at(index).phi(),cms2.els_p4().at(index).eta()) << std::endl;
}
//take dz from gsf, and if it does not exist (should always exist) take it from ctf track
float dzvtx = 100.0;
float d0vtx = 100.0;
if( ivtx >= 0 ){
dzvtx = elgsftkid>=0 ? gsftrks_dz_pv( elgsftkid,ivtx ).first : trks_dz_pv(eltkid,ivtx).first;
d0vtx = elgsftkid>=0 ? gsftrks_d0_pv( elgsftkid,ivtx ).first : trks_d0_pv(eltkid,ivtx).first;
}
// test cuts
if (fabs(cms2.els_dEtaIn()[index]) < dEtaInThresholds[det]) mask |= wp2012::DETAIN;
if (fabs(cms2.els_dPhiIn()[index]) < dPhiInThresholds[det]) mask |= wp2012::DPHIIN;
if (cms2.els_sigmaIEtaIEta()[index] < sigmaIEtaIEtaThresholds[det]) mask |= wp2012::SIGMAIETAIETA;
if (cms2.els_hOverE()[index] < hoeThresholds[det]) mask |= wp2012::HOE;
if (ooemoop < ooemoopThresholds[det]) mask |= wp2012::OOEMOOP;
if (fabs(d0vtx) < d0VtxThresholds[det]) mask |= wp2012::D0VTX;
if (fabs(dzvtx) < dzVtxThresholds[det]) mask |= wp2012::DZVTX;
if (!vtxFitThresholds[det] || !vtxFitConversion) mask |= wp2012::VTXFIT;
if (cms2.els_exp_innerlayers()[index] <= mHitsThresholds[det]) mask |= wp2012::MHITS;
if (pt >= 20.0 && pfiso < isoHiThresholds[det]) mask |= wp2012::ISO;
if (pt < 20.0 && pfiso < isoLoThresholds[det]) mask |= wp2012::ISO;
// return the mask
return mask;
}
// WP2012_v3: same as above function WP2012_v2 but with effective areas updated according to:
// https://twiki.cern.ch/twiki/bin/viewauth/CMS/EgammaEARhoCorrection
electronIdComponent_t electronId_WP2012_v3(const unsigned int index, const wp2012_tightness tightness, bool useOldIsolation)
{
// set return value
unsigned int mask = 0;
// cut values
std::vector<double> dEtaInThresholds;
std::vector<double> dPhiInThresholds;
std::vector<double> sigmaIEtaIEtaThresholds;
std::vector<double> hoeThresholds;
std::vector<double> ooemoopThresholds;
std::vector<double> d0VtxThresholds;
std::vector<double> dzVtxThresholds;
std::vector<bool> vtxFitThresholds;
std::vector<int> mHitsThresholds;
std::vector<double> isoHiThresholds;
std::vector<double> isoLoThresholds;
// set cut values
eidGetWP2012(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds, sigmaIEtaIEtaThresholds,
ooemoopThresholds, d0VtxThresholds, dzVtxThresholds, vtxFitThresholds, mHitsThresholds,
isoHiThresholds, isoLoThresholds);
// useful kinematic variables
unsigned int det = ((cms2.els_fiduciality()[index] & (1<<ISEB)) == (1<<ISEB)) ? 0 : 1;
float etaAbs = fabs(cms2.els_etaSC()[index]);
float pt = cms2.els_p4()[index].pt();
// get effective area
float AEff = 0.;
if (etaAbs <= 1.0 ) AEff = 0.13;
else if (etaAbs > 1.0 && etaAbs <= 1.479) AEff = 0.14;
else if (etaAbs > 1.479 && etaAbs <= 2.0 ) AEff = 0.07;
else if (etaAbs > 2.0 && etaAbs <= 2.2 ) AEff = 0.09;
else if (etaAbs > 2.2 && etaAbs <= 2.3 ) AEff = 0.11;
else if (etaAbs > 2.3 && etaAbs <= 2.4 ) AEff = 0.11;
else if (etaAbs > 2.4 ) AEff = 0.14;
// pf iso
// calculate from the ntuple for now...
float pfiso_ch = 0.0;
float pfiso_em = 0.0;
float pfiso_nh = 0.0;
if( useOldIsolation ){
pfiso_ch = cms2.els_iso03_pf2012_ch().at(index);
pfiso_em = cms2.els_iso03_pf2012_em().at(index);
pfiso_nh = cms2.els_iso03_pf2012_nh().at(index);
}
else{
pfiso_ch = cms2.els_iso03_pf2012ext_ch().at(index);
pfiso_em = cms2.els_iso03_pf2012ext_em().at(index);
pfiso_nh = cms2.els_iso03_pf2012ext_nh().at(index);
}
// rho
float rhoPrime = std::max(cms2.evt_kt6pf_foregiso_rho(), float(0.0));
float pfiso_n = std::max(pfiso_em + pfiso_nh - rhoPrime * AEff, float(0.0));
float pfiso = (pfiso_ch + pfiso_n) / pt;
// |1/E - 1/p|
float ooemoop = fabs( (1.0/cms2.els_ecalEnergy()[index]) - (cms2.els_eOverPIn()[index]/cms2.els_ecalEnergy()[index]) );
// MIT conversion vtx fit
bool vtxFitConversion = isMITConversion(index, 0, 1e-6, 2.0, true, false);
int elgsftkid = cms2.els_gsftrkidx().at(index);
int eltkid = cms2.els_trkidx().at(index);
int ivtx = firstGoodVertex();
// sanity check
if( elgsftkid < 0 ){
std::cout << __FILE__ << " " << __LINE__ << std::endl;
std::cout << "WARNING! found electron without valid GSF track index" << std::endl;
std::cout << cms2.evt_dataset().at(0) << " " << cms2.evt_run() << " " << cms2.evt_lumiBlock() << " " << cms2.evt_event() << std::endl;
std::cout << "Electron pT eta phi " << Form("%.1f %.1f %.1f",cms2.els_p4().at(index).pt(),cms2.els_p4().at(index).phi(),cms2.els_p4().at(index).eta()) << std::endl;
}
//take dz from gsf, and if it does not exist (should always exist) take it from ctf track
float dzvtx = 100.0;