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 | Private Types | Private Attributes
RPCRecHitProducer Class Reference

#include <RPCRecHitProducer.h>

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

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void produce (edm::Event &event, const edm::EventSetup &setup) override
 The method which produces the rechits. More...
 
 RPCRecHitProducer (const edm::ParameterSet &config)
 Constructor. More...
 
 ~RPCRecHitProducer () 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
 

Private Types

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

Private Attributes

enum RPCRecHitProducer::MaskSource deadSource_
 
std::vector
< RPCDeadStrips::DeadItem
DeadVec
 
enum RPCRecHitProducer::MaskSource maskSource_
 
std::vector
< RPCMaskedStrips::MaskItem
MaskVec
 
std::unique_ptr
< RPCRecHitBaseAlgo
theAlgo
 
edm::ESGetToken< RPCDeadStrips,
RPCDeadStripsRcd
theReadoutDeadStripsToken
 
edm::ESGetToken
< RPCMaskedStrips,
RPCMaskedStripsRcd
theReadoutMaskedStripsToken
 
std::unique_ptr< RPCDeadStripstheRPCDeadStripsObj
 
const edm::EDGetTokenT
< RPCDigiCollection
theRPCDigiLabel
 
const edm::ESGetToken
< RPCGeometry,
MuonGeometryRecord
theRPCGeomToken
 
std::unique_ptr< RPCMaskedStripstheRPCMaskedStripsObj
 

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 RPCRecHit production.

Author
M. Maggim – INFN Bari

Definition at line 23 of file RPCRecHitProducer.h.

Member Enumeration Documentation

enum RPCRecHitProducer::MaskSource
strongprivate
Enumerator
File 
EventSetup 

Definition at line 54 of file RPCRecHitProducer.h.

enum RPCRecHitProducer::MaskSource deadSource_
enum RPCRecHitProducer::MaskSource maskSource_

Constructor & Destructor Documentation

RPCRecHitProducer::RPCRecHitProducer ( const edm::ParameterSet config)

Constructor.

Definition at line 23 of file RPCRecHitProducer.cc.

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

24  : theRPCDigiLabel(consumes<RPCDigiCollection>(config.getParameter<InputTag>("rpcDigiLabel"))),
26  // Get the concrete reconstruction algo from the factory
27  theAlgo{RPCRecHitAlgoFactory::get()->create(config.getParameter<string>("recAlgo"),
28  config.getParameter<ParameterSet>("recAlgoConfig"))},
31  // Set verbose output
32  produces<RPCRecHitCollection>();
33 
34  // Get masked- and dead-strip information
35  theRPCMaskedStripsObj = std::make_unique<RPCMaskedStrips>();
36  theRPCDeadStripsObj = std::make_unique<RPCDeadStrips>();
37 
38  const string maskSource = config.getParameter<std::string>("maskSource");
39  if (maskSource == "File") {
41  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
42  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
43  if (!inputFile) {
44  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
45  exit(1);
46  }
47  while (inputFile.good()) {
49  inputFile >> Item.rawId >> Item.strip;
50  if (inputFile.good())
51  MaskVec.push_back(Item);
52  }
53  inputFile.close();
54  } else {
56  }
57 
58  const string deadSource = config.getParameter<std::string>("deadSource");
59  if (deadSource == "File") {
61  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
62  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
63  if (!inputFile) {
64  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
65  exit(1);
66  }
67  while (inputFile.good()) {
69  inputFile >> Item.rawId >> Item.strip;
70  if (inputFile.good())
71  DeadVec.push_back(Item);
72  }
73  inputFile.close();
74  } else {
76  }
77 }
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > theRPCGeomToken
edm::ESGetToken< RPCDeadStrips, RPCDeadStripsRcd > theReadoutDeadStripsToken
std::unique_ptr< RPCRecHitBaseAlgo > theAlgo
enum RPCRecHitProducer::MaskSource deadSource_
const edm::EDGetTokenT< RPCDigiCollection > theRPCDigiLabel
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
edm::ESGetToken< RPCMaskedStrips, RPCMaskedStripsRcd > theReadoutMaskedStripsToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
enum RPCRecHitProducer::MaskSource maskSource_
std::string fullPath() const
Definition: FileInPath.cc:161
std::vector< RPCMaskedStrips::MaskItem > MaskVec
#define get
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj
RPCRecHitProducer::~RPCRecHitProducer ( )
inlineoverride

Destructor.

Definition at line 29 of file RPCRecHitProducer.h.

29 {};

Member Function Documentation

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

Definition at line 79 of file RPCRecHitProducer.cc.

References deadSource_, DeadVec, EventSetup, File, edm::EventSetup::getData(), maskSource_, MaskVec, RPCDeadStrips::DeadItem::rawId, RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::strip, RPCMaskedStrips::MaskItem::strip, theReadoutDeadStripsToken, and theReadoutMaskedStripsToken.

79  {
80  // Getting the masked-strip information
83  } else if (maskSource_ == MaskSource::File) {
84  std::vector<RPCMaskedStrips::MaskItem>::iterator posVec;
85  for (posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec) {
87  Item.rawId = (*posVec).rawId;
88  Item.strip = (*posVec).strip;
89  theRPCMaskedStripsObj->MaskVec.push_back(Item);
90  }
91  }
92 
93  // Getting the dead-strip information
95  theRPCDeadStripsObj->DeadVec = setup.getData(theReadoutDeadStripsToken).DeadVec;
96  } else if (deadSource_ == MaskSource::File) {
97  std::vector<RPCDeadStrips::DeadItem>::iterator posVec;
98  for (posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec) {
100  Item.rawId = (*posVec).rawId;
101  Item.strip = (*posVec).strip;
102  theRPCDeadStripsObj->DeadVec.push_back(Item);
103  }
104  }
105 }
edm::ESGetToken< RPCDeadStrips, RPCDeadStripsRcd > theReadoutDeadStripsToken
enum RPCRecHitProducer::MaskSource deadSource_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
edm::ESGetToken< RPCMaskedStrips, RPCMaskedStripsRcd > theReadoutMaskedStripsToken
enum RPCRecHitProducer::MaskSource maskSource_
std::vector< RPCMaskedStrips::MaskItem > MaskVec
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj
void RPCRecHitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

The method which produces the rechits.

Definition at line 107 of file RPCRecHitProducer.cc.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::empty(), edm::OwnVector< T, P >::end(), edm::EventSetup::getData(), eostools::move(), sistrip::SpyUtilities::range(), DetId::rawId(), HLT_FULL_cff::recHits, theAlgo, theRPCDigiLabel, and theRPCGeomToken.

107  {
108  // Get the RPC Geometry
109  auto const& rpcGeom = setup.getData(theRPCGeomToken);
110 
111  // Get the digis from the event
113  event.getByToken(theRPCDigiLabel, digis);
114 
115  // Pass the EventSetup to the algo
116  theAlgo->setES(setup);
117 
118  // Create the pointer to the collection which will store the rechits
119  auto recHitCollection = std::make_unique<RPCRecHitCollection>();
120 
121  // Iterate through all digi collections ordered by LayerId
122 
123  for (auto rpcdgIt = digis->begin(); rpcdgIt != digis->end(); ++rpcdgIt) {
124  // The layerId
125  const RPCDetId& rpcId = (*rpcdgIt).first;
126 
127  // Get the GeomDet from the setup
128  const RPCRoll* roll = rpcGeom.roll(rpcId);
129  if (roll == nullptr) {
130  edm::LogError("BadDigiInput") << "Failed to find RPCRoll for ID " << rpcId;
131  continue;
132  }
133 
134  // Get the iterators over the digis associated with this LayerId
135  const RPCDigiCollection::Range& range = (*rpcdgIt).second;
136 
137  // Getting the roll mask, that includes dead strips, for the given RPCDet
138  RollMask mask;
139  const int rawId = rpcId.rawId();
140  for (const auto& tomask : theRPCMaskedStripsObj->MaskVec) {
141  if (tomask.rawId == rawId) {
142  const int bit = tomask.strip;
143  mask.set(bit - 1);
144  }
145  }
146 
147  for (const auto& tomask : theRPCDeadStripsObj->DeadVec) {
148  if (tomask.rawId == rawId) {
149  const int bit = tomask.strip;
150  mask.set(bit - 1);
151  }
152  }
153 
154  // Call the reconstruction algorithm
155  OwnVector<RPCRecHit> recHits = theAlgo->reconstruct(*roll, rpcId, range, mask);
156 
157  if (!recHits.empty()) //FIXME: is it really needed?
158  recHitCollection->put(rpcId, recHits.begin(), recHits.end());
159  }
160 
161  event.put(std::move(recHitCollection));
162 }
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > theRPCGeomToken
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::unique_ptr< RPCRecHitBaseAlgo > theAlgo
Log< level::Error, false > LogError
const uint16_t range(const Frame &aFrame)
iterator begin()
Definition: OwnVector.h:280
bool getData(T &iHolder) const
Definition: EventSetup.h:128
bool empty() const
Definition: OwnVector.h:305
def move
Definition: eostools.py:511
const edm::EDGetTokenT< RPCDigiCollection > theRPCDigiLabel
std::bitset< maskSIZE > RollMask
Definition: RPCRollMask.h:7
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
iterator end()
Definition: OwnVector.h:285
std::pair< const_iterator, const_iterator > Range
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj

Member Data Documentation

enum RPCRecHitProducer::MaskSource RPCRecHitProducer::deadSource_
private

Referenced by beginRun().

std::vector<RPCDeadStrips::DeadItem> RPCRecHitProducer::DeadVec
private

Definition at line 57 of file RPCRecHitProducer.h.

Referenced by beginRun().

enum RPCRecHitProducer::MaskSource RPCRecHitProducer::maskSource_
private

Referenced by beginRun().

std::vector<RPCMaskedStrips::MaskItem> RPCRecHitProducer::MaskVec
private

Definition at line 56 of file RPCRecHitProducer.h.

Referenced by beginRun().

std::unique_ptr<RPCRecHitBaseAlgo> RPCRecHitProducer::theAlgo
private

Definition at line 46 of file RPCRecHitProducer.h.

Referenced by produce().

edm::ESGetToken<RPCDeadStrips, RPCDeadStripsRcd> RPCRecHitProducer::theReadoutDeadStripsToken
private

Definition at line 42 of file RPCRecHitProducer.h.

Referenced by beginRun().

edm::ESGetToken<RPCMaskedStrips, RPCMaskedStripsRcd> RPCRecHitProducer::theReadoutMaskedStripsToken
private

Definition at line 41 of file RPCRecHitProducer.h.

Referenced by beginRun().

std::unique_ptr<RPCDeadStrips> RPCRecHitProducer::theRPCDeadStripsObj
private

Definition at line 51 of file RPCRecHitProducer.h.

const edm::EDGetTokenT<RPCDigiCollection> RPCRecHitProducer::theRPCDigiLabel
private

Definition at line 39 of file RPCRecHitProducer.h.

Referenced by produce().

const edm::ESGetToken<RPCGeometry, MuonGeometryRecord> RPCRecHitProducer::theRPCGeomToken
private

Definition at line 43 of file RPCRecHitProducer.h.

Referenced by produce().

std::unique_ptr<RPCMaskedStrips> RPCRecHitProducer::theRPCMaskedStripsObj
private

Definition at line 48 of file RPCRecHitProducer.h.