CMS 3D CMS Logo

SiPixelClusterProducer.cc
Go to the documentation of this file.
1 
14 // Our own stuff
15 #include "SiPixelClusterProducer.h"
17 
18 // Geometry
20 
21 // Data Formats
25 
26 // Database payloads
30 
31 // Framework
35 
36 // STL
37 #include <vector>
38 #include <memory>
39 #include <string>
40 #include <iostream>
41 
42 // MessageLogger
44 
45 //---------------------------------------------------------------------------
47 //---------------------------------------------------------------------------
49  : tPutPixelClusters(produces<SiPixelClusterCollectionNew>()),
50  clusterMode_(conf.getParameter<std::string>("ClusterMode")),
51  maxTotalClusters_(conf.getParameter<int32_t>("maxNumberOfClusters")) {
52  if (clusterMode_ == "PixelThresholdReclusterizer")
53  tPixelClusters = consumes<SiPixelClusterCollectionNew>(conf.getParameter<edm::InputTag>("src"));
54  else
55  tPixelDigi = consumes<edm::DetSetVector<PixelDigi>>(conf.getParameter<edm::InputTag>("src"));
56 
57  trackerTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>();
58  trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
59 
60  const auto& payloadType = conf.getParameter<std::string>("payloadType");
61  if (payloadType == "HLT")
62  theSiPixelGainCalibration_ = std::make_unique<SiPixelGainCalibrationForHLTService>(conf, consumesCollector());
63  else if (payloadType == "Offline")
64  theSiPixelGainCalibration_ = std::make_unique<SiPixelGainCalibrationOfflineService>(conf, consumesCollector());
65  else if (payloadType == "Full")
66  theSiPixelGainCalibration_ = std::make_unique<SiPixelGainCalibrationService>(conf, consumesCollector());
67 
68  //--- Make the algorithm(s) according to what the user specified
69  //--- in the ParameterSet.
70  setupClusterizer(conf);
71 }
72 
73 // Destructor
75 
78 
79  desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigis"));
80  desc.add<std::string>("ClusterMode", "PixelThresholdClusterizer");
81  desc.add<int>("maxNumberOfClusters", -1)->setComment("-1 means no limit");
82  desc.add<std::string>("payloadType", "Offline")
83  ->setComment("Options: HLT - column granularity, Offline - gain:col/ped:pix");
84 
86  SiPixelGainCalibrationServiceBase::fillPSetDescription(desc); // no-op, but in principle the structures are there...
87 
88  descriptions.add("SiPixelClusterizerDefault", desc);
89 }
90 
91 //---------------------------------------------------------------------------
93 //---------------------------------------------------------------------------
95  //Setup gain calibration service
96  theSiPixelGainCalibration_->setESObjects(es);
97 
98  // Step A.1: get input data
101  if (clusterMode_ == "PixelThresholdReclusterizer")
102  e.getByToken(tPixelClusters, inputClusters);
103  else
104  e.getByToken(tPixelDigi, inputDigi);
105 
106  // Step A.2: get event setup
108 
109  edm::ESHandle<TrackerTopology> trackerTopologyHandle = es.getHandle(trackerTopoToken_);
110  tTopo_ = trackerTopologyHandle.product();
111 
112  // Step B: create the final output collection
113  auto output = std::make_unique<SiPixelClusterCollectionNew>();
114  //FIXME: put a reserve() here
115 
116  // Step C: Iterate over DetIds and invoke the pixel clusterizer algorithm
117  // on each DetUnit
118  if (clusterMode_ == "PixelThresholdReclusterizer")
119  run(*inputClusters, geom, *output);
120  else
121  run(*inputDigi, geom, *output);
122 
123  // Step D: write output to file
124  output->shrink_to_fit();
125 
126  // set sequential identifier
127  for (auto& clusters : *output) {
128  uint16_t id = 0;
129  for (auto& cluster : clusters) {
130  cluster.setOriginalId(id++);
131  }
132  }
134 }
135 
136 //---------------------------------------------------------------------------
140 //---------------------------------------------------------------------------
142  if (clusterMode_ == "PixelThresholdReclusterizer" || clusterMode_ == "PixelThresholdClusterizer") {
143  clusterizer_ = std::make_unique<PixelThresholdClusterizer>(conf);
144  clusterizer_->setSiPixelGainCalibrationService(theSiPixelGainCalibration_.get());
145  } else {
146  throw cms::Exception("Configuration") << "[SiPixelClusterProducer]:"
147  << " choice " << clusterMode_ << " is invalid.\n"
148  << "Possible choices:\n"
149  << " PixelThresholdClusterizer";
150  }
151 }
152 
153 //---------------------------------------------------------------------------
155 //---------------------------------------------------------------------------
156 template <typename T>
160  int numberOfDetUnits = 0;
161  int numberOfClusters = 0;
162 
163  // Iterate on detector units
164  for (auto const& dsv : input) {
165  ++numberOfDetUnits;
166 
167  // LogDebug takes very long time, get rid off.
168  //LogDebug("SiStripClusterizer") << "[SiPixelClusterProducer::run] DetID" << dsv.id;
169 
170  std::vector<short> badChannels;
171  DetId detIdObject(dsv.detId());
172 
173  // Comment: At the moment the clusterizer depends on geometry
174  // to access information as the pixel topology (number of columns
175  // and rows in a detector module).
176  // In the future the geometry service will be replaced with
177  // a ES service.
178  const GeomDetUnit* geoUnit = geom->idToDetUnit(detIdObject);
179  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
180  if (!pixDet) {
181  // Fatal error! TO DO: throw an exception!
182  assert(0);
183  }
184  {
185  // Produce clusters for this DetUnit and store them in
186  // a DetSet
188  clusterizer_->clusterizeDetUnit(dsv, pixDet, tTopo_, badChannels, spc);
189  if (spc.empty()) {
190  spc.abort();
191  } else {
192  numberOfClusters += spc.size();
193  }
194  } // spc is not deleted and detsetvector updated
195  if ((maxTotalClusters_ >= 0) && (numberOfClusters > maxTotalClusters_)) {
196  edm::LogError("TooManyClusters")
197  << "Limit on the number of clusters exceeded. An empty cluster collection will be produced instead.\n";
199  empty.swap(output);
200  break;
201  }
202  } // end of DetUnit loop
203 
204  //LogDebug ("SiPixelClusterProducer") << " Executing "
205  // << clusterMode_ << " resulted in " << numberOfClusters
206  // << " SiPixelClusters in " << numberOfDetUnits << " DetUnits.";
207 }
208 
211 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Handle.h
SiPixelClusterProducer::tPixelClusters
edm::EDGetTokenT< SiPixelClusterCollectionNew > tPixelClusters
Definition: SiPixelClusterProducer.h:72
SiPixelClusterProducer::run
void run(const T &input, const edm::ESHandle< TrackerGeometry > &geom, edmNew::DetSetVector< SiPixelCluster > &output)
Iterate over DetUnits, and invoke the PixelClusterizer on each.
Definition: SiPixelClusterProducer.cc:157
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
ESHandle.h
SiPixelGainCalibrationOfflineService.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SiPixelClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPixelClusterProducer.cc:76
cms::cuda::assert
assert(be >=bs)
SiPixelClusterProducer::clusterMode_
const std::string clusterMode_
Definition: SiPixelClusterProducer.h:79
PixelDigi.h
SiPixelClusterProducer::SiPixelClusterProducer
SiPixelClusterProducer(const edm::ParameterSet &conf)
Constructor: set the ParameterSet and defer all thinking to setupClusterizer().
Definition: SiPixelClusterProducer.cc:48
SiPixelClusterProducer::tPutPixelClusters
edm::EDPutTokenT< SiPixelClusterCollectionNew > tPutPixelClusters
Definition: SiPixelClusterProducer.h:74
edm::Handle
Definition: AssociativeIterator.h:50
SiPixelGainCalibrationService.h
DetId
Definition: DetId.h:17
MakerMacros.h
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
SiPixelClusterProducer::tTopo_
const TrackerTopology * tTopo_
Definition: SiPixelClusterProducer.h:81
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
edm::ESHandle< TrackerGeometry >
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
ParameterSetDescription.h
SiPixelClusterProducer::tPixelDigi
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
Definition: SiPixelClusterProducer.h:73
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
SiPixelClusterProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
The "Event" entrypoint: gets called by framework for every event.
Definition: SiPixelClusterProducer.cc:94
SiPixelClusterProducer::trackerTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopoToken_
Definition: SiPixelClusterProducer.h:75
edm::ParameterSet
Definition: ParameterSet.h:47
SiPixelClusterProducer::trackerGeomToken_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeomToken_
Definition: SiPixelClusterProducer.h:76
SiPixelGainCalibrationForHLTService.h
SiPixelClusterProducer.h
ModuleDef.h
PixelThresholdClusterizer.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
SiPixelClusterProducer::clusterizer_
std::unique_ptr< PixelClusterizerBase > clusterizer_
Definition: SiPixelClusterProducer.h:80
SiPixelClusterProducer::~SiPixelClusterProducer
~SiPixelClusterProducer() override
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelGainCalibrationServiceBase::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: SiPixelGainCalibrationServiceBase.h:37
edmNew::DetSetVector
Definition: DetSetNew.h:13
HLT_FULL_cff.payloadType
payloadType
Definition: HLT_FULL_cff.py:9457
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
SiPixelClusterProducer::maxTotalClusters_
const int32_t maxTotalClusters_
Optional limit on the total number of clusters.
Definition: SiPixelClusterProducer.h:84
DetId.h
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:245
PixelGeomDetUnit.h
SiPixelClusterProducer
EDProducer to cluster PixelDigis into SiPixelClusters.
Definition: SiPixelClusterProducer.h:54
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edmNew::DetSetVector::FastFiller
Definition: DetSetVectorNew.h:202
edm::Event
Definition: Event.h:73
SiPixelClusterProducer::theSiPixelGainCalibration_
std::unique_ptr< SiPixelGainCalibrationServiceBase > theSiPixelGainCalibration_
Definition: SiPixelClusterProducer.h:78
edm::InputTag
Definition: InputTag.h:15
PixelThresholdClusterizer::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: PixelThresholdClusterizer.cc:71
SiPixelClusterProducer::setupClusterizer
void setupClusterizer(const edm::ParameterSet &conf)
Definition: SiPixelClusterProducer.cc:141
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37