CMS 3D CMS Logo

RPCSeedLayerFinder.cc
Go to the documentation of this file.
1 
7 
8 using namespace std;
9 using namespace edm;
10 
12  // Initiate the member
13  LayersinRPC.clear();
14  isConfigured = false;
15  isInputset = false;
16  isOutputset = false;
17 }
18 
20 
22  // Set the configuration
23  isCosmic = iConfig.getParameter<bool>("isCosmic");
24  isMixBarrelwithEndcap = iConfig.getParameter<bool>("isMixBarrelwithEndcap");
25  RangeofLayersinBarrel = iConfig.getParameter<std::vector<unsigned int> >("RangeofLayersinBarrel");
26  RangeofLayersinEndcap = iConfig.getParameter<std::vector<unsigned int> >("RangeofLayersinEndcap");
27  isSpecialLayers = iConfig.getParameter<bool>("isSpecialLayers");
28  LayersinBarrel = iConfig.getParameter<std::vector<unsigned int> >("LayersinBarrel");
29  LayersinEndcap = iConfig.getParameter<std::vector<unsigned int> >("LayersinEndcap");
30  constrainedLayersinBarrel = iConfig.getParameter<std::vector<unsigned int> >("constrainedLayersinBarrel");
31 
32  // Set the signal open
33  isConfigured = true;
34 }
35 
37  for (unsigned int i = 0; i < RPCLayerNumber; i++)
38  recHitsinLayers[i] = recHitsRPC[i].size();
39 
40  // Set the signal open
41  isInputset = true;
42 }
43 
44 void RPCSeedLayerFinder::unsetInput() { isInputset = false; }
45 
47  RPCrecHitFinderRef = Ref;
48  RPCCosmicrecHitFinderRef = CosmicRef;
49  isOutputset = true;
50 }
51 
53  // Check if already configured
54  if (isConfigured == false || isInputset == false || isOutputset == false) {
55  cout << "RPCSeedLayerFinder needs to be configured and set IO before running RPCSeedLayerFinder::fillLayers()"
56  << endl;
57  return;
58  }
59 
60  // Clear the vector LayersinRPC
61  LayersinRPC.clear();
62 
63  // Now fill the Layers
64  if (isCosmic == true) {
65  if (RPCCosmicrecHitFinderRef != nullptr)
66  fillCosmicLayers();
67  else
68  cout << "RPCCosmicrecHitFinderRef not set" << endl;
69  } else {
70  if (RPCrecHitFinderRef != nullptr)
71  fillLayers();
72  else
73  cout << "RPCrecHitFinderRef not set" << endl;
74  }
75 }
76 
78  if (isSpecialLayers == false && isMixBarrelwithEndcap == false) {
79  for (std::vector<unsigned int>::iterator NumberofLayersinBarrel = RangeofLayersinBarrel.begin();
80  NumberofLayersinBarrel != RangeofLayersinBarrel.end();
81  NumberofLayersinBarrel++) {
82  // find N layers out of 6 Barrel Layers to fill to SeedinRPC
83  unsigned int NumberofLayers = *NumberofLayersinBarrel;
84  if (NumberofLayers < 1 || NumberofLayers > BarrelLayerNumber)
85  continue;
86  int type = 0; // type=0 for barrel
87  LayersinRPC.clear();
88  SpecialLayers(-1, NumberofLayers, type);
89  LayersinRPC.clear();
90  }
91 
92  for (std::vector<unsigned int>::iterator NumberofLayersinEndcap = RangeofLayersinEndcap.begin();
93  NumberofLayersinEndcap != RangeofLayersinEndcap.end();
94  NumberofLayersinEndcap++) {
95  unsigned int NumberofLayers = *NumberofLayersinEndcap;
96  if (NumberofLayers < 1 || NumberofLayers > EachEndcapLayerNumber)
97  continue;
98  int type = 1; // type=1 for endcap
99  // for -Z layers
100  LayersinRPC.clear();
101  SpecialLayers(BarrelLayerNumber - 1, NumberofLayers, type);
102  LayersinRPC.clear();
103  //for +Z layers
104  LayersinRPC.clear();
105  SpecialLayers(BarrelLayerNumber + EachEndcapLayerNumber - 1, NumberofLayers, type);
106  LayersinRPC.clear();
107  }
108  }
109 
110  if (isSpecialLayers == true && isMixBarrelwithEndcap == false) {
111  // Fill barrel layer for seed
112  bool EnoughforBarrel = true;
113  unsigned int i = 0;
114  LayersinRPC.clear();
115  for (std::vector<unsigned int>::iterator it = LayersinBarrel.begin(); it != LayersinBarrel.end(); it++, i++) {
116  if ((*it) != 0 && i < BarrelLayerNumber) {
117  if (recHitsinLayers[i] != 0)
118  LayersinRPC.push_back(i);
119  else {
120  cout << "Not recHits in special Barrel layer " << i << endl;
121  EnoughforBarrel = false;
122  }
123  }
124  }
125  if (EnoughforBarrel && (!LayersinRPC.empty())) {
126  // Initiate and call recHit Finder
127  RPCrecHitFinderRef->setLayers(LayersinRPC);
128  RPCrecHitFinderRef->fillrecHits();
129  }
130  LayersinRPC.clear();
131 
132  // Fill -Z and +Z endcap layer
133  bool EnoughforEndcap = true;
134 
135  // Fill endcap- layer for seed
136  i = BarrelLayerNumber;
137  EnoughforEndcap = true;
138  LayersinRPC.clear();
139  for (std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
140  if ((*it) != 0 && i < (BarrelLayerNumber + EachEndcapLayerNumber)) {
141  if (recHitsinLayers[i] != 0)
142  LayersinRPC.push_back(i);
143  else {
144  cout << "Not recHits in special Endcap " << (i - BarrelLayerNumber) << endl;
145  EnoughforEndcap = false;
146  }
147  }
148  }
149  if (EnoughforEndcap && (!LayersinRPC.empty())) {
150  // Initiate and call recHit Finder
151  RPCrecHitFinderRef->setLayers(LayersinRPC);
152  RPCrecHitFinderRef->fillrecHits();
153  }
154  LayersinRPC.clear();
155 
156  //Fill endcap+ layer for seed
157  i = BarrelLayerNumber;
158  EnoughforEndcap = true;
159  LayersinRPC.clear();
160  for (std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
161  if ((*it) != 0 && i >= (BarrelLayerNumber + EachEndcapLayerNumber) &&
163  if (recHitsinLayers[i] != 0)
164  LayersinRPC.push_back(i);
165  else {
166  cout << "Not recHits in special Endcap " << i << endl;
167  EnoughforEndcap = false;
168  }
169  }
170  }
171  if (EnoughforEndcap && (!LayersinRPC.empty())) {
172  // Initiate and call recHit Finder
173  RPCrecHitFinderRef->setLayers(LayersinRPC);
174  RPCrecHitFinderRef->fillrecHits();
175  }
176  LayersinRPC.clear();
177  }
178 
179  if (isMixBarrelwithEndcap == true) {
180  cout << " Mix is not ready for non-cosmic case" << endl;
181  LayersinRPC.clear();
182  }
183 }
184 
186  // For cosmic only handle the SpecialLayers case
187  if (isSpecialLayers == true && isMixBarrelwithEndcap == false) {
188  // Fill barrel layer for seed
189  unsigned int i = 0;
190  LayersinRPC.clear();
191  for (std::vector<unsigned int>::iterator it = LayersinBarrel.begin(); it != LayersinBarrel.end(); it++, i++) {
192  if ((*it) != 0 && i < BarrelLayerNumber)
193  if (recHitsinLayers[i] != 0)
194  LayersinRPC.push_back(i);
195  }
196  if (!LayersinRPC.empty()) {
197  // Initiate and call recHit Finder
198  RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
199  RPCCosmicrecHitFinderRef->fillrecHits();
200  }
201  LayersinRPC.clear();
202 
203  // Fill -Z and +Z endcap layer
204 
205  // Fill endcap- layer for seed
206  i = BarrelLayerNumber;
207  LayersinRPC.clear();
208  for (std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
209  if ((*it) != 0 && i < (BarrelLayerNumber + EachEndcapLayerNumber))
210  if (recHitsinLayers[i] != 0)
211  LayersinRPC.push_back(i);
212  }
213  if (!LayersinRPC.empty()) {
214  // Initiate and call recHit Finder
215  RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
216  RPCCosmicrecHitFinderRef->fillrecHits();
217  }
218  LayersinRPC.clear();
219 
220  //Fill endcap+ layer for seed
221  i = BarrelLayerNumber;
222  LayersinRPC.clear();
223  for (std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
224  if ((*it) != 0 && i >= (BarrelLayerNumber + EachEndcapLayerNumber) &&
226  if (recHitsinLayers[i] != 0)
227  LayersinRPC.push_back(i);
228  }
229  if (!LayersinRPC.empty()) {
230  // Initiate and call recHit Finder
231  RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
232  RPCCosmicrecHitFinderRef->fillrecHits();
233  }
234  LayersinRPC.clear();
235  }
236 
237  if (isSpecialLayers == true && isMixBarrelwithEndcap == true) {
238  // Fill all
239  unsigned int i = 0;
240  LayersinRPC.clear();
241  for (std::vector<unsigned int>::iterator it = LayersinBarrel.begin(); it != LayersinBarrel.end(); it++, i++) {
242  if ((*it) != 0 && i < BarrelLayerNumber)
243  if (recHitsinLayers[i] != 0)
244  LayersinRPC.push_back(i);
245  }
246  i = BarrelLayerNumber;
247  for (std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
248  if ((*it) != 0 && i < (BarrelLayerNumber + EachEndcapLayerNumber * 2))
249  if (recHitsinLayers[i] != 0)
250  LayersinRPC.push_back(i);
251  }
252 
253  if (!LayersinRPC.empty()) {
254  // Initiate and call recHit Finder
255  RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
256  RPCCosmicrecHitFinderRef->fillrecHits();
257  }
258  LayersinRPC.clear();
259  }
260 
261  if (isSpecialLayers == false) {
262  cout << "Not ready for not SpecialLayers for Cosmic case" << endl;
263  LayersinRPC.clear();
264  }
265 }
266 
267 void RPCSeedLayerFinder::SpecialLayers(int last, unsigned int NumberofLayers, int type) {
268  // check type, 0=barrel, 1=endcap, 2=mix
269 
270  // barrel has 6 layers
271  if (type == 0) {
272  if (NumberofLayers > BarrelLayerNumber) {
273  cout << "NumberofLayers larger than max layers in barrel" << endl;
274  return;
275  }
276  for (unsigned int i = (last + 1); i <= (BarrelLayerNumber - NumberofLayers + LayersinRPC.size()); i++) {
277  if (recHitsinLayers[i] != 0) {
278  LayersinRPC.push_back(i);
279  last = i;
280  if (LayersinRPC.size() < NumberofLayers)
281  SpecialLayers(last, NumberofLayers, type);
282  else {
283  if (checkConstrain()) {
284  cout << "Find special barrel layers: ";
285  for (unsigned int k = 0; k < NumberofLayers; k++)
286  cout << LayersinRPC[k] << " ";
287  cout << endl;
288  // Initiate and call recHit Finder
289  RPCrecHitFinderRef->setLayers(LayersinRPC);
290  RPCrecHitFinderRef->fillrecHits();
291  } else
292  cout << "The layers don't contain all layers in constrain" << endl;
293  }
294  LayersinRPC.pop_back();
295  }
296  }
297  }
298 
299  // endcap has 3 layers for each -Z and +Z
300  if (type == 1) {
301  if (NumberofLayers > EachEndcapLayerNumber) {
302  cout << "NumberofLayers larger than max layers in endcap" << endl;
303  return;
304  }
305  if (last < (BarrelLayerNumber + EachEndcapLayerNumber - 1) ||
306  (last == (BarrelLayerNumber + EachEndcapLayerNumber - 1) && !LayersinRPC.empty())) {
307  // For -Z case
308  for (unsigned int i = (last + 1);
309  i <= (BarrelLayerNumber + EachEndcapLayerNumber - NumberofLayers + LayersinRPC.size());
310  i++) {
311  if (recHitsinLayers[i] != 0) {
312  LayersinRPC.push_back(i);
313  last = i;
314  if (LayersinRPC.size() < NumberofLayers)
315  SpecialLayers(last, NumberofLayers, type);
316  else {
317  cout << "Find special -Z endcap layers: ";
318  for (unsigned int k = 0; k < NumberofLayers; k++)
319  cout << LayersinRPC[k] << " ";
320  cout << endl;
321  // Initiate and call recHit Finder
322  RPCrecHitFinderRef->setLayers(LayersinRPC);
323  RPCrecHitFinderRef->fillrecHits();
324  }
325  LayersinRPC.pop_back();
326  }
327  }
328  } else {
329  // For +Z case
330  for (unsigned int i = (last + 1);
331  i <= (BarrelLayerNumber + EachEndcapLayerNumber * 2 - NumberofLayers + LayersinRPC.size());
332  i++) {
333  if (recHitsinLayers[i] != 0) {
334  LayersinRPC.push_back(i);
335  last = i;
336  if (LayersinRPC.size() < NumberofLayers)
337  SpecialLayers(last, NumberofLayers, type);
338  else {
339  cout << "Find special +Z endcap layers: ";
340  for (unsigned int k = 0; k < NumberofLayers; k++)
341  cout << LayersinRPC[k] << " ";
342  cout << endl;
343  // Initiate and call recHit Finder
344  RPCrecHitFinderRef->setLayers(LayersinRPC);
345  RPCrecHitFinderRef->fillrecHits();
346  }
347  LayersinRPC.pop_back();
348  }
349  }
350  }
351  }
352 }
353 
355  bool pass = true;
356  std::vector<unsigned int> fitConstrain = constrainedLayersinBarrel;
357  for (unsigned int i = 0; i < LayersinRPC.size(); i++)
358  fitConstrain[LayersinRPC[i]] = 0;
359  for (unsigned int i = 0; i < BarrelLayerNumber; i++)
360  if (fitConstrain[i] != 0)
361  pass = false;
362  return pass;
363 }
size
Write out results.
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
#define RPCLayerNumber
void configure(const edm::ParameterSet &iConfig)
void setInput(MuonRecHitContainer(&recHitsRPC)[12])
void setOutput(RPCSeedrecHitFinder *Ref, RPCCosmicSeedrecHitFinder *CosmicRef)
#define EachEndcapLayerNumber
HLT enums.
#define BarrelLayerNumber
void SpecialLayers(int last, unsigned int NumberofLayers, int type)