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::stream::EDProducer<>

Public Member Functions

 ShallowSimhitClustersProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordgeomToken_
 
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcdlaToken_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagFieldToken_
 
std::string Prefix
 
std::string runningmode_
 
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simhits_tokens_
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 18 of file ShallowSimhitClustersProducer.h.

Constructor & Destructor Documentation

◆ ShallowSimhitClustersProducer()

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

Definition at line 11 of file ShallowSimhitClustersProducer.cc.

13  geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
14  magFieldToken_(esConsumes<MagneticField, IdealMagneticFieldRecord>()),
15  laToken_(esConsumes<SiStripLorentzAngle, SiStripLorentzAngleRcd>(
16  edm::ESInputTag{"", iConfig.getParameter<std::string>("runningMode")})),
17  Prefix(iConfig.getParameter<std::string>("Prefix")),
18  runningmode_(iConfig.getParameter<std::string>("runningMode")) {
19  std::vector<edm::InputTag> simhits_tags = iConfig.getParameter<std::vector<edm::InputTag>>("InputTags");
20  for (const auto& itag : simhits_tags) {
21  simhits_tokens_.push_back(consumes<std::vector<PSimHit>>(itag));
22  }
23 
24  produces<std::vector<unsigned>>(Prefix + "hits");
25  produces<std::vector<float>>(Prefix + "strip");
26  produces<std::vector<float>>(Prefix + "localtheta");
27  produces<std::vector<float>>(Prefix + "localphi");
28  produces<std::vector<float>>(Prefix + "localx");
29  produces<std::vector<float>>(Prefix + "localy");
30  produces<std::vector<float>>(Prefix + "localz");
31  produces<std::vector<float>>(Prefix + "momentum");
32  produces<std::vector<float>>(Prefix + "energyloss");
33  produces<std::vector<float>>(Prefix + "time");
34  produces<std::vector<int>>(Prefix + "particle");
35  produces<std::vector<unsigned short>>(Prefix + "process");
36 }

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

Member Function Documentation

◆ match_cluster()

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 107 of file ShallowSimhitClustersProducer.cc.

111  {
112  shallow::CLUSTERMAP::const_iterator cluster = clustermap.end();
114  if (clustersDetSet != clusters.end()) {
115  edmNew::DetSet<SiStripCluster>::const_iterator left, right = clustersDetSet->begin();
116  while (right != clustersDetSet->end() && strip_ > right->barycenter())
117  right++;
118  left = right - 1;
119  if (right != clustersDetSet->end() && right != clustersDetSet->begin()) {
120  unsigned firstStrip =
121  (right->barycenter() - strip_) < (strip_ - left->barycenter()) ? right->firstStrip() : left->firstStrip();
122  cluster = clustermap.find(std::make_pair(id, firstStrip));
123  } else if (right != clustersDetSet->begin())
124  cluster = clustermap.find(std::make_pair(id, left->firstStrip()));
125  else
126  cluster = clustermap.find(std::make_pair(id, right->firstStrip()));
127  }
128  return cluster;
129 }

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

Referenced by produce().

◆ produce()

void ShallowSimhitClustersProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 38 of file ShallowSimhitClustersProducer.cc.

38  {
40 
41  int size = clustermap.size();
42  auto hits = std::make_unique<std::vector<unsigned>>(size, 0);
43  auto strip = std::make_unique<std::vector<float>>(size, -100);
44  auto localtheta = std::make_unique<std::vector<float>>(size, -100);
45  auto localphi = std::make_unique<std::vector<float>>(size, -100);
46  auto localx = std::make_unique<std::vector<float>>(size, -100);
47  auto localy = std::make_unique<std::vector<float>>(size, -100);
48  auto localz = std::make_unique<std::vector<float>>(size, -100);
49  auto momentum = std::make_unique<std::vector<float>>(size, 0);
50  auto energyloss = std::make_unique<std::vector<float>>(size, -1);
51  auto time = std::make_unique<std::vector<float>>(size, -1);
52  auto particle = std::make_unique<std::vector<int>>(size, -500);
53  auto process = std::make_unique<std::vector<unsigned short>>(size, 0);
54 
55  edm::ESHandle<TrackerGeometry> theTrackerGeometry = iSetup.getHandle(geomToken_);
59  iEvent.getByLabel("siStripClusters", "", clusters);
60 
61  for (auto& simhit_token : simhits_tokens_) {
63  iEvent.getByToken(simhit_token, simhits);
64  for (auto const& hit : *simhits) {
65  const uint32_t id = hit.detUnitId();
66  const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTrackerGeometry->idToDet(id));
68 
69  const float driftedstrip_ = theStripDet->specificTopology().strip(hit.localPosition() + 0.5 * drift);
70  const float hitstrip_ = theStripDet->specificTopology().strip(hit.localPosition());
71 
72  shallow::CLUSTERMAP::const_iterator cluster = match_cluster(id, driftedstrip_, clustermap, *clusters);
73  if (cluster != clustermap.end()) {
74  unsigned i = cluster->second;
75  hits->at(i) += 1;
76  if (hits->at(i) == 1) {
77  strip->at(i) = hitstrip_;
78  localtheta->at(i) = hit.thetaAtEntry();
79  localphi->at(i) = hit.phiAtEntry();
80  localx->at(i) = hit.localPosition().x();
81  localy->at(i) = hit.localPosition().y();
82  localz->at(i) = hit.localPosition().z();
83  momentum->at(i) = hit.pabs();
84  energyloss->at(i) = hit.energyLoss();
85  time->at(i) = hit.timeOfFlight();
86  particle->at(i) = hit.particleType();
87  process->at(i) = hit.processType();
88  }
89  }
90  }
91  }
92 
93  iEvent.put(std::move(hits), Prefix + "hits");
94  iEvent.put(std::move(strip), Prefix + "strip");
95  iEvent.put(std::move(localtheta), Prefix + "localtheta");
96  iEvent.put(std::move(localphi), Prefix + "localphi");
97  iEvent.put(std::move(localx), Prefix + "localx");
98  iEvent.put(std::move(localy), Prefix + "localy");
99  iEvent.put(std::move(localz), Prefix + "localz");
100  iEvent.put(std::move(momentum), Prefix + "momentum");
101  iEvent.put(std::move(energyloss), Prefix + "energyloss");
102  iEvent.put(std::move(time), Prefix + "time");
103  iEvent.put(std::move(particle), Prefix + "particle");
104  iEvent.put(std::move(process), Prefix + "process");
105 }

References bsc_activity_cfg::clusters, clusters_token_, shallow::drift(), geomToken_, edm::EventSetup::getHandle(), hfClusterShapes_cfi::hits, mps_fire::i, iEvent, laToken_, volumeBasedMagneticField_160812_cfi::magfield, magFieldToken_, shallow::make_cluster_map(), match_cluster(), eostools::move(), Prefix, LaserDQM_cfg::process, HLTBitAnalyser_cfi::simhits, simhits_tokens_, findQualityFiles::size, StripGeomDetUnit::specificTopology(), digitizers_cfi::strip, StripTopology::strip(), ntuplemaker::time, hit::x, hit::y, and hit::z.

Member Data Documentation

◆ clusters_token_

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

Definition at line 24 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

◆ geomToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> ShallowSimhitClustersProducer::geomToken_
private

Definition at line 25 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

◆ laToken_

const edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleRcd> ShallowSimhitClustersProducer::laToken_
private

Definition at line 27 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

◆ magFieldToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> ShallowSimhitClustersProducer::magFieldToken_
private

Definition at line 26 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

◆ Prefix

std::string ShallowSimhitClustersProducer::Prefix
private

Definition at line 28 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

◆ runningmode_

std::string ShallowSimhitClustersProducer::runningmode_
private

Definition at line 29 of file ShallowSimhitClustersProducer.h.

◆ simhits_tokens_

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

Definition at line 23 of file ShallowSimhitClustersProducer.h.

Referenced by produce().

Vector3DBase< float, LocalTag >
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
ShallowSimhitClustersProducer::simhits_tokens_
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simhits_tokens_
Definition: ShallowSimhitClustersProducer.h:23
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
hit::y
double y
Definition: SiStripHitEffFromCalibTree.cc:90
ShallowSimhitClustersProducer::runningmode_
std::string runningmode_
Definition: ShallowSimhitClustersProducer.h:29
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
ShallowSimhitClustersProducer::match_cluster
shallow::CLUSTERMAP::const_iterator match_cluster(const unsigned &, const float &, const shallow::CLUSTERMAP &, const edmNew::DetSetVector< SiStripCluster > &) const
Definition: ShallowSimhitClustersProducer.cc:107
ShallowSimhitClustersProducer::laToken_
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > laToken_
Definition: ShallowSimhitClustersProducer.h:27
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:197
edmNew::DetSetVector::begin
const_iterator begin(bool update=false) const
Definition: DetSetVectorNew.h:530
edm::Handle
Definition: AssociativeIterator.h:50
hit::x
double x
Definition: SiStripHitEffFromCalibTree.cc:89
shallow::drift
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:36
SiStripLorentzAngle
Definition: SiStripLorentzAngle.h:26
edm::ESHandle< TrackerGeometry >
StripTopology::strip
virtual float strip(const LocalPoint &) const =0
hit::z
double z
Definition: SiStripHitEffFromCalibTree.cc:91
ShallowSimhitClustersProducer::clusters_token_
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
Definition: ShallowSimhitClustersProducer.h:24
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
HLTBitAnalyser_cfi.simhits
simhits
SIM objects.
Definition: HLTBitAnalyser_cfi.py:21
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edmNew::DetSetVector
Definition: DetSetNew.h:13
shallow::make_cluster_map
CLUSTERMAP make_cluster_map(const edm::Event &, const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > &)
Definition: ShallowTools.cc:12
eostools.move
def move(src, dest)
Definition: eostools.py:511
ShallowSimhitClustersProducer::Prefix
std::string Prefix
Definition: ShallowSimhitClustersProducer.h:28
ShallowSimhitClustersProducer::magFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
Definition: ShallowSimhitClustersProducer.h:26
edmNew::DetSetVector::end
const_iterator end(bool update=false) const
Definition: DetSetVectorNew.h:535
ShallowSimhitClustersProducer::geomToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
Definition: ShallowSimhitClustersProducer.h:25
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
StripGeomDetUnit::specificTopology
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Definition: StripGeomDetUnit.cc:17
ntuplemaker.time
time
Definition: ntuplemaker.py:310
volumeBasedMagneticField_160812_cfi.magfield
magfield
Definition: volumeBasedMagneticField_160812_cfi.py:11
edm::InputTag
Definition: InputTag.h:15
shallow::CLUSTERMAP
std::map< std::pair< uint32_t, uint16_t >, unsigned int > CLUSTERMAP
Definition: ShallowTools.h:21
hit
Definition: SiStripHitEffFromCalibTree.cc:88
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31