CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MEChannel.cc
Go to the documentation of this file.
1 #include <cassert>
2 #include <iostream>
3 #include <iomanip>
4 using namespace std;
5 
9 
10 // ClassImp(MEChannel)
11 
12 MEChannel::MEChannel( int ix, int iy, int id_, MEChannel* mother )
13  : _m(mother)
14 {
15  if( _m==0 )
16  {
17  _ig=0;
18  }
19  else
20  {
21  _ig = _m->_ig+1;
22  }
23  _id.resize( _ig+1, -1 );
24  for( int ii=0; ii<_ig; ii++ )
25  {
26  _id[ii] = _m->_id[ii];
27  }
28  _id[_ig] = id_;
29  _ix = ix;
30  _iy = iy;
31 }
32 
34 {
35  for( unsigned ii=0; ii<_d.size(); ii++ )
36  {
37  delete _d[ii];
38  }
39 }
40 
41 MEChannel*
42 MEChannel::getDaughter( int ix, int iy, int id_ )
43 {
44  for( unsigned ii=0; ii<_d.size(); ii++ )
45  {
46  if( _d[ii]->id()==id_ )
47  {
48  return _d[ii];
49  }
50  }
51  return addDaughter( ix, iy, id_ );
52 }
53 
54 MEChannel*
55 MEChannel::addDaughter( int ix, int iy, int id_ )
56 {
57  MEChannel* d = new MEChannel( ix, iy, id_, this );
58  _d.push_back( d );
59  return d;
60 }
61 
62 int
64 {
65  return _id[_ig];
66 }
67 
68 bool
69 MEChannel::getListOfChannels( std::vector< MEChannel* >& vec )
70 {
71  if( n()==0 )
72  {
73  vec.push_back( this );
74  return true;
75  }
76  for( unsigned ii=0; ii<n(); ii++ )
77  {
78  bool ok = _d[ii]->getListOfChannels( vec );
79  assert( ok );
80  }
81  return true;
82 }
83 
84 bool
85 MEChannel::getListOfAncestors( std::vector< MEChannel* >& vec )
86 {
87  MEChannel* mother = this->m();
88  if( mother!=0 )
89  {
90  vec.push_back( mother );
91  mother->getListOfAncestors( vec );
92  }
93  return true;
94 }
95 
96 MEChannel*
98 {
99  if( _ig==g ) return this;
100 
101  MEChannel* mother = this->m();
102  if( mother!=0 )
103  {
104  if( mother->_ig==g ) return mother;
105  return mother->getAncestor( g );
106  }
107 
108  return 0;
109 }
110 
111 bool
112 MEChannel::getListOfDescendants( std::vector< MEChannel* >& vec )
113 {
114  for( unsigned ii=0; ii<n(); ii++ )
115  {
116  vec.push_back(_d[ii]);
117  _d[ii]->getListOfDescendants( vec );
118  }
119  return true;
120 }
121 
122 bool
123 MEChannel::getListOfDescendants( int ig, std::vector< MEChannel* >& vec )
124 {
125  for( unsigned ii=0; ii<n(); ii++ )
126  {
127  MEChannel* curLeaf = _d[ii];
128  if( curLeaf->_ig==ig ) vec.push_back(curLeaf);
129  curLeaf->getListOfDescendants( ig, vec );
130  }
131  return true;
132 }
133 
134 MEChannel*
135 MEChannel::getDescendant( int ig, int id_ )
136 {
137  std::vector< MEChannel* > vec;
138  bool OK = getListOfDescendants( ig, vec );
139  if( !OK ) return 0;
140  MEChannel* leaf(0);
141  for( unsigned int ii=0; ii<vec.size(); ii++ )
142  {
143  leaf = vec[ii];
144  if( leaf->id()==id_ ) return leaf;
145  }
146  return leaf;
147 }
148 
149 MEChannel*
151 {
152  std::vector< MEChannel* > vec;
153  bool OK = getListOfDescendants( ig, vec );
154  if( !OK ) return 0;
155  return vec[0];
156 }
157 
158 MEChannel*
159 MEChannel::getChannel( int ig, int ix, int iy )
160 {
161  assert( ig>=0 );
162  MEChannel* leaf = getChannel( ix, iy );
163  if( leaf==0 ) return 0;
164  while( ig!=leaf->_ig )
165  {
166  leaf = leaf->_m;
167  }
168  return leaf;
169 }
170 
171 MEChannel*
172 MEChannel::getChannel( int ix, int iy )
173 {
174  if( n()==0 )
175  {
176  if( ix==_ix && iy==_iy )
177  {
178  return this;
179  }
180  else
181  return 0;
182  }
183  MEChannel* leaf(0);
184  for( unsigned ii=0; ii<n(); ii++ )
185  {
186  leaf = _d[ii]->getChannel( ix, iy );
187  if( leaf!=0 ) break;
188  }
189  return leaf;
190 }
191 
192 void
193 MEChannel::print( ostream& o, bool recursif ) const
194 {
195  o << ME::granularity[_ig] << " ";
196  for( int ii=0; ii<=_ig; ii++ )
197  {
198  o << ME::granularity[ii] << "=" << _id[ii] << " ";
199  }
200  if( n()>0 )
201  {
202  o << "NDau=" << n() << " " ;
203  }
204  else
205  {
206  o << "ix=" << _ix << " iy=" << _iy << " " ;
207  }
208  o << std::endl;
209  if( recursif )
210  {
211  for( unsigned jj=0; jj<n(); jj++ )
212  {
213  _d[jj]->print( o, true );
214  }
215  }
216 }
217 
218 TString
220 {
221  assert( ig>=ME::iEcalRegion );
222  int reg_ = _id[ME::iEcalRegion];
223  TString out;
224  if( ig<ME::iLMRegion )
225  {
226  out += ME::region[reg_];
227  if( ig==ME::iSector ) out+="/S="; out+=_id[ME::iSector];
228  return out;
229  }
230  int lmr_ = _id[ME::iLMRegion];
231  std::pair<int,int> p_ = ME::dccAndSide( lmr_ );
233  out+="=";out += lmr_;
234  int dcc_=p_.first;
235  int side_=p_.second;
236  out+="(DCC="; out+=dcc_; out+=",";
237  out+= ME::smName(lmr_);
238  out+="/"; out+=side_; out+=")";
239  if( ig>=_ig ) ig=_ig;
240  if( ig>=ME::iLMModule )
241  {
242  int lmm_=_id[ME::iLMModule];
243  out+="/";
245  out+="=";
246  out+=lmm_;
247  if( ig>=ME::iSuperCrystal )
248  {
249  int sc_=_id[ME::iSuperCrystal];
250  out+="/";
252  out+="=";
253  out+=sc_;
254  if( ig>=ME::iCrystal )
255  {
256  int c_=_id[ME::iCrystal];
257  out+="/";
259  out+="=";
260  out+=c_;
261  if( reg_==ME::iEBM || reg_==ME::iEBP )
262  {
263  out += "/ieta="; out+=ix();
264  out += "/iphi="; out+=iy();
265  MEEBGeom::XYCoord ixy_ =
266  MEEBGeom::localCoord( ix(), iy() );
267  out += "(ix="; out+=ixy_.first;
268  out += "/iy="; out+=ixy_.second;
269  out += ")";
270  }
271  else
272  {
273  out += "/ix="; out+=ix();
274  out += "/iy="; out+=iy();
275  }
276  }
277  }
278  }
279  if( ig<ME::iCrystal )
280  {
281  std::vector< MEChannel* > _channels;
282  getListOfChannels( _channels );
283  int nchan = _channels.size();
284  if( nchan>1 )
285  {
286  out += "(";
287  out += nchan;
288  out += "xTals)";
289  }
290  }
291  return out;
292 }
293 
294 TString
296 {
297  assert( ig>=ME::iEcalRegion );
298  int reg_ = _id[ME::iEcalRegion];
299  TString out;
300  if( ig<ME::iLMRegion )
301  {
302  out = "ECAL_";
303  out += ME::region[reg_];
304  if( ig==ME::iSector ) out+="_S"; out+=_id[ME::iSector];
305  return out;
306  }
307  int lmr_ = _id[ME::iLMRegion];
309  out+=lmr_;
310  if( ig>=_ig ) ig=_ig;
311  if( ig>=ME::iLMModule )
312  {
313  int lmm_=_id[ME::iLMModule];
314  out+="_";
316  out+=lmm_;
317  if( ig>=ME::iSuperCrystal )
318  {
319  int sc_=_id[ME::iSuperCrystal];
320  out+="_";
322  out+=sc_;
323  if( ig>=ME::iCrystal )
324  {
325  int c_=_id[ME::iCrystal];
326  out+="_";
328  out+=c_;
329  if( reg_==ME::iEBM || reg_==ME::iEBP )
330  {
331  MEEBGeom::XYCoord ixy_ =
332  MEEBGeom::localCoord( ix(), iy() );
333  out += "_"; out+=ixy_.first;
334  out += "_"; out+=ixy_.second;
335  }
336  else
337  {
338  out += "_"; out+=ix();
339  out += "_"; out+=iy();
340  }
341  }
342  }
343  }
344  return out;
345 }
346 
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:153
int _ix
Definition: MEChannel.h:55
bool getListOfDescendants(std::vector< MEChannel * > &)
Definition: MEChannel.cc:112
MEChannel * getChannel(int ix, int iy)
Definition: MEChannel.cc:172
unsigned n() const
Definition: MEChannel.h:26
Definition: ME.h:16
assert(m_qm.get())
bool getListOfChannels(std::vector< MEChannel * > &)
Definition: MEChannel.cc:69
int ix() const
Definition: MEChannel.h:20
static TString granularity[iSizeG]
Definition: ME.h:60
int ii
Definition: cuy.py:588
bool getListOfAncestors(std::vector< MEChannel * > &)
Definition: MEChannel.cc:85
MEChannel * getDaughter(int ix, int iy, int ig)
Definition: MEChannel.cc:42
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
MEChannel * getDescendant(int ig, int ii)
Definition: MEChannel.cc:135
void print(std::ostream &o, bool recursif=false) const
Definition: MEChannel.cc:193
int _ig
Definition: MEChannel.h:52
tuple leaf
Definition: Node.py:62
static std::pair< int, int > dccAndSide(int ilmr)
Definition: ME.cc:313
int iy() const
Definition: MEChannel.h:21
int _iy
Definition: MEChannel.h:56
Definition: ME.h:16
MEChannel * addDaughter(int ix, int iy, int ii)
Definition: MEChannel.cc:55
std::pair< EBLocalCoord, EBLocalCoord > XYCoord
Definition: MEEBGeom.h:27
static TString region[4]
Definition: ME.h:57
MEChannel * m()
Definition: MEChannel.h:24
tuple out
Definition: dbtoconf.py:99
std::pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:136
virtual ~MEChannel()
Definition: MEChannel.cc:33
std::vector< MEChannel * > _d
Definition: MEChannel.h:49
TString oneLine()
Definition: MEChannel.h:41
TString oneWord()
Definition: MEChannel.h:43
MEChannel * getFirstDescendant(int ig)
Definition: MEChannel.cc:150
int id() const
Definition: MEChannel.cc:63
std::vector< int > _id
Definition: MEChannel.h:59
MEChannel * getAncestor(int ig)
Definition: MEChannel.cc:97
Definition: ME.h:18
static TString smName(int ilmr)
Definition: ME.cc:415
MEChannel * _m
Definition: MEChannel.h:48
MEChannel(int ix, int iy, int ii, MEChannel *mother)
Definition: MEChannel.cc:12
MEChannel * d(unsigned ii)
Definition: MEChannel.h:25