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 
31 
32 #include <string>
33 
34 
35 using namespace edm;
36 using namespace std;
37 
38 
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 
55  RPCMaskedStripsObj = new RPCMaskedStrips();
56 
57  RPCDeadStripsObj = new RPCDeadStrips();
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 }
94 
95 
97 
98  delete theAlgo;
99  delete RPCMaskedStripsObj;
100  delete RPCDeadStripsObj;
101 
102 }
103 
104 
105 
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 }
147 
148 
149 
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 }
218 
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(edm::Run &, const edm::EventSetup &)
iterator begin()
Definition: OwnVector.h:227
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
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
virtual void produce(edm::Event &event, const edm::EventSetup &setup)
The method which produces the rechits.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:33