1 |
bendavid |
1.14 |
// $Id: FillerTracks.cc,v 1.13 2008/07/31 12:34:04 loizides Exp $
|
2 |
loizides |
1.1 |
|
3 |
bendavid |
1.11 |
#include "MitProd/TreeFiller/interface/FillerTracks.h"
|
4 |
loizides |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
bendavid |
1.14 |
#include "DataFormats/TrackReco/interface/HitPattern.h"
|
7 |
loizides |
1.1 |
#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"
|
12 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
13 |
|
|
|
14 |
|
|
using namespace std;
|
15 |
|
|
using namespace edm;
|
16 |
|
|
using namespace mithep;
|
17 |
|
|
|
18 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
19 |
loizides |
1.13 |
FillerTracks::FillerTracks(const ParameterSet &cfg, const char *name, bool active) :
|
20 |
loizides |
1.7 |
BaseFiller(cfg,name,active),
|
21 |
loizides |
1.13 |
edmName_(Conf().getUntrackedParameter<string>("edmName","generalTracks")),
|
22 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkTrackBrn)),
|
23 |
loizides |
1.1 |
edmSimAssociationName_(Conf().getUntrackedParameter<string>("edmSimAssociationName","")),
|
24 |
loizides |
1.13 |
simMapName_(Conf().getUntrackedParameter<string>("simMapName","SimMap")),
|
25 |
|
|
trackMapName_(Conf().getUntrackedParameter<string>("trackMapName",
|
26 |
|
|
Form("%sMapName",mitName_.c_str()))),
|
27 |
|
|
simMap_(0),
|
28 |
loizides |
1.7 |
tracks_(new mithep::TrackArr(250)),
|
29 |
loizides |
1.1 |
trackMap_(new mithep::TrackMap)
|
30 |
|
|
{
|
31 |
loizides |
1.13 |
// Constructor.
|
32 |
loizides |
1.1 |
}
|
33 |
|
|
|
34 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
35 |
loizides |
1.1 |
FillerTracks::~FillerTracks()
|
36 |
|
|
{
|
37 |
loizides |
1.13 |
// Destructor.
|
38 |
|
|
|
39 |
loizides |
1.5 |
delete tracks_;
|
40 |
loizides |
1.1 |
delete trackMap_;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
44 |
loizides |
1.1 |
void FillerTracks::BookDataBlock(TreeWriter &tws)
|
45 |
|
|
{
|
46 |
loizides |
1.13 |
// Add tracks branch to tree, publish and get our objects.
|
47 |
|
|
|
48 |
loizides |
1.1 |
tws.AddBranch(mitName_.c_str(),&tracks_);
|
49 |
bendavid |
1.14 |
InitLayerMap();
|
50 |
loizides |
1.12 |
|
51 |
loizides |
1.13 |
simMap_ = OS()->get<SimParticleMap>(simMapName_.c_str());
|
52 |
|
|
OS()->add<TrackMap>(trackMap_,trackMapName_.c_str());
|
53 |
|
|
OS()->add<TrackArr>(tracks_,mitName_.c_str());
|
54 |
loizides |
1.1 |
}
|
55 |
|
|
|
56 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
57 |
loizides |
1.1 |
void FillerTracks::FillDataBlock(const edm::Event &event,
|
58 |
|
|
const edm::EventSetup &setup)
|
59 |
|
|
{
|
60 |
loizides |
1.13 |
// Fill tracks from edm collection into our collection.
|
61 |
|
|
|
62 |
paus |
1.10 |
tracks_ ->Reset();
|
63 |
loizides |
1.1 |
trackMap_->Reset();
|
64 |
loizides |
1.6 |
|
65 |
|
|
Handle<reco::TrackCollection> hTrackProduct;
|
66 |
|
|
GetProduct(edmName_, hTrackProduct, event);
|
67 |
loizides |
1.1 |
|
68 |
loizides |
1.6 |
trackMap_->SetEdmProductId(hTrackProduct.id().id());
|
69 |
|
|
const reco::TrackCollection inTracks = *(hTrackProduct.product());
|
70 |
loizides |
1.1 |
|
71 |
paus |
1.10 |
// for MC SimParticle association (reco->sim mappings)
|
72 |
loizides |
1.1 |
reco::RecoToSimCollection simAssociation;
|
73 |
|
|
if (simMap_ && !edmSimAssociationName_.empty()) {
|
74 |
|
|
Handle<reco::RecoToSimCollection> simAssociationProduct;
|
75 |
loizides |
1.6 |
GetProduct(edmSimAssociationName_, simAssociationProduct, event);
|
76 |
loizides |
1.1 |
simAssociation = *(simAssociationProduct.product());
|
77 |
|
|
}
|
78 |
|
|
|
79 |
paus |
1.10 |
// loop through all tracks and fill the information
|
80 |
|
|
for (reco::TrackCollection::const_iterator it = inTracks.begin();
|
81 |
|
|
it != inTracks.end(); ++it) {
|
82 |
loizides |
1.5 |
mithep::Track *outTrack = tracks_->Allocate();
|
83 |
paus |
1.10 |
// create track and set the core parameters
|
84 |
bendavid |
1.14 |
new (outTrack) mithep::Track(it->qoverp(),it->lambda(),it->phi(),it->dxy(),it->dsz());
|
85 |
|
|
outTrack->SetErrors(it->qoverpError(),it->lambdaError(),it->phiError(),it->dxyError(),it->dszError());
|
86 |
loizides |
1.1 |
|
87 |
bendavid |
1.14 |
//Fill track quality information
|
88 |
|
|
outTrack->SetChi2(it->chi2());
|
89 |
|
|
outTrack->SetNdof(it->ndof());
|
90 |
|
|
|
91 |
|
|
//Fill hit layer map
|
92 |
|
|
// Format is known to have changed slightly in 21x
|
93 |
|
|
// Also due to reco::HitPattern limitation in 20x currently we do not distinguish stereo hits
|
94 |
|
|
// from regular hits, and therefore the stereo information is merged into
|
95 |
|
|
// the normal layer hits (this also means that stereo hits are not treated as
|
96 |
|
|
// seperate hits when counting the number of hits). This will be fixed in 21x
|
97 |
|
|
const reco::HitPattern &hits = it->hitPattern();
|
98 |
|
|
for (Int_t i=0; i<hits.numberOfHits(); i++) {
|
99 |
|
|
uint32_t hit = hits.getHitPattern(i);
|
100 |
|
|
if ( hits.validHitFilter(hit) )
|
101 |
|
|
if ( hits.trackerHitFilter(hit) )
|
102 |
|
|
outTrack->SetHit(layerMap_[hit]);
|
103 |
|
|
|
104 |
|
|
// if ( hits.muonDTHitFilter(hit) )
|
105 |
|
|
// printf("Muon DT Layer = %i\n", hits.getLayer(hit));
|
106 |
|
|
// if ( hits.muonCSCHitFilter(hit) )
|
107 |
|
|
// printf("Muon CSC Layer = %i\n", hits.getLayer(hit));
|
108 |
|
|
// if ( hits.muonRPCHitFilter(hit) )
|
109 |
|
|
// printf("Muon RPC Layer = %i\n", hits.getLayer(hit));
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
|
113 |
loizides |
1.1 |
// add reference between mithep and edm object
|
114 |
paus |
1.10 |
reco::TrackRef theRef(hTrackProduct, it - inTracks.begin());
|
115 |
loizides |
1.1 |
trackMap_->Add(theRef, outTrack);
|
116 |
|
|
|
117 |
|
|
if (simMap_ && !edmSimAssociationName_.empty()) {
|
118 |
|
|
reco::TrackBaseRef theBaseRef(theRef);
|
119 |
|
|
vector<pair<TrackingParticleRef, double> > simRefs;
|
120 |
paus |
1.10 |
Bool_t noSimParticle = 0;
|
121 |
loizides |
1.1 |
try {
|
122 |
|
|
simRefs = simAssociation[theBaseRef]; //try to get the sim references if existing
|
123 |
|
|
}
|
124 |
loizides |
1.5 |
catch (edm::Exception &ex) {
|
125 |
paus |
1.10 |
noSimParticle = 1;
|
126 |
loizides |
1.1 |
}
|
127 |
paus |
1.10 |
|
128 |
loizides |
1.1 |
if (!noSimParticle) { //loop through sim match candidates
|
129 |
|
|
for (vector<pair<TrackingParticleRef, double> >::const_iterator simRefPair=simRefs.begin();
|
130 |
|
|
simRefPair != simRefs.end(); ++simRefPair)
|
131 |
|
|
|
132 |
paus |
1.10 |
if (simRefPair->second > 0.5) // require more than 50% shared hits between reco and sim
|
133 |
bendavid |
1.9 |
outTrack->SetMCPart(simMap_->GetMit(simRefPair->first)); //add reco->sim reference
|
134 |
loizides |
1.1 |
}
|
135 |
|
|
}
|
136 |
bendavid |
1.14 |
// printf("inTrack : px=%5f,py=%5f,pz=%5f\n",it->px(),it->py(),it->pz());
|
137 |
|
|
// printf("outTrack: px=%5f,py=%5f,pz=%5f\n",outTrack->Px(),outTrack->Py(),outTrack->Pz());
|
138 |
|
|
// printf("inTrack : p=%5f,pt=%5f,theta=%5f,phi=%5f,dz=%5f\n",it->p(),it->pt(),
|
139 |
|
|
// it->theta(),it->phi(),it->dz());
|
140 |
|
|
// printf("outTrack: p=%5f,pt=%5f,theta=%5f,phi=%5f,dz=%5f\n",outTrack->P(),outTrack->Pt()
|
141 |
|
|
// ,outTrack->Theta(),outTrack->Phi(),outTrack->Z0());
|
142 |
loizides |
1.1 |
}
|
143 |
|
|
tracks_->Trim();
|
144 |
|
|
}
|
145 |
bendavid |
1.14 |
|
146 |
|
|
//--------------------------------------------------------------------------------------------------
|
147 |
|
|
void FillerTracks::InitLayerMap()
|
148 |
|
|
{
|
149 |
|
|
// Initialize mapping between hit layer format in reco::HitPattern and the one used in
|
150 |
|
|
// mithep::Track
|
151 |
|
|
// This will have to be rewritten when we switch to 21x due to changes in
|
152 |
|
|
// reco::HitPattern
|
153 |
|
|
|
154 |
|
|
layerMap_[580] = mithep::Track::PXB1;
|
155 |
|
|
layerMap_[584] = mithep::Track::PXB2;
|
156 |
|
|
layerMap_[588] = mithep::Track::PXB3;
|
157 |
|
|
layerMap_[644] = mithep::Track::PXF1;
|
158 |
|
|
layerMap_[648] = mithep::Track::PXF2;
|
159 |
|
|
layerMap_[708] = mithep::Track::TIB1;
|
160 |
|
|
layerMap_[712] = mithep::Track::TIB2;
|
161 |
|
|
layerMap_[716] = mithep::Track::TIB3;
|
162 |
|
|
layerMap_[720] = mithep::Track::TIB4;
|
163 |
|
|
layerMap_[772] = mithep::Track::TID1;
|
164 |
|
|
layerMap_[776] = mithep::Track::TID2;
|
165 |
|
|
layerMap_[780] = mithep::Track::TID3;
|
166 |
|
|
layerMap_[836] = mithep::Track::TOB1;
|
167 |
|
|
layerMap_[840] = mithep::Track::TOB2;
|
168 |
|
|
layerMap_[844] = mithep::Track::TOB3;
|
169 |
|
|
layerMap_[848] = mithep::Track::TOB4;
|
170 |
|
|
layerMap_[852] = mithep::Track::TOB5;
|
171 |
|
|
layerMap_[856] = mithep::Track::TOB6;
|
172 |
|
|
layerMap_[900] = mithep::Track::TEC1;
|
173 |
|
|
layerMap_[904] = mithep::Track::TEC2;
|
174 |
|
|
layerMap_[908] = mithep::Track::TEC3;
|
175 |
|
|
layerMap_[912] = mithep::Track::TEC4;
|
176 |
|
|
layerMap_[916] = mithep::Track::TEC5;
|
177 |
|
|
layerMap_[920] = mithep::Track::TEC6;
|
178 |
|
|
layerMap_[924] = mithep::Track::TEC7;
|
179 |
|
|
layerMap_[928] = mithep::Track::TEC8;
|
180 |
|
|
layerMap_[932] = mithep::Track::TEC9;
|
181 |
|
|
}
|