CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTTSTheta.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTTSTheta.cpp
4 //
5 // Description: Implementation of TS Theta trigger algorithm
6 //
7 //
8 // Author List:
9 // C. Grandi
10 // Modifications:
11 // III/2005 : Sara Vanini NEWGEO update
12 // I/2007 : Carlo Battilana Config class update
13 // mar07 - S. Vanini : parameters from DTConfigManager
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
21 
22 //-------------------------------
23 // Collaborating Class Headers --
24 //-------------------------------
28 
29 //---------------
30 // C++ Headers --
31 //---------------
32 #include <iostream>
33 
34 //----------------
35 // Constructors --
36 //----------------
37 DTTSTheta::DTTSTheta(DTTrigGeom* geom, DTBtiCard* bticard) : DTGeomSupplier(geom), _bticard(bticard) {
38  for (int i = 0; i < DTConfigTSTheta::NSTEPL - DTConfigTSTheta::NSTEPF + 1; i++) {
39  _trig[i].zero();
40  _Htrig[i].zero();
41  _ntrig[i] = 0;
42  _nHtrig[i] = 0;
43  }
44 }
45 
46 //--------------
47 // Destructor --
48 //--------------
50  //delete _config;
51 }
52 
53 //--------------
54 // Operations --
55 //--------------
56 
58  for (int is = 0; is < DTConfigTSTheta::NSTEPL - DTConfigTSTheta::NSTEPF + 1; is++) {
59  // clear input bit masks
60  _trig[is].zero();
61  _Htrig[is].zero();
62  _ntrig[is] = 0;
63  _nHtrig[is] = 0;
64  }
65 }
66 
68  DTChamberId sid = ChamberId();
69  _config = conf->getDTConfigTSTheta(sid);
70 }
71 
73  localClear();
74  if (station() == 4)
75  return;
76 
77  if (config()->debug()) {
78  std::cout << "DTTSTheta::loadDTTSTheta called for wheel=" << wheel();
79  std::cout << ", station=" << station();
80  std::cout << ", sector=" << sector() << std::endl;
81  }
82 
83  // loop on all BTI triggers
84  std::vector<DTBtiTrigData>::const_iterator p;
85  std::vector<DTBtiTrigData>::const_iterator pend = _bticard->end();
86  for (p = _bticard->begin(); p != pend; p++) {
87  // Look only to BTIs in SL 2
88  if (p->btiSL() == 2) {
89  // BTI number
90  int step = p->step();
91  add_btiT(step, &(*p));
92  }
93  }
94 }
95 
96 void DTTSTheta::add_btiT(int step, const DTBtiTrigData* btitrig) {
97  int n = btitrig->btiNumber();
98 
99  /*
100 OBSOLETE! in NEWGEO the bti number order is the correct one!
101  // check where the BTI is, and reverse the order in stat 1 and 2 and 3 (only for some sectors)
102 
103  if( (wheel()==0 && (sector()==1 || sector()==4 || sector()==5 ||
104  sector()==8 || sector()==9 || sector()==12))
105  || wheel()==-1
106  || wheel()==-2)
107  {n=DTConfigTSTheta::NCELLTH + 1 - n; }
108 
109 */
110 
111  if (n < 1 || n > geom()->nCell(2)) {
112  std::cout << "DTTSTheta::add_btiT: BTI out of range: " << n;
113  std::cout << " trigger not added!" << std::endl;
114  return;
115  }
117  std::cout << "DTTSTheta::add_btiT: step out of range: " << step;
118  std::cout << " trigger not added!" << std::endl;
119  return;
120  }
121  _trig[step - DTConfigTSTheta::NSTEPF].set(n - 1);
123 
124  if (btitrig->code() == 8) {
125  _Htrig[step - DTConfigTSTheta::NSTEPF].set(n - 1);
127  }
128 
129  if (config()->debug()) {
130  std::cout << "BTI Trigger added at step " << step;
131  std::cout << " to DTTSTheta at position " << n << std::endl;
132  }
133  return;
134 }
135 
137  // Just make a DTChambThSegm for each step and store it
138  for (int is = DTConfigTSTheta::NSTEPF; is < DTConfigTSTheta::NSTEPL + 1; is++) {
139  if (_ntrig[is - DTConfigTSTheta::NSTEPF] > 0) {
140  int i = 0;
141  int code[8];
142  int pos[8];
143  int qual[8];
144  for (i = 0; i < 8; i++) {
145  //@@ MULT not implemented:
146  pos[i] = btiMask(is)->byte(i).any();
147  qual[i] = btiQual(is)->byte(i).any();
148  code[i] = pos[i] + qual[i];
149  }
150 
151  // SM .OR. response of BTI number 57 in previous group of 8 BTIs
152 
153  if (pos[7] > pos[6])
154  pos[6] = pos[7];
155  if (qual[7] > qual[6])
156  qual[6] = qual[7];
157  if (code[7] > code[6])
158  code[6] = code[7];
159 
160  if (config()->debug()) {
161  std::cout << " wheel = " << wheel() << " station = " << station() << " sector = " << sector() << std::endl;
162  std::cout << " pos : ";
163  for (i = 0; i < 8; i++) {
164  std::cout << pos[i] << " ";
165  }
166  std::cout << std::endl;
167  std::cout << " qual : ";
168  for (i = 0; i < 8; i++) {
169  std::cout << qual[i] << " ";
170  }
171  std::cout << std::endl;
172  std::cout << " code : ";
173  for (i = 0; i < 8; i++) {
174  std::cout << code[i] << " ";
175  }
176  std::cout << std::endl;
177  std::cout << std::endl;
178  }
179 
180  _cache.push_back(DTChambThSegm(ChamberId(), is, pos, qual));
181  }
182  }
183 
184  // debugging...
185  if (config()->debug()) {
186  if (!_cache.empty()) {
187  std::cout << "====================================================" << std::endl;
188  std::cout << " Theta segments " << std::endl;
189  std::vector<DTChambThSegm>::const_iterator p;
190  for (p = _cache.begin(); p < _cache.end(); p++) {
191  p->print();
192  }
193  std::cout << "====================================================" << std::endl;
194  }
195  }
196  // end debugging
197 }
198 
200  int n = 0;
201  std::vector<DTChambThSegm>::const_iterator p;
202  for (p = begin(); p < end(); p++) {
203  if (p->step() == step)
204  n++;
205  }
206  return n;
207 }
208 
209 const DTChambThSegm* DTTSTheta::segment(int step, unsigned n) {
210  std::vector<DTChambThSegm>::const_iterator p;
211  for (p = begin(); p < end(); p++) {
212  if (p->step() == step && n == 1)
213  return &(*p);
214  }
215  return nullptr;
216 }
217 
220  std::cout << "DTTSTheta::nTrig: step out of range " << step;
221  std::cout << " 0 returned" << std::endl;
222  return 0;
223  }
224  if (size() > 0)
225  return _ntrig[step - DTConfigTSTheta::NSTEPF];
226  return 0;
227 }
228 
231  std::cout << "DTTSTheta::nHTrig: step out of range " << step;
232  std::cout << " 0 returned" << std::endl;
233  return 0;
234  }
235  if (size() > 0)
236  return _nHtrig[step - DTConfigTSTheta::NSTEPF];
237  return 0;
238 }
239 
242  std::cout << "DTTSTheta::btiMask: step out of range " << step;
243  std::cout << " empty pointer returned" << std::endl;
244  return nullptr;
245  }
247 }
248 
251  std::cout << "DTTSTheta::btiQual: step out of range " << step;
252  std::cout << " empty pointer returned" << std::endl;
253  return nullptr;
254  }
256 }
257 
259  //const DTChambThSegm* trig = dynamic_cast<const DTChambThSegm*>(tr);
260  //@@ Not implemented yet
261  return LocalPoint(0, 0, 0);
262 }
263 
265  //const DTChambThSegm* trig = dynamic_cast<const DTChambThSegm*>(tr);
266  //@@ Not implemented yet
267  return LocalVector(0, 0, 0);
268 }
269 
270 void DTTSTheta::print(const DTTrigData* trig) const {
271  trig->print();
272  //@@ coordinate printing not implemented yet
273  //@@ rermove this method as soon as the local coordinates are meaningful
274 }
virtual void print() const =0
Print a trigger-data object with also local and global position/direction.
DTTrigGeom * geom() const
Associated geometry.
my_collection _cache
Definition: DTCache.h:53
Local3DVector LocalVector
Definition: LocalVector.h:12
int nHTrig(int step)
Return number of DTBtiChip fired with a HTRIG (used by DTTracoChip)
Definition: DTTSTheta.cc:229
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
int sector() const
Return sector number.
int any()
Definition: BitArray.h:176
BitArray< DTConfigTSTheta::NCELLTH > _trig[DTConfigTSTheta::NSTEPL-DTConfigTSTheta::NSTEPF+1]
Definition: DTTSTheta.h:111
void add_btiT(int step, const DTBtiTrigData *btitrig)
Add a DTBtiChip L1Trigger to the DTTSTheta.
Definition: DTTSTheta.cc:96
void zero()
Definition: BitArray.h:210
int _ntrig[DTConfigTSTheta::NSTEPL-DTConfigTSTheta::NSTEPF+1]
Definition: DTTSTheta.h:113
void runDTTSTheta()
run DTTSTheta algorithm (build the mask)
Definition: DTTSTheta.cc:136
BitArray< 8 > byte(const int i) const
Definition: BitArray.h:282
static const int NSTEPF
Definition: DTConfig.h:35
~DTTSTheta() override
Destructor.
Definition: DTTSTheta.cc:49
const DTChambThSegm * segment(int step, unsigned n)
Return the requested DTTSTheta segment (only the first)
Definition: DTTSTheta.cc:209
int station() const
Return station number.
BitArray< DTConfigTSTheta::NCELLTH > * btiMask(int step) const
Return the BitArray of DTBtiChip fired.
Definition: DTTSTheta.cc:240
int wheel() const
Return wheel number.
const DTConfigTSTheta * config() const
Return configuration.
Definition: DTTSTheta.h:54
int _nHtrig[DTConfigTSTheta::NSTEPL-DTConfigTSTheta::NSTEPF+1]
Definition: DTTSTheta.h:114
BitArray< DTConfigTSTheta::NCELLTH > * btiQual(int step) const
Return the BitArray of DTBtiChip fired with a HTRIG.
Definition: DTTSTheta.cc:249
void localClear()
Clear.
Definition: DTTSTheta.cc:57
DTChamberId ChamberId() const
Identifier of the associated chamber.
int nSegm(int step)
Return number of TStheta segments (just 1)
Definition: DTTSTheta.cc:199
LocalVector localDirection(const DTTrigData *) const override
Local direction in chamber of a L1Trigger-data object.
Definition: DTTSTheta.cc:264
static const int NSTEPL
Constants: first and last step to start trigger finding.
Definition: DTConfig.h:35
int btiNumber() const
Return parent BTI number.
Definition: DTBtiTrigData.h:96
DTBtiCard * _bticard
Definition: DTTSTheta.h:106
#define debug
Definition: HDRShower.cc:19
void print(const DTTrigData *trig) const override
Print a L1Trigger-data object with also local and global position/direction.
Definition: DTTSTheta.cc:270
LocalPoint localPosition(const DTTrigData *) const override
Local position in chamber of a L1Trigger-data object.
Definition: DTTSTheta.cc:258
const_iterator begin() const
Get first cache element.
Definition: DTCache.h:38
BitArray< DTConfigTSTheta::NCELLTH > _Htrig[DTConfigTSTheta::NSTEPL-DTConfigTSTheta::NSTEPF+1]
Definition: DTTSTheta.h:112
tuple cout
Definition: gather_cfg.py:144
step
Definition: StallMonitor.cc:94
const DTConfigTSTheta * getDTConfigTSTheta(DTChamberId) const
Get desired Trigger Server Theta configuration.
void setConfig(const DTConfigManager *conf)
Set configuration.
Definition: DTTSTheta.cc:67
const_iterator end() const
Get last cache element.
Definition: DTCache.h:41
void set(const int i)
Definition: BitArray.h:224
void loadDTTSTheta()
store DTBtiChip L1Triggers in the TST
Definition: DTTSTheta.cc:72
int size() const
Get cache vector&#39;s size.
Definition: DTCache.h:44
const DTConfigTSTheta * _config
Definition: DTTSTheta.h:108
int nTrig(int step)
Return number of DTBtiChip fired (used by DTTracoChip)
Definition: DTTSTheta.cc:218
DTTSTheta(DTTrigGeom *, DTBtiCard *)
Constructor.
Definition: DTTSTheta.cc:37
int code() const
Return trigger code.