CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
RPCRecHitProducer Class Reference

#include <RPCRecHitProducer.h>

Inheritance diagram for RPCRecHitProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
virtual void produce (edm::Event &event, const edm::EventSetup &setup) override
 The method which produces the rechits. More...
 
 RPCRecHitProducer (const edm::ParameterSet &config)
 Constructor. More...
 
virtual ~RPCRecHitProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::string deadSource
 
std::vector
< RPCDeadStrips::DeadItem
DeadVec
 
std::string maskSource
 
std::vector
< RPCMaskedStrips::MaskItem
MaskVec
 
RPCDeadStripsRPCDeadStripsObj
 
RPCMaskedStripsRPCMaskedStripsObj
 
RPCRecHitBaseAlgotheAlgo
 
edm::InputTag theRPCDigiLabel
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Module for RPCRecHit production.

Date:
2013/02/25 18:49:16
Revision:
1.7
Author
M. Maggim – INFN Bari

Definition at line 41 of file RPCRecHitProducer.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 40 of file RPCRecHitProducer.cc.

References dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, edm::FileInPath::fullPath(), reco::get(), edm::ParameterSet::getParameter(), recoMuon::in, analyzePatCOC_cfg::inputFile, RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, AlCaHLTBitMon_QueryRunRegistry::string, RPCMaskedStrips::MaskItem::strip, and RPCDeadStrips::DeadItem::strip.

40  {
41 
42  // Set verbose output
43 
44  produces<RPCRecHitCollection>();
45 
46  theRPCDigiLabel = config.getParameter<InputTag>("rpcDigiLabel");
47 
48  // Get the concrete reconstruction algo from the factory
49 
50  string theAlgoName = config.getParameter<string>("recAlgo");
51  theAlgo = RPCRecHitAlgoFactory::get()->create(theAlgoName,
52  config.getParameter<ParameterSet>("recAlgoConfig"));
53 
54  // Get masked- and dead-strip information
55 
57 
59 
60  maskSource = config.getParameter<std::string>("maskSource");
61 
62  if (maskSource == "File") {
63  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
64  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
65  if ( !inputFile ) {
66  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
67  exit(1);
68  }
69  while ( inputFile.good() ) {
71  inputFile >> Item.rawId >> Item.strip;
72  if ( inputFile.good() ) MaskVec.push_back(Item);
73  }
74  inputFile.close();
75  }
76 
77  deadSource = config.getParameter<std::string>("deadSource");
78 
79  if (deadSource == "File") {
80  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
81  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
82  if ( !inputFile ) {
83  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
84  exit(1);
85  }
86  while ( inputFile.good() ) {
88  inputFile >> Item.rawId >> Item.strip;
89  if ( inputFile.good() ) DeadVec.push_back(Item);
90  }
91  inputFile.close();
92  }
93 
94 }
T getParameter(std::string const &) const
std::string maskSource
std::string deadSource
RPCMaskedStrips * RPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
RPCRecHitBaseAlgo * theAlgo
RPCDeadStrips * RPCDeadStripsObj
edm::InputTag theRPCDigiLabel
std::vector< RPCMaskedStrips::MaskItem > MaskVec
std::string fullPath() const
Definition: FileInPath.cc:171
T get(const Candidate &c)
Definition: component.h:56
RPCRecHitProducer::~RPCRecHitProducer ( )
virtual

Destructor.

Definition at line 97 of file RPCRecHitProducer.cc.

97  {
98 
99  delete theAlgo;
100  delete RPCMaskedStripsObj;
101  delete RPCDeadStripsObj;
102 
103 }
RPCMaskedStrips * RPCMaskedStripsObj
RPCRecHitBaseAlgo * theAlgo
RPCDeadStrips * RPCDeadStripsObj

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 107 of file RPCRecHitProducer.cc.

References RPCDeadStrips::DeadVec, edm::EventSetup::get(), RPCMaskedStrips::MaskVec, edm::ESHandle< class >::product(), RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, RPCDeadStrips::DeadItem::strip, and RPCMaskedStrips::MaskItem::strip.

107  {
108 
109  // Getting the masked-strip information
110 
111  if ( maskSource == "EventSetup" ) {
112  edm::ESHandle<RPCMaskedStrips> readoutMaskedStrips;
113  setup.get<RPCMaskedStripsRcd>().get(readoutMaskedStrips);
114  const RPCMaskedStrips* tmp_obj = readoutMaskedStrips.product();
115  RPCMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
116  delete tmp_obj;
117  }
118  else if ( maskSource == "File" ) {
119  std::vector<RPCMaskedStrips::MaskItem>::iterator posVec;
120  for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
122  Item.rawId = (*posVec).rawId;
123  Item.strip = (*posVec).strip;
124  RPCMaskedStripsObj->MaskVec.push_back(Item);
125  }
126  }
127 
128  // Getting the dead-strip information
129 
130  if ( deadSource == "EventSetup" ) {
131  edm::ESHandle<RPCDeadStrips> readoutDeadStrips;
132  setup.get<RPCDeadStripsRcd>().get(readoutDeadStrips);
133  const RPCDeadStrips* tmp_obj = readoutDeadStrips.product();
134  RPCDeadStripsObj->DeadVec = tmp_obj->DeadVec;
135  delete tmp_obj;
136  }
137  else if ( deadSource == "File" ) {
138  std::vector<RPCDeadStrips::DeadItem>::iterator posVec;
139  for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
141  Item.rawId = (*posVec).rawId;
142  Item.strip = (*posVec).strip;
143  RPCDeadStripsObj->DeadVec.push_back(Item);
144  }
145  }
146 
147 }
std::string maskSource
std::vector< MaskItem > MaskVec
std::string deadSource
RPCMaskedStrips * RPCMaskedStripsObj
std::vector< RPCDeadStrips::DeadItem > DeadVec
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
RPCDeadStrips * RPCDeadStripsObj
std::vector< DeadItem > DeadVec
Definition: RPCDeadStrips.h:24
std::vector< RPCMaskedStrips::MaskItem > MaskVec
void RPCRecHitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
overridevirtual

The method which produces the rechits.

Implements edm::EDProducer.

Definition at line 151 of file RPCRecHitProducer.cc.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::end(), edm::EventSetup::get(), i, DetId::rawId(), and edm::OwnVector< T, P >::size().

151  {
152 
153  // Get the RPC Geometry
154 
155  ESHandle<RPCGeometry> rpcGeom;
156  setup.get<MuonGeometryRecord>().get(rpcGeom);
157 
158  // Get the digis from the event
159 
161  event.getByLabel(theRPCDigiLabel,digis);
162 
163  // Pass the EventSetup to the algo
164 
165  theAlgo->setES(setup);
166 
167  // Create the pointer to the collection which will store the rechits
168 
169  auto_ptr<RPCRecHitCollection> recHitCollection(new RPCRecHitCollection());
170 
171  // Iterate through all digi collections ordered by LayerId
172 
174  for (rpcdgIt = digis->begin(); rpcdgIt != digis->end();
175  ++rpcdgIt){
176 
177  // The layerId
178  const RPCDetId& rpcId = (*rpcdgIt).first;
179 
180  // Get the GeomDet from the setup
181  const RPCRoll* roll = rpcGeom->roll(rpcId);
182  if (roll == 0){
183  edm::LogError("BadDigiInput")<<"Failed to find RPCRoll for ID "<<rpcId;
184  continue;
185  }
186 
187  // Get the iterators over the digis associated with this LayerId
188  const RPCDigiCollection::Range& range = (*rpcdgIt).second;
189 
190 
191  // Getting the roll mask, that includes dead strips, for the given RPCDet
192 
193  RollMask mask;
194  int rawId = rpcId.rawId();
195  int Size = RPCMaskedStripsObj->MaskVec.size();
196  for (int i = 0; i < Size; i++ ) {
197  if ( RPCMaskedStripsObj->MaskVec[i].rawId == rawId ) {
198  int bit = RPCMaskedStripsObj->MaskVec[i].strip;
199  mask.set(bit-1);
200  }
201  }
202 
203  Size = RPCDeadStripsObj->DeadVec.size();
204  for (int i = 0; i < Size; i++ ) {
205  if ( RPCDeadStripsObj->DeadVec[i].rawId == rawId ) {
206  int bit = RPCDeadStripsObj->DeadVec[i].strip;
207  mask.set(bit-1);
208  }
209  }
210 
211  // Call the reconstruction algorithm
212 
213  OwnVector<RPCRecHit> recHits =
214  theAlgo->reconstruct(*roll, rpcId, range, mask);
215 
216  if(recHits.size() > 0) //FIXME: is it really needed?
217  recHitCollection->put(rpcId, recHits.begin(), recHits.end());
218  }
219 
220  event.put(recHitCollection);
221 
222 }
int i
Definition: DBlmapReader.cc:9
std::vector< MaskItem > MaskVec
size_type size() const
Definition: OwnVector.h:247
iterator begin()
Definition: OwnVector.h:227
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
RPCMaskedStrips * RPCMaskedStripsObj
virtual void setES(const edm::EventSetup &setup)=0
Pass the Event Setup to the algo at each event.
std::bitset< maskSIZE > RollMask
Definition: RPCRollMask.h:8
iterator end()
Definition: OwnVector.h:232
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
const T & get() const
Definition: EventSetup.h:55
RPCRecHitBaseAlgo * theAlgo
RPCDeadStrips * RPCDeadStripsObj
std::vector< DeadItem > DeadVec
Definition: RPCDeadStrips.h:24
edm::InputTag theRPCDigiLabel
std::pair< const_iterator, const_iterator > Range
virtual edm::OwnVector< RPCRecHit > reconstruct(const RPCRoll &roll, const RPCDetId &rpcId, const RPCDigiCollection::Range &digiRange, const RollMask &mask)
Build all hits in the range associated to the rpcId, at the 1st step.

Member Data Documentation

std::string RPCRecHitProducer::deadSource
private

Definition at line 72 of file RPCRecHitProducer.h.

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

Definition at line 75 of file RPCRecHitProducer.h.

std::string RPCRecHitProducer::maskSource
private

Definition at line 71 of file RPCRecHitProducer.h.

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

Definition at line 74 of file RPCRecHitProducer.h.

RPCDeadStrips* RPCRecHitProducer::RPCDeadStripsObj
private

Definition at line 68 of file RPCRecHitProducer.h.

RPCMaskedStrips* RPCRecHitProducer::RPCMaskedStripsObj
private

Definition at line 65 of file RPCRecHitProducer.h.

RPCRecHitBaseAlgo* RPCRecHitProducer::theAlgo
private

Definition at line 62 of file RPCRecHitProducer.h.

edm::InputTag RPCRecHitProducer::theRPCDigiLabel
private

Definition at line 59 of file RPCRecHitProducer.h.