CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiClusterTranslator Class Reference

#include <SiClusterTranslator.h>

Inheritance diagram for SiClusterTranslator:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run &run, const edm::EventSetup &es)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
 SiClusterTranslator (const edm::ParameterSet &conf)
 
virtual ~SiClusterTranslator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void loadPixelClusters (std::map< DetId, std::vector< SiPixelCluster > > &theClusters, SiPixelClusterCollectionNew &theClusterCollection) const
 
void loadStripClusters (std::map< DetId, std::vector< SiStripCluster > > &theClusters, edmNew::DetSetVector< SiStripCluster > &theClusterCollection) const
 

Private Attributes

const TrackerGeometrygeometry
 
std::vector< std::pair
< PSimHit, int > > 
theNewSimHitList
 
std::vector< edm::DetSet
< PixelDigiSimLink > > 
thePixelDigiLinkVector
 
std::vector< edm::DetSet
< StripDigiSimLink > > 
theStripDigiLinkVector
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Author
: Douglas Orbaker : Dougl.nosp@m.as.O.nosp@m.rbake.nosp@m.r@ce.nosp@m.rn.ch Clusters Produced by the FastSim and converts them to the standard cluster type.

Definition at line 35 of file SiClusterTranslator.h.

Constructor & Destructor Documentation

SiClusterTranslator::SiClusterTranslator ( const edm::ParameterSet conf)
explicit

SiClusterTranslator.cc

Description: see SiClusterTranslator.h Authors: R. Ranieri (CERN)

History: Sep 27, 2006 - initial version

Definition at line 56 of file SiClusterTranslator.cc.

57 {
58  produces<edmNew::DetSetVector<SiStripCluster> >();
59  produces<edmNew::DetSetVector<SiPixelCluster> >();
60  produces<edm::DetSetVector<StripDigiSimLink> >();
61  produces<edm::DetSetVector<PixelDigiSimLink> >();
62 }
SiClusterTranslator::~SiClusterTranslator ( )
virtual

Definition at line 65 of file SiClusterTranslator.cc.

65 {}

Member Function Documentation

void SiClusterTranslator::beginRun ( edm::Run run,
const edm::EventSetup es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 68 of file SiClusterTranslator.cc.

References geometry, and edm::EventSetup::get().

68  {
69 
70  // Initialize the Tracker Geometry
72  es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
73  geometry = &(*theGeometry);
74 }
const TrackerGeometry * geometry
const T & get() const
Definition: EventSetup.h:55
void SiClusterTranslator::loadPixelClusters ( std::map< DetId, std::vector< SiPixelCluster > > &  theClusters,
SiPixelClusterCollectionNew theClusterCollection 
) const
private

Definition at line 290 of file SiClusterTranslator.cc.

References edmNew::DetSetVector< T >::FastFiller::push_back().

Referenced by produce().

293 {
294 
295  std::map<DetId,std::vector<SiPixelCluster> >::const_iterator
296  it = theClusters.begin();
297  std::map<DetId,std::vector<SiPixelCluster> >::const_iterator
298  lastCluster = theClusters.end();
299  for( ; it != lastCluster ; ++it ) {
300  edmNew::DetSetVector<SiPixelCluster>::FastFiller spc(theClusterCollection, it->first);
301 
302  std::vector<SiPixelCluster>::const_iterator clust_it = it->second.begin();
303  std::vector<SiPixelCluster>::const_iterator clust_end = it->second.end();
304  for( ; clust_it != clust_end ; ++clust_it) {
305  spc.push_back(*clust_it);
306  }
307  }
308 }
void SiClusterTranslator::loadStripClusters ( std::map< DetId, std::vector< SiStripCluster > > &  theClusters,
edmNew::DetSetVector< SiStripCluster > &  theClusterCollection 
) const
private

Definition at line 270 of file SiClusterTranslator.cc.

References edmNew::DetSetVector< T >::FastFiller::push_back().

Referenced by produce().

273 {
274  std::map<DetId,std::vector<SiStripCluster> >::const_iterator
275  it = theClusters.begin();
276  std::map<DetId,std::vector<SiStripCluster> >::const_iterator
277  lastDet = theClusters.end();
278  for( ; it != lastDet ; ++it ) {
279  edmNew::DetSetVector<SiStripCluster>::FastFiller cluster_col(theClusterCollection, it->first);
280 
281  std::vector<SiStripCluster>::const_iterator clust_it = it->second.begin();
282  std::vector<SiStripCluster>::const_iterator clust_end = it->second.end();
283  for( ; clust_it != clust_end ; ++clust_it) {
284  cluster_col.push_back(*clust_it);
285  }
286  }
287 }
void SiClusterTranslator::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 77 of file SiClusterTranslator.cc.

References MixCollection< T >::begin(), DeDxDiscriminatorTools::charge(), ClusterParameterEstimator< T >::clearParameters(), edm::DetSet< T >::data, ClusterParameterEstimator< T >::enterLocalParameters(), error, edm::hlt::Exception, edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::getByType(), edm::DetSet< T >::id, TrackerGeometry::idToDetUnit(), loadPixelClusters(), loadStripClusters(), PixelTopology::pixel(), PixelChannelIdentifier::pixelToChannel(), position, edm::Handle< T >::product(), edm::Event::put(), DetId::rawId(), RectangularStripTopology::strip(), RadialStripTopology::strip(), DetId::subdetId(), theNewSimHitList, thePixelDigiLinkVector, theStripDigiLinkVector, GeomDetType::topology(), PixelGeomDetUnit::topology(), patCandidatesForDimuonsSequences_cff::tracker, and StripGeomDetUnit::type().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

78 {
79  // Step A: Get Inputs (FastGSRecHit's)
81  e.getByType(theFastClusters);
82 
84  es.get<TrackerDigiGeometryRecord>().get( tkgeom );
85  const TrackerGeometry &tracker(*tkgeom);
86 
88  es.get<TkPixelCPERecord>().get("FastPixelCPE",pixelCPE);
89  const PixelClusterParameterEstimator &pixelcpe(*pixelCPE);
90 
92  es.get<TkStripCPERecord>().get("FastStripCPE", stripCPE);
93  const StripClusterParameterEstimator &stripcpe(*stripCPE);
94 
96  std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
97  e.getByLabel("mix","famosSimHitsTrackerHits", cf_simhit);
98  cf_simhitvec.push_back(cf_simhit.product());
99 
100  std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
101  int counter =0;
102 
103  //Clearing vector to hopefully make it run faster.
104  theNewSimHitList.clear();
105  thePixelDigiLinkVector.clear();
106  theStripDigiLinkVector.clear();
107 
108  for(MixCollection<PSimHit>::iterator it = allTrackerHits->begin(); it!= allTrackerHits->end();it++){
109  counter++;
110  theNewSimHitList.push_back(std::make_pair((*it), counter));
111  }
112 
113  // Step B: fill a temporary full Cluster collection from the fast Cluster collection
114  FastTrackerClusterCollection::const_iterator aCluster = theFastClusters->begin();
115  FastTrackerClusterCollection::const_iterator theLastHit = theFastClusters->end();
116  std::map< DetId, std::vector<SiPixelCluster> > temporaryPixelClusters;
117  std::map< DetId, std::vector<SiStripCluster> > temporaryStripClusters;
118 
119  //Clearing CPE maps from previous event.
120  stripcpe.clearParameters();
121  pixelcpe.clearParameters();
122 
123  int ClusterNum = 0;
124 
125  // loop on Fast GS Hits
126  for ( ; aCluster != theLastHit; ++aCluster ) {
127  ClusterNum++;
128 
129  //Finding SubDet Id of cluster: 1 & 2 = Pixel, 3 & 4 & 5 & 6 = Strip, >6 = ?
130  DetId det = aCluster->id();
131  unsigned int subdet = det.subdetId();
132  int sim_counter = 0;
133  for (std::vector<std::pair<PSimHit,int> >::const_iterator
134  simcount = theNewSimHitList.begin() ; simcount != theNewSimHitList.end(); simcount ++){
135  if((aCluster->simtrackId() == (int)(*simcount).first.trackId())&&(det.rawId() == (*simcount).first.detUnitId())&&(aCluster->eeId() == (*simcount).first.eventId().rawId()))
136  sim_counter = (*simcount).second;
137  }
138  if (sim_counter == 0) throw cms::Exception("SiClusterTranslator") << "No Matching SimHit found.";
139 
140  //Separating into Pixels and Strips
141 
142  //Pixel
143  if (subdet < 3) {
144  //Here is the hard part. From the position of the FastSim Cluster I need to figure out the Pixel location for the Cluster.
145  LocalPoint position = aCluster->localPosition();
146  LocalError error = aCluster->localPositionError();
147  //std::cout << "The pixel charge is " << aCluster->charge() << std::endl;
148  int charge = (int)(aCluster->charge() + 0.5);
149  //std::cout << "The pixel charge after integer conversion is " << charge << std::endl;
150 
151  //std::vector<int> digi_vec;
152  //while (charge > 255) {
153  //digi_vec.push_back(charge);
154  //charge -= 256;
155  //}
156  //digi_vec.push_back(charge);
157 
158  const GeomDetUnit * geoDet = tracker.idToDetUnit(det);
159  const PixelGeomDetUnit * pixelDet=(const PixelGeomDetUnit*)(geoDet);
160  const PixelTopology& topol=(PixelTopology&)pixelDet->topology();
161 
162  //Out of pixel is float, but input of pixel is int. Hopeful it works...
163  std::pair<float,float> pixelPos_out = topol.pixel(position);
164  SiPixelCluster::PixelPos pixelPos((int)pixelPos_out.first, (int)pixelPos_out.second);
165 
166  //Filling Pixel CPE with information.
167  std::pair<int,int> row_col((int)pixelPos_out.first,(int)pixelPos_out.second);
168  pixelcpe.enterLocalParameters((unsigned int) det.rawId() , row_col, std::make_pair(position,error));
169 
170  unsigned int ch = PixelChannelIdentifier::pixelToChannel((int)pixelPos_out.first, (int)pixelPos_out.second);
171 
172  //Creating a new pixel cluster.
173  SiPixelCluster temporaryPixelCluster(pixelPos, charge);
174  temporaryPixelClusters[det].push_back(temporaryPixelCluster);
175 
176  //Making a PixelDigiSimLink.
177  edm::DetSet<PixelDigiSimLink> pixelDetSet;
178  pixelDetSet.id = det.rawId();
179  pixelDetSet.data.push_back(PixelDigiSimLink(ch,
180  aCluster->simtrackId(),
181  EncodedEventId(aCluster->eeId()),
182  1.0));
183  thePixelDigiLinkVector.push_back(pixelDetSet);
184  }
185 
186  //Strips
187  else if ((subdet > 2) && (subdet < 7)) {
188  //Getting pos/err info from the cluster
189  LocalPoint position = aCluster->localPosition();
190  LocalError error = aCluster->localPositionError();
191 
192  //Will have to make charge into ADC eventually...
193  uint16_t charge = (uint16_t)(aCluster->charge() + 0.5);
194 
195  //std::cout << "The charge is " << charge << std::endl;
196 
197  uint16_t strip_num = 0;
198  std::vector<uint16_t> digi_vec;
199  while (charge > 255) {
200  digi_vec.push_back(255);
201  charge -= 255;
202  }
203  if (charge > 0) digi_vec.push_back(charge);
204  //std::cout << "The digi_vec size is " << digi_vec.size() << std::endl;
205  //int totcharge = 0;
206  //for(int i = 0; i < digi_vec.size(); ++i) {
207  //totcharge += digi_vec[i];
208  //}
209  const GeomDetUnit * geoDet = tracker.idToDetUnit(det);
210  const StripGeomDetUnit * stripDet = (const StripGeomDetUnit*)(geoDet);
211 
212  //3 = TIB, 4 = TID, 5 = TOB, 6 = TEC
213  if((subdet == 3) || (subdet == 5)) {
214  const RectangularStripTopology& topol=(RectangularStripTopology&)stripDet->type().topology();
215  strip_num = (uint16_t)topol.strip(position);
216  } else if ((subdet == 4) || (subdet == 6)) {
217  const RadialStripTopology& topol=(RadialStripTopology&)stripDet->type().topology();
218  strip_num = (uint16_t)topol.strip(position);
219  }
220 
221  //Filling Strip CPE with info.
222  stripcpe.enterLocalParameters(det.rawId(), strip_num, std::make_pair(position,error));
223 
224  //Creating a new strip cluster
225  SiStripCluster temporaryStripCluster(det.rawId(), strip_num, digi_vec.begin(), digi_vec.end());
226  temporaryStripClusters[det].push_back(temporaryStripCluster);
227 
228  //Making a StripDigiSimLink
229  edm::DetSet<StripDigiSimLink> stripDetSet;
230  stripDetSet.id = det.rawId();
231  stripDetSet.data.push_back(StripDigiSimLink(strip_num,
232  aCluster->simtrackId(),
233  sim_counter,
234  EncodedEventId(aCluster->eeId()),
235  1.0));
236  theStripDigiLinkVector.push_back(stripDetSet);
237  }
238 
239  //?????
240  else {
241  throw cms::Exception("SiClusterTranslator") <<
242  "Trying to build a cluster that is not in the SiStripTracker or Pixels.\n";
243  }
244 
245  }//Cluster loop
246 
247  // Step C: from the temporary Cluster collections, create the real ones.
248 
249  //Pixels
250  std::auto_ptr<edmNew::DetSetVector<SiPixelCluster> >
251  siPixelClusterCollection(new edmNew::DetSetVector<SiPixelCluster>);
252  loadPixelClusters(temporaryPixelClusters, *siPixelClusterCollection);
253  std::auto_ptr<edm::DetSetVector<StripDigiSimLink> > stripoutputlink(new edm::DetSetVector<StripDigiSimLink>(theStripDigiLinkVector) );
254 
255 
256  //Strips
257  std::auto_ptr<edmNew::DetSetVector<SiStripCluster> >
258  siStripClusterCollection(new edmNew::DetSetVector<SiStripCluster>);
259  loadStripClusters(temporaryStripClusters, *siStripClusterCollection);
260  std::auto_ptr<edm::DetSetVector<PixelDigiSimLink> > pixeloutputlink(new edm::DetSetVector<PixelDigiSimLink>(thePixelDigiLinkVector) );
261 
262  // Step D: write output to file
263  e.put(siPixelClusterCollection);
264  e.put(siStripClusterCollection);
265  e.put(stripoutputlink);
266  e.put(pixeloutputlink);
267 }
virtual const Topology & topology() const
Returns a reference to the pixel proxy topology.
std::vector< edm::DetSet< PixelDigiSimLink > > thePixelDigiLinkVector
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
double charge(const std::vector< uint8_t > &Ampls)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
virtual std::pair< float, float > pixel(const LocalPoint &p) const =0
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void loadPixelClusters(std::map< DetId, std::vector< SiPixelCluster > > &theClusters, SiPixelClusterCollectionNew &theClusterCollection) const
std::vector< edm::DetSet< StripDigiSimLink > > theStripDigiLinkVector
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
Definition: DetId.h:20
iterator begin()
virtual const GeomDetType & type() const
std::vector< std::pair< PSimHit, int > > theNewSimHitList
virtual float strip(const LocalPoint &) const
T const * product() const
Definition: Handle.h:74
virtual const Topology & topology() const =0
virtual float strip(const LocalPoint &) const
collection_type data
Definition: DetSet.h:79
Pixel cluster – collection of neighboring pixels above threshold.
static int position[264][3]
Definition: ReadPGInfo.cc:509
det_id_type id
Definition: DetSet.h:78
void loadStripClusters(std::map< DetId, std::vector< SiStripCluster > > &theClusters, edmNew::DetSetVector< SiStripCluster > &theClusterCollection) const
static int pixelToChannel(int row, int col)

Member Data Documentation

const TrackerGeometry* SiClusterTranslator::geometry
private
std::vector<std::pair<PSimHit, int > > SiClusterTranslator::theNewSimHitList
private

Definition at line 51 of file SiClusterTranslator.h.

Referenced by produce().

std::vector<edm::DetSet<PixelDigiSimLink> > SiClusterTranslator::thePixelDigiLinkVector
private

Definition at line 50 of file SiClusterTranslator.h.

Referenced by produce().

std::vector<edm::DetSet<StripDigiSimLink> > SiClusterTranslator::theStripDigiLinkVector
private

Definition at line 49 of file SiClusterTranslator.h.

Referenced by produce().