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 
6 #include "RPCRecHitProducer.h"
7 
8 
12 
18 
22 
28 
29 #include <string>
30 
31 
32 using namespace edm;
33 using namespace std;
34 
35 
37 
38  // Set verbose output
39 
40  produces<RPCRecHitCollection>();
41 
42  theRPCDigiLabel = consumes<RPCDigiCollection>(config.getParameter<InputTag>("rpcDigiLabel"));
43 
44  // Get the concrete reconstruction algo from the factory
45 
46  string theAlgoName = config.getParameter<string>("recAlgo");
47  theAlgo = RPCRecHitAlgoFactory::get()->create(theAlgoName,
48  config.getParameter<ParameterSet>("recAlgoConfig"));
49 
50  // Get masked- and dead-strip information
51 
52  RPCMaskedStripsObj = new RPCMaskedStrips();
53 
54  RPCDeadStripsObj = new RPCDeadStrips();
55 
56  maskSource = config.getParameter<std::string>("maskSource");
57 
58  if (maskSource == "File") {
59  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
60  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
61  if ( !inputFile ) {
62  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
63  exit(1);
64  }
65  while ( inputFile.good() ) {
67  inputFile >> Item.rawId >> Item.strip;
68  if ( inputFile.good() ) MaskVec.push_back(Item);
69  }
70  inputFile.close();
71  }
72 
73  deadSource = config.getParameter<std::string>("deadSource");
74 
75  if (deadSource == "File") {
76  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
77  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
78  if ( !inputFile ) {
79  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
80  exit(1);
81  }
82  while ( inputFile.good() ) {
84  inputFile >> Item.rawId >> Item.strip;
85  if ( inputFile.good() ) DeadVec.push_back(Item);
86  }
87  inputFile.close();
88  }
89 
90 }
91 
92 
94 
95  delete theAlgo;
96  delete RPCMaskedStripsObj;
97  delete RPCDeadStripsObj;
98 
99 }
100 
101 
102 
104 
105  // Getting the masked-strip information
106 
107  if ( maskSource == "EventSetup" ) {
108  edm::ESHandle<RPCMaskedStrips> readoutMaskedStrips;
109  setup.get<RPCMaskedStripsRcd>().get(readoutMaskedStrips);
110  const RPCMaskedStrips* tmp_obj = readoutMaskedStrips.product();
111  RPCMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
112  delete tmp_obj;
113  }
114  else if ( maskSource == "File" ) {
115  std::vector<RPCMaskedStrips::MaskItem>::iterator posVec;
116  for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
118  Item.rawId = (*posVec).rawId;
119  Item.strip = (*posVec).strip;
120  RPCMaskedStripsObj->MaskVec.push_back(Item);
121  }
122  }
123 
124  // Getting the dead-strip information
125 
126  if ( deadSource == "EventSetup" ) {
127  edm::ESHandle<RPCDeadStrips> readoutDeadStrips;
128  setup.get<RPCDeadStripsRcd>().get(readoutDeadStrips);
129  const RPCDeadStrips* tmp_obj = readoutDeadStrips.product();
130  RPCDeadStripsObj->DeadVec = tmp_obj->DeadVec;
131  delete tmp_obj;
132  }
133  else if ( deadSource == "File" ) {
134  std::vector<RPCDeadStrips::DeadItem>::iterator posVec;
135  for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
137  Item.rawId = (*posVec).rawId;
138  Item.strip = (*posVec).strip;
139  RPCDeadStripsObj->DeadVec.push_back(Item);
140  }
141  }
142 
143 }
144 
145 
146 
148 
149  // Get the RPC Geometry
150 
151  ESHandle<RPCGeometry> rpcGeom;
152  setup.get<MuonGeometryRecord>().get(rpcGeom);
153 
154  // Get the digis from the event
155 
157  event.getByToken(theRPCDigiLabel,digis);
158 
159  // Pass the EventSetup to the algo
160 
161  theAlgo->setES(setup);
162 
163  // Create the pointer to the collection which will store the rechits
164 
165  auto_ptr<RPCRecHitCollection> recHitCollection(new RPCRecHitCollection());
166 
167  // Iterate through all digi collections ordered by LayerId
168 
170  for (rpcdgIt = digis->begin(); rpcdgIt != digis->end();
171  ++rpcdgIt){
172 
173  // The layerId
174  const RPCDetId& rpcId = (*rpcdgIt).first;
175 
176  // Get the GeomDet from the setup
177  const RPCRoll* roll = rpcGeom->roll(rpcId);
178  if (roll == 0){
179  edm::LogError("BadDigiInput")<<"Failed to find RPCRoll for ID "<<rpcId;
180  continue;
181  }
182 
183  // Get the iterators over the digis associated with this LayerId
184  const RPCDigiCollection::Range& range = (*rpcdgIt).second;
185 
186 
187  // Getting the roll mask, that includes dead strips, for the given RPCDet
188 
189  RollMask mask;
190  int rawId = rpcId.rawId();
191  int Size = RPCMaskedStripsObj->MaskVec.size();
192  for (int i = 0; i < Size; i++ ) {
193  if ( RPCMaskedStripsObj->MaskVec[i].rawId == rawId ) {
194  int bit = RPCMaskedStripsObj->MaskVec[i].strip;
195  mask.set(bit-1);
196  }
197  }
198 
199  Size = RPCDeadStripsObj->DeadVec.size();
200  for (int i = 0; i < Size; i++ ) {
201  if ( RPCDeadStripsObj->DeadVec[i].rawId == rawId ) {
202  int bit = RPCDeadStripsObj->DeadVec[i].strip;
203  mask.set(bit-1);
204  }
205  }
206 
207  // Call the reconstruction algorithm
208 
210  theAlgo->reconstruct(*roll, rpcId, range, mask);
211 
212  if(recHits.size() > 0) //FIXME: is it really needed?
213  recHitCollection->put(rpcId, recHits.begin(), recHits.end());
214  }
215 
216  event.put(recHitCollection);
217 
218 }
219 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< MaskItem > MaskVec
size_type size() const
Definition: OwnVector.h:264
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
iterator begin()
Definition: OwnVector.h:244
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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:249
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:56
T const * product() const
Definition: ESHandle.h:86
std::vector< DeadItem > DeadVec
Definition: RPCDeadStrips.h:28
std::pair< const_iterator, const_iterator > Range
std::string fullPath() const
Definition: FileInPath.cc:184
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:43