CMS 3D CMS Logo

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