CMS 3D CMS Logo

MTDSoAProducer.cc
Go to the documentation of this file.
9 
14 
15 using namespace edm;
16 
18 public:
20 
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23  void produce(edm::Event& ev, const edm::EventSetup& es) final;
24 
25 private:
40 };
41 
43  : tracksToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksSrc"))),
44  trackAssocToken_(consumes<edm::ValueMap<int>>(iConfig.getParameter<edm::InputTag>("trackAssocSrc"))),
45  t0Token_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("t0Src"))),
46  sigmat0Token_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("sigmat0Src"))),
47  tmtdToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("tmtdSrc"))),
48  sigmatmtdToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("sigmatmtdSrc"))),
49  betaToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("betamtd"))),
50  pathToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("pathmtd"))),
51  MVAQualityToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("mvaquality"))),
52  posInMtdToken_(consumes<edm::ValueMap<GlobalPoint>>(iConfig.getParameter<edm::InputTag>("posmtd"))),
53  momentumWithMTDToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("momentum"))),
54  probPiToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("probPi"))),
55  probKToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("probK"))),
56  probPToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("probP"))) {
57  produces<MtdHostCollection>();
58 }
59 
60 // Configuration descriptions
63  desc.add<edm::InputTag>("tracksSrc", edm::InputTag("generalTracks"));
64  desc.add<edm::InputTag>("trackAssocSrc", edm::InputTag("trackExtenderWithMTD:generalTrackassoc"));
65  desc.add<edm::InputTag>("t0Src", edm::InputTag("tofPID:t0"));
66  desc.add<edm::InputTag>("sigmat0Src", edm::InputTag("tofPID:sigmat0"));
67  desc.add<edm::InputTag>("tmtdSrc", edm::InputTag("trackExtenderWithMTD:generalTracktmtd"));
68  desc.add<edm::InputTag>("sigmatmtdSrc", edm::InputTag("trackExtenderWithMTD:generalTracksigmatmtd"));
69  desc.add<edm::InputTag>("betamtd", edm::InputTag("trackExtenderWithMTD:generalTrackBeta"));
70  desc.add<edm::InputTag>("pathmtd", edm::InputTag("trackExtenderWithMTD:generalTrackPathLength"));
71  desc.add<edm::InputTag>("mvaquality", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA"));
72  desc.add<edm::InputTag>("posmtd", edm::InputTag("trackExtenderWithMTD:generalTrackmtdpos"));
73  desc.add<edm::InputTag>("momentum", edm::InputTag("trackExtenderWithMTD:generalTrackp"));
74  desc.add<edm::InputTag>("probPi", edm::InputTag("tofPID:probPi"));
75  desc.add<edm::InputTag>("probK", edm::InputTag("tofPID:probK"));
76  desc.add<edm::InputTag>("probP", edm::InputTag("tofPID:probP"));
77 
78  descriptions.add("mtdSoAProducer", desc);
79 }
80 
83  ev.getByToken(tracksToken_, tracksH);
84  const auto& tracks = *tracksH;
85 
86  const auto& trackAssoc = ev.get(trackAssocToken_);
87 
88  const auto& t0 = ev.get(t0Token_);
89  const auto& sigmat0 = ev.get(sigmat0Token_);
90 
91  const auto& tmtd = ev.get(tmtdToken_);
92  const auto& sigmatmtd = ev.get(sigmatmtdToken_);
93 
94  const auto& beta = ev.get(betaToken_);
95  const auto& path = ev.get(pathToken_);
96  const auto& MVAquality = ev.get(MVAQualityToken_);
97  const auto& posInMTD = ev.get(posInMtdToken_);
98  const auto& momentum = ev.get(momentumWithMTDToken_);
99  const auto& probPi = ev.get(probPiToken_);
100  const auto& probK = ev.get(probKToken_);
101  const auto& probP = ev.get(probPToken_);
102 
103  auto MtdInfo = std::make_unique<MtdHostCollection>(tracks.size(), cms::alpakatools::host());
104 
105  auto& MtdInfoView = MtdInfo->view();
106  for (unsigned int iTrack = 0; iTrack < tracks.size(); ++iTrack) {
107  const reco::TrackRef trackref(tracksH, iTrack);
108 
109  if (trackAssoc[trackref] == -1) {
110  MtdInfoView.trackAsocMTD()[iTrack] = -1;
111  MtdInfoView.time0()[iTrack] = 0.f;
112  MtdInfoView.time0Err()[iTrack] = -1.f;
113  MtdInfoView.time()[iTrack] = 0.f;
114  MtdInfoView.timeErr()[iTrack] = -1.f;
115  MtdInfoView.MVAquality()[iTrack] = 0.f;
116  MtdInfoView.pathLength()[iTrack] = 0.f;
117  MtdInfoView.beta()[iTrack] = 0.f;
118  MtdInfoView.posInMTD_x()[iTrack] = 0.f;
119  MtdInfoView.posInMTD_y()[iTrack] = 0.f;
120  MtdInfoView.posInMTD_z()[iTrack] = 0.f;
121  MtdInfoView.momentumWithMTD()[iTrack] = 0.f;
122  MtdInfoView.probPi()[iTrack] = 0.f;
123  MtdInfoView.probK()[iTrack] = 0.f;
124  MtdInfoView.probP()[iTrack] = 0.f;
125  continue;
126  }
127 
128  MtdInfoView.trackAsocMTD()[iTrack] = trackAssoc[trackref];
129  MtdInfoView.time0()[iTrack] = t0[trackref];
130  MtdInfoView.time0Err()[iTrack] = sigmat0[trackref];
131  MtdInfoView.time()[iTrack] = tmtd[trackref];
132  MtdInfoView.timeErr()[iTrack] = sigmatmtd[trackref];
133  MtdInfoView.MVAquality()[iTrack] = MVAquality[trackref];
134  MtdInfoView.pathLength()[iTrack] = path[trackref];
135  MtdInfoView.beta()[iTrack] = beta[trackref];
136  MtdInfoView.posInMTD_x()[iTrack] = posInMTD[trackref].x();
137  MtdInfoView.posInMTD_y()[iTrack] = posInMTD[trackref].y();
138  MtdInfoView.posInMTD_z()[iTrack] = posInMTD[trackref].z();
139  MtdInfoView.momentumWithMTD()[iTrack] = momentum[trackref];
140  MtdInfoView.probPi()[iTrack] = probPi[trackref];
141  MtdInfoView.probK()[iTrack] = probK[trackref];
142  MtdInfoView.probP()[iTrack] = probP[trackref];
143  }
144 
145  ev.put(std::move(MtdInfo));
146 }
147 
148 //define this as a plug-in
edm::EDGetTokenT< edm::ValueMap< GlobalPoint > > posInMtdToken_
edm::EDGetTokenT< edm::ValueMap< float > > MVAQualityToken_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< edm::ValueMap< float > > probPiToken_
edm::EDGetTokenT< edm::ValueMap< float > > momentumWithMTDToken_
edm::EDGetTokenT< edm::ValueMap< float > > sigmatmtdToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::ValueMap< float > > sigmat0Token_
edm::EDGetTokenT< edm::ValueMap< float > > t0Token_
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
MTDSoAProducer(const ParameterSet &pset)
alpaka::DevCpu const & host()
Definition: host.h:14
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::ValueMap< int > > trackAssocToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::ValueMap< float > > tmtdToken_
fixed size matrix
HLT enums.
edm::EDGetTokenT< edm::ValueMap< float > > probKToken_
void produce(edm::Event &ev, const edm::EventSetup &es) final
edm::EDGetTokenT< edm::ValueMap< float > > pathToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::ValueMap< float > > probPToken_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::ValueMap< float > > betaToken_