CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCRecHitProducer.cc
Go to the documentation of this file.
1 
8 #include "RPCRecHitProducer.h"
9 
10 
14 
16 
22 
26 
32 
33 #include <string>
34 
35 
36 using namespace edm;
37 using namespace std;
38 
39 
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 
56  RPCMaskedStripsObj = new RPCMaskedStrips();
57 
58  RPCDeadStripsObj = new RPCDeadStrips();
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 }
95 
96 
98 
99  delete theAlgo;
100  delete RPCMaskedStripsObj;
101  delete RPCDeadStripsObj;
102 
103 }
104 
105 
106 
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 }
148 
149 
150 
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 }
223 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< MaskItem > MaskVec
size_type size() const
Definition: OwnVector.h:247
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
iterator begin()
Definition: OwnVector.h:227
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the rechits.
std::bitset< maskSIZE > RollMask
Definition: RPCRollMask.h:8
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual ~RPCRecHitProducer()
Destructor.
iterator end()
Definition: OwnVector.h:232
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
RPCRecHitProducer(const edm::ParameterSet &config)
Constructor.
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::vector< DeadItem > DeadVec
Definition: RPCDeadStrips.h:24
std::pair< const_iterator, const_iterator > Range
std::string fullPath() const
Definition: FileInPath.cc:171
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:36