CMS 3D CMS Logo

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) : _m(mother) {
13  if (_m == nullptr) {
14  _ig = 0;
15  } else {
16  _ig = _m->_ig + 1;
17  }
18  _id.resize(_ig + 1, -1);
19  for (int ii = 0; ii < _ig; ii++) {
20  _id[ii] = _m->_id[ii];
21  }
22  _id[_ig] = id_;
23  _ix = ix;
24  _iy = iy;
25 }
26 
28  for (unsigned ii = 0; ii < _d.size(); ii++) {
29  delete _d[ii];
30  }
31 }
32 
33 MEChannel* MEChannel::getDaughter(int ix, int iy, int id_) {
34  for (unsigned ii = 0; ii < _d.size(); ii++) {
35  if (_d[ii]->id() == id_) {
36  return _d[ii];
37  }
38  }
39  return addDaughter(ix, iy, id_);
40 }
41 
42 MEChannel* MEChannel::addDaughter(int ix, int iy, int id_) {
43  MEChannel* d = new MEChannel(ix, iy, id_, this);
44  _d.push_back(d);
45  return d;
46 }
47 
48 int MEChannel::id() const { return _id[_ig]; }
49 
50 bool MEChannel::getListOfChannels(std::vector<MEChannel*>& vec) {
51  if (n() == 0) {
52  vec.push_back(this);
53  return true;
54  }
55  for (unsigned ii = 0; ii < n(); ii++) {
56  bool ok = _d[ii]->getListOfChannels(vec);
57  assert(ok);
58  }
59  return true;
60 }
61 
62 bool MEChannel::getListOfAncestors(std::vector<MEChannel*>& vec) {
63  MEChannel* mother = this->m();
64  if (mother != nullptr) {
65  vec.push_back(mother);
66  mother->getListOfAncestors(vec);
67  }
68  return true;
69 }
70 
72  if (_ig == g)
73  return this;
74 
75  MEChannel* mother = this->m();
76  if (mother != nullptr) {
77  if (mother->_ig == g)
78  return mother;
79  return mother->getAncestor(g);
80  }
81 
82  return nullptr;
83 }
84 
85 bool MEChannel::getListOfDescendants(std::vector<MEChannel*>& vec) {
86  for (unsigned ii = 0; ii < n(); ii++) {
87  vec.push_back(_d[ii]);
88  _d[ii]->getListOfDescendants(vec);
89  }
90  return true;
91 }
92 
93 bool MEChannel::getListOfDescendants(int ig, std::vector<MEChannel*>& vec) {
94  for (unsigned ii = 0; ii < n(); ii++) {
95  MEChannel* curLeaf = _d[ii];
96  if (curLeaf->_ig == ig)
97  vec.push_back(curLeaf);
98  curLeaf->getListOfDescendants(ig, vec);
99  }
100  return true;
101 }
102 
104  std::vector<MEChannel*> vec;
105  bool OK = getListOfDescendants(ig, vec);
106  if (!OK)
107  return nullptr;
108  MEChannel* leaf(nullptr);
109  for (unsigned int ii = 0; ii < vec.size(); ii++) {
110  leaf = vec[ii];
111  if (leaf->id() == id_)
112  return leaf;
113  }
114  return leaf;
115 }
116 
118  std::vector<MEChannel*> vec;
119  bool OK = getListOfDescendants(ig, vec);
120  if (!OK)
121  return nullptr;
122  return vec[0];
123 }
124 
125 MEChannel* MEChannel::getChannel(int ig, int ix, int iy) {
126  assert(ig >= 0);
127  MEChannel* leaf = getChannel(ix, iy);
128  if (leaf == nullptr)
129  return nullptr;
130  while (ig != leaf->_ig) {
131  leaf = leaf->_m;
132  }
133  return leaf;
134 }
135 
137  if (n() == 0) {
138  if (ix == _ix && iy == _iy) {
139  return this;
140  } else
141  return nullptr;
142  }
143  MEChannel* leaf(nullptr);
144  for (unsigned ii = 0; ii < n(); ii++) {
145  leaf = _d[ii]->getChannel(ix, iy);
146  if (leaf != nullptr)
147  break;
148  }
149  return leaf;
150 }
151 
152 void MEChannel::print(ostream& o, bool recursif) const {
153  o << ME::granularity[_ig] << " ";
154  for (int ii = 0; ii <= _ig; ii++) {
155  o << ME::granularity[ii] << "=" << _id[ii] << " ";
156  }
157  if (n() > 0) {
158  o << "NDau=" << n() << " ";
159  } else {
160  o << "ix=" << _ix << " iy=" << _iy << " ";
161  }
162  o << std::endl;
163  if (recursif) {
164  for (unsigned jj = 0; jj < n(); jj++) {
165  _d[jj]->print(o, true);
166  }
167  }
168 }
169 
170 TString MEChannel::oneLine(int ig) {
172  int reg_ = _id[ME::iEcalRegion];
173  TString out;
174  if (ig < ME::iLMRegion) {
175  out += ME::region[reg_];
176  if (ig == ME::iSector) {
177  out += "/S=";
178  out += _id[ME::iSector];
179  }
180  return out;
181  }
182  int lmr_ = _id[ME::iLMRegion];
183  std::pair<int, int> p_ = ME::dccAndSide(lmr_);
185  out += "=";
186  out += lmr_;
187  int dcc_ = p_.first;
188  int side_ = p_.second;
189  out += "(DCC=";
190  out += dcc_;
191  out += ",";
192  out += ME::smName(lmr_);
193  out += "/";
194  out += side_;
195  out += ")";
196  if (ig >= _ig)
197  ig = _ig;
198  if (ig >= ME::iLMModule) {
199  int lmm_ = _id[ME::iLMModule];
200  out += "/";
202  out += "=";
203  out += lmm_;
204  if (ig >= ME::iSuperCrystal) {
205  int sc_ = _id[ME::iSuperCrystal];
206  out += "/";
208  out += "=";
209  out += sc_;
210  if (ig >= ME::iCrystal) {
211  int c_ = _id[ME::iCrystal];
212  out += "/";
214  out += "=";
215  out += c_;
216  if (reg_ == ME::iEBM || reg_ == ME::iEBP) {
217  out += "/ieta=";
218  out += ix();
219  out += "/iphi=";
220  out += iy();
222  out += "(ix=";
223  out += ixy_.first;
224  out += "/iy=";
225  out += ixy_.second;
226  out += ")";
227  } else {
228  out += "/ix=";
229  out += ix();
230  out += "/iy=";
231  out += iy();
232  }
233  }
234  }
235  }
236  if (ig < ME::iCrystal) {
237  std::vector<MEChannel*> _channels;
238  getListOfChannels(_channels);
239  int nchan = _channels.size();
240  if (nchan > 1) {
241  out += "(";
242  out += nchan;
243  out += "xTals)";
244  }
245  }
246  return out;
247 }
248 
249 TString MEChannel::oneWord(int ig) {
251  int reg_ = _id[ME::iEcalRegion];
252  TString out;
253  if (ig < ME::iLMRegion) {
254  out = "ECAL_";
255  out += ME::region[reg_];
256  if (ig == ME::iSector) {
257  out += "_S";
258  out += _id[ME::iSector];
259  }
260  return out;
261  }
262  int lmr_ = _id[ME::iLMRegion];
264  out += lmr_;
265  if (ig >= _ig)
266  ig = _ig;
267  if (ig >= ME::iLMModule) {
268  int lmm_ = _id[ME::iLMModule];
269  out += "_";
271  out += lmm_;
272  if (ig >= ME::iSuperCrystal) {
273  int sc_ = _id[ME::iSuperCrystal];
274  out += "_";
276  out += sc_;
277  if (ig >= ME::iCrystal) {
278  int c_ = _id[ME::iCrystal];
279  out += "_";
281  out += c_;
282  if (reg_ == ME::iEBM || reg_ == ME::iEBP) {
284  out += "_";
285  out += ixy_.first;
286  out += "_";
287  out += ixy_.second;
288  } else {
289  out += "_";
290  out += ix();
291  out += "_";
292  out += iy();
293  }
294  }
295  }
296  }
297  return out;
298 }
ME::iLMRegion
Definition: ME.h:16
MEChannel::print
void print(std::ostream &o, bool recursif=false) const
Definition: MEChannel.cc:152
MEChannel::_id
std::vector< int > _id
Definition: MEChannel.h:60
MEChannel::~MEChannel
virtual ~MEChannel()
Definition: MEChannel.cc:27
cms::cuda::assert
assert(be >=bs)
MEChannel::getAncestor
MEChannel * getAncestor(int ig)
Definition: MEChannel.cc:71
MEChannel::iy
int iy() const
Definition: MEChannel.h:19
MEChannel::ig
int ig() const
Definition: MEChannel.h:29
MEChannel::getFirstDescendant
MEChannel * getFirstDescendant(int ig)
Definition: MEChannel.cc:117
MEChannel::getDaughter
MEChannel * getDaughter(int ix, int iy, int ig)
Definition: MEChannel.cc:33
ME::iLMModule
Definition: ME.h:16
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
reco::OK
std::pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:126
ME::iEcalRegion
Definition: ME.h:16
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
hgcalDigitizer_cfi._m
_m
Definition: hgcalDigitizer_cfi.py:204
ME::iSuperCrystal
Definition: ME.h:16
MEChannel::getListOfAncestors
bool getListOfAncestors(std::vector< MEChannel * > &)
Definition: MEChannel.cc:62
MEChannel.h
MEChannel::_ix
int _ix
Definition: MEChannel.h:56
MEEBGeom::XYCoord
std::pair< EBLocalCoord, EBLocalCoord > XYCoord
Definition: MEEBGeom.h:25
ME::granularity
static TString granularity[iSizeG]
Definition: ME.h:54
ME::dccAndSide
static std::pair< int, int > dccAndSide(int ilmr)
Definition: ME.cc:295
ME::iCrystal
Definition: ME.h:16
MEChannel::oneWord
TString oneWord()
Definition: MEChannel.h:45
ME::region
static TString region[4]
Definition: ME.h:51
ME::iEBP
Definition: ME.h:14
MEChannel::getDescendant
MEChannel * getDescendant(int ig, int ii)
Definition: MEChannel.cc:103
MEGeom.h
MEChannel::m
MEChannel * m()
Definition: MEChannel.h:22
ME::iSector
Definition: ME.h:16
MEChannel::id
int id() const
Definition: MEChannel.cc:48
MEChannel::getListOfChannels
bool getListOfChannels(std::vector< MEChannel * > &)
Definition: MEChannel.cc:50
nchan
int nchan
Definition: TauolaWrapper.h:80
ME.h
MEChannel::oneLine
TString oneLine()
Definition: MEChannel.h:43
ME::smName
static TString smName(int ilmr)
Definition: ME.cc:391
MEChannel::_m
MEChannel * _m
Definition: MEChannel.h:49
MEChannel::addDaughter
MEChannel * addDaughter(int ix, int iy, int ii)
Definition: MEChannel.cc:42
MEChannel::_iy
int _iy
Definition: MEChannel.h:57
MEChannel::getListOfDescendants
bool getListOfDescendants(std::vector< MEChannel * > &)
Definition: MEChannel.cc:85
std
Definition: JetResolutionObject.h:76
MEChannel::MEChannel
MEChannel(int ix, int iy, int ii, MEChannel *mother)
Definition: MEChannel.cc:12
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
MEChannel::_ig
int _ig
Definition: MEChannel.h:53
MEChannel::_d
std::vector< MEChannel * > _d
Definition: MEChannel.h:50
MEEBGeom::localCoord
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:142
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
MEChannel::ix
int ix() const
Definition: MEChannel.h:18
MEChannel::d
MEChannel * d(unsigned ii)
Definition: MEChannel.h:23
ME::iEBM
Definition: ME.h:14
cuy.ii
ii
Definition: cuy.py:590
g
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
Definition: MEChannel.h:12
MEChannel::n
unsigned n() const
Definition: MEChannel.h:28
MEChannel::getChannel
MEChannel * getChannel(int ix, int iy)
Definition: MEChannel.cc:136