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  //---------------------------------------------------------------------------
58  // Begin job: get magnetic field
59  //---------------------------------------------------------------------------
60  //void SiPixelRecHitConverter::beginJob()
62  {
63  }
64 
65  //---------------------------------------------------------------------------
67  //---------------------------------------------------------------------------
69  {
70 
71  // Step A.1: get input data
73  e.getByToken( tPixelCluster, input);
74 
75  // Step A.2: get event setup
77  es.get<TrackerDigiGeometryRecord>().get( geom );
78 
79  // Step B: create empty output collection
80  std::auto_ptr<SiPixelRecHitCollectionNew> output(new SiPixelRecHitCollectionNew);
81 
82  // Step B*: create CPE
85  es.get<TkPixelCPERecord>().get(cpeName_,hCPE);
86  cpe_ = dynamic_cast< const PixelCPEBase* >(&(*hCPE));
87 
88  // Step C: Iterate over DetIds and invoke the strip CPE algorithm
89  // on each DetUnit
90 
91  run( input, *output, geom );
92 
93 
94  e.put(output);
95 
96  }
97 
98  //---------------------------------------------------------------------------
102  //---------------------------------------------------------------------------
106  if ( ! cpe_ )
107  {
108  edm::LogError("SiPixelRecHitConverter") << " at least one CPE is not ready -- can't run!";
109  // TO DO: throw an exception here? The user may want to know...
110  assert(0);
111  return; // clusterizer is invalid, bail out
112  }
113 
114  int numberOfDetUnits = 0;
115  int numberOfClusters = 0;
116 
117  const edmNew::DetSetVector<SiPixelCluster>& input = *inputhandle;
118 
120 
121  for ( ; DSViter != input.end() ; DSViter++) {
122  numberOfDetUnits++;
123  unsigned int detid = DSViter->detId();
124  DetId detIdObject( detid );
125  const GeomDetUnit * genericDet = geom->idToDetUnit( detIdObject );
126  const PixelGeomDetUnit * pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
127  assert(pixDet);
128  SiPixelRecHitCollectionNew::FastFiller recHitsOnDetUnit(output,detid);
129 
130  edmNew::DetSet<SiPixelCluster>::const_iterator clustIt = DSViter->begin(), clustEnd = DSViter->end();
131 
132  for ( ; clustIt != clustEnd; clustIt++) {
133  numberOfClusters++;
134  std::pair<LocalPoint, LocalError> lv = cpe_->localParameters( *clustIt, *genericDet );
135  LocalPoint lp( lv.first );
136  LocalError le( lv.second );
137  // Create a persistent edm::Ref to the cluster
139  // Make a RecHit and add it to the DetSet
140  // old : recHitsOnDetUnit.push_back( new SiPixelRecHit( lp, le, detIdObject, &*clustIt) );
141  SiPixelRecHit hit( lp, le, detIdObject, cluster);
142  // Copy the extra stuff;
143  hit.setRawQualityWord( cpe_->rawQualityWord() );
144  //
145  // Now save it =================
146  recHitsOnDetUnit.push_back(hit);
147  // =============================
148 
149  // std::cout << "SiPixelRecHitConverterVI " << numberOfClusters << ' '<< lp << " " << le << std::endl;
150  } // <-- End loop on Clusters
151 
152 
153  // LogDebug("SiPixelRecHitConverter")
154  //std::cout << "SiPixelRecHitConverterVI "
155  // << " Found " << recHitsOnDetUnit.size() << " RecHits on " << detid //;
156  // << std::endl;
157 
158 
159  } // <-- End loop on DetUnits
160 
161  // LogDebug ("SiPixelRecHitConverter")
162  // std::cout << "SiPixelRecHitConverterVI "
163  // << cpeName_ << " converted " << numberOfClusters
164  // << " SiPixelClusters into SiPixelRecHits, in "
165  // << numberOfDetUnits << " DetUnits." //;
166  // << std::endl;
167 
168  }
169 } // 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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void run(const edmNew::DetSetVector< SiPixelCluster > &input, SiPixelRecHitCollectionNew &output, edm::ESHandle< TrackerGeometry > &geom)
SiPixelRecHitQuality::QualWordType rawQualityWord() const
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:116
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:18
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > tPixelCluster
virtual void produce(edm::Event &e, const edm::EventSetup &c)
The &quot;Event&quot; entrypoint: gets called by framework for every event.
const T & get() const
Definition: EventSetup.h:55
Pixel cluster – collection of neighboring pixels above threshold.
const_iterator end(bool update=true) const
LocalValues localParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const
Definition: PixelCPEBase.h:73
const_iterator begin(bool update=true) const
PixelCPEBase const * cpe_
const PixelClusterParameterEstimator * cpe_; // what we got (for now, one ptr to base class) ...
Pixel Reconstructed Hit.