CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ShallowSimhitClustersProducer Class Reference

#include <ShallowSimhitClustersProducer.h>

Inheritance diagram for ShallowSimhitClustersProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ShallowSimhitClustersProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

shallow::CLUSTERMAP::const_iterator match_cluster (const unsigned &, const float &, const shallow::CLUSTERMAP &, const edmNew::DetSetVector< SiStripCluster > &) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
 
std::string Prefix
 
std::string runningmode_
 
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simhits_tokens_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 12 of file ShallowSimhitClustersProducer.h.

Constructor & Destructor Documentation

ShallowSimhitClustersProducer::ShallowSimhitClustersProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 18 of file ShallowSimhitClustersProducer.cc.

References edm::EDConsumerBase::consumes(), edm::ParameterSet::getParameter(), Prefix, produce(), and simhits_tokens_.

20  Prefix( iConfig.getParameter<std::string>("Prefix") ),
21  runningmode_( iConfig.getParameter<std::string>("runningMode") )
22 {
23  std::vector<edm::InputTag> simhits_tags = iConfig.getParameter<std::vector<edm::InputTag> >("InputTags");
24  for(auto itag : simhits_tags) {
25  simhits_tokens_.push_back(
26  consumes< std::vector<PSimHit> >(itag)
27  );
28  }
29 
30  produces <std::vector<unsigned> > ( Prefix + "hits" );
31  produces <std::vector<float> > ( Prefix + "strip" );
32  produces <std::vector<float> > ( Prefix + "localtheta" );
33  produces <std::vector<float> > ( Prefix + "localphi" );
34  produces <std::vector<float> > ( Prefix + "localx" );
35  produces <std::vector<float> > ( Prefix + "localy" );
36  produces <std::vector<float> > ( Prefix + "localz" );
37  produces <std::vector<float> > ( Prefix + "momentum" );
38  produces <std::vector<float> > ( Prefix + "energyloss" );
39  produces <std::vector<float> > ( Prefix + "time" );
40  produces <std::vector<int> > ( Prefix + "particle" );
41  produces <std::vector<unsigned short> > ( Prefix + "process" );
42 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simhits_tokens_

Member Function Documentation

shallow::CLUSTERMAP::const_iterator ShallowSimhitClustersProducer::match_cluster ( const unsigned &  id,
const float &  strip_,
const shallow::CLUSTERMAP clustermap,
const edmNew::DetSetVector< SiStripCluster > &  clusters 
) const
private

Definition at line 115 of file ShallowSimhitClustersProducer.cc.

References edmNew::DetSetVector< T >::begin(), edmNew::DetSetVector< T >::end(), and edmNew::DetSetVector< T >::find().

Referenced by produce().

115  {
116  shallow::CLUSTERMAP::const_iterator cluster = clustermap.end();
117  edmNew::DetSetVector<SiStripCluster>::const_iterator clustersDetSet = clusters.find(id);
118  if( clustersDetSet != clusters.end() ) {
119  edmNew::DetSet<SiStripCluster>::const_iterator left, right=clustersDetSet->begin();
120  while( right != clustersDetSet->end() && strip_ > right->barycenter() )
121  right++;
122  left = right-1;
123  if(right!=clustersDetSet->end() && right!=clustersDetSet->begin()) {
124  unsigned firstStrip = (right->barycenter()-strip_) < (strip_-left->barycenter()) ? right->firstStrip() : left->firstStrip();
125  cluster = clustermap.find( std::make_pair( id, firstStrip));
126  }
127  else if(right != clustersDetSet->begin())
128  cluster = clustermap.find( std::make_pair( id, left->firstStrip()));
129  else
130  cluster = clustermap.find( std::make_pair( id, right->firstStrip()));
131  }
132  return cluster;
133 }
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
data_type const * const_iterator
Definition: DetSetNew.h:30
const_iterator find(id_type i, bool update=false) const
const_iterator begin(bool update=false) const
void ShallowSimhitClustersProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 45 of file ShallowSimhitClustersProducer.cc.

References fastPrimaryVertexProducer_cfi::clusters, clusters_token_, shallow::drift(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::getByToken(), hfClusterShapes_cfi::hits, mps_fire::i, shallow::make_cluster_map(), match_cluster(), eostools::move(), Prefix, LaserDQM_cfg::process, edm::Event::put(), runningmode_, simhits_tokens_, findQualityFiles::size, StripGeomDetUnit::specificTopology(), digitizers_cfi::strip, StripTopology::strip(), ntuplemaker::time, hit::x, hit::y, and hit::z.

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

45  {
47 
48  int size = clustermap.size();
49  auto hits = std::make_unique <std::vector<unsigned>> (size, 0);
50  auto strip = std::make_unique <std::vector<float>> (size, -100);
51  auto localtheta = std::make_unique <std::vector<float>> (size, -100);
52  auto localphi = std::make_unique <std::vector<float>> (size, -100);
53  auto localx = std::make_unique <std::vector<float>> (size, -100);
54  auto localy = std::make_unique <std::vector<float>> (size, -100);
55  auto localz = std::make_unique <std::vector<float>> (size, -100);
56  auto momentum = std::make_unique <std::vector<float>> (size, 0);
57  auto energyloss = std::make_unique <std::vector<float>> (size, -1);
58  auto time = std::make_unique <std::vector<float>> (size, -1);
59  auto particle = std::make_unique <std::vector<int>> (size, -500);
60  auto process = std::make_unique <std::vector<unsigned short>> (size, 0);
61 
62  edm::ESHandle<TrackerGeometry> theTrackerGeometry; iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
63  edm::ESHandle<MagneticField> magfield; iSetup.get<IdealMagneticFieldRecord>().get(magfield);
65  edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusters; iEvent.getByLabel("siStripClusters", "", clusters);
66 
67  for(auto& simhit_token : simhits_tokens_) {
69  iEvent.getByToken(simhit_token, simhits);
70  for(auto const& hit : *simhits ) {
71 
72  const uint32_t id = hit.detUnitId();
73  const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( id ) );
74  const LocalVector drift = shallow::drift(theStripDet, *magfield, *SiStripLorentzAngle);
75 
76  const float driftedstrip_ = theStripDet->specificTopology().strip( hit.localPosition()+0.5*drift );
77  const float hitstrip_ = theStripDet->specificTopology().strip( hit.localPosition() );
78 
79  shallow::CLUSTERMAP::const_iterator cluster = match_cluster( id, driftedstrip_, clustermap, *clusters);
80  if(cluster != clustermap.end()) {
81  unsigned i = cluster->second;
82  hits->at(i)+=1;
83  if(hits->at(i) == 1) {
84  strip->at(i) = hitstrip_;
85  localtheta->at(i) = hit.thetaAtEntry();
86  localphi->at(i) = hit.phiAtEntry();
87  localx->at(i) = hit.localPosition().x();
88  localy->at(i) = hit.localPosition().y();
89  localz->at(i) = hit.localPosition().z();
90  momentum->at(i) = hit.pabs();
91  energyloss->at(i) = hit.energyLoss();
92  time->at(i) = hit.timeOfFlight();
93  particle->at(i) = hit.particleType();
94  process->at(i) = hit.processType();
95  }
96  }
97  }
98  }
99 
100  iEvent.put(std::move(hits), Prefix + "hits" );
101  iEvent.put(std::move(strip), Prefix + "strip" );
102  iEvent.put(std::move(localtheta), Prefix + "localtheta" );
103  iEvent.put(std::move(localphi), Prefix + "localphi" );
104  iEvent.put(std::move(localx), Prefix + "localx" );
105  iEvent.put(std::move(localy), Prefix + "localy" );
106  iEvent.put(std::move(localz), Prefix + "localz" );
107  iEvent.put(std::move(momentum), Prefix + "momentum" );
108  iEvent.put(std::move(energyloss), Prefix + "energyloss" );
109  iEvent.put(std::move(time), Prefix + "time" );
110  iEvent.put(std::move(particle), Prefix + "particle" );
111  iEvent.put(std::move(process), Prefix + "process" );
112 }
size
Write out results.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
shallow::CLUSTERMAP::const_iterator match_cluster(const unsigned &, const float &, const shallow::CLUSTERMAP &, const edmNew::DetSetVector< SiStripCluster > &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:37
virtual float strip(const LocalPoint &) const =0
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
CLUSTERMAP make_cluster_map(const edm::Event &, const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > &)
Definition: ShallowTools.cc:13
std::map< std::pair< uint32_t, uint16_t >, unsigned int > CLUSTERMAP
Definition: ShallowTools.h:19
T get() const
Definition: EventSetup.h:71
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simhits_tokens_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const edm::EDGetTokenT< edmNew::DetSetVector<SiStripCluster> > ShallowSimhitClustersProducer::clusters_token_
private

Definition at line 18 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

std::string ShallowSimhitClustersProducer::Prefix
private

Definition at line 19 of file ShallowSimhitClustersProducer.h.

Referenced by produce(), and ShallowSimhitClustersProducer().

std::string ShallowSimhitClustersProducer::runningmode_
private

Definition at line 20 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

std::vector< edm::EDGetTokenT< std::vector<PSimHit> > > ShallowSimhitClustersProducer::simhits_tokens_
private

Definition at line 17 of file ShallowSimhitClustersProducer.h.

Referenced by produce(), and ShallowSimhitClustersProducer().