CMS 3D CMS Logo

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::DeadItemDeadVec
 
enum RPCRecHitProducer::MaskSource maskSource_
 
std::vector< RPCMaskedStrips::MaskItemMaskVec
 
std::unique_ptr< RPCRecHitBaseAlgotheAlgo
 
edm::ESGetToken< RPCDeadStrips, RPCDeadStripsRcdtheReadoutDeadStripsToken
 
edm::ESGetToken< RPCMaskedStrips, RPCMaskedStripsRcdtheReadoutMaskedStripsToken
 
std::unique_ptr< RPCDeadStripstheRPCDeadStripsObj
 
const edm::EDGetTokenT< RPCDigiCollectiontheRPCDigiLabel
 
const edm::ESGetToken< RPCGeometry, MuonGeometryRecordtheRPCGeomToken
 
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

◆ MaskSource

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

Constructor.

Definition at line 23 of file RPCRecHitProducer.cc.

References get.

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 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > theRPCGeomToken
edm::ESGetToken< RPCDeadStrips, RPCDeadStripsRcd > theReadoutDeadStripsToken
std::unique_ptr< RPCRecHitBaseAlgo > theAlgo
Definition: config.py:1
enum RPCRecHitProducer::MaskSource deadSource_
const edm::EDGetTokenT< RPCDigiCollection > theRPCDigiLabel
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
edm::ESGetToken< RPCMaskedStrips, RPCMaskedStripsRcd > theReadoutMaskedStripsToken
enum RPCRecHitProducer::MaskSource maskSource_
std::vector< RPCMaskedStrips::MaskItem > MaskVec
#define get
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj
def exit(msg="")

◆ ~RPCRecHitProducer()

RPCRecHitProducer::~RPCRecHitProducer ( )
inlineoverride

Destructor.

Definition at line 29 of file RPCRecHitProducer.h.

29 {};

Member Function Documentation

◆ beginRun()

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, maskSource_, MaskVec, RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, singleTopDQM_cfi::setup, RPCMaskedStrips::MaskItem::strip, RPCDeadStrips::DeadItem::strip, theReadoutDeadStripsToken, theReadoutMaskedStripsToken, theRPCDeadStripsObj, and theRPCMaskedStripsObj.

79  {
80  // Getting the masked-strip information
82  theRPCMaskedStripsObj->MaskVec = setup.getData(theReadoutMaskedStripsToken).MaskVec;
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_
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

◆ produce()

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 triggerObjects_cff::bit, gpuClustering::pixelStatus::mask, eostools::move(), FastTimerService_cff::range, DetId::rawId(), FastTrackerRecHitMaskProducer_cfi::recHits, singleTopDQM_cfi::setup, theAlgo, theRPCDeadStripsObj, theRPCDigiLabel, theRPCGeomToken, and theRPCMaskedStripsObj.

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
std::unique_ptr< RPCRecHitBaseAlgo > theAlgo
Log< level::Error, false > LogError
constexpr uint32_t mask
Definition: gpuClustering.h:24
const edm::EDGetTokenT< RPCDigiCollection > theRPCDigiLabel
std::bitset< maskSIZE > RollMask
Definition: RPCRollMask.h:7
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj

Member Data Documentation

◆ deadSource_

enum RPCRecHitProducer::MaskSource RPCRecHitProducer::deadSource_
private

Referenced by beginRun().

◆ DeadVec

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

Definition at line 57 of file RPCRecHitProducer.h.

Referenced by beginRun().

◆ maskSource_

enum RPCRecHitProducer::MaskSource RPCRecHitProducer::maskSource_
private

Referenced by beginRun().

◆ MaskVec

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

Definition at line 56 of file RPCRecHitProducer.h.

Referenced by beginRun().

◆ theAlgo

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

Definition at line 46 of file RPCRecHitProducer.h.

Referenced by produce().

◆ theReadoutDeadStripsToken

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

Definition at line 42 of file RPCRecHitProducer.h.

Referenced by beginRun().

◆ theReadoutMaskedStripsToken

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

Definition at line 41 of file RPCRecHitProducer.h.

Referenced by beginRun().

◆ theRPCDeadStripsObj

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

Definition at line 51 of file RPCRecHitProducer.h.

Referenced by beginRun(), and produce().

◆ theRPCDigiLabel

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

Definition at line 39 of file RPCRecHitProducer.h.

Referenced by produce().

◆ theRPCGeomToken

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

Definition at line 43 of file RPCRecHitProducer.h.

Referenced by produce().

◆ theRPCMaskedStripsObj

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

Definition at line 48 of file RPCRecHitProducer.h.

Referenced by beginRun(), and produce().