CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
GEMDeadStripsRcd
deadStripsToken_
 
edm::ESHandle< GEMGeometrygemGeom_
 
edm::ESGetToken< GEMGeometry,
MuonGeometryRecord
gemGeomToken_
 
std::map< GEMDetId,
EtaPartitionMask
gemMask_
 
edm::ESGetToken
< GEMMaskedStrips,
GEMMaskedStripsRcd
maskedStripsToken_
 
enum GEMRecHitProducer::MaskSource maskSource_
 
std::unique_ptr
< GEMRecHitBaseAlgo
theAlgo
 
std::unique_ptr< GEMDeadStripstheGEMDeadStripsObj
 
edm::EDGetTokenT
< GEMDigiCollection
theGEMDigiToken
 
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

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 ( const edm::ParameterSet config)

Constructor.

Definition at line 22 of file GEMRecHitProducer.cc.

References get, and edm::ParameterSet::getParameter().

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  // Get masked- and dead-strip information from file
33  applyMasking_ = config.getParameter<bool>("applyMasking");
34  if (applyMasking_) {
35  if (config.existsAs<edm::FileInPath>("maskFile")) {
37  std::ifstream inputFile(config.getParameter<edm::FileInPath>("maskFile").fullPath());
38  if (!inputFile) {
39  throw cms::Exception("GEMRecHitProducer") << "Masked Strips File cannot not be opened";
40  }
41  theGEMMaskedStripsObj = std::make_unique<GEMMaskedStrips>();
42  while (inputFile.good()) {
44  inputFile >> Item.rawId >> Item.strip;
45  if (inputFile.good())
46  theGEMMaskedStripsObj->fillMaskVec(Item);
47  }
48  inputFile.close();
49  }
50 
51  if (config.existsAs<edm::FileInPath>("deadFile")) {
53  std::ifstream inputFile(config.getParameter<edm::FileInPath>("deadFile").fullPath());
54  if (!inputFile) {
55  throw cms::Exception("GEMRecHitProducer") << "Dead Strips File cannot not be opened";
56  }
57  theGEMDeadStripsObj = std::make_unique<GEMDeadStrips>();
58  while (inputFile.good()) {
60  inputFile >> Item.rawId >> Item.strip;
61  if (inputFile.good())
62  theGEMDeadStripsObj->fillDeadVec(Item);
63  }
64  inputFile.close();
65  }
67  maskedStripsToken_ = esConsumes<GEMMaskedStrips, GEMMaskedStripsRcd, edm::Transition::BeginRun>();
68  }
70  deadStripsToken_ = esConsumes<GEMDeadStrips, GEMDeadStripsRcd, edm::Transition::BeginRun>();
71  }
72  }
73 }
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::ESGetToken< GEMMaskedStrips, GEMMaskedStripsRcd > maskedStripsToken_
enum GEMRecHitProducer::MaskSource deadSource_
edm::ESGetToken< GEMDeadStrips, GEMDeadStripsRcd > deadStripsToken_
std::unique_ptr< GEMDeadStrips > theGEMDeadStripsObj
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
std::unique_ptr< GEMMaskedStrips > theGEMMaskedStripsObj
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
enum GEMRecHitProducer::MaskSource maskSource_
std::string fullPath() const
Definition: FileInPath.cc:161
std::unique_ptr< GEMRecHitBaseAlgo > theAlgo
#define get
edm::EDGetTokenT< GEMDigiCollection > theGEMDigiToken
GEMRecHitProducer::~GEMRecHitProducer ( )
overridedefault

Destructor.

Member Function Documentation

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

Definition at line 89 of file GEMRecHitProducer.cc.

References deadSource_, deadStripsToken_, EventSetup, gemGeom_, gemGeomToken_, gemMask_, edm::EventSetup::getHandle(), maskedStripsToken_, maskSource_, edm::ESHandle< class >::product(), DetId::rawId(), theGEMDeadStripsObj, and theGEMMaskedStripsObj.

89  {
90  // Get the GEM Geometry
92 
93  if (applyMasking_) {
94  // Getting the masked-strip information
96  edm::ESHandle<GEMMaskedStrips> readoutMaskedStrips = setup.getHandle(maskedStripsToken_);
97  theGEMMaskedStripsObj = std::make_unique<GEMMaskedStrips>(*readoutMaskedStrips.product());
98  }
99  // Getting the dead-strip information
101  edm::ESHandle<GEMDeadStrips> readoutDeadStrips = setup.getHandle(deadStripsToken_);
102  theGEMDeadStripsObj = std::make_unique<GEMDeadStrips>(*readoutDeadStrips.product());
103  }
104 
105  for (auto gems : gemGeom_->etaPartitions()) {
106  // Getting the EtaPartitionMask mask, that includes dead strips, for the given GEMDet
107  GEMDetId gemId = gems->id();
108  EtaPartitionMask mask;
109  const int rawId = gemId.rawId();
110  for (const auto& tomask : theGEMMaskedStripsObj->getMaskVec()) {
111  if (tomask.rawId == rawId) {
112  const int bit = tomask.strip;
113  mask.set(bit);
114  }
115  }
116  for (const auto& tomask : theGEMDeadStripsObj->getDeadVec()) {
117  if (tomask.rawId == rawId) {
118  const int bit = tomask.strip;
119  mask.set(bit);
120  }
121  }
122  // add to masking map if masking present in etaPartition
123  if (mask.any()) {
124  gemMask_.emplace(gemId, mask);
125  }
126  }
127  }
128 }
edm::ESGetToken< GEMMaskedStrips, GEMMaskedStripsRcd > maskedStripsToken_
enum GEMRecHitProducer::MaskSource deadSource_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
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
T const * product() const
Definition: ESHandle.h:86
enum GEMRecHitProducer::MaskSource maskSource_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
void GEMRecHitProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 77 of file GEMRecHitProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

77  {
79  edm::ParameterSetDescription recAlgoConfigDesc;
80  desc.add<edm::ParameterSetDescription>("recAlgoConfig", recAlgoConfigDesc);
81  desc.add<std::string>("recAlgo", "GEMRecHitStandardAlgo");
82  desc.add<edm::InputTag>("gemDigiLabel", edm::InputTag("muonGEMDigis"));
83  desc.add<bool>("applyMasking", false);
84  desc.addOptional<edm::FileInPath>("maskFile");
85  desc.addOptional<edm::FileInPath>("deadFile");
86  descriptions.add("gemRecHitsDef", desc);
87 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void GEMRecHitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

The method which produces the rechits.

Definition at line 130 of file GEMRecHitProducer.cc.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::empty(), edm::OwnVector< T, P >::end(), gemGeom_, gemMask_, eostools::move(), sistrip::SpyUtilities::range(), HLT_FULL_cff::recHits, theAlgo, and theGEMDigiToken.

130  {
131  // Get the digis from the event
133  event.getByToken(theGEMDigiToken, digis);
134 
135  // Pass the EventSetup to the algo
136  theAlgo->setES(setup);
137 
138  // Create the pointer to the collection which will store the rechits
139  auto recHitCollection = std::make_unique<GEMRecHitCollection>();
140 
141  // Iterate through all digi collections ordered by LayerId
142  for (auto gemdgIt = digis->begin(); gemdgIt != digis->end(); ++gemdgIt) {
143  // The layerId
144  const GEMDetId& gemId = (*gemdgIt).first;
145 
146  // Get the GeomDet from the setup
147  const GEMEtaPartition* roll = gemGeom_->etaPartition(gemId);
148  if (roll == nullptr) {
149  edm::LogError("BadDigiInput") << "Failed to find GEMEtaPartition for ID " << gemId;
150  continue;
151  }
152 
153  // Get the iterators over the digis associated with this LayerId
154  const GEMDigiCollection::Range& range = (*gemdgIt).second;
155 
156  // get mask from map
157  EtaPartitionMask mask;
158  if (applyMasking_) {
159  auto gemmaskIt = gemMask_.find(gemId);
160  if (gemmaskIt != gemMask_.end())
161  mask = gemmaskIt->second;
162  }
163 
164  // Call the reconstruction algorithm
165  OwnVector<GEMRecHit> recHits = theAlgo->reconstruct(*roll, gemId, range, mask);
166 
167  if (!recHits.empty()) //FIXME: is it really needed?
168  recHitCollection->put(gemId, recHits.begin(), recHits.end());
169  }
170 
171  event.put(std::move(recHitCollection));
172 }
Log< level::Error, false > LogError
const uint16_t range(const Frame &aFrame)
iterator begin()
Definition: OwnVector.h:280
bool empty() const
Definition: OwnVector.h:305
def move
Definition: eostools.py:511
edm::ESHandle< GEMGeometry > gemGeom_
std::bitset< maskSIZE > EtaPartitionMask
std::map< GEMDetId, EtaPartitionMask > gemMask_
iterator end()
Definition: OwnVector.h:285
std::pair< const_iterator, const_iterator > Range
std::unique_ptr< GEMRecHitBaseAlgo > theAlgo
edm::EDGetTokenT< GEMDigiCollection > theGEMDigiToken

Member Data Documentation

bool GEMRecHitProducer::applyMasking_
private

Definition at line 67 of file GEMRecHitProducer.h.

enum GEMRecHitProducer::MaskSource GEMRecHitProducer::deadSource_
private

Referenced by beginRun().

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

Definition at line 62 of file GEMRecHitProducer.h.

Referenced by beginRun().

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

Definition at line 58 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

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

Definition at line 60 of file GEMRecHitProducer.h.

Referenced by beginRun().

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

Definition at line 65 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

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

Definition at line 61 of file GEMRecHitProducer.h.

Referenced by beginRun().

enum GEMRecHitProducer::MaskSource GEMRecHitProducer::maskSource_
private

Referenced by beginRun().

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

Definition at line 48 of file GEMRecHitProducer.h.

Referenced by produce().

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

Definition at line 54 of file GEMRecHitProducer.h.

Referenced by beginRun().

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

Definition at line 45 of file GEMRecHitProducer.h.

Referenced by produce().

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

Definition at line 51 of file GEMRecHitProducer.h.

Referenced by beginRun().