-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDPAnalysis.cc
More file actions
2533 lines (2066 loc) · 106 KB
/
DPAnalysis.cc
File metadata and controls
2533 lines (2066 loc) · 106 KB
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
// -*- C++ -*-
// Package: DPAnalysis
// Class: DPAnalysis
//
/**\class DPAnalysis DPAnalysis.cc EXO/DPAnalysis/src/DPAnalysis.cc
Description: [one line class summary]
Implementation:
[Notes on implementation]
*/
//
// Original Author: Shih-Chuan Kao
// Created: Sat Oct 8 06:50:16 CDT 2011
// Second Author: Tambe E. Norbert
//$Id$
//
//
// system include files
#include "DPAnalysis.h"
#include "Ntuple.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/CSCGeometry/interface/CSCChamber.h"
#include "DataFormats/CSCRecHit/interface/CSCSegment.h"
// For DT Segment
#include "Geometry/DTGeometry/interface/DTChamber.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
// For PFIsolation
#include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
#include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
#include "DataFormats/PatCandidates/interface/Isolation.h"
// global tracking geometry
//#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
//#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
using namespace cms ;
using namespace edm ;
using namespace std ;
//static bool HtDecreasing( VtxInfo s1, VtxInfo s2) { return ( s1.ht > s2.ht ); }
//static bool ZDecreasing( VtxInfo s1, VtxInfo s2) { return ( s1.z > s2.z ); }
//static bool Z0Decreasing( TrkInfo s1, TrkInfo s2) { return ( s1.dz > s2.dz ); }
// constants, enums and typedefs
// static data member definitions
// constructors and destructor
DPAnalysis::DPAnalysis(const edm::ParameterSet& iConfig){
//now do what ever initialization is needed
rootFileName = iConfig.getUntrackedParameter<string> ("rootFileName");
trigSource = iConfig.getParameter<edm::InputTag> ("trigSource");
l1GTSource = iConfig.getParameter<string> ("L1GTSource");
pvSource = iConfig.getParameter<edm::InputTag> ("pvSource");
beamSpotSource = iConfig.getParameter<edm::InputTag> ("beamSpotSource");
muonSource = iConfig.getParameter<edm::InputTag> ("muonSource");
electronSource = iConfig.getParameter<edm::InputTag> ("electronSource");
photonSource = iConfig.getParameter<edm::InputTag> ("photonSource");
metSource = iConfig.getParameter<edm::InputTag> ("metSource");
type1metSource = iConfig.getParameter<edm::InputTag> ("type1metSource");
jetSource = iConfig.getParameter<edm::InputTag> ("jetSource");
patJetSource = iConfig.getParameter<edm::InputTag> ("patJetSource");
trackSource = iConfig.getParameter<edm::InputTag> ("trackSource");
EBRecHitCollection = iConfig.getParameter<edm::InputTag> ("EBRecHitCollection") ;
EERecHitCollection = iConfig.getParameter<edm::InputTag> ("EERecHitCollection") ;
DTSegmentTag = iConfig.getParameter<edm::InputTag> ("DTSegmentCollection") ;
CSCSegmentTag = iConfig.getParameter<edm::InputTag> ("CSCSegmentCollection") ;
cscHaloTag = iConfig.getParameter<edm::InputTag> ("cscHaloData");
staMuons = iConfig.getParameter<edm::InputTag> ("staMuons");
theBarrelSuperClusterCollection_ = iConfig.getParameter<edm::InputTag> ("BarrelSuperClusterCollection") ;
theEndcapSuperClusterCollection_ = iConfig.getParameter<edm::InputTag> ("EndcapSuperClusterCollection") ;
//pileupSource = iConfig.getParameter<edm::InputTag>("addPileupInfo");
vtxCuts = iConfig.getParameter<std::vector<double> >("vtxCuts");
jetCuts = iConfig.getParameter<std::vector<double> >("jetCuts");
metCuts = iConfig.getParameter<std::vector<double> >("metCuts");
photonCuts = iConfig.getParameter<std::vector<double> >("photonCuts");
photonIso = iConfig.getParameter<std::vector<double> >("photonIso");
electronCuts = iConfig.getParameter<std::vector<double> >("electronCuts");
muonCuts = iConfig.getParameter<std::vector<double> >("muonCuts");
//triggerPatent = iConfig.getUntrackedParameter<string> ("triggerName");
triggerPatent = iConfig.getParameter< std::vector<string> >("triggerName");
L1Select = iConfig.getParameter<bool> ("L1Select");
isData = iConfig.getParameter<bool> ("isData");
tau = iConfig.getParameter<double> ("tau");
const InputTag TrigEvtTag("hltTriggerSummaryAOD","","HLT");
trigEvent = iConfig.getUntrackedParameter<edm::InputTag>("triggerEventTag", TrigEvtTag);
gen = new GenStudy( iConfig );
theFile = new TFile( rootFileName.c_str(), "RECREATE") ;
theFile->cd () ;
theTree = new TTree ( "DPAnalysis","DPAnalysis" ) ;
setBranches( theTree, leaves ) ;
CutFlowTree = new TTree( "CutFlow", "CutFlow") ;
CutFlowTree->Branch("counter", counter, "counter[12]/I");
h_z0 = new TH1D("h_z0", " z0 for tracks", 121, -181.5, 181.5 ) ;
targetTrig = 0 ;
firedTrig.clear() ;
for ( size_t i=0; i< triggerPatent.size(); i++ ) firedTrig.push_back(-1) ;
// reset the counter
for ( int i=0; i< 12 ; i++) counter[i] = 0 ;
runID_ = 0 ;
debugT = false ;
rhoIso = 0 ;
beamspot = 0 ;
// PF isolation for photon
isolator.initializePhotonIsolation(kTRUE);
isolator.setConeSize(0.3);
}
DPAnalysis::~DPAnalysis()
{
// do anything here that needs to be done at desctruction time
delete gen ;
cout<<"All:"<< counter[0]<<" Trigger:"<<counter[1]<<" Vertex:"<< counter[2] ;
cout<<" Fiducial: "<< counter[3]<<" Conversion: "<< counter[4]<<" sMaj_sMin: "<< counter[5]<<" dR(g,trk):"<< counter[6] ;
cout<<" LeadingPt:"<<counter[7] ;
cout<<" beamHalo:"<< counter[8] <<" Jet:"<< counter[9] <<" MET:"<<counter[10] <<" Pre-Selection:"<<counter[11] <<endl ;
CutFlowTree->Fill() ;
theFile->cd () ;
theTree->Write() ;
CutFlowTree->Write() ;
h_z0->Write() ;
// theFile->Write() ;
theFile->Close() ;
}
//
// member functions
//
// ------------ method called for each event ------------
void DPAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
// get calibration service
// IC's
iSetup.get<EcalIntercalibConstantsRcd>().get(ical);
// ADCtoGeV
iSetup.get<EcalADCToGeVConstantRcd>().get(agc);
// transp corrections
iSetup.get<EcalLaserDbRecord>().get(laser);
// Geometry
//iSetup.get<CaloGeometryRecord> ().get (pGeometry) ;
//theGeometry = pGeometry.product() ;
// event time
eventTime = iEvent.time() ;
// Initialize ntuple branches
initializeBranches( theTree, leaves );
leaves.bx = iEvent.bunchCrossing();
leaves.lumiSection = iEvent.id().luminosityBlock();
leaves.orbit = iEvent.orbitNumber();
leaves.runId = iEvent.id().run() ;
leaves.eventId = iEvent.id().event() ;
/*
Handle<std::vector< PileupSummaryInfo > > PileUpInfo;
iEvent.getByLabel(pileupSource, PupInfo);
for( std::vector<PileupSummaryInfo>::const_iterator PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
std::cout << " Pileup Information: bunchXing, nvtx: " << PVI->getBunchCrossing() << " " << PVI->getPU_NumInteractions() << std::endl;
}
*/
// For conversion veto
iEvent.getByLabel( beamSpotSource, bsHandle);
beamspot = bsHandle.product();
iEvent.getByLabel("allConversions", hConversions);
iEvent.getByLabel( electronSource, electrons);
// For PFIso
iEvent.getByLabel( "kt6PFJets", "rho", rho_ );
rhoIso = *(rho_.product());
// Get the JES Uncertainty
edm::ESHandle<JetCorrectorParametersCollection> JetCorParColl;
iSetup.get<JetCorrectionsRecord>().get("AK5PFchs",JetCorParColl);
JetCorrectorParameters const & JetCorPar = (*JetCorParColl)["Uncertainty"];
jecUnc = new JetCorrectionUncertainty(JetCorPar);
if (counter[0] == 0 ) PrintTriggers( iEvent ) ;
int run_id = iEvent.id().run() ;
// Global Tracking Geometry
//ESHandle<GlobalTrackingGeometry> trackingGeometry;
//iSetup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
counter[0]++ ; // All events
// L1 Trigger Selection
passL1 = L1TriggerSelection( iEvent, iSetup ) ;
// HLT trigger analysis
Handle<edm::TriggerResults> triggers;
iEvent.getByLabel( trigSource, triggers );
const edm::TriggerNames& trgNameList = iEvent.triggerNames( *triggers ) ;
TriggerTagging( triggers, trgNameList, run_id, firedTrig ) ;
passHLT = TriggerSelection( triggers, firedTrig ) ;
// Using L1 or HLT to select events ?!
bool passTrigger = ( L1Select ) ? passL1 : passHLT ;
if ( passTrigger ) counter[1]++ ; // Pass trigger cut
// get the generator information
if ( !isData && tau > -0.1 ) {
gen->GetGenEvent( iEvent, leaves, true );
//gen->GetGen( iEvent, leaves );
}
//if ( !isData ) gen->PrintGenEvent( iEvent );
bool pass = EventSelection( iEvent, iSetup ) ;
if ( pass && passTrigger ) counter[11]++ ;
// fill the ntuple
if ( pass && !isData ) theTree->Fill();
if ( pass && isData && passTrigger ) theTree->Fill();
delete jecUnc ;
}
bool DPAnalysis::EventSelection(const edm::Event& iEvent, const edm::EventSetup& iSetup ) {
Handle<reco::BeamHaloSummary> beamHaloSummary ;
Handle<edm::TriggerResults> triggers;
Handle<reco::VertexCollection> recVtxs;
Handle<reco::PhotonCollection> photons;
//Handle<reco::GsfElectronCollection> electrons;
Handle<reco::MuonCollection> muons;
Handle<reco::PFJetCollection> jets;
Handle<std::vector<pat::Jet> > patjets;
Handle<reco::PFMETCollection> met0;
Handle<reco::PFMETCollection> met;
Handle<EcalRecHitCollection> recHitsEB ;
Handle<EcalRecHitCollection> recHitsEE ;
Handle<reco::TrackCollection> tracks;
Handle<reco::PFCandidateCollection> pfCand ;
edm::Handle<reco::SuperClusterCollection> theBarrelSuperClusters ;
edm::Handle<reco::SuperClusterCollection> theEndcapSuperClusters ;
iEvent.getByLabel( trigSource, triggers );
iEvent.getByLabel( pvSource, recVtxs );
iEvent.getByLabel( photonSource, photons );
//iEvent.getByLabel( electronSource, electrons);
iEvent.getByLabel( muonSource, muons );
iEvent.getByLabel( jetSource, jets );
iEvent.getByLabel( patJetSource, patjets);
iEvent.getByLabel( metSource, met0 );
iEvent.getByLabel( type1metSource, met );
iEvent.getByLabel( EBRecHitCollection, recHitsEB );
iEvent.getByLabel( EERecHitCollection, recHitsEE );
iEvent.getByLabel("BeamHaloSummary", beamHaloSummary) ;
iEvent.getByLabel( trackSource, tracks );
iEvent.getByLabel( "particleFlow", pfCand ) ;
iEvent.getByLabel( theBarrelSuperClusterCollection_, theBarrelSuperClusters ) ;
iEvent.getByLabel( theEndcapSuperClusterCollection_, theEndcapSuperClusters ) ;
bool passEvent = true ;
lazyTools = new EcalClusterLazyTools( iEvent, iSetup, EBRecHitCollection, EERecHitCollection );
// find trigger matched objects
//cout<<" ~~~~~~~~~~~~~~~~~ "<<endl ;
const reco::Photon rPho ;
GetTrgMatchObject( rPho , iEvent, photonSource ) ;
//cout<<" ----------------- "<<endl ;
const reco::PFMET pfMet_ = (*met)[0] ;
GetTrgMatchObject( pfMet_, iEvent, metSource ) ;
//cout<<" ================= "<<endl ;
//cout<<" "<<endl ;
Track_Z0( tracks ) ;
bool hasGoodVtx = VertexSelection( recVtxs );
if ( !hasGoodVtx ) passEvent = false ;
if ( passEvent ) counter[2]++ ; // pass vertex cuts
selectedPhotons.clear() ;
PhotonSelection( photons, recHitsEB, recHitsEE, tracks, selectedPhotons ) ;
// Check event flow with photon cuts
if ( passEvent ) {
if ( gcounter[2] > 0 ) counter[3]++ ; // pt & fiducial
if ( gcounter[3] > 0 ) counter[4]++ ; // conversion
if ( gcounter[5] > 0 ) counter[5]++ ; // sMaj & sMin
if ( gcounter[6] > 0 ) counter[6]++ ; // dR(phot, track)
}
if ( selectedPhotons.size() < (size_t)photonCuts[6] ) passEvent = false ;
if ( passEvent ) counter[7]++ ; // pass photon cuts
// Stupid PFIso
if ( passEvent ) {
reco::VertexRef vtxRef(recVtxs, 0);
PhotonPFIso( selectedPhotons, &(*pfCand), vtxRef, recVtxs ) ;
}
if( beamHaloSummary.isValid() ) {
const reco::BeamHaloSummary TheSummary = (*beamHaloSummary.product() );
if( !TheSummary.CSCTightHaloId() && passEvent ) {
counter[8]++ ;
} else {
passEvent = false ;
}
} else {
counter[8]++ ;
}
CSCHaloCleaning( iEvent, selectedPhotons ) ;
// for cscsegments and halo muon/photon studies
Handle<CSCSegmentCollection> cscSegments ;
iEvent.getByLabel( CSCSegmentTag, cscSegments );
BeamHaloMatch( cscSegments, selectedPhotons, iSetup ) ;
Handle<DTRecSegment4DCollection> dtSegments ;
iEvent.getByLabel( DTSegmentTag, dtSegments );
CosmicRayMatch( dtSegments, selectedPhotons, iSetup ) ;
//CosmicRayMatch( muons, selectedPhotons ) ;
//Handle< edm::OwnVector<TrackingRecHit> > mu_rhits ;
//iEvent.getByLabel( staMuons, mu_rhits );
//bool haloMuon = BeamHaloMatch( *(mu_rhits.product()), selectedPhotons, iSetup ) ;
//IsoPhotonSelection( selectedPhotons ) ;
//if ( selectedPhotons.size() < photonCuts[5] ) passEvent = false ;
selectedJets_.clear() ; // if using pat_Jet
selectedJets.clear() ; // if using PFJet
JetSelection( patjets, selectedPhotons, selectedJets_ ) ; // if pat_Jet use
// Is designed to use reco::PFJ
/* JetSelectionWithTimingInfo( patjets, recHitsEB, recHitsEE, selectedJets_, selectedPhotons );
JetSelectionWithTimingInfo( jets, recHitsEB, recHitsEE, selectedJets, selectedPhotons ) ;
*/
MatchSuperClusterToJet( iEvent, iSetup, jets, theBarrelSuperClusters, theEndcapSuperClusters, lazyTools, recHitsEB, recHitsEE, selectedJets, selectedPhotons ) ;
//bool isGammaJets = GammaJetVeto( selectedPhotons, selectedJets ) ;
//if ( isGammaJets ) passEvent = false ;
// if ( selectedJets.size() < jetCuts[3] ) passEvent = false ;
if ( selectedJets_.size() < jetCuts[3] ) passEvent = false ;
if ( passEvent ) counter[9]++ ;
//JERUncertainty( patjets ) ;
selectedElectrons.clear() ;
ElectronSelection( electrons, selectedElectrons ) ;
selectedMuons.clear() ;
MuonSelection( muons, selectedMuons );
//HLTMET( jets, selectedMuons );
const reco::PFMET pfMet0 = (*met0)[0] ;
leaves.met0 = pfMet0.et() ;
leaves.met0Px = pfMet0.px() ;
leaves.met0Py = pfMet0.py() ;
const reco::PFMET pfMet = (*met)[0] ;
leaves.met = pfMet.et() ;
leaves.metPx = pfMet.px() ;
leaves.metPy = pfMet.py() ;
if ( pfMet.pt() < metCuts[0] ) passEvent = false;
if ( passEvent ) counter[10]++ ;
return passEvent ;
}
bool DPAnalysis::L1TriggerSelection( const edm::Event& iEvent, const edm::EventSetup& iSetup ) {
// Get L1 Trigger menu
ESHandle<L1GtTriggerMenu> menuRcd;
iSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
const L1GtTriggerMenu* menu = menuRcd.product();
// Get L1 Trigger record
Handle< L1GlobalTriggerReadoutRecord > gtRecord;
iEvent.getByLabel( edm::InputTag("gtDigis"), gtRecord);
// Get dWord after masking disabled bits
const DecisionWord dWord = gtRecord->decisionWord();
bool l1_accepted = menu->gtAlgorithmResult( l1GTSource , dWord);
//int passL1 = ( l1SingleEG22 ) ? 1 : 0 ;
//cout<<" pass L1 EG22 ? "<< passL1 <<endl ;
if ( l1_accepted ) leaves.L1a = 1 ;
return l1_accepted ;
}
void DPAnalysis::CSCHaloCleaning( const edm::Event& iEvent, vector<const reco::Photon*>& selectedPhotons ) {
Handle<reco::CSCHaloData> cschalo;
iEvent.getByLabel( cscHaloTag, cschalo );
if ( cschalo.isValid() ) {
const reco::CSCHaloData cscData = *(cschalo.product()) ;
int nOutTimeHits = cscData.NumberOfOutTimeHits() ;
int nMinusHTrks = cscData.NHaloTracks( reco::HaloData::minus ) ;
int nPlusHTrks = cscData.NHaloTracks( reco::HaloData::plus ) ;
//int nTrksSmallBeta = cscData.NTracksSmallBeta() ;
//int nHaloSegs = cscData.NFlatHaloSegments() ;
//cout<<" nOutT: "<< nOutTimeHits <<" nTrkBeta:"<< nTrksSmallBeta <<" nHaloSeg: "<< nHaloSegs ;
//cout<<" N Minus tracks : "<< nMinusHTrks <<" N Plus tracks : "<< nPlusHTrks << endl ;
RefVector< reco::TrackCollection > trkRef = cscData.GetTracks() ;
//cout<<" NTrkRefs = "<< trkRef.size() << endl ;
/*
// the first track is closed to the ImpactPosition
for( RefVector< reco::TrackCollection >::const_iterator it = trkRef.begin(); it != trkRef.end() ; ++it ) {
const vector<reco::Track>* trks = it->product() ;
for ( size_t j=0; j< trks->size(); j++ ) {
if ( ! (*trks)[j].innerOk() ) continue ;
math::XYZPoint tXYZ = (*trks)[j].innerPosition() ;
cout<<" --> ( "<< tXYZ.Phi() <<", " << tXYZ.Rho() <<", " << tXYZ.Z() <<") "<<endl ;
}
}
*/
leaves.nOutTimeHits = nOutTimeHits ;
leaves.nHaloTrack = nMinusHTrks + nPlusHTrks ;
//std::vector<GlobalPoint> gp = cscData.GetCSCTrackImpactPositions() ;
//cout<<" impact gp sz : "<< gp.size() <<" photon sz:"<< selectedPhotons.size() << endl ;
//for (vector<GlobalPoint>::const_iterator it = gp.begin(); it != gp.end() ; ++it ) {
// double rho = sqrt( (it->x()*it->x()) + (it->y()*it->y()) );
//cout<<" ==> phi:"<< it->phi() <<" rho: "<< rho << " z: "<< it->z() <<endl ;
// leaves.haloPhi = it->phi() ;
// leaves.haloRho = rho ;
/*
for ( size_t i=0; i< selectedPhotons.size() ; i++ ) {
double dPhi = fabs( selectedPhotons[i]->phi() - it->phi() ) ;
double rhoG = sqrt( ( selectedPhotons[i]->p4().x()*selectedPhotons[i]->p4().x() )
+ ( selectedPhotons[i]->p4().y()*selectedPhotons[i]->p4().y() ) );
double dRho = fabs( rho - rhoG ) ;
cout<<" ("<< i << ") ==> dPhi : "<< dPhi <<" dRho : "<< dRho << endl ;
}
*/
//}
}
}
void DPAnalysis::TriggerTagging( Handle<edm::TriggerResults> triggers, const edm::TriggerNames& trgNameList, int RunId, vector<int>& firedTrig ) {
if ( runID_ != RunId ) {
for (size_t j=0; j< triggerPatent.size(); j++ ) firedTrig[j] = -1;
// loop through trigger menu
for ( size_t i =0 ; i < trgNameList.size(); i++ ) {
string tName = trgNameList.triggerName( i );
// loop through desired triggers
for ( size_t j=0; j< triggerPatent.size(); j++ ) {
if ( strncmp( tName.c_str(), triggerPatent[j].c_str(), triggerPatent[j].size() ) ==0 ) {
firedTrig[j] = i;
//cout<<" Trigger Found ("<<j <<"): "<<tName ;
//cout<<" Idx: "<< i <<" triggers "<<endl;
}
}
}
runID_ = RunId ;
}
}
// current used method
bool DPAnalysis::TriggerSelection( Handle<edm::TriggerResults> triggers, vector<int> firedTrigID ) {
bool pass =false ;
uint32_t trgbits = 0 ;
for ( size_t i=0; i< firedTrigID.size(); i++ ) {
if ( firedTrigID[i] == -1 ) continue ;
if ( triggers->accept( firedTrigID[i] ) == 1 ) trgbits |= ( 1 << i ) ;
//`cout<<" ("<< i <<") Trigger Found : "<< firedTrigID[i] <<" pass ? "<< triggers->accept( firedTrigID[i] ) <<" trigbit = "<< trgbits << endl;
}
if ( trgbits != 0 ) {
pass = true ;
}
leaves.triggered = (int)(trgbits) ;
targetTrig = (int)(trgbits) ;
return pass ;
}
template<class object >
bool DPAnalysis::GetTrgMatchObject( object, const edm::Event& iEvent, InputTag inputProducer_ ) {
bool findMatch = false ;
// Get the input collection
Handle<edm::View<object> > candHandle;
iEvent.getByLabel( inputProducer_ , candHandle);
Handle<trigger::TriggerEvent> trgEvent;
iEvent.getByLabel( trigEvent, trgEvent);
// get trigger object
const trigger::TriggerObjectCollection& TOC( trgEvent->getObjects() );
// find how many objects there are
unsigned int nobj=0;
double mindR = 999. ;
double minP4[5] = { 0, 0, 0, 0, 0 } ;
bool testPho = false ;
bool testMET = false ;
for( typename edm::View< object>::const_iterator j = candHandle->begin(); j != candHandle->end(); ++j, ++nobj) {
// find out what filter is
//cout<<" trg : "<< inputProducer_.label() <<" filter sz: "<< trgEvent->sizeFilters() <<" nObj:"<< nobj << endl;
for ( size_t ia = 0; ia < trgEvent->sizeFilters(); ++ia ) {
// get the hlt filter
string fullname = trgEvent->filterTag(ia).encode();
size_t p = fullname.find_first_of(':');
string filterName = ( p != std::string::npos) ? fullname.substr(0, p) : fullname ;
//cout<<" ... filterName : " << fullname <<" ==> "<< filterName << endl ;
bool trigPhoton = false ;
bool trigPfMet = false ;
if ( strncmp( filterName.c_str(), "hltPhoton65CaloIdVLIsoLTrackIsoFilter", filterName.size() ) ==0 ) trigPhoton = true ;
if ( strncmp( filterName.c_str(), "hltPFMET25", filterName.size() ) ==0 ) trigPfMet = true ;
if ( strncmp( filterName.c_str(), "hltPFMET25Filter", filterName.size() ) ==0 ) trigPfMet = true ;
testPho = ( strncmp( inputProducer_.label().c_str(), "myphotons", 9 ) == 0 ) ;
testMET = ( strncmp( inputProducer_.label().c_str(), "pfMet", 5 ) == 0 ) ;
if ( !trigPhoton && !trigPfMet ) continue ;
if ( trigPhoton && !testPho ) continue ;
if ( trigPfMet && !testMET ) continue ;
//if ( trigPhoton ) cout<<" Photon filter name: "<< filterName ;
//if ( trigPfMet ) cout<<" PfMet filter name: "<< filterName ;
// Get cut decision for each candidate
const trigger::Keys& KEYS( trgEvent->filterKeys( ia ) );
int nKey = (int) KEYS.size() ;
//cout<<" nKey : "<< nKey << endl ;
for (int ipart = 0; ipart != nKey; ++ipart) {
const trigger::TriggerObject& TO = TOC[KEYS[ipart]];
double dRval = deltaR( j->eta(), j->phi(), TO.eta(), TO.phi() );
//cout<<" Reco pt:"<< j->pt() <<" TO pt: "<< TO.pt() <<endl ;
//cout<<" -- > dR = " << dRval <<endl ;
if ( dRval < mindR ) {
mindR = dRval ;
minP4[0] = TO.px() ;
minP4[1] = TO.py() ;
minP4[2] = TO.pz() ;
minP4[3] = TO.energy() ;
minP4[4] = TO.pt() ;
}
}
}
}
if ( mindR < 0.5 ) findMatch = true ;
if ( mindR < 9. && testMET ) {
leaves.t_metPx = minP4[0] ;
leaves.t_metPy = minP4[1] ;
leaves.t_met = minP4[4] ;
leaves.t_metdR = mindR ;
//if ( mindR < 0.5 ) cout<<" ** GOT MET => "<< minP4[4] << endl ;
}
if ( mindR < 9. && testPho ) {
leaves.t_phoPx = minP4[0] ;
leaves.t_phoPy = minP4[1] ;
leaves.t_phoPz = minP4[2] ;
leaves.t_phoE = minP4[3] ;
leaves.t_phodR = mindR ;
//if ( mindR < 0.5 ) cout<<" ** GOT Photon => "<< minP4[4] << endl ;
}
return findMatch ;
}
void DPAnalysis::PrintTriggers( const edm::Event& iEvent ) {
Handle<edm::TriggerResults> triggers;
iEvent.getByLabel( trigSource, triggers );
cout<<" ** Trigger size = "<< triggers->size() <<endl;
const edm::TriggerNames& trgNames = iEvent.triggerNames( *triggers );
for ( size_t i =0 ; i < trgNames.size(); i++ ) {
string tName = trgNames.triggerName( i );
int trgIndex = trgNames.triggerIndex(tName);
int trgResult = triggers->accept(trgIndex);
cout<<" name: "<< tName <<" ("<< i <<") idx:"<< trgIndex <<" accept:"<< trgResult <<endl;
for ( size_t j=0; j< triggerPatent.size(); j++) {
if ( strncmp( tName.c_str(), triggerPatent[j].c_str(), triggerPatent[j].size() ) ==0 ) {
//TriggerName = tName ;
cout<<" Trigger Found : "<< tName <<" accepted ? "<< triggers->accept(i) <<endl;
}
}
//string triggered = triggers->accept(i) ? "Yes" : "No" ;
//cout<<" path("<<i<<") accepted ? "<< triggered ;
}
}
void DPAnalysis::Track_Z0( Handle<reco::TrackCollection> tracks ) {
//vector<TrkInfo> trkColl ;
double in_trk = 0 ;
double out_trk = 0 ;
for (reco::TrackCollection::const_iterator it = tracks->begin(); it != tracks->end(); it++ ) {
if ( fabs(it->d0()) >= vtxCuts[2] ) continue ;
/*
TrkInfo tf ;
tf.dz = it->dz() ;
tf.dsz = it->dsz() ;
tf.d0 = it->d0() ;
tf.pt = it->pt() ;
tf.vz = it->vz() ;
tf.vr = sqrt( (it->vx()*it->vx()) + (it->vy()*it->vy()) ) ;
trkColl.push_back(tf) ;
*/
h_z0->Fill( it->dz() ) ;
if ( fabs( it->dz() ) < 20. ) in_trk += 1. ;
else out_trk += 1. ;
/*
int ibin = (int)( (it->dz() + 155. ) / 10.) + 1;
if ( it->dz() < -155. ) ibin = 0 ;
if ( it->dz() > 155. ) ibin = 32 ;
leaves.nTrkZ0[ ibin ] += 1 ;
*/
}
leaves.z0Ratio = ( in_trk > 0. ) ? (out_trk / in_trk) : -1 ;
/*
sort( trkColl.begin(), trkColl.end(), Z0Decreasing ) ;
//printf("=============================== \n") ;
vector<TrkInfo> selTrk ;
double ddz = 99. ;
for (size_t i=0 ; i < trkColl.size() ; i++) {
//printf( "= dZ = %f , dsz: %f, d0: %f, pt: %f ", trkColl[i].dz , trkColl[i].dsz, trkColl[i].d0, trkColl[i].pt ) ;
//printf( " v_z: %f , v_r: %f ", trkColl[i].vz , trkColl[i].vr ) ;
ddz = ( i > 0 ) ? fabs( trkColl[i].dz - selTrk[ selTrk.size() -1 ].dz ) : 99. ;
if ( ddz > 1. ) {
selTrk.push_back( trkColl[i] ) ;
//printf(" -- add \n") ;
} else {
if ( trkColl[i].pt > selTrk[ selTrk.size() -1 ].pt ) {
//printf(" \n") ;
//printf(" => delete track : dZ: %f, pt: %f \n", selTrk[ selTrk.size()-1].dz , selTrk[ selTrk.size()-1].pt ) ;
selTrk.erase( selTrk.end() - 1 );
selTrk.push_back( trkColl[i] ) ;
//printf(" => add track : dZ: %f, pt: %f \n", selTrk[ selTrk.size()-1].dz , selTrk[ selTrk.size()-1].pt ) ;
} else {
//printf(" -- skip \n") ;
}
}
}
printf(" ----------------- \n") ;
for (size_t i=0 ; i < selTrk.size() ; i++) {
printf( "* dZ = %f , dsz: %f, d0: %f, pt: %f \n", selTrk[i].dz , selTrk[i].dsz, selTrk[i].d0, selTrk[i].pt ) ;
}
*/
}
bool DPAnalysis::VertexSelection( Handle<reco::VertexCollection> vtx ) {
bool hasGoodVertex = true ;
int totalN_vtx = 0 ;
int i = 0 ;
for (reco::VertexCollection::const_iterator v=vtx->begin(); v!=vtx->end() ; v++){
if ( ! v->isValid() || v->isFake() ) continue ;
//printf("@@ N of trk: %d , ndof: %.1f", (int)v->tracksSize(), v->ndof() ) ;
int ntrk = 0;
//double ht = 0 ;
for (reco::Vertex::trackRef_iterator itrk = v->tracks_begin(); itrk != v->tracks_end(); ++itrk) {
double d0 = (*itrk)->d0() ;
//double z0 = (*itrk)->dz() ;
//double sz = (*itrk)->dsz() ;
//printf("* d0: %f , z0: %f , sz: %f \n", d0, z0 , sz ) ;
if ( d0 >= vtxCuts[2] ) continue ;
//ht += (*itrk)->pt() ;
ntrk++ ;
}
//printf(" N of trk: %d , ht: %f, vtx_z: %f \n", ntrk, ht, v->z() ) ;
//if ( fabs(v->z()) >= vtxCuts[0] ) continue ;
if ( v->ndof() < vtxCuts[1] ) continue ;
// counting real number of vertices
totalN_vtx++ ;
if ( i >= MAXVTX ) continue ;
leaves.vtxNTracks[i] = ntrk ;
leaves.vtxChi2[i] = v->normalizedChi2() ;
leaves.vtxNdof[i] = v->ndof() ;
leaves.vtxRho[i] = sqrt( ( v->y()*v->y() ) + ( v->x()*v->x() ) );
leaves.vtxZ[i] = v->z() ;
i++ ;
}
leaves.nVertices = i ;
leaves.totalNVtx = totalN_vtx ;
if ( i < 1 ) hasGoodVertex = false ;
return hasGoodVertex ;
}
bool DPAnalysis::PhotonSelection( Handle<reco::PhotonCollection> photons, Handle<EcalRecHitCollection> recHitsEB, Handle<EcalRecHitCollection> recHitsEE, Handle<reco::TrackCollection> tracks, vector<const reco::Photon*>& selectedPhotons ) {
for ( int i=0; i<7; i++) gcounter[i] = 0 ;
int k= 0 ;
double maxPt = 0 ;
double met_dx(0), met_dy(0) ;
for(reco::PhotonCollection::const_iterator it = photons->begin(); it != photons->end(); it++) {
// calculate met uncertainty
if ( it->pt() < 10. ) continue ;
met_dx += it->px() ;
met_dy += it->py() ;
//double ptscale = ( it->isEB() ) ? 0.994 : 0.985;
double ptscale = ( it->isEB() ) ? 1.006 : 1.015 ;
met_dx -= ( it->px() * ptscale ) ;
met_dy -= ( it->py() * ptscale ) ;
gcounter[0]++ ;
// fiducial cuts
if ( k >= MAXPHO ) continue ;
gcounter[1]++ ;
if ( it->pt() < photonCuts[0] || fabs( it->eta() ) > photonCuts[1] ) continue ;
gcounter[2]++ ;
//float hcalIsoRatio = it->hcalTowerSumEtConeDR04() / it->pt() ;
//if ( ( hcalIsoRatio + it->hadronicOverEm() )*it->energy() >= 6.0 ) continue ;
// pixel veto - replaced by Conversion Veto
//if ( it->hasPixelSeed() ) continue ;
//if ( ConversionVeto( &(*it) ) ) cout<<" Got Conversion Case !! " << endl ;
if ( ConversionVeto( &(*it) ) ) continue;
gcounter[3]++ ;
// S_Minor Cuts from the seed cluster
reco::CaloClusterPtr SCseed = it->superCluster()->seed() ;
const EcalRecHitCollection* rechits = ( it->isEB()) ? recHitsEB.product() : recHitsEE.product() ;
Cluster2ndMoments moments = EcalClusterTools::cluster2ndMoments(*SCseed, *rechits);
float sMin = moments.sMin ;
float sMaj = moments.sMaj ;
// seed Time
pair<DetId, float> maxRH = EcalClusterTools::getMaximum( *SCseed, rechits );
DetId seedCrystalId = maxRH.first;
EcalRecHitCollection::const_iterator seedRH = rechits->find(seedCrystalId);
float seedTime = (float)seedRH->time();
float seedTimeErr = (float)seedRH->timeError();
float swissX = EcalTools::swissCross( seedCrystalId, *rechits , 0., true ) ;
// sMin and sMaj cuts
if ( sMaj > photonCuts[2] ) continue ;
gcounter[4]++ ;
if ( sMin <= photonCuts[3] || sMin >= photonCuts[4] ) continue ;
gcounter[5]++ ;
// Isolation Cuts
float ecalSumEt = it->ecalRecHitSumEtConeDR04();
float hcalSumEt = it->hcalTowerSumEtConeDR04();
float trkSumPt = it->trkSumPtSolidConeDR04();
//bool trkIso = ( ( trkSumPt / it->pt()) < photonIso[0] ) ;
//bool ecalIso = ( (ecalSumEt / it->energy()) < photonIso[2] && ecalSumEt < photonIso[1] ) ;
//bool hcalIso = ( (hcalSumEt / it->energy()) < photonIso[4] && hcalSumEt < photonIso[3] ) ;
//if ( !trkIso || !ecalIso || !hcalIso ) continue ;
// PF Isolation - still not working , useless
//float cHadIso = max( it->chargedHadronIso() - RhoCorrection( 1, it->eta() ), 0. );
//float nHadIso = max( it->neutralHadronIso() - RhoCorrection( 2, it->eta() ), 0. );
//float photIso = max( it->photonIso() - RhoCorrection( 3, it->eta() ), 0. );
//printf(" cHad: %.3f, nHad: %.3f, phot: %.3f \n", it->chargedHadronIso(), it->neutralHadronIso(), it->photonIso() ) ;
// Track Veto
int nTrk = 0 ;
double minDR = 99. ;
double trkPt = 0 ;
for (reco::TrackCollection::const_iterator itrk = tracks->begin(); itrk != tracks->end(); itrk++ ) {
if ( itrk->pt() < 3. ) continue ;
LorentzVector trkP4( itrk->px(), itrk->py(), itrk->pz(), itrk->p() ) ;
double dR = ROOT::Math::VectorUtil::DeltaR( trkP4 , it->p4() ) ;
if ( dR < minDR ) {
minDR = dR ;
trkPt = itrk->pt() ;
}
if ( dR < photonCuts[5] ) nTrk++ ;
}
if ( nTrk > 0 ) continue ;
gcounter[6]++ ;
// check leading photon pt
maxPt = ( it->pt() > maxPt ) ? it->pt() : maxPt ;
// Timing Calculation
pair<double,double> AveXtalTE = ClusterTime( it->superCluster(), recHitsEB , recHitsEE );
PhoInfo phoTmp ;
phoTmp.t = AveXtalTE.first ;
phoTmp.dt = AveXtalTE.second ;
phoTmp.nchi2 = 0 ;
phoTmp.nxtals = 0 ;
phoTmp.nBC = 0 ;
phoTmp.fSpike = -1 ;
phoTmp.maxSX = -1 ;
//cout<<" 1st xT : "<< aveXtalTime <<" xTE : "<< aveXtalTimeErr << endl;
// Only use the seed cluster
//if ( seedTime > 5. ) debugT = true ;
if ( debugT ) printf("===== seedT: %.2f, 1st Ave.T: %.2f =====\n", seedTime, AveXtalTE.first ) ;
ClusterTime( it->superCluster(), recHitsEB , recHitsEE, phoTmp );
//cout<<" 2nd xT : "<< aveXtalTime <<" xTE : "<< aveXtalTimeErr << endl;
leaves.aveTime1[k] = phoTmp.t ; // weighted ave. time of seed cluster
leaves.aveTimeErr1[k] = phoTmp.dt ;
leaves.timeChi2[k] = phoTmp.nchi2 ;
leaves.nXtals[k] = phoTmp.nxtals ;
leaves.nBC[k] = phoTmp.nBC ;
leaves.fSpike[k] = phoTmp.fSpike ;
leaves.maxSwissX[k] = phoTmp.maxSX ;
leaves.seedSwissX[k] = swissX ;
debugT = false ;
// refine the timing to exclude out-of-time xtals
ClusterTime( it->superCluster(), recHitsEB , recHitsEE, phoTmp );
//cout<<" 3rd xT : "<< aveXtalTime <<" xTE : "<< aveXtalTimeErr << endl;
leaves.phoPx[k] = it->p4().Px() ;
leaves.phoPy[k] = it->p4().Py() ;
leaves.phoPz[k] = it->p4().Pz() ;
leaves.phoE[k] = it->p4().E() ;
//leaves.phoHoverE[k] = it->hadronicOverEm() ;
leaves.phoHoverE[k] = it->hadTowOverEm() ;
leaves.phoEcalIso[k] = ecalSumEt ;
leaves.phoHcalIso[k] = hcalSumEt ;
leaves.phoTrkIso[k] = trkSumPt ;
// the PFIso values need to be filled by PhotonPFIso function
//leaves.cHadIso[k] = cHadIso ;
//leaves.nHadIso[k] = nHadIso ;
//leaves.photIso[k] = photIso ;
leaves.dR_TrkPho[k] = minDR ;
leaves.pt_TrkPho[k] = trkPt ;
leaves.sMinPho[k] = sMin ;
leaves.sMajPho[k] = sMaj ;
leaves.seedTime[k] = seedTime ;
leaves.seedTimeErr[k] = seedTimeErr ;
leaves.aveTime[k] = phoTmp.t ; // weighted ave. time of seed cluster
leaves.aveTimeErr[k] = phoTmp.dt ;
leaves.sigmaEta[k] = it->sigmaEtaEta() ;
leaves.sigmaIeta[k] = it->sigmaIetaIeta() ;
selectedPhotons.push_back( &(*it) ) ;
k++ ;
}
leaves.nPhotons = k ;
leaves.met_dx3 += met_dx ;
leaves.met_dy3 += met_dy ;
//leaves.nPhotons = (int)( selectedPhotons.size() ) ;
if ( selectedPhotons.size() > 0 && maxPt >= photonCuts[7] ) return true ;
else return false ;
}
// AOD version - using TrackingRecHits
bool DPAnalysis::BeamHaloMatch( OwnVector<TrackingRecHit> rhits, vector<const reco::Photon*>& selectedPhotons, const EventSetup& iSetup ) {
ESHandle<CSCGeometry> cscGeom;
iSetup.get<MuonGeometryRecord>().get(cscGeom);
bool halomatch = false ;
for ( size_t i=0; i< selectedPhotons.size() ; i++ ) {
float dPhi = 99. ;
float cscRho = -1. ;
for (OwnVector<TrackingRecHit>::const_iterator rh = rhits.begin(); rh != rhits.end() ; rh++ ) {
//if( ! rh->isValid() ) continue ;
if ( rh->geographicalId().subdetId() != MuonSubdetId::CSC ) continue ;
if ( rh->geographicalId().det() != 2 ) continue ;
//CSCDetId cscId( rh->rawId() );
CSCDetId cscId( rh->geographicalId().rawId() );
const CSCChamber* cscchamber = cscGeom->chamber( cscId );
GlobalPoint gp = cscchamber->toGlobal( rh->localPosition() );
double gpMag = sqrt( (gp.x()*gp.x()) + (gp.y()*gp.y()) + (gp.z()*gp.z()) ) ;
LorentzVector segP4( gp.x(), gp.y(), gp.z(), gpMag ) ;
if ( fabs( gp.eta() ) < 1.6 ) continue ;
float dPhi_ = ROOT::Math::VectorUtil::DeltaPhi( segP4, selectedPhotons[i]->p4() ) ;
float rho = sqrt( (gp.x()*gp.x()) + (gp.y()*gp.y()) ) ;
//printf(" (%d) phi_g: %.3f, phi_m: %.3f , dphi: %.3f , rho: %.1f \n ",
// i, selectedPhotons[i]->p4().Phi() , segP4.Phi(), dPhi_ , rho ) ;
if ( fabs(dPhi_) < dPhi ) {
dPhi = fabs( dPhi_ ) ;
cscRho = rho ;
}
//cout<<" ("<< k<<") gpMag : "<< gpMag <<" eta: "<< gp.eta() << endl ;
}
//printf(" (%d) dphi: %.3f , rho: %.1f \n ",
// (int)i, dPhi , cscRho ) ;
leaves.cscRho[i] = cscRho ;
leaves.cscdPhi[i] = dPhi ;
if ( dPhi < 0.1 ) halomatch = true ;
}
return halomatch ;
}
// Use cosmic muon
/*
bool DPAnalysis::CosmicRayMatch( Handle<reco::MuonCollection> muons, vector<const reco::Photon*>& selectedPhotons )
{
for ( size_t i=0; i< selectedPhotons.size() ; i++ )
{
double dPhi = 99. ;
double dEta = 99. ;
double dR = 99. ;
int nMu = 0 ;
LorentzVector gP4 = selectedPhotons[i]->p4() ;
printf("** Photon pos:[ %f, %f, %f, %f ] \n", gP4.x(), gP4.y(), gP4.z(), gP4.rho() ) ;
for (reco::MuonCollection::const_iterator it = muons->begin(); it != muons->end(); it++)
{
TrackRef inTrkRef = it->innerTrack() ;
const std::vector<reco::Track>* inTrk = inTrkRef.product();
if ( inTrk != NULL )
{
const math::XYZPoint iPos = (*inTrk)[0].outerPosition() ;
printf(" inner pos:( %f, %f, %f, %f ) \n", iPos.x() , iPos.y() , iPos.z(), iPos.rho() ) ;
}
TrackRef outTrkRef = it->outerTrack() ;
const std::vector<reco::Track>* outTrk = outTrkRef.product();
if ( outTrk != NULL )
{
const math::XYZPoint oPos = (*outTrk)[0].innerPosition() ;
printf(" outer pos:( %f, %f, %f, %f ) \n", oPos.x() , oPos.y() , oPos.z(), oPos.rho() ) ;
}
}
}
return true ;
}
*/
// Use CosmicMuon track
bool DPAnalysis::CosmicRayMatch( Handle<reco::MuonCollection> muons, vector<const reco::Photon*>& selectedPhotons )
{
//cout<<" --------------- "<<endl ;
for ( size_t i=0; i< selectedPhotons.size() ; i++ )
{
double dPhi = 99. ;
double dEta = 99. ;
double dR = 99. ;
int nMu = 0 ;
for (reco::MuonCollection::const_iterator it = muons->begin(); it != muons->end(); it++)
{
nMu++ ;
//cout<<" =========== Cosmic Muon ===== "<< nMu ;
//if ( it->isCaloCompatibilityValid() ) cout<<" , CaloCaloCompatibility is valid -> " << it->caloCompatibility() << endl ;
// Associated Track is only availabe for RECO ( information from TrackExtra ) , AOD can't use it !
/*
const reco::Track* track = 0;
if ( ! it->track().isNull() ) {
track = it->track().get();
}
else {
if ( ! it->standAloneMuon().isNull() ) {