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

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
 
std::unique_ptr< RPCDeadStripstheRPCDeadStripsObj
 
const edm::EDGetTokenT< RPCDigiCollectiontheRPCDigiLabel
 
std::unique_ptr< RPCMaskedStripstheRPCMaskedStripsObj
 

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

Author
M. Maggim – INFN Bari

Definition at line 19 of file RPCRecHitProducer.h.

Member Enumeration Documentation

enum RPCRecHitProducer::MaskSource
strongprivate
Enumerator
File 
EventSetup 

Definition at line 48 of file RPCRecHitProducer.h.

enum RPCRecHitProducer::MaskSource deadSource_
enum RPCRecHitProducer::MaskSource maskSource_
Definition: File.h:11

Constructor & Destructor Documentation

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

Constructor.

Definition at line 29 of file RPCRecHitProducer.cc.

References MessageLogger_cfi::cerr, beamerCreator::create(), rpcRecHits_cfi::deadSource, deadSource_, DeadVec, cmsRelvalreport::exit, File, edm::FileInPath::fullPath(), reco::get(), edm::ParameterSet::getParameter(), recoMuon::in, analyzePatCleaning_cfg::inputFile, rpcRecHits_cfi::maskSource, maskSource_, MaskVec, RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, AlCaHLTBitMon_QueryRunRegistry::string, RPCDeadStrips::DeadItem::strip, RPCMaskedStrips::MaskItem::strip, theAlgo, theRPCDeadStripsObj, and theRPCMaskedStripsObj.

29  :
30  theRPCDigiLabel(consumes<RPCDigiCollection>(config.getParameter<InputTag>("rpcDigiLabel"))),
32 {
33  // Set verbose output
34  produces<RPCRecHitCollection>();
35 
36  // Get the concrete reconstruction algo from the factory
37  const string theAlgoName = config.getParameter<string>("recAlgo");
38  theAlgo.reset(RPCRecHitAlgoFactory::get()->create(theAlgoName,
39  config.getParameter<ParameterSet>("recAlgoConfig")));
40 
41  // Get masked- and dead-strip information
42  theRPCMaskedStripsObj = std::make_unique<RPCMaskedStrips>();
43  theRPCDeadStripsObj = std::make_unique<RPCDeadStrips>();
44 
45  const string maskSource = config.getParameter<std::string>("maskSource");
46  if (maskSource == "File") {
48  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
49  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
50  if ( !inputFile ) {
51  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
52  exit(1);
53  }
54  while ( inputFile.good() ) {
56  inputFile >> Item.rawId >> Item.strip;
57  if ( inputFile.good() ) MaskVec.push_back(Item);
58  }
59  inputFile.close();
60  }
61 
62  const string deadSource = config.getParameter<std::string>("deadSource");
63  if (deadSource == "File") {
65  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
66  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
67  if ( !inputFile ) {
68  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
69  exit(1);
70  }
71  while ( inputFile.good() ) {
73  inputFile >> Item.rawId >> Item.strip;
74  if ( inputFile.good() ) DeadVec.push_back(Item);
75  }
76  inputFile.close();
77  }
78 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
std::unique_ptr< RPCRecHitBaseAlgo > theAlgo
enum RPCRecHitProducer::MaskSource deadSource_
const edm::EDGetTokenT< RPCDigiCollection > theRPCDigiLabel
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
enum RPCRecHitProducer::MaskSource maskSource_
std::string fullPath() const
Definition: FileInPath.cc:197
std::vector< RPCMaskedStrips::MaskItem > MaskVec
T get(const Candidate &c)
Definition: component.h:55
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj
RPCRecHitProducer::~RPCRecHitProducer ( )
inlineoverride

Destructor.

Definition at line 26 of file RPCRecHitProducer.h.

References beginRun(), produce(), and GeneralSetup::setup().

26 {};

Member Function Documentation

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

Definition at line 81 of file RPCRecHitProducer.cc.

References deadSource_, RPCDeadStrips::DeadVec, DeadVec, EventSetup, File, edm::EventSetup::get(), maskSource_, RPCMaskedStrips::MaskVec, MaskVec, edm::ESHandle< T >::product(), RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, RPCDeadStrips::DeadItem::strip, RPCMaskedStrips::MaskItem::strip, theRPCDeadStripsObj, and theRPCMaskedStripsObj.

Referenced by ~RPCRecHitProducer().

81  {
82  // Getting the masked-strip information
84  edm::ESHandle<RPCMaskedStrips> readoutMaskedStrips;
85  setup.get<RPCMaskedStripsRcd>().get(readoutMaskedStrips);
86  const RPCMaskedStrips* tmp_obj = readoutMaskedStrips.product();
87  theRPCMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
88  delete tmp_obj;
89  }
90  else if ( maskSource_ == MaskSource::File ) {
91  std::vector<RPCMaskedStrips::MaskItem>::iterator posVec;
92  for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
94  Item.rawId = (*posVec).rawId;
95  Item.strip = (*posVec).strip;
96  theRPCMaskedStripsObj->MaskVec.push_back(Item);
97  }
98  }
99 
100  // Getting the dead-strip information
102  edm::ESHandle<RPCDeadStrips> readoutDeadStrips;
103  setup.get<RPCDeadStripsRcd>().get(readoutDeadStrips);
104  const RPCDeadStrips* tmp_obj = readoutDeadStrips.product();
105  theRPCDeadStripsObj->DeadVec = tmp_obj->DeadVec;
106  delete tmp_obj;
107  }
108  else if ( deadSource_ == MaskSource::File ) {
109  std::vector<RPCDeadStrips::DeadItem>::iterator posVec;
110  for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
112  Item.rawId = (*posVec).rawId;
113  Item.strip = (*posVec).strip;
114  theRPCDeadStripsObj->DeadVec.push_back(Item);
115  }
116  }
117 
118 }
std::vector< MaskItem > MaskVec
enum RPCRecHitProducer::MaskSource deadSource_
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
const T & get() const
Definition: EventSetup.h:59
enum RPCRecHitProducer::MaskSource maskSource_
std::vector< DeadItem > DeadVec
Definition: RPCDeadStrips.h:28
std::vector< RPCMaskedStrips::MaskItem > MaskVec
T const * product() const
Definition: ESHandle.h:86
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 120 of file RPCRecHitProducer.cc.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::empty(), edm::OwnVector< T, P >::end(), edm::EventSetup::get(), RecoTauDiscriminantConfiguration::mask, eostools::move(), DetId::rawId(), RPCGeometry::roll(), theAlgo, theRPCDeadStripsObj, theRPCDigiLabel, and theRPCMaskedStripsObj.

Referenced by ~RPCRecHitProducer().

120  {
121  // Get the RPC Geometry
122  ESHandle<RPCGeometry> rpcGeom;
123  setup.get<MuonGeometryRecord>().get(rpcGeom);
124 
125  // Get the digis from the event
127  event.getByToken(theRPCDigiLabel,digis);
128 
129  // Pass the EventSetup to the algo
130  theAlgo->setES(setup);
131 
132  // Create the pointer to the collection which will store the rechits
133  auto recHitCollection = std::make_unique<RPCRecHitCollection>();
134 
135  // Iterate through all digi collections ordered by LayerId
136 
137  for ( auto rpcdgIt = digis->begin(); rpcdgIt != digis->end(); ++rpcdgIt ) {
138  // The layerId
139  const RPCDetId& rpcId = (*rpcdgIt).first;
140 
141  // Get the GeomDet from the setup
142  const RPCRoll* roll = rpcGeom->roll(rpcId);
143  if (roll == nullptr){
144  edm::LogError("BadDigiInput")<<"Failed to find RPCRoll for ID "<<rpcId;
145  continue;
146  }
147 
148  // Get the iterators over the digis associated with this LayerId
149  const RPCDigiCollection::Range& range = (*rpcdgIt).second;
150 
151  // Getting the roll mask, that includes dead strips, for the given RPCDet
152  RollMask mask;
153  const int rawId = rpcId.rawId();
154  for ( const auto& tomask : theRPCMaskedStripsObj->MaskVec ) {
155  if ( tomask.rawId == rawId ) {
156  const int bit = tomask.strip;
157  mask.set(bit-1);
158  }
159  }
160 
161  for ( const auto& tomask : theRPCDeadStripsObj->DeadVec ) {
162  if ( tomask.rawId == rawId ) {
163  const int bit = tomask.strip;
164  mask.set(bit-1);
165  }
166  }
167 
168  // Call the reconstruction algorithm
169  OwnVector<RPCRecHit> recHits = theAlgo->reconstruct(*roll, rpcId, range, mask);
170 
171  if(!recHits.empty()) //FIXME: is it really needed?
172  recHitCollection->put(rpcId, recHits.begin(), recHits.end());
173  }
174 
175  event.put(std::move(recHitCollection));
176 
177 }
std::unique_ptr< RPCRecHitBaseAlgo > theAlgo
iterator begin()
Definition: OwnVector.h:244
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
bool empty() const
Definition: OwnVector.h:269
const edm::EDGetTokenT< RPCDigiCollection > theRPCDigiLabel
std::bitset< maskSIZE > RollMask
Definition: RPCRollMask.h:7
std::unique_ptr< RPCMaskedStrips > theRPCMaskedStripsObj
iterator end()
Definition: OwnVector.h:249
const T & get() const
Definition: EventSetup.h:59
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:510
std::unique_ptr< RPCDeadStrips > theRPCDeadStripsObj
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:75

Member Data Documentation

enum RPCRecHitProducer::MaskSource RPCRecHitProducer::deadSource_
private

Referenced by beginRun(), and RPCRecHitProducer().

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

Definition at line 51 of file RPCRecHitProducer.h.

Referenced by beginRun(), and RPCRecHitProducer().

enum RPCRecHitProducer::MaskSource RPCRecHitProducer::maskSource_
private

Referenced by beginRun(), and RPCRecHitProducer().

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

Definition at line 50 of file RPCRecHitProducer.h.

Referenced by beginRun(), and RPCRecHitProducer().

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

Definition at line 40 of file RPCRecHitProducer.h.

Referenced by produce(), and RPCRecHitProducer().

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

Definition at line 45 of file RPCRecHitProducer.h.

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

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

Definition at line 36 of file RPCRecHitProducer.h.

Referenced by produce().

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

Definition at line 42 of file RPCRecHitProducer.h.

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