CMS 3D CMS Logo

MTDClusterProducer.cc
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
6 //---------------------------------------------------------------------------
7 // Our own stuff
10 
11 // Data Formats
13 
14 // STL
15 #include <vector>
16 #include <memory>
17 #include <string>
18 #include <iostream>
19 
20 // MessageLogger
29 
38 
40 public:
41  //--- Constructor, virtual destructor (just in case)
42  explicit MTDClusterProducer(const edm::ParameterSet& conf);
43  ~MTDClusterProducer() override = default;
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  //--- The top-level event method.
47  void produce(edm::Event& e, const edm::EventSetup& c) override;
48 
49  //--- Execute the algorithm(s).
50  template <typename T>
51  void run(const T& input, FTLClusterCollection& output);
52 
53 private:
56 
57  const std::string ftlbInstance_; // instance name of barrel clusters
58  const std::string ftleInstance_; // instance name of endcap clusters
59 
60  const std::string clusterMode_; // user's choice of the clusterizer
61  std::unique_ptr<MTDClusterizerBase> clusterizer_; // what we got (for now, one ptr to base class)
62 
65 };
66 
67 //---------------------------------------------------------------------------
69 //---------------------------------------------------------------------------
71  : btlHits_(consumes<FTLRecHitCollection>(conf.getParameter<edm::InputTag>("srcBarrel"))),
72  etlHits_(consumes<FTLRecHitCollection>(conf.getParameter<edm::InputTag>("srcEndcap"))),
73  ftlbInstance_(conf.getParameter<std::string>("BarrelClusterName")),
74  ftleInstance_(conf.getParameter<std::string>("EndcapClusterName")),
75  clusterMode_(conf.getParameter<std::string>("ClusterMode")),
76  clusterizer_(nullptr) // the default, in case we fail to make one
77 {
78  //--- Declare to the EDM what kind of collections we will be making.
79  produces<FTLClusterCollection>(ftlbInstance_);
80  produces<FTLClusterCollection>(ftleInstance_);
81 
82  //--- Make the algorithm(s) according to what the user specified
83  //--- in the ParameterSet.
84  if (clusterMode_ == "MTDThresholdClusterizer") {
85  clusterizer_ = std::make_unique<MTDThresholdClusterizer>(conf);
86  } else {
87  throw cms::Exception("MTDClusterProducer") << "[MTDClusterProducer]:"
88  << " choice " << clusterMode_ << " is invalid.\n"
89  << "Possible choices:\n"
90  << " MTDThresholdClusterizer";
91  }
92 }
93 
94 // Configuration descriptions
97  desc.add<edm::InputTag>("srcBarrel", edm::InputTag("mtdRecHits:FTLBarrel"));
98  desc.add<edm::InputTag>("srcEndcap", edm::InputTag("mtdRecHits:FTLEndcap"));
99  desc.add<std::string>("BarrelClusterName", "FTLBarrel");
100  desc.add<std::string>("EndcapClusterName", "FTLEndcap");
101  desc.add<std::string>("ClusterMode", "MTDThresholdClusterizer");
103  descriptions.add("mtdClusterProducer", desc);
104 }
105 
106 //---------------------------------------------------------------------------
108 //---------------------------------------------------------------------------
110  // Step A.1: get input data
113  e.getByToken(btlHits_, inputBarrel);
114  e.getByToken(etlHits_, inputEndcap);
115 
116  // Step A.2: get event setup
119  geom_ = geom.product();
120 
122  es.get<MTDTopologyRcd>().get(mtdTopo);
123  topo_ = mtdTopo.product();
124 
125  // Step B: create the final output collection
126  auto outputBarrel = std::make_unique<FTLClusterCollection>();
127  auto outputEndcap = std::make_unique<FTLClusterCollection>();
128 
129  run(*inputBarrel, *outputBarrel);
130  run(*inputEndcap, *outputEndcap);
131 
132  e.put(std::move(outputBarrel), ftlbInstance_);
133  e.put(std::move(outputEndcap), ftleInstance_);
134 }
135 
136 //---------------------------------------------------------------------------
138 //---------------------------------------------------------------------------
139 template <typename T>
141  if (!clusterizer_) {
142  throw cms::Exception("MTDClusterProducer") << " at least one clusterizer is not ready -- can't run!";
143  }
144 
145  clusterizer_->clusterize(input, geom_, topo_, output);
146 
147  LogDebug("MTDClusterProducer") << " Executing " << clusterMode_ << " resulted in " << output.size()
148  << " MTDClusters for " << input.size() << " Hits.";
149 }
150 
153 
ConfigurationDescriptions.h
MTDDigiGeometryRecord
Definition: MTDDigiGeometryRecord.h:15
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Handle.h
MTDThresholdClusterizer.h
MTDClusterProducer::run
void run(const T &input, FTLClusterCollection &output)
Iterate over DetUnits, and invoke the PixelClusterizer on each.
Definition: MTDClusterProducer.cc:140
MTDClusterizerBase.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
ESHandle.h
MTDClusterProducer::~MTDClusterProducer
~MTDClusterProducer() override=default
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
MTDClusterProducer::ftlbInstance_
const std::string ftlbInstance_
Definition: MTDClusterProducer.cc:57
MTDClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: MTDClusterProducer.cc:95
MTDGeometry.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MTDDigiGeometryRecord.h
MTDClusterProducer::etlHits_
const edm::EDGetTokenT< FTLRecHitCollection > etlHits_
Definition: MTDClusterProducer.cc:55
EDProducer.h
edm::SortedCollection
Definition: SortedCollection.h:49
MTDClusterProducer
EDProducer to cluster FTLRecHits into FTLClusters.
Definition: MTDClusterProducer.cc:39
edm::Handle
Definition: AssociativeIterator.h:50
MTDClusterProducer::ftleInstance_
const std::string ftleInstance_
Definition: MTDClusterProducer.cc:58
MTDClusterProducer::topo_
const MTDTopology * topo_
Definition: MTDClusterProducer.cc:64
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
FTLRecHit.h
edm::ESHandle
Definition: DTSurvey.h:22
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
MTDClusterProducer::geom_
const MTDGeometry * geom_
Definition: MTDClusterProducer.cc:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MTDTopology
Definition: MTDTopology.h:16
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
MTDTopologyRcd
Definition: MTDTopologyRcd.h:10
Event.h
MTDClusterProducer::clusterMode_
const std::string clusterMode_
Definition: MTDClusterProducer.cc:60
ModuleDef.h
MTDThresholdClusterizer::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &desc)
Definition: MTDThresholdClusterizer.cc:47
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
MTDClusterProducer::clusterizer_
std::unique_ptr< MTDClusterizerBase > clusterizer_
Definition: MTDClusterProducer.cc:61
InputTag.h
FTLRecHitCollections.h
MTDGeometry
Definition: MTDGeometry.h:14
edmNew::DetSetVector
Definition: DetSetNew.h:13
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
MTDTopologyRcd.h
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:246
MTDClusterProducer::btlHits_
const edm::EDGetTokenT< FTLRecHitCollection > btlHits_
Definition: MTDClusterProducer.cc:54
EventSetup.h
MTDClusterProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
The "Event" entrypoint: gets called by framework for every event.
Definition: MTDClusterProducer.cc:109
ParameterSet.h
MTDClusterProducer::MTDClusterProducer
MTDClusterProducer(const edm::ParameterSet &conf)
Constructor: set the ParameterSet and defer all thinking to setupClusterizer().
Definition: MTDClusterProducer.cc:70
edm::Event
Definition: Event.h:73
FTLClusterCollections.h
Topology.h
edm::InputTag
Definition: InputTag.h:15
MTDTopology.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37