test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelRecHitConverter.cc
Go to the documentation of this file.
1 
12 // Our own stuff
14 // Geometry
17 
18 // Data Formats
22 
23 
24 // STL
25 #include <vector>
26 #include <memory>
27 #include <string>
28 #include <iostream>
29 
30 // MessageLogger
32 
34 
35 using namespace std;
36 
37 namespace cms
38 {
39  //---------------------------------------------------------------------------
41  //---------------------------------------------------------------------------
42  SiPixelRecHitConverter::SiPixelRecHitConverter(edm::ParameterSet const& conf)
43  :
44  conf_(conf),
45  src_( conf.getParameter<edm::InputTag>( "src" ) ),
46  tPixelCluster(consumes< edmNew::DetSetVector<SiPixelCluster> >( src_)) {
47  //--- Declare to the EDM what kind of collections we will be making.
48  produces<SiPixelRecHitCollection>();
49 
50  }
51 
52  // Destructor
54  {
55  }
56 
57  //---------------------------------------------------------------------------
59  //---------------------------------------------------------------------------
61  {
62 
63  // Step A.1: get input data
65  e.getByToken( tPixelCluster, input);
66 
67  // Step A.2: get event setup
69  es.get<TrackerDigiGeometryRecord>().get( geom );
70 
71  // Step B: create empty output collection
72  std::auto_ptr<SiPixelRecHitCollectionNew> output(new SiPixelRecHitCollectionNew);
73 
74  // Step B*: create CPE
77  es.get<TkPixelCPERecord>().get(cpeName_,hCPE);
78  cpe_ = dynamic_cast< const PixelCPEBase* >(&(*hCPE));
79 
80  // Step C: Iterate over DetIds and invoke the strip CPE algorithm
81  // on each DetUnit
82 
83  run( input, *output, geom );
84 
85  output->shrink_to_fit();
86  e.put(output);
87 
88  }
89 
90  //---------------------------------------------------------------------------
94  //---------------------------------------------------------------------------
98  if ( ! cpe_ )
99  {
100  edm::LogError("SiPixelRecHitConverter") << " at least one CPE is not ready -- can't run!";
101  // TO DO: throw an exception here? The user may want to know...
102  assert(0);
103  return; // clusterizer is invalid, bail out
104  }
105 
106  int numberOfDetUnits = 0;
107  int numberOfClusters = 0;
108 
109  const edmNew::DetSetVector<SiPixelCluster>& input = *inputhandle;
110 
112 
113  for ( ; DSViter != input.end() ; DSViter++) {
114  numberOfDetUnits++;
115  unsigned int detid = DSViter->detId();
116  DetId detIdObject( detid );
117  const GeomDetUnit * genericDet = geom->idToDetUnit( detIdObject );
118  const PixelGeomDetUnit * pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
119  assert(pixDet);
120  SiPixelRecHitCollectionNew::FastFiller recHitsOnDetUnit(output,detid);
121 
122  edmNew::DetSet<SiPixelCluster>::const_iterator clustIt = DSViter->begin(), clustEnd = DSViter->end();
123 
124  for ( ; clustIt != clustEnd; clustIt++) {
125  numberOfClusters++;
126  std::tuple<LocalPoint, LocalError,SiPixelRecHitQuality::QualWordType> tuple = cpe_->getParameters( *clustIt, *genericDet );
127  LocalPoint lp( std::get<0>(tuple) );
128  LocalError le( std::get<1>(tuple) );
129  SiPixelRecHitQuality::QualWordType rqw( std::get<2>(tuple) );
130  // Create a persistent edm::Ref to the cluster
132  // Make a RecHit and add it to the DetSet
133  // old : recHitsOnDetUnit.push_back( new SiPixelRecHit( lp, le, detIdObject, &*clustIt) );
134  SiPixelRecHit hit( lp, le, rqw, *genericDet, cluster);
135  //
136  // Now save it =================
137  recHitsOnDetUnit.push_back(hit);
138  // =============================
139 
140  // std::cout << "SiPixelRecHitConverterVI " << numberOfClusters << ' '<< lp << " " << le << std::endl;
141  } // <-- End loop on Clusters
142 
143 
144  // LogDebug("SiPixelRecHitConverter")
145  //std::cout << "SiPixelRecHitConverterVI "
146  // << " Found " << recHitsOnDetUnit.size() << " RecHits on " << detid //;
147  // << std::endl;
148 
149 
150  } // <-- End loop on DetUnits
151 
152  // LogDebug ("SiPixelRecHitConverter")
153  // std::cout << "SiPixelRecHitConverterVI "
154  // << cpeName_ << " converted " << numberOfClusters
155  // << " SiPixelClusters into SiPixelRecHits, in "
156  // << numberOfDetUnits << " DetUnits." //;
157  // << std::endl;
158 
159  }
160 } // 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)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void run(const edmNew::DetSetVector< SiPixelCluster > &input, SiPixelRecHitCollectionNew &output, edm::ESHandle< TrackerGeometry > &geom)
assert(m_qm.get())
data_type const * const_iterator
Definition: DetSetNew.h:30
static std::string const input
Definition: EdmProvDump.cc:44
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
The &quot;Event&quot; entrypoint: gets called by framework for every event.
Definition: DetId.h:18
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > tPixelCluster
const T & get() const
Definition: EventSetup.h:56
Pixel cluster – collection of neighboring pixels above threshold.
PixelCPEBase const * cpe_
const PixelClusterParameterEstimator * cpe_; // what we got (for now, one ptr to base class) ...
const_iterator begin(bool update=false) const
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const
Definition: PixelCPEBase.h:139
Our base class.
Definition: SiPixelRecHit.h:23