CMS 3D CMS Logo

TrackerGeometryCompare.cc
Go to the documentation of this file.
5 #include "CLHEP/Vector/RotationInterfaces.h"
11 
15 
17 
23 
39 
40 #include "TrackerGeometryCompare.h"
41 #include "TFile.h"
42 #include "CLHEP/Vector/ThreeVector.h"
43 
44 // Database
48 
51 
52 #include <iostream>
53 #include <fstream>
54 #include <sstream>
55 
57  : cpvTokenDDD_(esConsumes()),
58  cpvTokenDD4hep_(esConsumes()),
59  topoToken_(esConsumes()),
60  geomDetToken_(esConsumes()),
61  ptpToken_(esConsumes()),
62  pixQualityToken_(esConsumes()),
63  stripQualityToken_(esConsumes()),
64  referenceTracker(nullptr),
65  dummyTracker(nullptr),
66  currentTracker(nullptr),
67  theSurveyIndex(0),
68  theSurveyValues(nullptr),
69  theSurveyErrors(nullptr),
70  levelStrings_(cfg.getUntrackedParameter<std::vector<std::string> >("levels")),
71  fromDD4hep_(cfg.getUntrackedParameter<bool>("fromDD4hep")),
72  writeToDB_(cfg.getUntrackedParameter<bool>("writeToDB")),
73  commonTrackerLevel_(align::invalid),
74  moduleListFile_(),
75  moduleList_(0),
76  inputRootFile1_(nullptr),
77  inputRootFile2_(nullptr),
78  inputTree01_(nullptr),
79  inputTree02_(nullptr),
80  inputTree11_(nullptr),
81  inputTree12_(nullptr),
82  m_nBins_(10000),
83  m_rangeLow_(-.1),
84  m_rangeHigh_(.1),
85  firstEvent_(true),
86  m_vtkmap_(13) {
87  moduleListName_ = cfg.getUntrackedParameter<std::string>("moduleList");
88 
89  //input is ROOT
90  inputFilename1_ = cfg.getUntrackedParameter<std::string>("inputROOTFile1");
91  inputFilename2_ = cfg.getUntrackedParameter<std::string>("inputROOTFile2");
92  inputTreenameAlign_ = cfg.getUntrackedParameter<std::string>("treeNameAlign");
93  inputTreenameDeform_ = cfg.getUntrackedParameter<std::string>("treeNameDeform");
94 
95  //output file
96  filename_ = cfg.getUntrackedParameter<std::string>("outputFile");
97  //output dir for surface deformations
98  surfdir_ = cfg.getUntrackedParameter<std::string>("surfDir");
99 
100  weightBy_ = cfg.getUntrackedParameter<std::string>("weightBy");
101  setCommonTrackerSystem_ = cfg.getUntrackedParameter<std::string>("setCommonTrackerSystem");
102  detIdFlag_ = cfg.getUntrackedParameter<bool>("detIdFlag");
103  detIdFlagFile_ = cfg.getUntrackedParameter<std::string>("detIdFlagFile");
104  weightById_ = cfg.getUntrackedParameter<bool>("weightById");
105  weightByIdFile_ = cfg.getUntrackedParameter<std::string>("weightByIdFile");
106 
107  // if want to use, make id cut list
108  if (detIdFlag_) {
109  std::ifstream fin;
110  fin.open(detIdFlagFile_.c_str());
111 
112  while (!fin.eof() && fin.good()) {
113  uint32_t id;
114  fin >> id;
115  detIdFlagVector_.push_back(id);
116  }
117  fin.close();
118  }
119 
120  // turn weightByIdFile into weightByIdVector
121  if (weightById_) {
122  std::ifstream inFile;
123  inFile.open(weightByIdFile_.c_str());
124  while (!inFile.eof()) {
125  unsigned int listId;
126  inFile >> listId;
127  inFile.ignore(256, '\n');
128 
129  weightByIdVector_.push_back(listId);
130  }
131  inFile.close();
132  }
133 
134  //root configuration
135  theFile_ = new TFile(filename_.c_str(), "RECREATE");
136  alignTree_ = new TTree("alignTree",
137  "alignTree"); //,"id:level:mid:mlevel:sublevel:x:y:z:r:phi:a:b:c:dx:dy:dz:dr:dphi:da:db:dc");
138  alignTree_->Branch("id", &id_, "id/I");
139  alignTree_->Branch("badModuleQuality", &badModuleQuality_, "badModuleQuality/I");
140  alignTree_->Branch("inModuleList", &inModuleList_, "inModuleList/I");
141  alignTree_->Branch("level", &level_, "level/I");
142  alignTree_->Branch("mid", &mid_, "mid/I");
143  alignTree_->Branch("mlevel", &mlevel_, "mlevel/I");
144  alignTree_->Branch("sublevel", &sublevel_, "sublevel/I");
145  alignTree_->Branch("x", &xVal_, "x/F");
146  alignTree_->Branch("y", &yVal_, "y/F");
147  alignTree_->Branch("z", &zVal_, "z/F");
148  alignTree_->Branch("r", &rVal_, "r/F");
149  alignTree_->Branch("phi", &phiVal_, "phi/F");
150  alignTree_->Branch("eta", &etaVal_, "eta/F");
151  alignTree_->Branch("alpha", &alphaVal_, "alpha/F");
152  alignTree_->Branch("beta", &betaVal_, "beta/F");
153  alignTree_->Branch("gamma", &gammaVal_, "gamma/F");
154  alignTree_->Branch("dx", &dxVal_, "dx/F");
155  alignTree_->Branch("dy", &dyVal_, "dy/F");
156  alignTree_->Branch("dz", &dzVal_, "dz/F");
157  alignTree_->Branch("dr", &drVal_, "dr/F");
158  alignTree_->Branch("dphi", &dphiVal_, "dphi/F");
159  alignTree_->Branch("dalpha", &dalphaVal_, "dalpha/F");
160  alignTree_->Branch("dbeta", &dbetaVal_, "dbeta/F");
161  alignTree_->Branch("dgamma", &dgammaVal_, "dgamma/F");
162  alignTree_->Branch("du", &duVal_, "du/F");
163  alignTree_->Branch("dv", &dvVal_, "dv/F");
164  alignTree_->Branch("dw", &dwVal_, "dw/F");
165  alignTree_->Branch("da", &daVal_, "da/F");
166  alignTree_->Branch("db", &dbVal_, "db/F");
167  alignTree_->Branch("dg", &dgVal_, "dg/F");
168  alignTree_->Branch("useDetId", &useDetId_, "useDetId/I");
169  alignTree_->Branch("detDim", &detDim_, "detDim/I");
170  alignTree_->Branch("surW", &surWidth_, "surW/F");
171  alignTree_->Branch("surL", &surLength_, "surL/F");
172  alignTree_->Branch("surRot", &surRot_, "surRot[9]/D");
173  alignTree_->Branch("identifiers", &identifiers_, "identifiers[6]/I");
174  alignTree_->Branch("type", &type_, "type/I");
175  alignTree_->Branch("surfDeform", &surfDeform_, "surfDeform[13]/D");
176 
177  for (std::vector<TrackerMap>::iterator it = m_vtkmap_.begin(); it != m_vtkmap_.end(); ++it) {
178  it->setPalette(1);
179  it->addPixel(true);
180  }
181 
183  TFileDirectory subDir_All = fs->mkdir("AllSubdetectors");
184  TFileDirectory subDir_PXB = fs->mkdir("PixelBarrel");
185  TFileDirectory subDir_PXF = fs->mkdir("PixelEndcap");
186  for (int ii = 0; ii < 13; ++ii) {
187  std::stringstream histname0;
188  histname0 << "SurfDeform_Par_" << ii;
189  m_h1_[histname0.str()] = subDir_All.make<TH1D>(
190  (histname0.str()).c_str(), (histname0.str()).c_str(), m_nBins_, m_rangeLow_, m_rangeHigh_);
191 
192  std::stringstream histname1;
193  histname1 << "SurfDeform_PixelBarrel_Par_" << ii;
194  m_h1_[histname1.str()] = subDir_PXB.make<TH1D>(
195  (histname1.str()).c_str(), (histname1.str()).c_str(), m_nBins_, m_rangeLow_, m_rangeHigh_);
196 
197  std::stringstream histname2;
198  histname2 << "SurfDeform_PixelEndcap_Par_" << ii;
199  m_h1_[histname2.str()] = subDir_PXF.make<TH1D>(
200  (histname2.str()).c_str(), (histname2.str()).c_str(), m_nBins_, m_rangeLow_, m_rangeHigh_);
201  }
202 }
203 
206  desc.setComment("Validates alignment payloads by comparing positions of tracker modules positiona and orientations");
207  desc.addUntracked<std::vector<std::string> >("levels", {});
208  desc.addUntracked<bool>("fromDD4hep", false);
209  desc.addUntracked<bool>("writeToDB", false);
210  desc.addUntracked<std::string>("moduleList", "moduleList.txt");
211  desc.addUntracked<std::string>("inputROOTFile1", "IDEAL");
212  desc.addUntracked<std::string>("inputROOTFile2", "idealtracker2.root");
213  desc.addUntracked<std::string>("treeNameAlign", "alignTree");
214  desc.addUntracked<std::string>("treeNameDeform", "alignTreeDeformations");
215  desc.addUntracked<std::string>("outputFile", "output.root");
216  desc.addUntracked<std::string>("surfDir", ".");
217  desc.addUntracked<std::string>("weightBy", "DetUnit");
218  desc.addUntracked<std::string>("setCommonTrackerSystem", "NONE");
219  desc.addUntracked<bool>("detIdFlag", false);
220  desc.addUntracked<std::string>("detIdFlagFile", "blah.txt");
221  desc.addUntracked<bool>("weightById", false);
222  desc.addUntracked<std::string>("weightByIdFile", "blah2.txt");
223  descriptions.addWithDefaultLabel(desc);
224 }
225 
227 
229  int iname(0);
230  for (std::vector<TrackerMap>::iterator it = m_vtkmap_.begin(); it != m_vtkmap_.end(); ++it) {
231  std::stringstream mapname;
232  mapname << surfdir_ << "/TkMap_SurfDeform_0" << iname << ".png";
233  it->save(true, 0, 0, mapname.str());
234  mapname.str(std::string());
235  mapname.clear();
236  mapname << surfdir_ << "/TkMap_SurfDeform_1" << iname << ".pdf";
237  it->save(true, 0, 0, mapname.str());
238  ++iname;
239  }
240 
241  theFile_->cd();
242  alignTree_->Write();
243  theFile_->Close();
244 }
245 
247  if (firstEvent_) {
248  //Retrieve tracker topology from geometry
249  const TrackerTopology* const tTopo = &iSetup.getData(topoToken_);
250 
251  //upload the ROOT geometries
252  createROOTGeometry(iSetup);
253 
254  //setting the levels being used in the geometry comparator
255  edm::LogInfo("TrackerGeometryCompare") << "levels: " << levelStrings_.size();
256  for (const auto& level : levelStrings_) {
258  edm::LogInfo("TrackerGeometryCompare") << "level: " << level;
259  edm::LogInfo("TrackerGeometryCompare")
260  << "structure type: " << currentTracker->objectIdProvider().stringToId(level);
261  }
262 
263  //set common tracker system first
264  // if setting the tracker common system
265  if (setCommonTrackerSystem_ != "NONE") {
267  }
268 
269  //compare the goemetries
272 
273  //write out ntuple
274  //might be better to do within output module
275 
276  if (writeToDB_) {
277  Alignments* myAlignments = currentTracker->alignments();
278  AlignmentErrorsExtended* myAlignmentErrorsExtended = currentTracker->alignmentErrors();
279 
280  // 2. Store alignment[Error]s to DB
282  // Call service
283  if (!poolDbService.isAvailable()) // Die if not available
284  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
285 
286  poolDbService->writeOneIOV<Alignments>(*myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd");
287  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
288  *myAlignmentErrorsExtended, poolDbService->beginOfTime(), "TrackerAlignmentErrorExtendedRcd");
289  }
290 
291  firstEvent_ = false;
292  }
293 }
294 
296  int inputRawId1, inputRawId2;
297  double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
298  double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
299 
300  //Retrieve tracker topology from geometry
301  const TrackerTopology* const tTopo = &iSetup.getData(topoToken_);
302 
303  // Fill module IDs from file into a list
305  if (moduleListFile_.is_open()) {
307  while (!moduleListFile_.eof()) {
308  std::getline(moduleListFile_, line);
309  moduleList_.push_back(std::atoi(line.c_str()));
310  }
311  } else {
312  edm::LogInfo("TrackerGeometryCompare") << "Error: Module list not found! Please verify that given list exists!";
313  }
314 
315  //declare alignments
316  Alignments* alignments1 = new Alignments();
317  AlignmentErrorsExtended* alignmentErrors1 = new AlignmentErrorsExtended();
318  if (inputFilename1_ != "IDEAL") {
319  inputRootFile1_ = new TFile(inputFilename1_.c_str());
320  TTree* inputTree01_ = (TTree*)inputRootFile1_->Get(inputTreenameAlign_.c_str());
321  inputTree01_->SetBranchAddress("rawid", &inputRawId1);
322  inputTree01_->SetBranchAddress("x", &inputX1);
323  inputTree01_->SetBranchAddress("y", &inputY1);
324  inputTree01_->SetBranchAddress("z", &inputZ1);
325  inputTree01_->SetBranchAddress("alpha", &inputAlpha1);
326  inputTree01_->SetBranchAddress("beta", &inputBeta1);
327  inputTree01_->SetBranchAddress("gamma", &inputGamma1);
328 
329  int nEntries1 = inputTree01_->GetEntries();
330  //fill alignments
331  for (int i = 0; i < nEntries1; ++i) {
332  inputTree01_->GetEntry(i);
333  CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
334  CLHEP::HepEulerAngles eulerangles1(inputAlpha1, inputBeta1, inputGamma1);
335  uint32_t detid1 = inputRawId1;
336  AlignTransform transform1(translation1, eulerangles1, detid1);
337  alignments1->m_align.push_back(transform1);
338 
339  // dummy errors
340  // APE matrix was 3x3, now it's 6x6 (because of muons), see PR #6483
341  CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
342  AlignTransformErrorExtended transformError(clhepSymMatrix, detid1);
343  alignmentErrors1->m_alignError.push_back(transformError);
344  }
345 
346  // to get the right order, sort by rawId
347  std::sort(alignments1->m_align.begin(), alignments1->m_align.end());
348  std::sort(alignmentErrors1->m_alignError.begin(), alignmentErrors1->m_alignError.end());
349  }
350  //------------------
351  Alignments* alignments2 = new Alignments();
352  AlignmentErrorsExtended* alignmentErrors2 = new AlignmentErrorsExtended();
353  if (inputFilename2_ != "IDEAL") {
354  inputRootFile2_ = new TFile(inputFilename2_.c_str());
355  TTree* inputTree02_ = (TTree*)inputRootFile2_->Get(inputTreenameAlign_.c_str());
356  inputTree02_->SetBranchAddress("rawid", &inputRawId2);
357  inputTree02_->SetBranchAddress("x", &inputX2);
358  inputTree02_->SetBranchAddress("y", &inputY2);
359  inputTree02_->SetBranchAddress("z", &inputZ2);
360  inputTree02_->SetBranchAddress("alpha", &inputAlpha2);
361  inputTree02_->SetBranchAddress("beta", &inputBeta2);
362  inputTree02_->SetBranchAddress("gamma", &inputGamma2);
363 
364  int nEntries2 = inputTree02_->GetEntries();
365  //fill alignments
366  for (int i = 0; i < nEntries2; ++i) {
367  inputTree02_->GetEntry(i);
368  CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
369  CLHEP::HepEulerAngles eulerangles2(inputAlpha2, inputBeta2, inputGamma2);
370  uint32_t detid2 = inputRawId2;
371  AlignTransform transform2(translation2, eulerangles2, detid2);
372  alignments2->m_align.push_back(transform2);
373 
374  // dummy errors
375  // APE matrix was 3x3, now it's 6x6 (because of muons), see PR #6483
376  CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
377  AlignTransformErrorExtended transformError(clhepSymMatrix, detid2);
378  alignmentErrors2->m_alignError.push_back(transformError);
379  }
380 
381  // to get the right order, sort by rawId
382  std::sort(alignments2->m_align.begin(), alignments2->m_align.end());
383  std::sort(alignmentErrors2->m_alignError.begin(), alignmentErrors2->m_alignError.end());
384  }
385 
386  //accessing the initial geometry
387  if (!fromDD4hep_) {
389  } else {
391  }
392 
393  const GeometricDet* theGeometricDet = &iSetup.getData(geomDetToken_);
394  const PTrackerParameters* ptp = &iSetup.getData(ptpToken_);
395  TrackerGeomBuilderFromGeometricDet trackerBuilder;
396 
397  //reference tracker
398  TrackerGeometry* theRefTracker = trackerBuilder.build(theGeometricDet, *ptp, tTopo);
399  if (inputFilename1_ != "IDEAL") {
400  GeometryAligner aligner1;
402  &(*theRefTracker), &(*alignments1), &(*alignmentErrors1), AlignTransform());
403  }
404  referenceTracker = new AlignableTracker(&(*theRefTracker), tTopo);
405  //referenceTracker->setSurfaceDeformation(surfDef1, true) ;
406 
407  //set tracker pixel Phase, assume current tracker is the same Phase
408  if (theRefTracker->isThere(GeomDetEnumerators::P2PXB) || theRefTracker->isThere(GeomDetEnumerators::P2PXEC)) {
410  } else if (theRefTracker->isThere(GeomDetEnumerators::P1PXB) || theRefTracker->isThere(GeomDetEnumerators::P1PXEC)) {
412  } else {
414  }
415 
416  int inputRawid1;
417  int inputRawid2;
418  int inputDtype1, inputDtype2;
419  std::vector<double> inputDpar1;
420  std::vector<double> inputDpar2;
421  std::vector<double>* p_inputDpar1 = &inputDpar1;
422  std::vector<double>* p_inputDpar2 = &inputDpar2;
423 
424  const auto& comp1 = referenceTracker->deepComponents();
425 
426  SurfaceDeformation* surfDef1;
427  if (inputFilename1_ != "IDEAL") {
428  TTree* inputTree11_ = (TTree*)inputRootFile1_->Get(inputTreenameDeform_.c_str());
429  inputTree11_->SetBranchAddress("irawid", &inputRawid1);
430  inputTree11_->SetBranchAddress("dtype", &inputDtype1);
431  inputTree11_->SetBranchAddress("dpar", &p_inputDpar1);
432 
433  unsigned int nEntries11 = inputTree11_->GetEntries();
434  edm::LogInfo("TrackerGeometryCompare") << " nentries11 = " << nEntries11;
435  for (unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
436  inputTree11_->GetEntry(iEntry);
437 
438  surfDef1 = SurfaceDeformationFactory::create(inputDtype1, inputDpar1);
439 
440  if (int(comp1[iEntry]->id()) == inputRawid1) {
441  comp1[iEntry]->setSurfaceDeformation(surfDef1, true);
442  }
443  }
444  }
445 
446  //currernt tracker
447  TrackerGeometry* theCurTracker = trackerBuilder.build(&*theGeometricDet, *ptp, tTopo);
448  if (inputFilename2_ != "IDEAL") {
449  GeometryAligner aligner2;
451  &(*theCurTracker), &(*alignments2), &(*alignmentErrors2), AlignTransform());
452  }
453  currentTracker = new AlignableTracker(&(*theCurTracker), tTopo);
454 
455  const auto& comp2 = currentTracker->deepComponents();
456 
457  SurfaceDeformation* surfDef2;
458  if (inputFilename2_ != "IDEAL") {
459  TTree* inputTree12_ = (TTree*)inputRootFile2_->Get(inputTreenameDeform_.c_str());
460  inputTree12_->SetBranchAddress("irawid", &inputRawid2);
461  inputTree12_->SetBranchAddress("dtype", &inputDtype2);
462  inputTree12_->SetBranchAddress("dpar", &p_inputDpar2);
463 
464  unsigned int nEntries12 = inputTree12_->GetEntries();
465  edm::LogInfo("TrackerGeometryCompare") << " nentries12 = " << nEntries12;
466  for (unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
467  inputTree12_->GetEntry(iEntry);
468 
469  surfDef2 = SurfaceDeformationFactory::create(inputDtype2, inputDpar2);
470 
471  if (int(comp2[iEntry]->id()) == inputRawid2) {
472  comp2[iEntry]->setSurfaceDeformation(surfDef2, true);
473  }
474  }
475  }
476 
477  delete alignments1;
478  delete alignmentErrors1;
479  delete alignments2;
480  delete alignmentErrors2;
481 }
482 
483 void TrackerGeometryCompare::compareSurfaceDeformations(TTree* refTree, TTree* curTree) {
484  if (inputFilename1_ != "IDEAL" && inputFilename2_ != "IDEAL") {
485  int inputRawid1;
486  int inputRawid2;
487  int inputSubdetid1, inputSubdetid2;
488  int inputDtype1, inputDtype2;
489  std::vector<double> inputDpar1;
490  std::vector<double> inputDpar2;
491  std::vector<double>* p_inputDpar1 = &inputDpar1;
492  std::vector<double>* p_inputDpar2 = &inputDpar2;
493 
494  TTree* refTree = (TTree*)inputRootFile1_->Get(inputTreenameDeform_.c_str());
495  refTree->SetBranchAddress("irawid", &inputRawid1);
496  refTree->SetBranchAddress("subdetid", &inputSubdetid1);
497  refTree->SetBranchAddress("dtype", &inputDtype1);
498  refTree->SetBranchAddress("dpar", &p_inputDpar1);
499 
500  TTree* curTree = (TTree*)inputRootFile2_->Get(inputTreenameDeform_.c_str());
501  curTree->SetBranchAddress("irawid", &inputRawid2);
502  curTree->SetBranchAddress("subdetid", &inputSubdetid2);
503  curTree->SetBranchAddress("dtype", &inputDtype2);
504  curTree->SetBranchAddress("dpar", &p_inputDpar2);
505 
506  unsigned int nEntries11 = refTree->GetEntries();
507  unsigned int nEntries12 = curTree->GetEntries();
508 
509  if (nEntries11 != nEntries12) {
510  edm::LogError("TrackerGeometryCompare") << " Surface deformation parameters in two geometries differ!\n";
511  return;
512  }
513 
514  for (unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
515  refTree->GetEntry(iEntry);
516  curTree->GetEntry(iEntry);
517  for (int ii = 0; ii < 13; ++ii) {
518  surfDeform_[ii] = -1.0;
519  }
520  for (int npar = 0; npar < int(inputDpar2.size()); ++npar) {
521  if (inputRawid1 == inputRawid2) {
522  surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
523  std::stringstream histname0;
524  histname0 << "SurfDeform_Par_" << npar;
525  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
526  m_h1_[histname0.str()]->Fill(surfDeform_[npar]);
527  if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
528  std::stringstream histname1;
529  histname1 << "SurfDeform_PixelBarrel_Par_" << npar;
530  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
531  m_h1_[histname1.str()]->Fill(surfDeform_[npar]);
532  }
533  if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
534  std::stringstream histname2;
535  histname2 << "SurfDeform_PixelEndcap_Par_" << npar;
536  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
537  m_h1_[histname2.str()]->Fill(surfDeform_[npar]);
538  }
541  (m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
542  } else {
543  // old-style tracker map does not support Phase1 Pixel
544  if (!(inputSubdetid1 == 1 && inputSubdetid2 == 1) && !(inputSubdetid1 == 2 && inputSubdetid2 == 2)) {
545  (m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
546  }
547  }
548  }
549  }
550  }
551  }
552 
553  } else if (inputFilename1_ == "IDEAL" && inputFilename2_ != "IDEAL") {
554  int inputRawid2;
555  int inputSubdetid2;
556  int inputDtype2;
557  std::vector<double> inputDpar2;
558  std::vector<double>* p_inputDpar2 = &inputDpar2;
559 
560  TTree* curTree = (TTree*)inputRootFile2_->Get(inputTreenameDeform_.c_str());
561  curTree->SetBranchAddress("irawid", &inputRawid2);
562  curTree->SetBranchAddress("subdetid", &inputSubdetid2);
563  curTree->SetBranchAddress("dtype", &inputDtype2);
564  curTree->SetBranchAddress("dpar", &p_inputDpar2);
565 
566  unsigned int nEntries12 = curTree->GetEntries();
567  for (unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
568  curTree->GetEntry(iEntry);
569  for (int ii = 0; ii < 12; ++ii) {
570  surfDeform_[ii] = -1.0;
571  }
572  for (int npar = 0; npar < int(inputDpar2.size()); ++npar) {
573  surfDeform_[npar] = inputDpar2.at(npar);
574  std::stringstream histname0;
575  histname0 << "SurfDeform_Par_" << npar;
576  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
577  m_h1_[histname0.str()]->Fill(surfDeform_[npar]);
578  if (inputSubdetid2 == 1) {
579  std::stringstream histname1;
580  histname1 << "SurfDeform_PixelBarrel_Par_" << npar;
581  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
582  m_h1_[histname1.str()]->Fill(surfDeform_[npar]);
583  }
584  if (inputSubdetid2 == 2) {
585  std::stringstream histname2;
586  histname2 << "SurfDeform_PixelEndcap_Par_" << npar;
587  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
588  m_h1_[histname2.str()]->Fill(surfDeform_[npar]);
589  }
592  (m_vtkmap_.at(npar)).fill_current_val(inputRawid2, surfDeform_[npar]);
593  } else {
594  // old-style tracker map does not support Phase1 Pixel
595  if (inputSubdetid2 != 1 && inputSubdetid2 != 2) {
596  (m_vtkmap_.at(npar)).fill_current_val(inputRawid2, surfDeform_[npar]);
597  }
598  }
599  }
600  }
601  }
602 
603  } else if (inputFilename1_ != "IDEAL" && inputFilename2_ == "IDEAL") {
604  int inputRawid1;
605  int inputSubdetid1;
606  int inputDtype1;
607  std::vector<double> inputDpar1;
608  std::vector<double>* p_inputDpar1 = &inputDpar1;
609 
610  TTree* refTree = (TTree*)inputRootFile1_->Get(inputTreenameDeform_.c_str());
611  refTree->SetBranchAddress("irawid", &inputRawid1);
612  refTree->SetBranchAddress("subdetid", &inputSubdetid1);
613  refTree->SetBranchAddress("dtype", &inputDtype1);
614  refTree->SetBranchAddress("dpar", &p_inputDpar1);
615  unsigned int nEntries11 = refTree->GetEntries();
616 
617  for (unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
618  refTree->GetEntry(iEntry);
619  for (int ii = 0; ii < 12; ++ii) {
620  surfDeform_[ii] = -1.0;
621  }
622  for (int npar = 0; npar < int(inputDpar1.size()); ++npar) {
623  surfDeform_[npar] = -inputDpar1.at(npar);
624  std::stringstream histname0;
625  histname0 << "SurfDeform_Par_" << npar;
626  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
627  m_h1_[histname0.str()]->Fill(surfDeform_[npar]);
628  if (inputSubdetid1 == 1) {
629  std::stringstream histname1;
630  histname1 << "SurfDeform_PixelBarrel_Par_" << npar;
631  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
632  m_h1_[histname1.str()]->Fill(surfDeform_[npar]);
633  }
634  if (inputSubdetid1 == 2) {
635  std::stringstream histname2;
636  histname2 << "SurfDeform_PixelEndcap_Par_" << npar;
637  if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
638  m_h1_[histname2.str()]->Fill(surfDeform_[npar]);
639  }
642  (m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
643  } else {
644  // old-style tracker map does not support Phase1 Pixel
645  if (inputSubdetid1 != 1 && inputSubdetid1 != 2) {
646  (m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
647  }
648  }
649  }
650  }
651  }
652 
653  } else if (inputFilename1_ == "IDEAL" && inputFilename2_ == "IDEAL") {
654  edm::LogInfo("TrackerGeometryCompare") << ">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
655  }
656  return;
657 }
658 
660  Alignable* curAli,
661  const TrackerTopology* tTopo,
662  const edm::EventSetup& iSetup) {
663  using namespace align;
664 
665  const auto& refComp = refAli->components();
666  const auto& curComp = curAli->components();
667 
668  unsigned int nComp = refComp.size();
669  //only perform for designate levels
670  bool useLevel = false;
671  for (unsigned int i = 0; i < m_theLevels.size(); ++i) {
672  if (refAli->alignableObjectId() == m_theLevels[i])
673  useLevel = true;
674  }
675 
676  //another added level for difference between det and detunit
677  //if ((refAli->alignableObjectId()==2)&&(nComp == 1)) useLevel = false;
678 
679  //coordinate matching, etc etc
680  if (useLevel) {
681  DetId detid(refAli->id());
682 
683  CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
684  Rtotal.set(0., 0., 0.);
685  Wtotal.set(0., 0., 0.);
686  lRtotal.set(0., 0., 0.);
687  lWtotal.set(0., 0., 0.);
688 
689  bool converged = false;
690 
692 
693  for (int i = 0; i < 100; i++) {
694  // Get differences between alignments for rotations and translations
695  // both local and global
697 
698  // 'diffAlignables' returns 'refAli - curAli' for translations and 'curAli - refAli' for rotations.
699  // The plan is to unify this at some point, but a simple change of the sign for one of them was postponed
700  // to do some further checks to understand the rotations better
701  //Updated July 2018: as requested the sign in the translations has been changed to match the one in rotations. A test was done to change the diffAlignables function and solve the issue there, but proved quite time consuming. To unify the sign convention in the least amount of time the choice was made to change the sign here.
702  CLHEP::Hep3Vector dR(-diff[0], -diff[1], -diff[2]);
703  CLHEP::Hep3Vector dW(diff[3], diff[4], diff[5]);
704  CLHEP::Hep3Vector dRLocal(-diff[6], -diff[7], -diff[8]);
705  CLHEP::Hep3Vector dWLocal(diff[9], diff[10], diff[11]);
706 
707  // Translations
708  Rtotal += dR;
709  lRtotal += dRLocal;
710 
711  //Rotations
712  CLHEP::HepRotation rot(Wtotal.unit(), Wtotal.mag());
713  CLHEP::HepRotation drot(dW.unit(), dW.mag());
714  rot *= drot;
715  Wtotal.set(rot.axis().x() * rot.delta(), rot.axis().y() * rot.delta(), rot.axis().z() * rot.delta());
716 
717  CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
718  CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
719  rotLocal *= drotLocal;
720  lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
721  rotLocal.axis().y() * rotLocal.delta(),
722  rotLocal.axis().z() * rotLocal.delta());
723 
724  // Move current alignable by shift and check if difference
725  // is smaller than tolerance value
726  // if true, break the loop
727  align::moveAlignable(curAli, diff);
728  float tolerance = 1e-7;
730  align::GlobalVector checkR(check[0], check[1], check[2]);
731  align::GlobalVector checkW(check[3], check[4], check[5]);
732  if ((checkR.mag() < tolerance) && (checkW.mag() < tolerance)) {
733  converged = true;
734  break;
735  }
736  }
737 
738  // give an exception if difference has not fallen below tolerance level
739  // i.e. method has not converged
740  if (!converged) {
741  edm::LogInfo("TrackerGeometryCompare")
742  << "Tolerance Exceeded!(alObjId: " << refAli->alignableObjectId()
743  << ", rawId: " << refAli->geomDetId().rawId() << ", subdetId: " << detid.subdetId() << "): " << diff << check;
744  throw cms::Exception("Tolerance in TrackerGeometryCompare exceeded");
745  }
746  AlgebraicVector TRtot(12);
747  // global
748  TRtot(1) = Rtotal.x();
749  TRtot(2) = Rtotal.y();
750  TRtot(3) = Rtotal.z();
751  TRtot(4) = Wtotal.x();
752  TRtot(5) = Wtotal.y();
753  TRtot(6) = Wtotal.z();
754  // local
755  TRtot(7) = lRtotal.x();
756  TRtot(8) = lRtotal.y();
757  TRtot(9) = lRtotal.z();
758  TRtot(10) = lWtotal.x();
759  TRtot(11) = lWtotal.y();
760  TRtot(12) = lWtotal.z();
761 
762  fillTree(refAli, TRtot, tTopo, iSetup);
763  }
764 
765  // another added level for difference between det and detunit
766  for (unsigned int i = 0; i < nComp; ++i)
767  compareGeometries(refComp[i], curComp[i], tTopo, iSetup);
768 }
769 
771  edm::LogInfo("TrackerGeometryCompare") << "Setting Common Tracker System....";
772 
773  // DM_534??AlignableObjectId dummy;
774  // DM_534??_commonTrackerLevel = dummy.nameToType(_setCommonTrackerSystem);
776 
778 
779  align::EulerAngles dOmega(3);
780  dOmega[0] = TrackerCommonR_.x();
781  dOmega[1] = TrackerCommonR_.y();
782  dOmega[2] = TrackerCommonR_.z();
785 
786  edm::LogInfo("TrackerGeometryCompare") << "what we get from overlaying the pixels..." << theR << ", " << rot;
787 
788  //transform to the Tracker System
790  align::GlobalVector cmDiff(
791  trackerCM.x() - TrackerCommonCM_.x(), trackerCM.y() - TrackerCommonCM_.y(), trackerCM.z() - TrackerCommonCM_.z());
792 
793  edm::LogInfo("TrackerGeometryCompare") << "Pixel CM: " << TrackerCommonCM_ << ", tracker CM: " << trackerCM;
794 
795  //adjust translational difference factoring in different rotational CM
796  //needed because rotateInGlobalFrame is about CM of alignable, not Tracker
797  const align::GlobalVector::BasicVectorType& lpvgf = cmDiff.basicVector();
798  align::GlobalVector moveV(rot.multiplyInverse(lpvgf) - lpvgf);
799  align::GlobalVector theRprime(theR + moveV);
800 
801  AlgebraicVector TrackerCommonTR(6);
802  TrackerCommonTR(1) = theRprime.x();
803  TrackerCommonTR(2) = theRprime.y();
804  TrackerCommonTR(3) = theRprime.z();
805  TrackerCommonTR(4) = TrackerCommonR_.x();
806  TrackerCommonTR(5) = TrackerCommonR_.y();
807  TrackerCommonTR(6) = TrackerCommonR_.z();
808 
809  edm::LogInfo("TrackerGeometryCompare") << "and after the transformation: " << TrackerCommonTR;
810  align::moveAlignable(currentTracker, TrackerCommonTR);
811 }
812 
814  const auto& refComp = refAli->components();
815  const auto& curComp = curAli->components();
816  unsigned int nComp = refComp.size();
817  //only perform for designate levels
818  bool useLevel = false;
819  if (refAli->alignableObjectId() == commonTrackerLevel_)
820  useLevel = true;
821 
822  //useLevel = false;
823  if (useLevel) {
824  CLHEP::Hep3Vector Rtotal, Wtotal;
825  Rtotal.set(0., 0., 0.);
826  Wtotal.set(0., 0., 0.);
827 
829  CLHEP::Hep3Vector dR(diff[0], diff[1], diff[2]);
830  Rtotal += dR;
831  CLHEP::Hep3Vector dW(diff[3], diff[4], diff[5]);
832  CLHEP::HepRotation rot(Wtotal.unit(), Wtotal.mag());
833  CLHEP::HepRotation drot(dW.unit(), dW.mag());
834  rot *= drot;
835  Wtotal.set(rot.axis().x() * rot.delta(), rot.axis().y() * rot.delta(), rot.axis().z() * rot.delta());
836 
837  TrackerCommonT_ = align::GlobalVector(Rtotal.x(), Rtotal.y(), Rtotal.z());
838  TrackerCommonR_ = align::GlobalVector(Wtotal.x(), Wtotal.y(), Wtotal.z());
839  TrackerCommonCM_ = curAli->globalPosition();
840 
841  } else {
842  for (unsigned int i = 0; i < nComp; ++i)
843  diffCommonTrackerSystem(refComp[i], curComp[i]);
844  }
845 }
846 
848  const AlgebraicVector& diff,
849  const TrackerTopology* tTopo,
850  const edm::EventSetup& iSetup) {
851  //Get bad modules
852  const SiPixelQuality* SiPixelModules = &iSetup.getData(pixQualityToken_);
853  const SiStripQuality* SiStripModules = &iSetup.getData(stripQualityToken_);
854 
855  id_ = refAli->id();
856 
857  badModuleQuality_ = 0;
858  //check if module has a bad quality tag
859  if (SiPixelModules->IsModuleBad(id_)) {
860  badModuleQuality_ = 1;
861  }
862  if (SiStripModules->IsModuleBad(id_)) {
863  badModuleQuality_ = 1;
864  }
865 
866  //check if module is in a given list of bad/untouched etc. modules
867  inModuleList_ = 0;
868  for (unsigned int i = 0; i < moduleList_.size(); i++) {
869  if (moduleList_[i] == id_) {
870  inModuleList_ = 1;
871  break;
872  }
873  }
874 
875  level_ = refAli->alignableObjectId();
876  //need if ali has no mother
877  if (refAli->mother()) {
878  mid_ = refAli->mother()->geomDetId().rawId();
879  mlevel_ = refAli->mother()->alignableObjectId();
880  } else {
881  mid_ = -1;
882  mlevel_ = -1;
883  }
884  DetId detid(id_);
885  sublevel_ = detid.subdetId();
886  fillIdentifiers(sublevel_, id_, tTopo);
887  xVal_ = refAli->globalPosition().x();
888  yVal_ = refAli->globalPosition().y();
889  zVal_ = refAli->globalPosition().z();
891  rVal_ = vec.perp();
892  phiVal_ = vec.phi();
893  etaVal_ = vec.eta();
895  align::EulerAngles eulerAngles = align::toAngles(rot);
896  alphaVal_ = eulerAngles[0];
897  betaVal_ = eulerAngles[1];
898  gammaVal_ = eulerAngles[2];
899  // global
900  dxVal_ = diff[0];
901  dyVal_ = diff[1];
902  dzVal_ = diff[2];
903  // local
904  duVal_ = diff[6];
905  dvVal_ = diff[7];
906  dwVal_ = diff[8];
907  //...TODO...
909  //getting dR and dPhi
912  drVal_ = vCur.perp() - vRef.perp();
913  dphiVal_ = vCur.phi() - vRef.phi();
914  // global
915  dalphaVal_ = diff[3];
916  dbetaVal_ = diff[4];
917  dgammaVal_ = diff[5];
918  // local
919  daVal_ = diff[9];
920  dbVal_ = diff[10];
921  dgVal_ = diff[11];
922  //detIdFlag
923  if (refAli->alignableObjectId() == align::AlignableDetUnit) {
924  if (detIdFlag_) {
925  if ((passIdCut(refAli->id())) || (passIdCut(refAli->mother()->id()))) {
926  useDetId_ = 1;
927  } else {
928  useDetId_ = 0;
929  }
930  }
931  }
932  // det module dimension
933  if (refAli->alignableObjectId() == align::AlignableDetUnit) {
934  if (refAli->mother()->alignableObjectId() != align::AlignableDet)
935  detDim_ = 1;
936  else if (refAli->mother()->alignableObjectId() == align::AlignableDet)
937  detDim_ = 2;
938  } else
939  detDim_ = 0;
940 
941  surWidth_ = refAli->surface().width();
942  surLength_ = refAli->surface().length();
944  surRot_[0] = rt.xx();
945  surRot_[1] = rt.xy();
946  surRot_[2] = rt.xz();
947  surRot_[3] = rt.yx();
948  surRot_[4] = rt.yy();
949  surRot_[5] = rt.yz();
950  surRot_[6] = rt.zx();
951  surRot_[7] = rt.zy();
952  surRot_[8] = rt.zz();
953 
954  //Fill
955  alignTree_->Fill();
956 }
957 
959  Alignments* alignVals,
960  AlignmentErrorsExtended* alignErrors) {
961  //getting the right alignables for the alignment record
962  auto detPB = ali->pixelHalfBarrelGeomDets();
963  auto detPEC = ali->pixelEndcapGeomDets();
964  auto detTIB = ali->innerBarrelGeomDets();
965  auto detTID = ali->TIDGeomDets();
966  auto detTOB = ali->outerBarrelGeomDets();
967  auto detTEC = ali->endcapGeomDets();
968 
969  align::Alignables allGeomDets;
970  std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
971  std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
972  std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
973  std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
974  std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
975  std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
976 
977  align::Alignables rcdAlis;
978  for (const auto& i : allGeomDets) {
979  if (i->components().size() == 1) {
980  rcdAlis.push_back(i);
981  } else if (i->components().size() > 1) {
982  rcdAlis.push_back(i);
983  const auto& comp = i->components();
984  for (const auto& j : comp)
985  rcdAlis.push_back(j);
986  }
987  }
988 
989  //turning them into alignments
990  for (const auto& k : rcdAlis) {
991  const SurveyDet* surveyInfo = k->survey();
992  const align::PositionType& pos(surveyInfo->position());
993  align::RotationType rot(surveyInfo->rotation());
994  CLHEP::Hep3Vector clhepVector(pos.x(), pos.y(), pos.z());
995  CLHEP::HepRotation clhepRotation(
996  CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
997  AlignTransform transform(clhepVector, clhepRotation, k->id());
998  AlignTransformErrorExtended transformError(CLHEP::HepSymMatrix(3, 1), k->id());
999  alignVals->m_align.push_back(transform);
1000  alignErrors->m_alignError.push_back(transformError);
1001  }
1002 
1003  // to get the right order, sort by rawId
1004  std::sort(alignVals->m_align.begin(), alignVals->m_align.end());
1005  std::sort(alignErrors->m_alignError.begin(), alignErrors->m_alignError.end());
1006 }
1007 
1009  const auto& comp = ali->components();
1010 
1011  unsigned int nComp = comp.size();
1012 
1013  for (unsigned int i = 0; i < nComp; ++i)
1014  addSurveyInfo(comp[i]);
1015 
1017 
1018  if (ali->geomDetId().rawId() != error.rawId() || ali->alignableObjectId() != error.structureType()) {
1019  throw cms::Exception("DatabaseError") << "Error reading survey info from DB. Mismatched id!";
1020  }
1021 
1022  const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation();
1023  const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation();
1024 
1025  AlignableSurface surf(
1026  align::PositionType(pos.x(), pos.y(), pos.z()),
1027  align::RotationType(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
1028 
1029  surf.setWidth(ali->surface().width());
1030  surf.setLength(ali->surface().length());
1031 
1032  ali->setSurvey(new SurveyDet(surf, error.matrix()));
1033 
1034  ++theSurveyIndex;
1035 }
1036 
1038  bool pass = false;
1039  int nEntries = detIdFlagVector_.size();
1040 
1041  for (int i = 0; i < nEntries; i++) {
1042  if (detIdFlagVector_[i] == id)
1043  pass = true;
1044  }
1045 
1046  return pass;
1047 }
1048 
1049 void TrackerGeometryCompare::fillIdentifiers(int subdetlevel, int rawid, const TrackerTopology* tTopo) {
1050  switch (subdetlevel) {
1051  case 1: {
1052  identifiers_[0] = tTopo->pxbModule(rawid);
1053  identifiers_[1] = tTopo->pxbLadder(rawid);
1054  identifiers_[2] = tTopo->pxbLayer(rawid);
1055  identifiers_[3] = 999;
1056  identifiers_[4] = 999;
1057  identifiers_[5] = 999;
1058  break;
1059  }
1060  case 2: {
1061  identifiers_[0] = tTopo->pxfModule(rawid);
1062  identifiers_[1] = tTopo->pxfPanel(rawid);
1063  identifiers_[2] = tTopo->pxfBlade(rawid);
1064  identifiers_[3] = tTopo->pxfDisk(rawid);
1065  identifiers_[4] = tTopo->pxfSide(rawid);
1066  identifiers_[5] = 999;
1067  break;
1068  }
1069  case 3: {
1070  identifiers_[0] = tTopo->tibModule(rawid);
1071  identifiers_[1] = tTopo->tibStringInfo(rawid)[0];
1072  identifiers_[2] = tTopo->tibStringInfo(rawid)[1];
1073  identifiers_[3] = tTopo->tibStringInfo(rawid)[2];
1074  identifiers_[4] = tTopo->tibLayer(rawid);
1075  identifiers_[5] = 999;
1076  break;
1077  }
1078  case 4: {
1079  identifiers_[0] = tTopo->tidModuleInfo(rawid)[0];
1080  identifiers_[1] = tTopo->tidModuleInfo(rawid)[1];
1081  identifiers_[2] = tTopo->tidRing(rawid);
1082  identifiers_[3] = tTopo->tidWheel(rawid);
1083  identifiers_[4] = tTopo->tidSide(rawid);
1084  identifiers_[5] = 999;
1085  break;
1086  }
1087  case 5: {
1088  identifiers_[0] = tTopo->tobModule(rawid);
1089  identifiers_[1] = tTopo->tobRodInfo(rawid)[0];
1090  identifiers_[2] = tTopo->tobRodInfo(rawid)[1];
1091  identifiers_[3] = tTopo->tobLayer(rawid);
1092  identifiers_[4] = 999;
1093  identifiers_[5] = 999;
1094  break;
1095  }
1096  case 6: {
1097  identifiers_[0] = tTopo->tecModule(rawid);
1098  identifiers_[1] = tTopo->tecRing(rawid);
1099  identifiers_[2] = tTopo->tecPetalInfo(rawid)[0];
1100  identifiers_[3] = tTopo->tecPetalInfo(rawid)[1];
1101  identifiers_[4] = tTopo->tecWheel(rawid);
1102  identifiers_[5] = tTopo->tecSide(rawid);
1103  break;
1104  }
1105  default: {
1106  edm::LogInfo("TrackerGeometryCompare") << "Error: bad subdetid!!";
1107  break;
1108  }
1109  }
1110 }
1111 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
unsigned int tobLayer(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91
T perp() const
Definition: PV3DBase.h:69
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
align::GlobalVector TrackerCommonR_
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
Alignments * alignments() const override
Return alignments, sorted by DetId.
Vector3DBase< Scalar, GlobalTag > GlobalVector
Definition: Definitions.h:31
void compareGeometries(Alignable *refAli, Alignable *curAli, const TrackerTopology *tTopo, const edm::EventSetup &iSetup)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
unsigned int pxfBlade(const DetId &id) const
Class to update a given geometry with a set of alignments.
T z() const
Definition: PV3DBase.h:61
unsigned int tibModule(const DetId &id) const
unsigned int tidSide(const DetId &id) const
std::vector< align::StructureType > m_theLevels
const double tolerance
const std::vector< std::string > levelStrings_
const Alignments * theSurveyValues
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
unsigned int pxfModule(const DetId &id) const
void addSurveyInfo(Alignable *ali)
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
T eta() const
Definition: PV3DBase.h:73
bool IsModuleBad(uint32_t detid) const
AlgebraicVector diffAlignables(Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
Definition: AlignTools.cc:10
align::Scalar width() const
std::vector< TrackerMap > m_vtkmap_
void diffCommonTrackerSystem(Alignable *refAli, Alignable *curAli)
bool IsModuleBad(const uint32_t &detid) const
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
void setWidth(align::Scalar width)
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
const Alignables & deepComponents() const
Definition: Alignable.h:72
std::map< std::string, TH1D * > m_h1_
std::vector< int > moduleList_
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
unsigned int tecRing(const DetId &id) const
ring id
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
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
void setLength(align::Scalar length)
T * make(const Args &...args) const
make new ROOT object
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
unsigned int tecModule(const DetId &id) const
std::vector< uint32_t > detIdFlagVector_
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
const align::RotationType & rotation() const
Definition: SurveyDet.h:60
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
unsigned int tecSide(const DetId &id) const
bool isThere(GeomDetEnumerators::SubDetector subdet) const
const edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvTokenDDD_
std::vector< unsigned int > weightByIdVector_
Alignables & TIDGeomDets()
Return TID GeomDets.
T mag() const
Definition: PV3DBase.h:64
unsigned int pxfDisk(const DetId &id) const
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
void beginJob() override
Read from DB and print survey info.
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
TrackerGeometryCompare(const edm::ParameterSet &)
Do nothing. Required by framework.
const align::PositionType & position() const
Definition: SurveyDet.h:58
align::GlobalVector TrackerCommonT_
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:8
virtual const Alignables & components() const =0
Return vector of all direct components.
Alignables & endcapGeomDets()
Return endcap GeomDets.
Alignables & pixelEndcapGeomDets()
Return pixel endcap GeomDets.
void fillTree(Alignable *refAli, const AlgebraicVector &diff, const TrackerTopology *tTopo, const edm::EventSetup &iSetup)
ii
Definition: cuy.py:589
unsigned int pxfPanel(const DetId &id) const
Log< level::Info, false > LogInfo
Definition: DetId.h:17
CLHEP::HepVector AlgebraicVector
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
unsigned int pxfSide(const DetId &id) const
AlgebraicVector EulerAngles
Definition: Definitions.h:34
std::vector< unsigned int > tibStringInfo(const DetId &id) const
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
AlignableTracker * currentTracker
void surveyToTracker(AlignableTracker *ali, Alignments *alignVals, AlignmentErrorsExtended *alignErrors)
std::vector< AlignTransformErrorExtended > m_alignError
const DetId & geomDetId() const
Definition: Alignable.h:177
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
const edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokenDD4hep_
align::Scalar length() const
align::StructureType commonTrackerLevel_
void fillIdentifiers(int subdetlevel, int rawid, const TrackerTopology *tTopo)
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
align::StructureType stringToId(const char *) const
AlignableTracker * referenceTracker
std::vector< unsigned int > tobRodInfo(const DetId &id) const
void createROOTGeometry(const edm::EventSetup &iSetup)
align::PositionType TrackerCommonCM_
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:34
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:141
const AlignableObjectId & objectIdProvider() const
Return tracker alignable object ID provider derived from the tracker&#39;s geometry.
unsigned int tidRing(const DetId &id) const
const SurveyErrors * theSurveyErrors
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
bool isAvailable() const
Definition: Service.h:40
unsigned int tibLayer(const DetId &id) const
unsigned int tobModule(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:22
void moveAlignable(Alignable *ali, AlgebraicVector diff)
Moves the alignable by the AlgebraicVector.
Definition: AlignTools.cc:84
SurfaceDeformation * create(int type, const std::vector< double > &params)
void compareSurfaceDeformations(TTree *_inputTree11, TTree *_inputTree12)
const edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > pixQualityToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned transform(const HcalDetId &id, unsigned transformCode)