CMS 3D CMS Logo

SiPixelRecHitConverter.cc
Go to the documentation of this file.
1 
12 // Our own stuff
14 // Geometry
17 
18 // Data Formats
22 
23 // STL
24 #include <vector>
25 #include <memory>
26 #include <string>
27 #include <iostream>
28 
29 // MessageLogger
31 
33 
34 using namespace std;
35 
36 namespace cms {
37  //---------------------------------------------------------------------------
39  //---------------------------------------------------------------------------
40  SiPixelRecHitConverter::SiPixelRecHitConverter(edm::ParameterSet const& conf)
41  : conf_(conf),
42  src_(conf.getParameter<edm::InputTag>("src")),
43  tPixelCluster(consumes<edmNew::DetSetVector<SiPixelCluster> >(src_)) {
44  //--- Declare to the EDM what kind of collections we will be making.
45  produces<SiPixelRecHitCollection>();
46  }
47 
48  // Destructor
50 
51  //---------------------------------------------------------------------------
53  //---------------------------------------------------------------------------
55  // Step A.1: get input data
57  e.getByToken(tPixelCluster, input);
58 
59  // Step A.2: get event setup
61  es.get<TrackerDigiGeometryRecord>().get(geom);
62 
63  // Step B: create empty output collection
64  auto output = std::make_unique<SiPixelRecHitCollectionNew>();
65 
66  // Step B*: create CPE
69  es.get<TkPixelCPERecord>().get(cpeName_, hCPE);
70  cpe_ = dynamic_cast<const PixelCPEBase*>(&(*hCPE));
71 
72  // Step C: Iterate over DetIds and invoke the strip CPE algorithm
73  // on each DetUnit
74 
75  run(input, *output, geom);
76 
77  output->shrink_to_fit();
78  e.put(std::move(output));
79  }
80 
81  //---------------------------------------------------------------------------
85  //---------------------------------------------------------------------------
89  if (!cpe_) {
90  edm::LogError("SiPixelRecHitConverter") << " at least one CPE is not ready -- can't run!";
91  // TO DO: throw an exception here? The user may want to know...
92  assert(0);
93  return; // clusterizer is invalid, bail out
94  }
95 
96  int numberOfDetUnits = 0;
97  int numberOfClusters = 0;
98 
99  const edmNew::DetSetVector<SiPixelCluster>& input = *inputhandle;
100 
102 
103  for (; DSViter != input.end(); DSViter++) {
104  numberOfDetUnits++;
105  unsigned int detid = DSViter->detId();
106  DetId detIdObject(detid);
107  const GeomDetUnit* genericDet = geom->idToDetUnit(detIdObject);
108  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
109  assert(pixDet);
110  SiPixelRecHitCollectionNew::FastFiller recHitsOnDetUnit(output, detid);
111 
112  edmNew::DetSet<SiPixelCluster>::const_iterator clustIt = DSViter->begin(), clustEnd = DSViter->end();
113 
114  for (; clustIt != clustEnd; clustIt++) {
115  numberOfClusters++;
116  std::tuple<LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType> tuple =
117  cpe_->getParameters(*clustIt, *genericDet);
118  LocalPoint lp(std::get<0>(tuple));
119  LocalError le(std::get<1>(tuple));
120  SiPixelRecHitQuality::QualWordType rqw(std::get<2>(tuple));
121  // Create a persistent edm::Ref to the cluster
123  edmNew::makeRefTo(inputhandle, clustIt);
124  // Make a RecHit and add it to the DetSet
125  // old : recHitsOnDetUnit.push_back( new SiPixelRecHit( lp, le, detIdObject, &*clustIt) );
126  SiPixelRecHit hit(lp, le, rqw, *genericDet, cluster);
127  //
128  // Now save it =================
129  recHitsOnDetUnit.push_back(hit);
130  // =============================
131 
132  // std::cout << "SiPixelRecHitConverterVI " << numberOfClusters << ' '<< lp << " " << le << std::endl;
133  } // <-- End loop on Clusters
134 
135  // LogDebug("SiPixelRecHitConverter")
136  //std::cout << "SiPixelRecHitConverterVI "
137  // << " Found " << recHitsOnDetUnit.size() << " RecHits on " << detid //;
138  // << std::endl;
139 
140  } // <-- End loop on DetUnits
141 
142  // LogDebug ("SiPixelRecHitConverter")
143  // std::cout << "SiPixelRecHitConverterVI "
144  // << cpeName_ << " converted " << numberOfClusters
145  // << " SiPixelClusters into SiPixelRecHits, in "
146  // << numberOfDetUnits << " DetUnits." //;
147  // << std::endl;
148  }
149 } // end of namespace cms
T getParameter(std::string const &) const
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
void push_back(data_type const &d)
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const override
Definition: PixelCPEBase.h:143
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void run(const edmNew::DetSetVector< SiPixelCluster > &input, SiPixelRecHitCollectionNew &output, edm::ESHandle< TrackerGeometry > &geom)
data_type const * const_iterator
Definition: DetSetNew.h:31
static std::string const input
Definition: EdmProvDump.cc:48
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void produce(edm::Event &e, const edm::EventSetup &c) override
The "Event" entrypoint: gets called by framework for every event.
Namespace of DDCMS conversion namespace.
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > tPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
HLT enums.
T get() const
Definition: EventSetup.h:73
PixelCPEBase const * cpe_
const PixelClusterParameterEstimator * cpe_; // what we got (for now, one ptr to base class) ...
def move(src, dest)
Definition: eostools.py:511
const_iterator begin(bool update=false) const
Our base class.
Definition: SiPixelRecHit.h:23