CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
GEMRecHitProducer Class Reference

#include <GEMRecHitProducer.h>

Inheritance diagram for GEMRecHitProducer:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 GEMRecHitProducer (const edm::ParameterSet &config)
 Constructor. More...
 
void produce (edm::Event &event, const edm::EventSetup &setup) override
 The method which produces the rechits. More...
 
 ~GEMRecHitProducer () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

enum  MaskSource { MaskSource::File, MaskSource::EventSetup }
 

Private Attributes

bool applyMasking_
 
enum GEMRecHitProducer::MaskSource deadSource_
 
edm::ESGetToken< GEMDeadStrips, GEMDeadStripsRcddeadStripsToken_
 
bool ge21Off_
 
edm::ESHandle< GEMGeometrygemGeom_
 
edm::ESGetToken< GEMGeometry, MuonGeometryRecordgemGeomToken_
 
std::map< GEMDetId, EtaPartitionMaskgemMask_
 
edm::ESGetToken< GEMMaskedStrips, GEMMaskedStripsRcdmaskedStripsToken_
 
enum GEMRecHitProducer::MaskSource maskSource_
 
std::unique_ptr< GEMRecHitBaseAlgotheAlgo
 
std::unique_ptr< GEMDeadStripstheGEMDeadStripsObj
 
edm::EDGetTokenT< GEMDigiCollectiontheGEMDigiToken
 
std::unique_ptr< GEMMaskedStripstheGEMMaskedStripsObj
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Module for GEMRecHit production.

Author
M. Maggim – INFN Bari

Definition at line 27 of file GEMRecHitProducer.h.

Member Enumeration Documentation

◆ MaskSource

enum GEMRecHitProducer::MaskSource
strongprivate
Enumerator
File 
EventSetup 

Definition at line 56 of file GEMRecHitProducer.h.

enum GEMRecHitProducer::MaskSource deadSource_
enum GEMRecHitProducer::MaskSource maskSource_

Constructor & Destructor Documentation

◆ GEMRecHitProducer()

GEMRecHitProducer::GEMRecHitProducer ( const edm::ParameterSet config)

Constructor.

Definition at line 22 of file GEMRecHitProducer.cc.

References get.

23  : theGEMDigiToken(consumes<GEMDigiCollection>(config.getParameter<InputTag>("gemDigiLabel"))),
24  // Get the concrete reconstruction algo from the factory
25  theAlgo{GEMRecHitAlgoFactory::get()->create(config.getParameter<string>("recAlgo"),
26  config.getParameter<ParameterSet>("recAlgoConfig"))},
29  gemGeomToken_(esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>()) {
30  produces<GEMRecHitCollection>();
31 
32  // Turns off GE2/1 demonstrator reconstruction in Run3
33  ge21Off_ = config.getParameter<bool>("ge21Off");
34  // Get masked- and dead-strip information from file
35  applyMasking_ = config.getParameter<bool>("applyMasking");
36  if (applyMasking_) {
37  if (config.existsAs<edm::FileInPath>("maskFile")) {
39  std::ifstream inputFile(config.getParameter<edm::FileInPath>("maskFile").fullPath());
40  if (!inputFile) {
41  throw cms::Exception("GEMRecHitProducer") << "Masked Strips File cannot not be opened";
42  }
43  theGEMMaskedStripsObj = std::make_unique<GEMMaskedStrips>();
44  while (inputFile.good()) {
46  inputFile >> Item.rawId >> Item.strip;
47  if (inputFile.good())
48  theGEMMaskedStripsObj->fillMaskVec(Item);
49  }
50  inputFile.close();
51  }
52 
53  if (config.existsAs<edm::FileInPath>("deadFile")) {
55  std::ifstream inputFile(config.getParameter<edm::FileInPath>("deadFile").fullPath());
56  if (!inputFile) {
57  throw cms::Exception("GEMRecHitProducer") << "Dead Strips File cannot not be opened";
58  }
59  theGEMDeadStripsObj = std::make_unique<GEMDeadStrips>();
60  while (inputFile.good()) {
62  inputFile >> Item.rawId >> Item.strip;
63  if (inputFile.good())
64  theGEMDeadStripsObj->fillDeadVec(Item);
65  }
66  inputFile.close();
67  }
69  maskedStripsToken_ = esConsumes<GEMMaskedStrips, GEMMaskedStripsRcd, edm::Transition::BeginRun>();
70  }
72  deadStripsToken_ = esConsumes<GEMDeadStrips, GEMDeadStripsRcd, edm::Transition::BeginRun>();
73  }
74  }
75 }
edm::ESGetToken< GEMMaskedStrips, GEMMaskedStripsRcd > maskedStripsToken_
std::string fullPath() const
Definition: FileInPath.cc:161
enum GEMRecHitProducer::MaskSource deadSource_
Definition: config.py:1
edm::ESGetToken< GEMDeadStrips, GEMDeadStripsRcd > deadStripsToken_
std::unique_ptr< GEMDeadStrips > theGEMDeadStripsObj
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
std::unique_ptr< GEMMaskedStrips > theGEMMaskedStripsObj
enum GEMRecHitProducer::MaskSource maskSource_
std::unique_ptr< GEMRecHitBaseAlgo > theAlgo
#define get
edm::EDGetTokenT< GEMDigiCollection > theGEMDigiToken

◆ ~GEMRecHitProducer()

GEMRecHitProducer::~GEMRecHitProducer ( )
overridedefault

Destructor.

Member Function Documentation

◆ beginRun()

void GEMRecHitProducer::beginRun ( const edm::Run r,
const edm::EventSetup setup 
)
override

Definition at line 92 of file GEMRecHitProducer.cc.

References applyMasking_, triggerObjects_cff::bit, deadSource_, deadStripsToken_, GEMGeometry::etaPartitions(), EventSetup, ge21Off_, gemGeom_, gemGeomToken_, gemMask_, gpuClustering::pixelStatus::mask, maskedStripsToken_, maskSource_, edm::ESHandle< T >::product(), DetId::rawId(), singleTopDQM_cfi::setup, GEMDetId::station(), theGEMDeadStripsObj, and theGEMMaskedStripsObj.

92  {
93  // Get the GEM Geometry
94  gemGeom_ = setup.getHandle(gemGeomToken_);
95 
96  if (applyMasking_) {
97  // Getting the masked-strip information
99  edm::ESHandle<GEMMaskedStrips> readoutMaskedStrips = setup.getHandle(maskedStripsToken_);
100  theGEMMaskedStripsObj = std::make_unique<GEMMaskedStrips>(*readoutMaskedStrips.product());
101  }
102  // Getting the dead-strip information
104  edm::ESHandle<GEMDeadStrips> readoutDeadStrips = setup.getHandle(deadStripsToken_);
105  theGEMDeadStripsObj = std::make_unique<GEMDeadStrips>(*readoutDeadStrips.product());
106  }
107 
108  for (auto gems : gemGeom_->etaPartitions()) {
109  // Getting the EtaPartitionMask mask, that includes dead strips, for the given GEMDet
110  GEMDetId gemId = gems->id();
111  if (ge21Off_ && gemId.station() == 2) {
112  continue;
113  }
115  const int rawId = gemId.rawId();
116  for (const auto& tomask : theGEMMaskedStripsObj->getMaskVec()) {
117  if (tomask.rawId == rawId) {
118  const int bit = tomask.strip;
119  mask.set(bit);
120  }
121  }
122  for (const auto& tomask : theGEMDeadStripsObj->getDeadVec()) {
123  if (tomask.rawId == rawId) {
124  const int bit = tomask.strip;
125  mask.set(bit);
126  }
127  }
128  // add to masking map if masking present in etaPartition
129  if (mask.any()) {
130  gemMask_.emplace(gemId, mask);
131  }
132  }
133  }
134 }
constexpr int station() const
Definition: GEMDetId.h:179
edm::ESGetToken< GEMMaskedStrips, GEMMaskedStripsRcd > maskedStripsToken_
enum GEMRecHitProducer::MaskSource deadSource_
constexpr uint32_t mask
Definition: gpuClustering.h:26
T const * product() const
Definition: ESHandle.h:86
edm::ESGetToken< GEMDeadStrips, GEMDeadStripsRcd > deadStripsToken_
edm::ESHandle< GEMGeometry > gemGeom_
std::unique_ptr< GEMDeadStrips > theGEMDeadStripsObj
std::bitset< maskSIZE > EtaPartitionMask
std::map< GEMDetId, EtaPartitionMask > gemMask_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
std::unique_ptr< GEMMaskedStrips > theGEMMaskedStripsObj
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
enum GEMRecHitProducer::MaskSource maskSource_
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40

◆ fillDescriptions()

void GEMRecHitProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 79 of file GEMRecHitProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

79  {
81  edm::ParameterSetDescription recAlgoConfigDesc;
82  desc.add<edm::ParameterSetDescription>("recAlgoConfig", recAlgoConfigDesc);
83  desc.add<std::string>("recAlgo", "GEMRecHitStandardAlgo");
84  desc.add<edm::InputTag>("gemDigiLabel", edm::InputTag("muonGEMDigis"));
85  desc.add<bool>("applyMasking", false);
86  desc.add<bool>("ge21Off", false);
87  desc.addOptional<edm::FileInPath>("maskFile");
88  desc.addOptional<edm::FileInPath>("deadFile");
89  descriptions.add("gemRecHitsDef", desc);
90 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void GEMRecHitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

The method which produces the rechits.

Definition at line 136 of file GEMRecHitProducer.cc.

References applyMasking_, GEMGeometry::etaPartition(), ge21Off_, gemGeom_, gemMask_, gpuClustering::pixelStatus::mask, eostools::move(), FastTimerService_cff::range, FastTrackerRecHitMaskProducer_cfi::recHits, singleTopDQM_cfi::setup, GEMDetId::station(), theAlgo, and theGEMDigiToken.

136  {
137  // Get the digis from the event
139  event.getByToken(theGEMDigiToken, digis);
140 
141  // Pass the EventSetup to the algo
142  theAlgo->setES(setup);
143 
144  // Create the pointer to the collection which will store the rechits
145  auto recHitCollection = std::make_unique<GEMRecHitCollection>();
146 
147  // Iterate through all digi collections ordered by LayerId
148  for (auto gemdgIt = digis->begin(); gemdgIt != digis->end(); ++gemdgIt) {
149  // The layerId
150  const GEMDetId& gemId = (*gemdgIt).first;
151  if (ge21Off_ && gemId.station() == 2) {
152  continue;
153  }
154 
155  // Get the GeomDet from the setup
156  const GEMEtaPartition* roll = gemGeom_->etaPartition(gemId);
157  if (roll == nullptr) {
158  edm::LogError("BadDigiInput") << "Failed to find GEMEtaPartition for ID " << gemId;
159  continue;
160  }
161 
162  // Get the iterators over the digis associated with this LayerId
163  const GEMDigiCollection::Range& range = (*gemdgIt).second;
164 
165  // get mask from map
167  if (applyMasking_) {
168  auto gemmaskIt = gemMask_.find(gemId);
169  if (gemmaskIt != gemMask_.end())
170  mask = gemmaskIt->second;
171  }
172 
173  // Call the reconstruction algorithm
174  OwnVector<GEMRecHit> recHits = theAlgo->reconstruct(*roll, gemId, range, mask);
175 
176  if (!recHits.empty()) //FIXME: is it really needed?
177  recHitCollection->put(gemId, recHits.begin(), recHits.end());
178  }
179 
180  event.put(std::move(recHitCollection));
181 }
constexpr int station() const
Definition: GEMDetId.h:179
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:77
Log< level::Error, false > LogError
constexpr uint32_t mask
Definition: gpuClustering.h:26
edm::ESHandle< GEMGeometry > gemGeom_
std::bitset< maskSIZE > EtaPartitionMask
std::map< GEMDetId, EtaPartitionMask > gemMask_
std::pair< const_iterator, const_iterator > Range
std::unique_ptr< GEMRecHitBaseAlgo > theAlgo
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< GEMDigiCollection > theGEMDigiToken

Member Data Documentation

◆ applyMasking_

bool GEMRecHitProducer::applyMasking_
private

Definition at line 67 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

◆ deadSource_

enum GEMRecHitProducer::MaskSource GEMRecHitProducer::deadSource_
private

Referenced by beginRun().

◆ deadStripsToken_

edm::ESGetToken<GEMDeadStrips, GEMDeadStripsRcd> GEMRecHitProducer::deadStripsToken_
private

Definition at line 62 of file GEMRecHitProducer.h.

Referenced by beginRun().

◆ ge21Off_

bool GEMRecHitProducer::ge21Off_
private

Definition at line 68 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

◆ gemGeom_

edm::ESHandle<GEMGeometry> GEMRecHitProducer::gemGeom_
private

Definition at line 58 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

◆ gemGeomToken_

edm::ESGetToken<GEMGeometry, MuonGeometryRecord> GEMRecHitProducer::gemGeomToken_
private

Definition at line 60 of file GEMRecHitProducer.h.

Referenced by beginRun().

◆ gemMask_

std::map<GEMDetId, EtaPartitionMask> GEMRecHitProducer::gemMask_
private

Definition at line 65 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

◆ maskedStripsToken_

edm::ESGetToken<GEMMaskedStrips, GEMMaskedStripsRcd> GEMRecHitProducer::maskedStripsToken_
private

Definition at line 61 of file GEMRecHitProducer.h.

Referenced by beginRun().

◆ maskSource_

enum GEMRecHitProducer::MaskSource GEMRecHitProducer::maskSource_
private

Referenced by beginRun().

◆ theAlgo

std::unique_ptr<GEMRecHitBaseAlgo> GEMRecHitProducer::theAlgo
private

Definition at line 48 of file GEMRecHitProducer.h.

Referenced by produce().

◆ theGEMDeadStripsObj

std::unique_ptr<GEMDeadStrips> GEMRecHitProducer::theGEMDeadStripsObj
private

Definition at line 54 of file GEMRecHitProducer.h.

Referenced by beginRun().

◆ theGEMDigiToken

edm::EDGetTokenT<GEMDigiCollection> GEMRecHitProducer::theGEMDigiToken
private

Definition at line 45 of file GEMRecHitProducer.h.

Referenced by produce().

◆ theGEMMaskedStripsObj

std::unique_ptr<GEMMaskedStrips> GEMRecHitProducer::theGEMMaskedStripsObj
private

Definition at line 51 of file GEMRecHitProducer.h.

Referenced by beginRun().