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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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::ESHandle< GEMGeometrygemGeom_
 
std::map< GEMDetId, EtaPartitionMaskgemMask_
 
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<>
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

Module for GEMRecHit production.

Author
M. Maggim – INFN Bari

Definition at line 23 of file GEMRecHitProducer.h.

Member Enumeration Documentation

enum GEMRecHitProducer::MaskSource
strongprivate
Enumerator
File 
EventSetup 

Definition at line 54 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 25 of file GEMRecHitProducer.cc.

References applyMasking_, deadSource_, EventSetup, Exception, File, edm::FileInPath::fullPath(), reco::get(), edm::ParameterSet::getParameter(), analyzePatCleaning_cfg::inputFile, maskSource_, GEMMaskedStrips::MaskItem::rawId, GEMDeadStrips::DeadItem::rawId, GEMDeadStrips::DeadItem::strip, GEMMaskedStrips::MaskItem::strip, theGEMDeadStripsObj, theGEMMaskedStripsObj, and ~GEMRecHitProducer().

25  :
26  theGEMDigiToken(consumes<GEMDigiCollection>(config.getParameter<InputTag>("gemDigiLabel"))),
27  // Get the concrete reconstruction algo from the factory
28  theAlgo{GEMRecHitAlgoFactory::get()->create(config.getParameter<string>("recAlgo"),
29  config.getParameter<ParameterSet>("recAlgoConfig"))},
31 {
32  produces<GEMRecHitCollection>();
33 
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() ) theGEMMaskedStripsObj->fillMaskVec(Item);
48 
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() ) theGEMDeadStripsObj->fillDeadVec(Item);
64  }
65  inputFile.close();
66  }
67  }
68 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
enum GEMRecHitProducer::MaskSource deadSource_
std::unique_ptr< GEMDeadStrips > theGEMDeadStripsObj
std::unique_ptr< GEMMaskedStrips > theGEMMaskedStripsObj
enum GEMRecHitProducer::MaskSource maskSource_
std::string fullPath() const
Definition: FileInPath.cc:163
std::unique_ptr< GEMRecHitBaseAlgo > theAlgo
T get(const Candidate &c)
Definition: component.h:55
edm::EDGetTokenT< GEMDigiCollection > theGEMDigiToken
GEMRecHitProducer::~GEMRecHitProducer ( )
overridedefault

Destructor.

Referenced by GEMRecHitProducer().

Member Function Documentation

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

Definition at line 85 of file GEMRecHitProducer.cc.

References applyMasking_, deadSource_, GEMGeometry::etaPartitions(), EventSetup, gemGeom_, gemMask_, edm::EventSetup::get(), RecoTauDiscriminantConfiguration::mask, maskSource_, edm::ESHandle< T >::product(), DetId::rawId(), theGEMDeadStripsObj, and theGEMMaskedStripsObj.

86 {
87  // Get the GEM Geometry
88  setup.get<MuonGeometryRecord>().get(gemGeom_);
89 
90  if (applyMasking_) {
91  // Getting the masked-strip information
93  edm::ESHandle<GEMMaskedStrips> readoutMaskedStrips;
94  setup.get<GEMMaskedStripsRcd>().get(readoutMaskedStrips);
95  theGEMMaskedStripsObj = std::make_unique<GEMMaskedStrips>(*readoutMaskedStrips.product());
96  }
97  // Getting the dead-strip information
99  edm::ESHandle<GEMDeadStrips> readoutDeadStrips;
100  setup.get<GEMDeadStripsRcd>().get(readoutDeadStrips);
101  theGEMDeadStripsObj = std::make_unique<GEMDeadStrips>(*readoutDeadStrips.product());
102  }
103 
104  for (auto gems: gemGeom_->etaPartitions()) {
105  // Getting the EtaPartitionMask mask, that includes dead strips, for the given GEMDet
106  GEMDetId gemId = gems->id();
108  const int rawId = gemId.rawId();
109  for ( const auto& tomask : theGEMMaskedStripsObj->getMaskVec() ) {
110  if ( tomask.rawId == rawId ) {
111  const int bit = tomask.strip;
112  mask.set(bit-1);
113  }
114  }
115  for ( const auto& tomask : theGEMDeadStripsObj->getDeadVec() ) {
116  if ( tomask.rawId == rawId ) {
117  const int bit = tomask.strip;
118  mask.set(bit-1);
119  }
120  }
121  // add to masking map if masking present in etaPartition
122  if (mask.any()) {
123  gemMask_.emplace(gemId,mask);
124  }
125  }
126  }
127 }
enum GEMRecHitProducer::MaskSource deadSource_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
edm::ESHandle< GEMGeometry > gemGeom_
std::unique_ptr< GEMDeadStrips > theGEMDeadStripsObj
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:63
std::bitset< maskSIZE > EtaPartitionMask
std::unique_ptr< GEMMaskedStrips > theGEMMaskedStripsObj
enum GEMRecHitProducer::MaskSource maskSource_
T get() const
Definition: EventSetup.h:71
std::map< GEMDetId, EtaPartitionMask > gemMask_
T const * product() const
Definition: ESHandle.h:86
void GEMRecHitProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 72 of file GEMRecHitProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), and AlCaHLTBitMon_QueryRunRegistry::string.

73 {
75  edm::ParameterSetDescription recAlgoConfigDesc;
76  desc.add<edm::ParameterSetDescription>("recAlgoConfig", recAlgoConfigDesc);
77  desc.add<std::string>("recAlgo", "GEMRecHitStandardAlgo");
78  desc.add<edm::InputTag>("gemDigiLabel", edm::InputTag("muonGEMDigis"));
79  desc.add<bool>("applyMasking", false);
80  desc.addOptional<edm::FileInPath>("maskFile");
81  desc.addOptional<edm::FileInPath>("deadFile");
82  descriptions.add("gemRecHitsDef",desc);
83 }
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 129 of file GEMRecHitProducer.cc.

References applyMasking_, edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::empty(), edm::OwnVector< T, P >::end(), GEMGeometry::etaPartition(), gemGeom_, gemMask_, RecoTauDiscriminantConfiguration::mask, eostools::move(), 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
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 }
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
iterator begin()
Definition: OwnVector.h:244
bool empty() const
Definition: OwnVector.h:269
edm::ESHandle< GEMGeometry > gemGeom_
std::bitset< maskSIZE > EtaPartitionMask
iterator end()
Definition: OwnVector.h:249
std::map< GEMDetId, EtaPartitionMask > gemMask_
std::unique_ptr< GEMRecHitBaseAlgo > theAlgo
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< GEMDigiCollection > theGEMDigiToken

Member Data Documentation

bool GEMRecHitProducer::applyMasking_
private

Definition at line 61 of file GEMRecHitProducer.h.

Referenced by beginRun(), GEMRecHitProducer(), and produce().

enum GEMRecHitProducer::MaskSource GEMRecHitProducer::deadSource_
private

Referenced by beginRun(), and GEMRecHitProducer().

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

Definition at line 56 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

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

Definition at line 59 of file GEMRecHitProducer.h.

Referenced by beginRun(), and produce().

enum GEMRecHitProducer::MaskSource GEMRecHitProducer::maskSource_
private

Referenced by beginRun(), and GEMRecHitProducer().

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

Definition at line 46 of file GEMRecHitProducer.h.

Referenced by produce().

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

Definition at line 52 of file GEMRecHitProducer.h.

Referenced by beginRun(), and GEMRecHitProducer().

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

Definition at line 43 of file GEMRecHitProducer.h.

Referenced by produce().

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

Definition at line 49 of file GEMRecHitProducer.h.

Referenced by beginRun(), and GEMRecHitProducer().