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 
48 
50 };
51 
53  : tracksToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksSrc"))),
54  tracksMTDToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksMTDSrc"))),
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  trackAssocToken_(consumes<edm::ValueMap<int>>(iConfig.getParameter<edm::InputTag>("trackAssocSrc"))),
64  mva_(iConfig.getParameter<edm::FileInPath>("qualityBDT_weights_file").fullPath()) {
65  produces<edm::ValueMap<float>>(mvaName);
66 }
67 
68 // Configuration descriptions
71  desc.add<edm::InputTag>("tracksSrc", edm::InputTag("generalTracks"))->setComment("Input tracks collection");
72  desc.add<edm::InputTag>("tracksMTDSrc", edm::InputTag("trackExtenderWithMTD"))
73  ->setComment("Input tracks collection for MTD extended tracks");
74  desc.add<edm::InputTag>("btlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchChi2"))
75  ->setComment("BTL Chi2 Matching value Map");
76  desc.add<edm::InputTag>("btlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchTimeChi2"))
77  ->setComment("BTL Chi2 Matching value Map");
78  desc.add<edm::InputTag>("etlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchChi2"))
79  ->setComment("ETL Chi2 Matching value Map");
80  desc.add<edm::InputTag>("etlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchTimeChi2"))
81  ->setComment("ETL Chi2 Matching value Map");
82  desc.add<edm::InputTag>("mtdTimeSrc", edm::InputTag("trackExtenderWithMTD", "tmtd"))
83  ->setComment("MTD TIme value Map");
84  desc.add<edm::InputTag>("pathLengthSrc", edm::InputTag("trackExtenderWithMTD", "pathLength"))
85  ->setComment("MTD PathLength value Map");
86  desc.add<edm::InputTag>("trackAssocSrc", edm::InputTag("trackExtenderWithMTD", "generalTrackassoc"))
87  ->setComment("Association between General and MTD Extended tracks");
88  desc.add<edm::FileInPath>("qualityBDT_weights_file",
89  edm::FileInPath("RecoMTD/TimingIDTools/data/clf4D_MTDquality_bo.xml"))
90  ->setComment("Track MTD quality BDT weights");
91  descriptions.add("mtdTrackQualityMVAProducer", desc);
92 }
93 
94 template <class H, class T>
96  const edm::Handle<H>& handle,
97  const std::vector<T>& vec,
98  const std::string& name) const {
99  auto out = std::make_unique<edm::ValueMap<T>>();
101  filler.insert(handle, vec.begin(), vec.end());
102  filler.fill();
103  iEvent.put(std::move(out), name);
104 }
105 
108  ev.getByToken(tracksToken_, tracksH);
109  const auto& tracks = *tracksH;
110 
112  ev.getByToken(tracksMTDToken_, tracksMTDH);
113 
114  const auto& btlMatchChi2 = ev.get(btlMatchChi2Token_);
115  const auto& btlMatchTimeChi2 = ev.get(btlMatchTimeChi2Token_);
116  const auto& etlMatchChi2 = ev.get(etlMatchChi2Token_);
117  const auto& etlMatchTimeChi2 = ev.get(etlMatchTimeChi2Token_);
118  const auto& pathLength = ev.get(pathLengthToken_);
119  const auto& trackAssoc = ev.get(trackAssocToken_);
120  const auto& mtdTime = ev.get(mtdTimeToken_);
121 
122  std::vector<float> mvaOutRaw;
123 
124  //Loop over tracks collection
125  for (unsigned int itrack = 0; itrack < tracks.size(); ++itrack) {
126  const reco::TrackRef trackref(tracksH, itrack);
127  if (trackAssoc[trackref] == -1)
128  mvaOutRaw.push_back(-1.);
129  else {
130  const reco::TrackRef mtdTrackref = reco::TrackRef(tracksMTDH, trackAssoc[trackref]);
131  mvaOutRaw.push_back(mva_(
132  trackref, mtdTrackref, btlMatchChi2, btlMatchTimeChi2, etlMatchChi2, etlMatchTimeChi2, mtdTime, pathLength));
133  }
134  }
135  fillValueMap(ev, tracksH, mvaOutRaw, mvaName);
136 }
137 
138 //define this as a plug-in
ConfigurationDescriptions.h
MTDTrackQualityMVAProducer::btlMatchTimeChi2Token_
edm::EDGetTokenT< edm::ValueMap< float > > btlMatchTimeChi2Token_
Definition: MTDTrackQualityMVAProducer.cc:42
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
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:49
MTDTrackQualityMVAProducer::MTDTrackQualityMVAProducer
MTDTrackQualityMVAProducer(const ParameterSet &pset)
Definition: MTDTrackQualityMVAProducer.cc:52
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
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:95
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
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:64
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:17
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
MTDTrackQualityMVAProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: MTDTrackQualityMVAProducer.cc:69
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
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:106
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
MTDTrackQualityMVAProducer::trackAssocToken_
edm::EDGetTokenT< edm::ValueMap< int > > trackAssocToken_
Definition: MTDTrackQualityMVAProducer.cc:47
ValueMap.h
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::ValueMap
Definition: ValueMap.h:107
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
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