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::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run &, const edm::EventSetup &)
 
virtual void endRun (edm::Run &, const edm::EventSetup &)
 
virtual void produce (edm::Event &event, const edm::EventSetup &setup)
 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 &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Module for RPCRecHit production.

Date:
2010/10/19 19:18:52
Revision:
1.6
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 39 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, RPCDeadStrips::DeadItem::strip, and RPCMaskedStrips::MaskItem::strip.

39  {
40 
41  // Set verbose output
42 
43  produces<RPCRecHitCollection>();
44 
45  theRPCDigiLabel = config.getParameter<InputTag>("rpcDigiLabel");
46 
47  // Get the concrete reconstruction algo from the factory
48 
49  string theAlgoName = config.getParameter<string>("recAlgo");
50  theAlgo = RPCRecHitAlgoFactory::get()->create(theAlgoName,
51  config.getParameter<ParameterSet>("recAlgoConfig"));
52 
53  // Get masked- and dead-strip information
54 
56 
58 
59  maskSource = config.getParameter<std::string>("maskSource");
60 
61  if (maskSource == "File") {
62  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
63  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
64  if ( !inputFile ) {
65  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
66  exit(1);
67  }
68  while ( inputFile.good() ) {
70  inputFile >> Item.rawId >> Item.strip;
71  if ( inputFile.good() ) MaskVec.push_back(Item);
72  }
73  inputFile.close();
74  }
75 
76  deadSource = config.getParameter<std::string>("deadSource");
77 
78  if (deadSource == "File") {
79  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
80  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
81  if ( !inputFile ) {
82  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
83  exit(1);
84  }
85  while ( inputFile.good() ) {
87  inputFile >> Item.rawId >> Item.strip;
88  if ( inputFile.good() ) DeadVec.push_back(Item);
89  }
90  inputFile.close();
91  }
92 
93 }
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 96 of file RPCRecHitProducer.cc.

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

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 106 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.

106  {
107 
108  // Getting the masked-strip information
109 
110  if ( maskSource == "EventSetup" ) {
111  edm::ESHandle<RPCMaskedStrips> readoutMaskedStrips;
112  setup.get<RPCMaskedStripsRcd>().get(readoutMaskedStrips);
113  const RPCMaskedStrips* tmp_obj = readoutMaskedStrips.product();
114  RPCMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
115  delete tmp_obj;
116  }
117  else if ( maskSource == "File" ) {
118  std::vector<RPCMaskedStrips::MaskItem>::iterator posVec;
119  for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
121  Item.rawId = (*posVec).rawId;
122  Item.strip = (*posVec).strip;
123  RPCMaskedStripsObj->MaskVec.push_back(Item);
124  }
125  }
126 
127  // Getting the dead-strip information
128 
129  if ( deadSource == "EventSetup" ) {
130  edm::ESHandle<RPCDeadStrips> readoutDeadStrips;
131  setup.get<RPCDeadStripsRcd>().get(readoutDeadStrips);
132  const RPCDeadStrips* tmp_obj = readoutDeadStrips.product();
133  RPCDeadStripsObj->DeadVec = tmp_obj->DeadVec;
134  delete tmp_obj;
135  }
136  else if ( deadSource == "File" ) {
137  std::vector<RPCDeadStrips::DeadItem>::iterator posVec;
138  for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
140  Item.rawId = (*posVec).rawId;
141  Item.strip = (*posVec).strip;
142  RPCDeadStripsObj->DeadVec.push_back(Item);
143  }
144  }
145 
146 }
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
virtual void RPCRecHitProducer::endRun ( edm::Run ,
const edm::EventSetup  
)
inlinevirtual

Reimplemented from edm::EDProducer.

Definition at line 52 of file RPCRecHitProducer.h.

52 {;}
void RPCRecHitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
virtual

The method which produces the rechits.

Implements edm::EDProducer.

Definition at line 150 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().

150  {
151 
152  // Get the RPC Geometry
153 
154  ESHandle<RPCGeometry> rpcGeom;
155  setup.get<MuonGeometryRecord>().get(rpcGeom);
156 
157  // Get the digis from the event
158 
160  event.getByLabel(theRPCDigiLabel,digis);
161 
162  // Pass the EventSetup to the algo
163 
164  theAlgo->setES(setup);
165 
166  // Create the pointer to the collection which will store the rechits
167 
168  auto_ptr<RPCRecHitCollection> recHitCollection(new RPCRecHitCollection());
169 
170  // Iterate through all digi collections ordered by LayerId
171 
173  for (rpcdgIt = digis->begin(); rpcdgIt != digis->end();
174  ++rpcdgIt){
175 
176  // The layerId
177  const RPCDetId& rpcId = (*rpcdgIt).first;
178 
179  // Get the GeomDet from the setup
180  const RPCRoll* roll = rpcGeom->roll(rpcId);
181 
182  // Get the iterators over the digis associated with this LayerId
183  const RPCDigiCollection::Range& range = (*rpcdgIt).second;
184 
185 
186  // Getting the roll mask, that includes dead strips, for the given RPCDet
187 
188  RollMask mask;
189  int rawId = rpcId.rawId();
190  int Size = RPCMaskedStripsObj->MaskVec.size();
191  for (int i = 0; i < Size; i++ ) {
192  if ( RPCMaskedStripsObj->MaskVec[i].rawId == rawId ) {
193  int bit = RPCMaskedStripsObj->MaskVec[i].strip;
194  mask.set(bit-1);
195  }
196  }
197 
198  Size = RPCDeadStripsObj->DeadVec.size();
199  for (int i = 0; i < Size; i++ ) {
200  if ( RPCDeadStripsObj->DeadVec[i].rawId == rawId ) {
201  int bit = RPCDeadStripsObj->DeadVec[i].strip;
202  mask.set(bit-1);
203  }
204  }
205 
206  // Call the reconstruction algorithm
207 
208  OwnVector<RPCRecHit> recHits =
209  theAlgo->reconstruct(*roll, rpcId, range, mask);
210 
211  if(recHits.size() > 0) //FIXME: is it really needed?
212  recHitCollection->put(rpcId, recHits.begin(), recHits.end());
213  }
214 
215  event.put(recHitCollection);
216 
217 }
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 73 of file RPCRecHitProducer.h.

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

Definition at line 76 of file RPCRecHitProducer.h.

std::string RPCRecHitProducer::maskSource
private

Definition at line 72 of file RPCRecHitProducer.h.

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

Definition at line 75 of file RPCRecHitProducer.h.

RPCDeadStrips* RPCRecHitProducer::RPCDeadStripsObj
private

Definition at line 69 of file RPCRecHitProducer.h.

RPCMaskedStrips* RPCRecHitProducer::RPCMaskedStripsObj
private

Definition at line 66 of file RPCRecHitProducer.h.

RPCRecHitBaseAlgo* RPCRecHitProducer::theAlgo
private

Definition at line 63 of file RPCRecHitProducer.h.

edm::InputTag RPCRecHitProducer::theRPCDigiLabel
private

Definition at line 60 of file RPCRecHitProducer.h.