3 |
|
#include "MitProd/TreeFiller/interface/FillerTracks.h" |
4 |
|
#include "FWCore/MessageLogger/interface/MessageLogger.h" |
5 |
|
#include "DataFormats/Common/interface/Handle.h" |
6 |
+ |
#include "DataFormats/TrackReco/interface/HitPattern.h" |
7 |
|
#include "DataFormats/TrackReco/interface/Track.h" |
8 |
|
#include "DataFormats/TrackReco/interface/TrackFwd.h" |
9 |
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" |
10 |
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" |
11 |
|
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h" |
11 |
– |
#include "MitAna/DataTree/interface/Names.h" |
12 |
|
|
13 |
|
using namespace std; |
14 |
|
using namespace edm; |
15 |
|
using namespace mithep; |
16 |
|
|
17 |
|
//-------------------------------------------------------------------------------------------------- |
18 |
< |
FillerTracks::FillerTracks(const ParameterSet &cfg, const char *name, bool active) : |
18 |
> |
FillerTracks::FillerTracks(const ParameterSet &cfg, const char *name, bool active, |
19 |
> |
const char *edmName, const char *mitName) : |
20 |
|
BaseFiller(cfg,name,active), |
21 |
< |
edmName_(Conf().getUntrackedParameter<string>("edmName","generalTracks")), |
22 |
< |
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkTrackBrn)), |
23 |
< |
edmSimAssociationName_(Conf().getUntrackedParameter<string>("edmSimAssociationName","")), |
24 |
< |
simMapName_(Conf().getUntrackedParameter<string>("simMapName","SimMap")), |
21 |
> |
edmName_(Conf().getUntrackedParameter<string>("edmName",edmName)), |
22 |
> |
mitName_(Conf().getUntrackedParameter<string>("mitName",mitName)), |
23 |
> |
edmSimAssocName_(Conf().getUntrackedParameter<string>("edmSimAssociationName","")), |
24 |
> |
trackingMapName_(Conf().getUntrackedParameter<string>("trackingMapName","TrackingMap")), |
25 |
|
trackMapName_(Conf().getUntrackedParameter<string>("trackMapName", |
26 |
|
Form("%sMapName",mitName_.c_str()))), |
27 |
< |
simMap_(0), |
27 |
> |
trackingMap_(0), |
28 |
|
tracks_(new mithep::TrackArr(250)), |
29 |
|
trackMap_(new mithep::TrackMap) |
30 |
|
{ |
47 |
|
|
48 |
|
tws.AddBranch(mitName_.c_str(),&tracks_); |
49 |
|
|
50 |
< |
simMap_ = OS()->get<SimParticleMap>(simMapName_.c_str()); |
50 |
> |
trackingMap_ = OS()->get<TrackingParticleMap>(trackingMapName_.c_str()); |
51 |
|
OS()->add<TrackMap>(trackMap_,trackMapName_.c_str()); |
52 |
|
OS()->add<TrackArr>(tracks_,mitName_.c_str()); |
53 |
|
} |
69 |
|
|
70 |
|
// for MC SimParticle association (reco->sim mappings) |
71 |
|
reco::RecoToSimCollection simAssociation; |
72 |
< |
if (simMap_ && !edmSimAssociationName_.empty()) { |
72 |
> |
if (trackingMap_ && !edmSimAssocName_.empty()) { |
73 |
|
Handle<reco::RecoToSimCollection> simAssociationProduct; |
74 |
< |
GetProduct(edmSimAssociationName_, simAssociationProduct, event); |
74 |
> |
GetProduct(edmSimAssocName_, simAssociationProduct, event); |
75 |
|
simAssociation = *(simAssociationProduct.product()); |
76 |
+ |
//printf("SimAssociation Map Size = %i\n",simAssociation.size()); |
77 |
|
} |
78 |
|
|
79 |
|
// loop through all tracks and fill the information |
81 |
|
it != inTracks.end(); ++it) { |
82 |
|
mithep::Track *outTrack = tracks_->Allocate(); |
83 |
|
// create track and set the core parameters |
84 |
< |
new (outTrack) mithep::Track(it->phi(),it->d0(),it->pt(),it->dz(),it->theta()); |
85 |
< |
outTrack->SetErrors(it->phiError(),it->d0Error(),it->ptError(),it->dzError(),it->thetaError()); |
86 |
< |
outTrack->SetCharge(it->charge()); |
84 |
> |
new (outTrack) mithep::Track(it->qoverp(),it->lambda(), |
85 |
> |
it->phi(),it->dxy(),it->dsz()); |
86 |
> |
outTrack->SetErrors(it->qoverpError(),it->lambdaError(), |
87 |
> |
it->phiError(),it->dxyError(),it->dszError()); |
88 |
|
|
89 |
+ |
// fill track quality information |
90 |
+ |
outTrack->SetChi2(it->chi2()); |
91 |
+ |
outTrack->SetNdof(static_cast<Int_t>(it->ndof())); |
92 |
+ |
|
93 |
+ |
//fill hit layer map |
94 |
+ |
const reco::HitPattern &hits = it->hitPattern(); |
95 |
+ |
for (Int_t i=0; i<hits.numberOfHits(); i++) { |
96 |
+ |
uint32_t hit = hits.getHitPattern(i); |
97 |
+ |
if (hits.validHitFilter(hit)) |
98 |
+ |
if (hits.trackerHitFilter(hit)) |
99 |
+ |
outTrack->SetHit(hitReader_.Layer(hit)); |
100 |
+ |
|
101 |
+ |
if (0) { |
102 |
+ |
if (hits.muonDTHitFilter(hit)) |
103 |
+ |
printf("Muon DT Layer = %i\n", hits.getLayer(hit)); |
104 |
+ |
if (hits.muonCSCHitFilter(hit)) |
105 |
+ |
printf("Muon CSC Layer = %i\n", hits.getLayer(hit)); |
106 |
+ |
if (hits.muonRPCHitFilter(hit)) |
107 |
+ |
printf("Muon RPC Layer = %i\n", hits.getLayer(hit)); |
108 |
+ |
} |
109 |
+ |
} |
110 |
+ |
|
111 |
|
// add reference between mithep and edm object |
112 |
|
reco::TrackRef theRef(hTrackProduct, it - inTracks.begin()); |
113 |
|
trackMap_->Add(theRef, outTrack); |
114 |
|
|
115 |
< |
if (simMap_ && !edmSimAssociationName_.empty()) { |
115 |
> |
if (trackingMap_ && !edmSimAssocName_.empty()) { |
116 |
> |
//printf("Trying Track-Sim association\n"); |
117 |
|
reco::TrackBaseRef theBaseRef(theRef); |
118 |
|
vector<pair<TrackingParticleRef, double> > simRefs; |
119 |
|
Bool_t noSimParticle = 0; |
125 |
|
} |
126 |
|
|
127 |
|
if (!noSimParticle) { //loop through sim match candidates |
128 |
+ |
//printf("Applying track-sim association\n"); |
129 |
|
for (vector<pair<TrackingParticleRef, double> >::const_iterator simRefPair=simRefs.begin(); |
130 |
|
simRefPair != simRefs.end(); ++simRefPair) |
131 |
|
|
132 |
|
if (simRefPair->second > 0.5) // require more than 50% shared hits between reco and sim |
133 |
< |
outTrack->SetMCPart(simMap_->GetMit(simRefPair->first)); //add reco->sim reference |
133 |
> |
outTrack->SetMCPart(trackingMap_->GetMit(simRefPair->first)); //add reco->sim reference |
134 |
|
} |
135 |
|
} |
136 |
|
} |
137 |
|
tracks_->Trim(); |
138 |
|
} |
139 |
+ |
|