CMS 3D CMS Logo

BXAnalyzer.h
Go to the documentation of this file.
1 
10 #ifndef ADD_BXAnalyzer
11 #define ADD_BXAnalyzer
12 
13 
16 
17 std::vector<std::vector<ConvertedHit>> GroupBX(std::vector<ConvertedHit> ConvHits){
18 
19  std::vector<ConvertedHit> tmp;
20  std::vector<std::vector<ConvertedHit>> output (3,tmp);
21 
22  const int CentralBX = 6;
23 
24  for(std::vector<ConvertedHit>::iterator i = ConvHits.begin();i != ConvHits.end();i++){
25 
26  int diff = i->BX() - CentralBX;
27 
28  if((diff > -3) && (diff < 1))
29  output[0].push_back(*i);
30 
31  if((diff < 3) && (diff > -1))
32  output[2].push_back(*i);
33 
34  if(std::abs(diff) < 2)
35  output[1].push_back(*i);
36  }
37 
38  for (int i = 1; i < 3; i++) {
39  unsigned int HasAllInNext = 0;
40  for (unsigned int it = 0; it != output[i-1].size(); it++) {
41  bool InNext = false;
42  for (unsigned int it2 = 0; it2 != output[i].size(); it2++) {
43  if( output[i-1][it].Phi() == output[i][it2].Phi() &&
44  output[i-1][it].Theta() == output[i][it2].Theta() &&
45  output[i-1][it].Ph_hit() == output[i][it2].Ph_hit() &&
46  output[i-1][it].Phzvl() == output[i][it2].Phzvl() &&
47  output[i-1][it].Station() == output[i][it2].Station() &&
48  output[i-1][it].Sub() == output[i][it2].Sub() &&
49  output[i-1][it].Id() == output[i][it2].Id() &&
50  output[i-1][it].Quality() == output[i][it2].Quality() &&
51  output[i-1][it].Pattern() == output[i][it2].Pattern() &&
52  output[i-1][it].Wire() == output[i][it2].Wire() &&
53  output[i-1][it].Strip() == output[i][it2].Strip() &&
54  output[i-1][it].BX() == output[i][it2].BX() ) InNext = true;
55  }
56  if (InNext) HasAllInNext++;
57  }
58  if (HasAllInNext == output[i-1].size()) output[i-1].clear();
59  }
60 
61  for(int i=0;i<3;i++){
62 
63  for(std::vector<ConvertedHit>::iterator it = output[i].begin();it != output[i].end();it++){
64  for(std::vector<ConvertedHit>::iterator it2 = it;it2 != output[i].end();it2++){
65 
66  if(it == it2) continue;
67 
68  //add that phis have to be equal if assuming that a phi position can have only 2 possible thetas
69  if(it->Station() == it2->Station() && it->Id() == it2->Id() && it->IsNeighbor() == it2->IsNeighbor()){
70 
71  it->SetTheta2(it2->Theta());
72  it2->SetTheta2(it->Theta());
73 
74  it->AddTheta(it2->Theta());
75  it2->AddTheta(it->Theta());
76  }
77 
78  }
79  }
80 
81  }
82 
83  return output;
84 }
85 
86 PatternOutput DeleteDuplicatePatterns(std::vector<PatternOutput> Pout){
87 
88  std::vector<int> tmp (192,0);//was 128
89  std::vector<std::vector<int>> rank (4,tmp), layer(4,tmp),straightness(4,tmp),bxgroup(4,tmp);
90  std::vector<ConvertedHit> Hits;
91 
92  for(int i=0;i<3;i++){
93 
94  bool set = 0;
95 
96  for(int zone=0;zone<4;zone++){
97  for(int strip=0;strip<192;strip++){//was 128
98 
99  if(Pout[i].detected.rank[zone][strip] > rank[zone][strip]){
100 
101  rank[zone][strip] = Pout[i].detected.rank[zone][strip];
102  layer[zone][strip] = Pout[i].detected.layer[zone][strip];
103  straightness[zone][strip] = Pout[i].detected.straightness[zone][strip];
104  bxgroup[zone][strip] = i+1;
105  set = 1;
106  }
107  }
108  }
109 
110  if(set ){/*//&& (Pout[i].hits.size() >= Hits.size())){*/
111 
112  std::vector<ConvertedHit> test = Pout[i].hits;
113 
114  for(std::vector<ConvertedHit>::iterator it = test.begin();it != test.end();it++){
115  Hits.push_back(*it);
116  }
117  }
118 
119  }
120 
121  QualityOutput qout;
122  qout.rank = rank;
123  qout.layer = layer;
124  qout.straightness = straightness;
125  qout.bxgroup = bxgroup;
126 
128  output.detected = qout;
129  output.hits = Hits;
130 
131  return output;
132 
133 }
134 
135 #endif
size
Write out results.
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:30
PatternOutput DeleteDuplicatePatterns(std::vector< PatternOutput > Pout)
Definition: BXAnalyzer.h:86
std::vector< std::vector< ConvertedHit > > GroupBX(std::vector< ConvertedHit > ConvHits)
Definition: BXAnalyzer.h:17
QualityOutput detected
std::vector< ConvertedHit > hits