CMS 3D CMS Logo

SiStripDetKey.cc
Go to the documentation of this file.
1 
5 #include <iomanip>
6 
7 // -----------------------------------------------------------------------------
8 //
10  : SiStripKey(), partition_(partition), apvPairNumber_(sistrip::invalid_), apvWithinPair_(sistrip::invalid_) {
11  // order is important!
12  initFromValue();
13  initFromKey();
14  initFromPath();
16 }
17 
18 // -----------------------------------------------------------------------------
19 //
20 SiStripDetKey::SiStripDetKey(const DetId& det_id, const uint16_t& apv_pair_number, const uint16_t& apv_within_pair)
21  : SiStripKey(), partition_(sistrip::invalid_), apvPairNumber_(apv_pair_number), apvWithinPair_(apv_within_pair) {
22  // order is important!
23  initFromValue();
24  initFromKey();
25  initFromPath();
27 }
28 
29 // -----------------------------------------------------------------------------
30 //
32  : SiStripKey(),
34  apvPairNumber_(sistrip::invalid_),
35  apvWithinPair_(sistrip::invalid_) {
36  // order is important!
37  initFromValue();
38  initFromKey();
39  initFromPath();
41 }
42 
43 // -----------------------------------------------------------------------------
44 //
45 SiStripDetKey::SiStripDetKey(const uint32_t& det_key)
46  : SiStripKey(det_key),
48  apvPairNumber_(sistrip::invalid_),
49  apvWithinPair_(sistrip::invalid_) {
50  // order is important!
51  initFromKey();
52  initFromValue();
53  initFromPath();
55 }
56 
57 // -----------------------------------------------------------------------------
58 //
60  : SiStripKey(path),
62  apvPairNumber_(sistrip::invalid_),
63  apvWithinPair_(sistrip::invalid_) {
64  // order is important!
65  initFromPath();
66  initFromValue();
67  initFromKey();
69 }
70 
71 // -----------------------------------------------------------------------------
72 //
74  : SiStripKey(),
76  apvPairNumber_(input.apvPairNumber()),
77  apvWithinPair_(input.apvWithinPair()) {
78  key(input.key());
79  path(input.path());
80  granularity(input.granularity());
81 }
82 
83 // -----------------------------------------------------------------------------
84 //
86  : SiStripKey(),
88  apvPairNumber_(sistrip::invalid_),
89  apvWithinPair_(sistrip::invalid_) {
90  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
91  key(det_key.key());
92  path(det_key.path());
93  granularity(det_key.granularity());
94  partition_ = det_key.partition();
95  apvPairNumber_ = det_key.apvPairNumber();
96  apvWithinPair_ = det_key.apvWithinPair();
97 }
98 
99 // -----------------------------------------------------------------------------
100 //
102  : SiStripKey(), partition_(0), apvPairNumber_(0), apvWithinPair_(0) {
103  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
104  if (gran == sistrip::PARTITION) {
105  partition_ = det_key.partition();
106  }
107 
108  initFromValue();
109  initFromKey();
110  initFromPath();
111  initGranularity();
112 }
113 
114 // -----------------------------------------------------------------------------
115 //
117  : SiStripKey(),
119  apvPairNumber_(sistrip::invalid_),
120  apvWithinPair_(sistrip::invalid_) {
121  ;
122 }
123 
124 // -----------------------------------------------------------------------------
125 //
127  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
128  if (partition_ == input.partition() && apvPairNumber_ == input.apvPairNumber() &&
129  apvWithinPair_ == input.apvWithinPair()) {
130  return true;
131  } else {
132  return false;
133  }
134 }
135 
136 // -----------------------------------------------------------------------------
137 //
139  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
140  if (isEqual(input)) {
141  return false;
142  } else if ((partition_ == 0 || input.partition() == 0) && (apvPairNumber_ == 0 || input.apvPairNumber() == 0) &&
143  (apvWithinPair_ == 0 || input.apvWithinPair() == 0)) {
144  return true;
145  } else {
146  return false;
147  }
148 }
149 
150 // -----------------------------------------------------------------------------
151 //
152 bool SiStripDetKey::isValid() const { return isValid(sistrip::APV); }
153 
154 // -----------------------------------------------------------------------------
155 //
157  if (gran == sistrip::TRACKER) {
158  return true;
159  } else if (gran == sistrip::UNDEFINED_GRAN || gran == sistrip::UNKNOWN_GRAN) {
160  return false;
161  }
162 
163  if (partition_ != sistrip::invalid_) {
164  if (gran == sistrip::PARTITION) {
165  return true;
166  }
167  }
168  return false;
169 }
170 
171 // -----------------------------------------------------------------------------
172 //
174 
175 // -----------------------------------------------------------------------------
176 //
178  if (gran == sistrip::TRACKER) {
179  return false;
180  } else if (gran == sistrip::UNDEFINED_GRAN || gran == sistrip::UNKNOWN_GRAN) {
181  return false;
182  }
183 
184  if (partition_ == sistrip::invalid_) {
185  if (gran == sistrip::PARTITION) {
186  return true;
187  }
188  }
189  return false;
190 }
191 
192 // -----------------------------------------------------------------------------
193 //
195  // partition
196  if (partition_ > 4) {
198  }
199 }
200 
201 // -----------------------------------------------------------------------------
202 //
204  if (key() == sistrip::invalid32_) {
205  // ---------- Set DetKey based on member data ----------
206 
207  // Initialise to null value
208  key(0);
209 
210  // Extract partition
211  if (partition_ >= 1 && //sistrip::PARTITION_MIN &&
212  partition_ <= 4) { //sistrip::PARTITION_MAX ) {
214  } else if (partition_ == 0) {
216  } else {
218  }
219 
220  } else {
221  // ---------- Set member data based on Det key ----------
222 
224 
225  if (partition_ == partitionMask_) {
227  }
228  }
229 }
230 
231 // -----------------------------------------------------------------------------
232 //
234  if (path() == sistrip::null_) {
235  // ---------- Set directory path based on member data ----------
236 
237  std::stringstream dir;
238 
240 
241  // Add partition
242  if (partition_) {
244  }
245 
246  std::string temp(dir.str());
247  path(temp);
248 
249  } else {
250  // ---------- Set member data based on directory path ----------
251 
252  partition_ = 0;
253 
254  // Check if root is found
255  if (path().find(sistrip::root_) == std::string::npos) {
256  std::string temp = path();
258  }
259 
260  size_t curr = 0; // current string position
261  size_t next = 0; // next string position
262  next = path().find(sistrip::detectorView_, curr);
263 
264  // Extract view
265  curr = next;
266  if (curr != std::string::npos) {
267  next = path().find(sistrip::partition_, curr);
268  std::string detector_view(
269  path(), curr + (sizeof(sistrip::detectorView_) - 1), next - (sizeof(sistrip::dir_) - 1) - curr);
270  // Extract partition
271  curr = next;
272  if (curr != std::string::npos) {
273  next = std::string::npos;
275  path(), curr + (sizeof(sistrip::partition_) - 1), next - (sizeof(sistrip::dir_) - 1) - curr);
276  partition_ = std::atoi(partition.c_str());
277  }
278  } else {
279  std::stringstream ss;
281  //ss << sistrip::root_ << sistrip::dir_
282  //<< sistrip::unknownView_ << sistrip::dir_;
283  std::string temp(ss.str());
284  path(temp);
285  }
286  }
287 }
288 
289 // -----------------------------------------------------------------------------
290 //
293  channel(0);
297  } else if (partition_ == sistrip::invalid_) {
300  }
301 }
302 
303 // -----------------------------------------------------------------------------
304 //
305 void SiStripDetKey::terse(std::stringstream& ss) const { ss << "DET:partition= " << partition(); }
306 
307 // -----------------------------------------------------------------------------
308 //
309 void SiStripDetKey::print(std::stringstream& ss) const {
310  ss << " [SiStripDetKey::print]" << std::endl
311  << std::hex << " 32-bit Det key : 0x" << std::setfill('0') << std::setw(8) << key() << std::endl
312  << std::setfill(' ') << std::dec << " Partition : " << partition() << std::endl
313  << " Directory : " << path() << std::endl
314  << " Granularity : " << SiStripEnumsAndStrings::granularity(granularity()) << std::endl
315  << " Channel : " << channel() << std::endl
316  << " isValid : " << isValid();
317 }
318 
319 // -----------------------------------------------------------------------------
320 //
321 std::ostream& operator<<(std::ostream& os, const SiStripDetKey& input) {
322  std::stringstream ss;
323  input.print(ss);
324  os << ss.str();
325  return os;
326 }
const uint16_t & channel() const
Definition: SiStripKey.h:123
bool isEqual(const SiStripKey &) const override
std::ostream & operator<<(std::ostream &os, const SiStripDetKey &input)
uint16_t apvPairNumber_
static const char dir_[]
const uint16_t & apvWithinPair() const
void initFromPath() override
static const uint32_t invalid32_
Definition: Constants.h:15
bool isValid() const override
const std::string & path() const
Definition: SiStripKey.h:121
static std::string granularity(const sistrip::Granularity &)
void initGranularity() override
static const uint16_t partitionOffset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static const char detectorView_[]
sistrip classes
static std::string const input
Definition: EdmProvDump.cc:50
static const char partition_[]
void initFromKey() override
void terse(std::stringstream &ss) const override
const uint32_t & key() const
Definition: SiStripKey.h:120
Base utility class that identifies a position within a logical structure of the strip tracker...
Definition: SiStripKey.h:23
key
prepare the HTCondor submission files and eventually submit them
bool isInvalid() const override
Utility class that identifies a position within the strip tracker geometrical structure, down to the level of an APV25 chip.
Definition: SiStripDetKey.h:28
static const uint16_t partitionMask_
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
Definition: DetId.h:17
const uint16_t & apvPairNumber() const
void initFromValue() override
static const uint16_t invalid_
Definition: Constants.h:16
static const char root_[]
uint16_t apvWithinPair_
void print(std::stringstream &ss) const override
bool isConsistent(const SiStripKey &) const override
uint16_t partition_
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:122
const uint16_t & partition() const
static const char null_[]
Definition: Constants.h:22