CMS 3D CMS Logo

CmsTrackerDetIdBuilder.cc
Go to the documentation of this file.
6 
7 #include <iostream>
8 #include <fstream>
9 #include <sstream>
10 #include <string>
11 #include <bitset>
12 
13 CmsTrackerDetIdBuilder::CmsTrackerDetIdBuilder(const std::vector<int>& detidShifts) : m_detidshifts() {
14  if (detidShifts.size() != nSubDet * maxLevels)
15  edm::LogError("WrongConfiguration") << "Wrong configuration of TrackerGeometricDetESModule. Vector of "
16  << detidShifts.size() << " elements provided";
17  else {
18  for (unsigned int i = 0; i < nSubDet * maxLevels; ++i) {
19  m_detidshifts[i] = detidShifts[i];
20  }
21  }
22 }
23 
25  LogDebug("BuildingTrackerDetId") << "Starting to build Tracker DetIds";
26 
28  tracker.setGeographicalID(t);
29  iterate(tracker, 0, tracker.geographicalID().rawId());
30 }
31 
33  std::bitset<32> binary_ID(ID);
34 
35  // SubDetector (useful to know fron now on, valid only after level 0, where SubDetector is assigned)
36  uint32_t mask = (7 << 25);
37  uint32_t iSubDet = ID & mask;
38  iSubDet = iSubDet >> 25;
39  //
40 
41  LogTrace("BuildingTrackerDetId") << std::string(2 * level, '-') << "+" << ID << " " << iSubDet << " " << level;
42 
43  switch (level) {
44  // level 0: special case because it is used to assign the proper detid bits based on the endcap-like subdetector position: +z or -z
45  case 0: {
46  for (uint32_t i = 0; i < in.components().size(); i++) {
47  GeometricDet* component = in.component(i);
48  uint32_t iSubDet = component->geographicalID().rawId();
49  uint32_t temp = ID;
50  temp |= (iSubDet << 25);
51  component->setGeographicalID(temp);
52 
53  if (iSubDet > 0 && iSubDet <= nSubDet && m_detidshifts[level * nSubDet + iSubDet - 1] >= 0) {
54  if (m_detidshifts[level * nSubDet + iSubDet - 1] + 2 < 25)
55  temp |= (0 << (m_detidshifts[level * nSubDet + iSubDet - 1] + 2));
56  bool negside = component->translation().z() < 0.;
57  if (std::abs(component->translation().z()) < 1.)
58  negside = component->components().front()->translation().z() <
59  0.; // needed for subdet like TID which are NOT translated
60  LogTrace("BuildingTrackerDetId")
61  << "Is negative endcap? " << negside << ", because z translation is " << component->translation().z()
62  << " and component z translation is " << component->components().front()->translation().z();
63  if (negside) {
64  temp |= (1 << m_detidshifts[level * nSubDet + iSubDet - 1]);
65  } else {
66  temp |= (2 << m_detidshifts[level * nSubDet + iSubDet - 1]);
67  }
68  }
69  component->setGeographicalID(DetId(temp));
70 
71  // next level
72  iterate(*component, level + 1, (in.components())[i]->geographicalID().rawId());
73  }
74  break;
75  }
76  // level 1 to 5
77  default: {
78  for (uint32_t i = 0; i < in.components().size(); i++) {
79  auto component = in.component(i);
80  uint32_t temp = ID;
81 
82  if (level < maxLevels) {
83  if (iSubDet > 0 && iSubDet <= nSubDet && m_detidshifts[level * nSubDet + iSubDet - 1] >= 0) {
84  temp |= (component->geographicalID().rawId() << m_detidshifts[level * nSubDet + iSubDet - 1]);
85  }
86  component->setGeographicalID(temp);
87  // next level
88  iterate(*component, level + 1, (in.components())[i]->geographicalID().rawId());
89  }
90  }
91 
92  break;
93  }
94  // level switch ends
95  }
96 
97  return;
98 }
personalPlayback.level
level
Definition: personalPlayback.py:22
CmsTrackerDetIdBuilder.h
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
GeometricDet::components
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:139
CmsTrackerDetIdBuilder::m_detidshifts
std::array< int, nSubDet *maxLevels > m_detidshifts
Definition: CmsTrackerDetIdBuilder.h:27
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
DetId
Definition: DetId.h:17
GeometricDet::setGeographicalID
void setGeographicalID(DetId id)
Definition: GeometricDet.h:97
GeometricDet
Definition: GeometricDet.h:30
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CmsTrackerDetIdBuilder::CmsTrackerDetIdBuilder
CmsTrackerDetIdBuilder(const std::vector< int > &detidShifts)
Definition: CmsTrackerDetIdBuilder.cc:13
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
align::ID
uint32_t ID
Definition: Definitions.h:24
DetId::Tracker
Definition: DetId.h:25
CmsTrackerDetIdBuilder::nSubDet
static const unsigned int nSubDet
Definition: CmsTrackerDetIdBuilder.h:22
recoMuon::in
Definition: RecoMuonEnumerators.h:6
GeometricDet::geographicalID
DetId geographicalID() const
Definition: GeometricDet.h:153
GeometricDet.h
CmsTrackerDetIdBuilder::maxLevels
static const int maxLevels
Definition: CmsTrackerDetIdBuilder.h:23
CmsTrackerDetIdBuilder::iterate
void iterate(GeometricDet &det, int level, unsigned int ID)
Definition: CmsTrackerDetIdBuilder.cc:32
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
DetId.h
Exception.h
CmsTrackerDetIdBuilder::buildId
void buildId(GeometricDet &det)
Definition: CmsTrackerDetIdBuilder.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
GeometricDet::translation
Translation const & translation() const
Definition: GeometricDet.h:120