CMS 3D CMS Logo

MTDTrackQualityMVAProducer.cc
Go to the documentation of this file.
8 
15 
17 
18 using namespace std;
19 using namespace edm;
20 
22 public:
24 
25  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
26 
27  template <class H, class T>
28  void fillValueMap(edm::Event& iEvent,
29  const edm::Handle<H>& handle,
30  const std::vector<T>& vec,
31  const std::string& name) const;
32 
33  void produce(edm::Event& ev, const edm::EventSetup& es) final;
34 
35 private:
36  static constexpr char mvaName[] = "mtdQualMVA";
37 
40 
49 
51 };
52 
54  : tracksToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksSrc"))),
55  btlMatchChi2Token_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("btlMatchChi2Src"))),
56  btlMatchTimeChi2Token_(
57  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("btlMatchTimeChi2Src"))),
58  etlMatchChi2Token_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("etlMatchChi2Src"))),
59  etlMatchTimeChi2Token_(
60  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("etlMatchTimeChi2Src"))),
61  mtdTimeToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("mtdTimeSrc"))),
62  pathLengthToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("pathLengthSrc"))),
63  npixBarrelToken_(consumes<edm::ValueMap<int>>(iConfig.getParameter<edm::InputTag>("npixBarrelSrc"))),
64  npixEndcapToken_(consumes<edm::ValueMap<int>>(iConfig.getParameter<edm::InputTag>("npixEndcapSrc"))),
65  mva_(iConfig.getParameter<edm::FileInPath>("qualityBDT_weights_file").fullPath()) {
66  produces<edm::ValueMap<float>>(mvaName);
67 }
68 
69 // Configuration descriptions
72  desc.add<edm::InputTag>("tracksSrc", edm::InputTag("generalTracks"))->setComment("Input tracks collection");
73  desc.add<edm::InputTag>("btlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchChi2"))
74  ->setComment("BTL Chi2 Matching value Map");
75  desc.add<edm::InputTag>("btlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchTimeChi2"))
76  ->setComment("BTL Chi2 Matching value Map");
77  desc.add<edm::InputTag>("etlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchChi2"))
78  ->setComment("ETL Chi2 Matching value Map");
79  desc.add<edm::InputTag>("etlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchTimeChi2"))
80  ->setComment("ETL Chi2 Matching value Map");
81  desc.add<edm::InputTag>("mtdTimeSrc", edm::InputTag("trackExtenderWithMTD", "generalTracktmtd"))
82  ->setComment("MTD TIme value Map");
83  desc.add<edm::InputTag>("pathLengthSrc", edm::InputTag("trackExtenderWithMTD", "generalTrackPathLength"))
84  ->setComment("MTD PathLength value Map");
85  desc.add<edm::InputTag>("npixBarrelSrc", edm::InputTag("trackExtenderWithMTD", "npixBarrel"))
86  ->setComment("# of Barrel pixel associated to refitted tracks");
87  desc.add<edm::InputTag>("npixEndcapSrc", edm::InputTag("trackExtenderWithMTD", "npixEndcap"))
88  ->setComment("# of Endcap pixel associated to refitted tracks");
89  desc.add<edm::FileInPath>("qualityBDT_weights_file",
90  edm::FileInPath("RecoMTD/TimingIDTools/data/clf4D_MTDquality_bo.xml"))
91  ->setComment("Track MTD quality BDT weights");
92  descriptions.add("mtdTrackQualityMVAProducer", desc);
93 }
94 
95 template <class H, class T>
97  const edm::Handle<H>& handle,
98  const std::vector<T>& vec,
99  const std::string& name) const {
100  auto out = std::make_unique<edm::ValueMap<T>>();
102  filler.insert(handle, vec.begin(), vec.end());
103  filler.fill();
104  iEvent.put(std::move(out), name);
105 }
106 
109  ev.getByToken(tracksToken_, tracksH);
110  const auto& tracks = *tracksH;
111 
112  const auto& btlMatchChi2 = ev.get(btlMatchChi2Token_);
113  const auto& btlMatchTimeChi2 = ev.get(btlMatchTimeChi2Token_);
114  const auto& etlMatchChi2 = ev.get(etlMatchChi2Token_);
115  const auto& etlMatchTimeChi2 = ev.get(etlMatchTimeChi2Token_);
116  const auto& pathLength = ev.get(pathLengthToken_);
117  const auto& npixBarrel = ev.get(npixBarrelToken_);
118  const auto& npixEndcap = ev.get(npixEndcapToken_);
119  const auto& mtdTime = ev.get(mtdTimeToken_);
120 
121  std::vector<float> mvaOutRaw;
122 
123  //Loop over tracks collection
124  for (unsigned int itrack = 0; itrack < tracks.size(); ++itrack) {
125  const reco::TrackRef trackref(tracksH, itrack);
126  if (pathLength[trackref] == -1.)
127  mvaOutRaw.push_back(-1.);
128  else {
129  mvaOutRaw.push_back(mva_(trackref,
130  npixBarrel,
131  npixEndcap,
132  btlMatchChi2,
133  btlMatchTimeChi2,
134  etlMatchChi2,
135  etlMatchTimeChi2,
136  mtdTime,
137  pathLength));
138  }
139  }
140  fillValueMap(ev, tracksH, mvaOutRaw, mvaName);
141 }
142 
143 //define this as a plug-in
ConfigurationDescriptions.h
MTDTrackQualityMVAProducer::btlMatchTimeChi2Token_
edm::EDGetTokenT< edm::ValueMap< float > > btlMatchTimeChi2Token_
Definition: MTDTrackQualityMVAProducer.cc:42
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
ESHandle.h
MTDTrackQualityMVAProducer::tracksMTDToken_
edm::EDGetTokenT< reco::TrackCollection > tracksMTDToken_
Definition: MTDTrackQualityMVAProducer.cc:39
MTDTrackQualityMVAProducer::mva_
MTDTrackQualityMVA mva_
Definition: MTDTrackQualityMVAProducer.cc:50
MTDTrackQualityMVAProducer::MTDTrackQualityMVAProducer
MTDTrackQualityMVAProducer(const ParameterSet &pset)
Definition: MTDTrackQualityMVAProducer.cc:53
patZpeak.handle
handle
Definition: patZpeak.py:23
edm::EDGetTokenT< reco::TrackCollection >
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm
HLT enums.
Definition: AlignableModifier.h:19
MTDTrackQualityMVAProducer::btlMatchChi2Token_
edm::EDGetTokenT< edm::ValueMap< float > > btlMatchChi2Token_
Definition: MTDTrackQualityMVAProducer.cc:41
MTDTrackQualityMVA.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
MTDTrackQualityMVAProducer::fillValueMap
void fillValueMap(edm::Event &iEvent, const edm::Handle< H > &handle, const std::vector< T > &vec, const std::string &name) const
Definition: MTDTrackQualityMVAProducer.cc:96
MTDTrackQualityMVAProducer::npixBarrelToken_
edm::EDGetTokenT< edm::ValueMap< int > > npixBarrelToken_
Definition: MTDTrackQualityMVAProducer.cc:47
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< TrackCollection >
MTDTrackQualityMVAProducer::pathLengthToken_
edm::EDGetTokenT< edm::ValueMap< float > > pathLengthToken_
Definition: MTDTrackQualityMVAProducer.cc:46
MTDTrackQualityMVAProducer::mvaName
static constexpr char mvaName[]
Definition: MTDTrackQualityMVAProducer.cc:36
MTDTrackQualityMVAProducer::etlMatchTimeChi2Token_
edm::EDGetTokenT< edm::ValueMap< float > > etlMatchTimeChi2Token_
Definition: MTDTrackQualityMVAProducer.cc:44
MTDTrackQualityMVAProducer
Definition: MTDTrackQualityMVAProducer.cc:21
edm::FileInPath
Definition: FileInPath.h:61
MakerMacros.h
MTDTrackQualityMVA
Definition: MTDTrackQualityMVA.h:31
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MTDTrackQualityMVAProducer::mtdTimeToken_
edm::EDGetTokenT< edm::ValueMap< float > > mtdTimeToken_
Definition: MTDTrackQualityMVAProducer.cc:45
MTDTrackQualityMVAProducer::etlMatchChi2Token_
edm::EDGetTokenT< edm::ValueMap< float > > etlMatchChi2Token_
Definition: MTDTrackQualityMVAProducer.cc:43
taus_updatedMVAIds_cff.mvaName
mvaName
Definition: taus_updatedMVAIds_cff.py:18
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
MTDTrackQualityMVAProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: MTDTrackQualityMVAProducer.cc:70
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
MTDTrackQualityMVAProducer::produce
void produce(edm::Event &ev, const edm::EventSetup &es) final
Definition: MTDTrackQualityMVAProducer.cc:107
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ValueMap.h
VertexFwd.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Vertex.h
Frameworkfwd.h
edm::ValueMap
Definition: ValueMap.h:107
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
MTDTrackQualityMVAProducer::npixEndcapToken_
edm::EDGetTokenT< edm::ValueMap< int > > npixEndcapToken_
Definition: MTDTrackQualityMVAProducer.cc:48
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
MTDTrackQualityMVAProducer::tracksToken_
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
Definition: MTDTrackQualityMVAProducer.cc:38
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27