CMS 3D CMS Logo

PPSGeometryBuilder.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Author:
4  *
5  * Wagner Carvalho (wcarvalh@cern.ch)
6  *
7  * DB builder for PPS geometry
8  *
9  ****************************************************************************/
10 
20 
23 
26 
32 
35 
37 
38 #include <regex>
39 
40 //----------------------------------------------------------------------------------------------------
41 
43 public:
44  explicit PPSGeometryBuilder(const edm::ParameterSet&);
45  void analyze(const edm::Event&, const edm::EventSetup&) override;
46 
47 private:
50 
54 };
55 
56 //----------------------------------------------------------------------------------------------------
57 
59  : compactViewTag_(iConfig.getUntrackedParameter<std::string>("compactViewTag", "XMLIdealGeometryESSource_CTPPS")) {}
60 
61 //----------------------------------------------------------------------------------------------------
62 
65 
66  // Get DDCompactView from IdealGeometryRecord
67  if (watcherIdealGeometry_.check(iSetup)) {
68  iSetup.get<IdealGeometryRecord>().get(compactViewTag_.c_str(), cpv);
69  }
70 
71  // Create DDFilteredView and apply the filter
73  DDFilteredView fv((*cpv), filter);
74 
75  // Persistent geometry data
76  PDetGeomDesc* pdet = new PDetGeomDesc;
77  // Build geometry
78  buildPDetGeomDesc(&fv, pdet);
79 
80  // Save geometry in the database
81  if (pdet->container_.empty()) {
82  throw cms::Exception("PPSGeometryBuilder") << "PDetGeomDesc is empty, no geometry to save in the database.";
83  } else {
84  if (dbservice_.isAvailable()) {
85  dbservice_->writeOne(pdet, dbservice_->beginOfTime(), "VeryForwardIdealGeometryRecord");
86  } else {
87  throw cms::Exception("PoolDBService required.");
88  }
89  }
90 
91  return;
92 }
93 
94 //----------------------------------------------------------------------------------------------------//----------------------------------------------------------------------------------------------------
95 
97  // try to dive into next level
98  if (!fv->firstChild())
99  return;
100 
101  // loop over siblings in the level
102  do {
103  // Create a PDetGeomDesc::Item node and add it to the parent's (gd) list
105 
106  // =======================================================================
107  // Fill Item
108  // =======================================================================
109 
110  item.dx_ = fv->translation().X();
111  item.dy_ = fv->translation().Y();
112  item.dz_ = fv->translation().Z();
113  const DDRotationMatrix& rot = fv->rotation();
114  double xx, xy, xz, yx, yy, yz, zx, zy, zz;
115  rot.GetComponents(xx, xy, xz, yx, yy, yz, zx, zy, zz);
116  item.axx_ = xx;
117  item.axy_ = xy;
118  item.axz_ = xz;
119  item.ayx_ = yx;
120  item.ayy_ = yy;
121  item.ayz_ = yz;
122  item.azx_ = zx;
123  item.azy_ = zy;
124  item.azz_ = zz;
125  item.name_ = ((fv->logicalPart()).ddname()).name();
126  item.params_ = ((fv->logicalPart()).solid()).parameters();
127  item.copy_ = fv->copyno();
128  item.z_ = fv->geoHistory().back().absTranslation().z();
129  // Sensor Type
130  item.sensorType_ = "";
131  std::string sensor_name = fv->geoHistory().back().logicalPart().name().fullname();
132  std::size_t found = sensor_name.find(DDD_CTPPS_PIXELS_SENSOR_NAME);
133  if (found != std::string::npos && sensor_name.substr(found - 4, 3) == DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2) {
135  }
136  // Geographical ID
137  item.geographicalID_ = getGeographicalID(fv);
138 
139  // =======================================================================
140 
141  // add component
142  gd->container_.push_back(item);
143 
144  // recursion
145  buildPDetGeomDesc(fv, gd);
146  } while (fv->nextSibling());
147 
148  // go a level up
149  fv->parent();
150 }
151 
152 //----------------------------------------------------------------------------------------------------//----------------------------------------------------------------------------------------------------
153 
155  uint32_t geoID = 0;
156  const std::string name = view->logicalPart().name().name();
157 
158  // strip sensors
160  const std::vector<int>& copy_num = view->copyNumbers();
161  // check size of copy numubers array
162  if (copy_num.size() < 3)
163  throw cms::Exception("DDDTotemRPContruction")
164  << "size of copyNumbers for strip sensor is " << copy_num.size() << ". It must be >= 3.";
165 
166  // extract information
167  const unsigned int decRPId = copy_num[copy_num.size() - 3];
168  const unsigned int arm = decRPId / 100;
169  const unsigned int station = (decRPId % 100) / 10;
170  const unsigned int rp = decRPId % 10;
171  const unsigned int detector = copy_num[copy_num.size() - 1];
172  geoID = TotemRPDetId(arm, station, rp, detector);
173  }
174 
175  // strip and pixels RPs
177  unsigned int decRPId = view->copyno();
178 
179  // check if it is a pixel RP
180  if (decRPId >= 10000) {
181  decRPId = decRPId % 10000;
182  const unsigned int armIdx = (decRPId / 100) % 10;
183  const unsigned int stIdx = (decRPId / 10) % 10;
184  const unsigned int rpIdx = decRPId % 10;
185  geoID = CTPPSPixelDetId(armIdx, stIdx, rpIdx);
186  } else {
187  const unsigned int armIdx = (decRPId / 100) % 10;
188  const unsigned int stIdx = (decRPId / 10) % 10;
189  const unsigned int rpIdx = decRPId % 10;
190  geoID = TotemRPDetId(armIdx, stIdx, rpIdx);
191  }
192  }
193 
194  else if (std::regex_match(name, std::regex(DDD_TOTEM_TIMING_SENSOR_TMPL))) {
195  const std::vector<int>& copy_num = view->copyNumbers();
196  // check size of copy numbers array
197  if (copy_num.size() < 4)
198  throw cms::Exception("DDDTotemRPContruction")
199  << "size of copyNumbers for TOTEM timing sensor is " << copy_num.size() << ". It must be >= 4.";
200 
201  const unsigned int decRPId = copy_num[copy_num.size() - 4];
202  const unsigned int arm = decRPId / 100, station = (decRPId % 100) / 10, rp = decRPId % 10;
203  const unsigned int plane = copy_num[copy_num.size() - 2], channel = copy_num[copy_num.size() - 1];
204  geoID = TotemTimingDetId(arm, station, rp, plane, channel);
205  }
206 
207  else if (name == DDD_TOTEM_TIMING_RP_NAME) {
208  const unsigned int arm = view->copyno() / 100, station = (view->copyno() % 100) / 10, rp = view->copyno() % 10;
209  geoID = TotemTimingDetId(arm, station, rp);
210  }
211 
212  // pixel sensors
213  else if (name == DDD_CTPPS_PIXELS_SENSOR_NAME) {
214  const std::vector<int>& copy_num = view->copyNumbers();
215  // check size of copy numubers array
216  if (copy_num.size() < 4)
217  throw cms::Exception("DDDTotemRPContruction")
218  << "size of copyNumbers for pixel sensor is " << copy_num.size() << ". It must be >= 4.";
219 
220  // extract information
221  const unsigned int decRPId = copy_num[copy_num.size() - 4] % 10000;
222  const unsigned int arm = decRPId / 100;
223  const unsigned int station = (decRPId % 100) / 10;
224  const unsigned int rp = decRPId % 10;
225  const unsigned int detector = copy_num[copy_num.size() - 2] - 1;
226  geoID = CTPPSPixelDetId(arm, station, rp, detector);
227  }
228 
229  // diamond/UFSD sensors
231  const std::vector<int>& copy_num = view->copyNumbers();
232 
233  const unsigned int id = copy_num[copy_num.size() - 1];
234  const unsigned int arm = copy_num[1] - 1;
235  const unsigned int station = 1;
236  const unsigned int rp = 6;
237  const unsigned int plane = (id / 100);
238  const unsigned int channel = id % 100;
239 
240  geoID = CTPPSDiamondDetId(arm, station, rp, plane, channel);
241  }
242 
243  // diamond/UFSD RPs
244  else if (name == DDD_CTPPS_DIAMONDS_RP_NAME) {
245  const std::vector<int>& copy_num = view->copyNumbers();
246 
247  // check size of copy numubers array
248  if (copy_num.size() < 2)
249  throw cms::Exception("DDDTotemRPContruction")
250  << "size of copyNumbers for diamond RP is " << copy_num.size() << ". It must be >= 2.";
251 
252  const unsigned int arm = copy_num[1] - 1;
253  const unsigned int station = 1;
254  const unsigned int rp = 6;
255 
256  geoID = CTPPSDiamondDetId(arm, station, rp);
257  }
258 
259  return geoID;
260 }
261 
262 //----------------------------------------------------------------------------------------------------
263 
PPSGeometryBuilder::watcherIdealGeometry_
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry_
Definition: PPSGeometryBuilder.cc:59
PPSGeometryBuilder::buildPDetGeomDesc
void buildPDetGeomDesc(DDFilteredView *, PDetGeomDesc *)
Definition: PPSGeometryBuilder.cc:96
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
EDAnalyzer.h
PPSGeometryBuilder::PPSGeometryBuilder
PPSGeometryBuilder(const edm::ParameterSet &)
Definition: PPSGeometryBuilder.cc:58
DDD_CTPPS_UFSD_SEGMENT_NAME
const std::string DDD_CTPPS_UFSD_SEGMENT_NAME
Definition: CTPPSDDDNames.h:17
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
geometryCSVtoXML.yz
yz
Definition: geometryCSVtoXML.py:19
ESTransientHandle.h
DDD_CTPPS_PIXELS_SENSOR_NAME
const std::string DDD_CTPPS_PIXELS_SENSOR_NAME
Definition: CTPPSDDDNames.h:14
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:187
edm::ESWatcher< IdealGeometryRecord >
PPSGeometryBuilder::compactViewTag_
std::string compactViewTag_
Definition: PPSGeometryBuilder.cc:58
ESHandle.h
PDetGeomDesc::Item
Definition: PDetGeomDesc.h:14
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
CTPPSPixelDetId.h
DDFilteredView::copyNumbers
nav_type copyNumbers() const
return the stack of copy numbers
Definition: DDFilteredView.cc:193
DDD_CTPPS_PIXELS_RP_NAME
const std::string DDD_CTPPS_PIXELS_RP_NAME
Definition: CTPPSDDDNames.h:22
DDD_TOTEM_TIMING_RP_NAME
const std::string DDD_TOTEM_TIMING_RP_NAME
Definition: CTPPSDDDNames.h:25
PPSGeometryBuilder
Definition: PPSGeometryBuilder.cc:42
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
DDFilteredView::parent
bool parent()
set the current node to the parent node ...
Definition: DDFilteredView.cc:161
DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2
const std::string DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2
Definition: CTPPSDDDNames.h:15
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
DDCompactView.h
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
DDD_CTPPS_DIAMONDS_SEGMENT_NAME
const std::string DDD_CTPPS_DIAMONDS_SEGMENT_NAME
Definition: CTPPSDDDNames.h:16
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
MakerMacros.h
PoolDBOutputService.h
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DDFilteredView.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PDetGeomDesc.h
Service.h
TotemTimingDetId.h
DDBase::name
const N & name() const
Definition: DDBase.h:59
edm::ESHandle
Definition: DTSurvey.h:22
DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling ...
Definition: DDFilteredView.cc:124
PDetGeomDesc::container_
std::vector< Item > container_
Definition: PDetGeomDesc.h:29
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TotemTimingDetId
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...
Definition: TotemTimingDetId.h:26
CTPPSDiamondDetId.h
CTPPSDiamondDetId
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
Definition: CTPPSDiamondDetId.h:24
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
DDD_CTPPS_DIAMONDS_RP_NAME
const std::string DDD_CTPPS_DIAMONDS_RP_NAME
Definition: CTPPSDDDNames.h:24
geometryCSVtoXML.xz
xz
Definition: geometryCSVtoXML.py:19
edm::Service< cond::service::PoolDBOutputService >
DDD_TOTEM_TIMING_SENSOR_TMPL
const std::string DDD_TOTEM_TIMING_SENSOR_TMPL
Definition: CTPPSDDDNames.h:18
iEvent
int iEvent
Definition: GenABIO.cc:224
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
DDD_TOTEM_RP_RP_NAME
const std::string DDD_TOTEM_RP_RP_NAME
DDD names of RP volumes.
Definition: CTPPSDDDNames.h:21
IdealGeometryRecord.h
DDFilteredView::geoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
Definition: DDFilteredView.cc:30
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:57
CTPPSDDDNames.h
CTPPSPixelDetId
Definition: CTPPSPixelDetId.h:16
PDetGeomDesc
Definition: PDetGeomDesc.h:9
get
#define get
PPSGeometryBuilder::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: PPSGeometryBuilder.cc:63
PPSGeometryBuilder::dbservice_
edm::Service< cond::service::PoolDBOutputService > dbservice_
Definition: PPSGeometryBuilder.cc:60
VeryForwardIdealGeometryRecord.h
std
Definition: JetResolutionObject.h:76
DDPassAllFilter
A DDFilter that always returns true.
Definition: DDFilter.h:26
ESWatcher.h
DDFilteredView::translation
const DDTranslation & translation() const
The absolute translation of the current node.
Definition: DDFilteredView.cc:26
Exception
Definition: hltDiff.cc:246
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:57
DDD_TOTEM_RP_SENSOR_NAME
const std::string DDD_TOTEM_RP_SENSOR_NAME
DDD names of sensors.
Definition: CTPPSDDDNames.h:13
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
TotemRPDetId.h
PPSGeometryBuilder::getGeographicalID
uint32_t getGeographicalID(DDFilteredView *)
Definition: PPSGeometryBuilder.cc:154
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
Exception.h
DDFilteredView::rotation
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Definition: DDFilteredView.cc:28
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
DDFilteredView
Definition: DDFilteredView.h:20
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::Event
Definition: Event.h:73
TotemRPDetId
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:29
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
DDFilteredView::copyno
int copyno() const
Copy number associated with the current node.
Definition: DDFilteredView.cc:48