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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &es) override
 
virtual void produce (edm::Event &e, const edm::EventSetup &c) override
 
 SiClusterTranslator (const edm::ParameterSet &conf)
 
virtual ~SiClusterTranslator ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

edm::InputTag fastTrackerClusterCollectionTag_
 
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::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 36 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.

56  :
57  fastTrackerClusterCollectionTag_(conf.getParameter<edm::InputTag>("fastTrackerClusterCollectionTag"))
58 {
59  produces<edmNew::DetSetVector<SiStripCluster> >();
60  produces<edmNew::DetSetVector<SiPixelCluster> >();
61  produces<edm::DetSetVector<StripDigiSimLink> >();
62  produces<edm::DetSetVector<PixelDigiSimLink> >();
63 }
T getParameter(std::string const &) const
edm::InputTag fastTrackerClusterCollectionTag_
SiClusterTranslator::~SiClusterTranslator ( )
virtual

Definition at line 66 of file SiClusterTranslator.cc.

66 {}

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 69 of file SiClusterTranslator.cc.

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

69  {
70 
71  // Initialize the Tracker Geometry
73  es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
74  geometry = &(*theGeometry);
75 }
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 296 of file SiClusterTranslator.cc.

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

Referenced by produce().

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

Definition at line 276 of file SiClusterTranslator.cc.

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

Referenced by produce().

279 {
280  std::map<DetId,std::vector<SiStripCluster> >::const_iterator
281  it = theClusters.begin();
282  std::map<DetId,std::vector<SiStripCluster> >::const_iterator
283  lastDet = theClusters.end();
284  for( ; it != lastDet ; ++it ) {
285  edmNew::DetSetVector<SiStripCluster>::FastFiller cluster_col(theClusterCollection, it->first);
286 
287  std::vector<SiStripCluster>::const_iterator clust_it = it->second.begin();
288  std::vector<SiStripCluster>::const_iterator clust_end = it->second.end();
289  for( ; clust_it != clust_end ; ++clust_it) {
290  cluster_col.push_back(*clust_it);
291  }
292  }
293 }
void SiClusterTranslator::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 78 of file SiClusterTranslator.cc.

References counter, edm::DetSet< T >::data, edm::hlt::Exception, fastTrackerClusterCollectionTag_, edm::EventSetup::get(), edm::Event::getByLabel(), edm::DetSet< T >::id, TrackerGeometry::idToDetUnit(), loadPixelClusters(), loadStripClusters(), PixelTopology::pixel(), HLT_25ns14e33_v1_cff::pixelCPE, 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().

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

Member Data Documentation

edm::InputTag SiClusterTranslator::fastTrackerClusterCollectionTag_
private

Definition at line 60 of file SiClusterTranslator.h.

Referenced by produce().

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

Definition at line 52 of file SiClusterTranslator.h.

Referenced by produce().

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

Definition at line 51 of file SiClusterTranslator.h.

Referenced by produce().

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

Definition at line 50 of file SiClusterTranslator.h.

Referenced by produce().