1 |
bbetchar |
1.1 |
#include "UserCode/ShallowTools/interface/ShallowSimTracksProducer.h"
|
2 |
|
|
#include "UserCode/ShallowTools/interface/ShallowTools.h"
|
3 |
|
|
|
4 |
|
|
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
|
5 |
|
|
#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
|
6 |
|
|
#include "SimTracker/TrackAssociation/interface/TrackAssociatorByChi2.h"
|
7 |
|
|
#include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h"
|
8 |
|
|
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h"
|
9 |
|
|
|
10 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
11 |
|
|
|
12 |
|
|
ShallowSimTracksProducer::ShallowSimTracksProducer(const edm::ParameterSet& conf)
|
13 |
|
|
: Prefix( conf.getParameter<std::string>("Prefix") ),
|
14 |
|
|
Suffix( conf.getParameter<std::string>("Suffix") ),
|
15 |
|
|
trackingParticles_tag( conf.getParameter<edm::InputTag>("TrackingParticles")),
|
16 |
|
|
associator_tag( conf.getParameter<edm::ESInputTag>("Associator")),
|
17 |
|
|
tracks_tag( conf.getParameter<edm::InputTag>("Tracks"))
|
18 |
|
|
{
|
19 |
|
|
produces <std::vector<unsigned> > ( Prefix + "multi" + Suffix );
|
20 |
|
|
produces <std::vector<int> > ( Prefix + "type" + Suffix );
|
21 |
|
|
produces <std::vector<float> > ( Prefix + "charge" + Suffix );
|
22 |
|
|
produces <std::vector<float> > ( Prefix + "momentum" + Suffix );
|
23 |
|
|
produces <std::vector<float> > ( Prefix + "pt" + Suffix );
|
24 |
|
|
produces <std::vector<double> > ( Prefix + "theta" + Suffix );
|
25 |
|
|
produces <std::vector<double> > ( Prefix + "phi" + Suffix );
|
26 |
|
|
produces <std::vector<double> > ( Prefix + "eta" + Suffix );
|
27 |
|
|
produces <std::vector<double> > ( Prefix + "vx" + Suffix );
|
28 |
|
|
produces <std::vector<double> > ( Prefix + "vy" + Suffix );
|
29 |
|
|
produces <std::vector<double> > ( Prefix + "vz" + Suffix );
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
void ShallowSimTracksProducer::
|
34 |
|
|
produce(edm::Event& event, const edm::EventSetup& setup) {
|
35 |
|
|
|
36 |
|
|
edm::Handle<edm::View<reco::Track> > tracks ; event.getByLabel( tracks_tag, tracks);
|
37 |
|
|
edm::Handle<TrackingParticleCollection> trackingParticles ; event.getByLabel( trackingParticles_tag, trackingParticles );
|
38 |
|
|
edm::ESHandle<TrackAssociatorBase> associator ; setup.get<TrackAssociatorRecord>().get( associator_tag, associator);
|
39 |
|
|
|
40 |
|
|
unsigned size = tracks->size();
|
41 |
|
|
std::auto_ptr<std::vector<unsigned> > multi ( new std::vector<unsigned>(size, 0));
|
42 |
|
|
std::auto_ptr<std::vector<int> > type ( new std::vector<int> (size, 0));
|
43 |
|
|
std::auto_ptr<std::vector<float> > charge ( new std::vector<float> (size, 0));
|
44 |
|
|
std::auto_ptr<std::vector<float> > momentum ( new std::vector<float> (size, -1));
|
45 |
|
|
std::auto_ptr<std::vector<float> > pt ( new std::vector<float> (size, -1));
|
46 |
|
|
std::auto_ptr<std::vector<double> > theta ( new std::vector<double> (size,-1000));
|
47 |
|
|
std::auto_ptr<std::vector<double> > phi ( new std::vector<double> (size,-1000));
|
48 |
|
|
std::auto_ptr<std::vector<double> > eta ( new std::vector<double> (size,-1000));
|
49 |
|
|
std::auto_ptr<std::vector<double> > dxy ( new std::vector<double> (size,-1000));
|
50 |
|
|
std::auto_ptr<std::vector<double> > dsz ( new std::vector<double> (size,-1000));
|
51 |
|
|
std::auto_ptr<std::vector<double> > vx ( new std::vector<double> (size,-1000));
|
52 |
|
|
std::auto_ptr<std::vector<double> > vy ( new std::vector<double> (size,-1000));
|
53 |
|
|
std::auto_ptr<std::vector<double> > vz ( new std::vector<double> (size,-1000));
|
54 |
|
|
|
55 |
|
|
reco::RecoToSimCollection associations = associator->associateRecoToSim( tracks, trackingParticles, &event );
|
56 |
|
|
|
57 |
|
|
for( reco::RecoToSimCollection::const_iterator association = associations.begin();
|
58 |
|
|
association != associations.end(); association++) {
|
59 |
|
|
|
60 |
|
|
const reco::Track* track = association->key.get();
|
61 |
|
|
const int matches = association->val.size();
|
62 |
|
|
if(matches>0) {
|
63 |
|
|
const TrackingParticle* tparticle = association->val[0].first.get();
|
64 |
|
|
unsigned i = shallow::findTrackIndex(tracks, track);
|
65 |
|
|
|
66 |
|
|
multi->at(i) = matches;
|
67 |
|
|
type->at(i) = tparticle->pdgId();
|
68 |
|
|
charge->at(i)= tparticle->charge();
|
69 |
|
|
momentum->at(i)=tparticle->p() ;
|
70 |
|
|
pt->at(i) = tparticle->pt() ;
|
71 |
|
|
theta->at(i) = tparticle->theta() ;
|
72 |
|
|
phi->at(i) = tparticle->phi() ;
|
73 |
|
|
eta->at(i) = tparticle->eta() ;
|
74 |
|
|
|
75 |
|
|
const TrackingVertex* tvertex = tparticle->parentVertex().get();
|
76 |
|
|
vx->at(i) = tvertex->position().x();
|
77 |
|
|
vy->at(i) = tvertex->position().y();
|
78 |
|
|
vz->at(i) = tvertex->position().z();
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
event.put( multi ,Prefix + "multi" + Suffix );
|
83 |
|
|
event.put( type ,Prefix + "type" + Suffix );
|
84 |
|
|
event.put( charge ,Prefix + "charge" + Suffix );
|
85 |
|
|
event.put( momentum ,Prefix + "momentum" + Suffix );
|
86 |
|
|
event.put( pt ,Prefix + "pt" + Suffix );
|
87 |
|
|
event.put( theta ,Prefix + "theta" + Suffix );
|
88 |
|
|
event.put( phi ,Prefix + "phi" + Suffix );
|
89 |
|
|
event.put( eta ,Prefix + "eta" + Suffix );
|
90 |
|
|
event.put( vx ,Prefix + "vx" + Suffix );
|
91 |
|
|
event.put( vy ,Prefix + "vy" + Suffix );
|
92 |
|
|
event.put( vz ,Prefix + "vz" + Suffix );
|
93 |
|
|
|
94 |
|
|
}
|