CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerGeometryCompare.cc
Go to the documentation of this file.
3 #include "CLHEP/Vector/RotationInterfaces.h"
14 
28 
29 //#include "Alignment/OfflineValidation/interface/ComparisonUtilities.h"
30 //#include "Alignment/CommonAlignment/interface/AlignTools.h"
31 
32 //#include "Alignment/OfflineValidation/plugins/TrackerGeometryCompare.h"
33 #include "TrackerGeometryCompare.h"
34 #include "TFile.h"
35 #include "CLHEP/Vector/ThreeVector.h"
36 
37 // Database
40 //#include "Geometry/Records/interface/PGeometricDetRcd.h"
41 
48 
49 #include <iostream>
50 #include <fstream>
51 
53 {
54 
55  //input is ROOT
56  _inputFilename1 = cfg.getUntrackedParameter< std::string > ("inputROOTFile1");
57  _inputFilename2 = cfg.getUntrackedParameter< std::string > ("inputROOTFile2");
58  _inputTreename = cfg.getUntrackedParameter< std::string > ("treeName");
59 
60  //output file
61  _filename = cfg.getUntrackedParameter< std::string > ("outputFile");
62 
63  _writeToDB = cfg.getUntrackedParameter< bool > ("writeToDB" );
64 
65  const std::vector<std::string>& levels = cfg.getUntrackedParameter< std::vector<std::string> > ("levels");
66 
67  _weightBy = cfg.getUntrackedParameter< std::string > ("weightBy");
68  _setCommonTrackerSystem = cfg.getUntrackedParameter< std::string > ("setCommonTrackerSystem");
69  _detIdFlag = cfg.getUntrackedParameter< bool > ("detIdFlag");
70  _detIdFlagFile = cfg.getUntrackedParameter< std::string > ("detIdFlagFile");
71  _weightById = cfg.getUntrackedParameter< bool > ("weightById");
72  _weightByIdFile = cfg.getUntrackedParameter< std::string > ("weightByIdFile");
73 
74  //setting the levels being used in the geometry comparator
75  AlignableObjectId dummy;
76  edm::LogInfo("TrackerGeometryCompare") << "levels: " << levels.size();
77  for (unsigned int l = 0; l < levels.size(); ++l){
78  theLevels.push_back( dummy.nameToType(levels[l]));
79  edm::LogInfo("TrackerGeometryCompare") << "level: " << levels[l];
80  }
81 
82 
83  // if want to use, make id cut list
84  if (_detIdFlag){
85  ifstream fin;
86  fin.open( _detIdFlagFile.c_str() );
87 
88  while (!fin.eof() && fin.good() ){
89 
90  uint32_t id;
91  fin >> id;
92  _detIdFlagVector.push_back(id);
93  }
94  fin.close();
95  }
96 
97  // turn weightByIdFile into weightByIdVector
98  if (_weightById){
99  std::ifstream inFile;
100  inFile.open( _weightByIdFile.c_str() );
101  int ctr = 0;
102  while ( !inFile.eof() ){
103  ctr++;
104  unsigned int listId;
105  inFile >> listId;
106  inFile.ignore(256, '\n');
107 
108  _weightByIdVector.push_back( listId );
109  }
110  inFile.close();
111  }
112 
113 
114  //root configuration
115  _theFile = new TFile(_filename.c_str(),"RECREATE");
116  _alignTree = new TTree("alignTree","alignTree");//,"id:level:mid:mlevel:sublevel:x:y:z:r:phi:a:b:c:dx:dy:dz:dr:dphi:da:db:dc");
117  _alignTree->Branch("id", &_id, "id/I");
118  _alignTree->Branch("level", &_level, "level/I");
119  _alignTree->Branch("mid", &_mid, "mid/I");
120  _alignTree->Branch("mlevel", &_mlevel, "mlevel/I");
121  _alignTree->Branch("sublevel", &_sublevel, "sublevel/I");
122  _alignTree->Branch("x", &_xVal, "x/F");
123  _alignTree->Branch("y", &_yVal, "y/F");
124  _alignTree->Branch("z", &_zVal, "z/F");
125  _alignTree->Branch("r", &_rVal, "r/F");
126  _alignTree->Branch("phi", &_phiVal, "phi/F");
127  _alignTree->Branch("eta", &_etaVal, "eta/F");
128  _alignTree->Branch("alpha", &_alphaVal, "alpha/F");
129  _alignTree->Branch("beta", &_betaVal, "beta/F");
130  _alignTree->Branch("gamma", &_gammaVal, "gamma/F");
131  _alignTree->Branch("dx", &_dxVal, "dx/F");
132  _alignTree->Branch("dy", &_dyVal, "dy/F");
133  _alignTree->Branch("dz", &_dzVal, "dz/F");
134  _alignTree->Branch("dr", &_drVal, "dr/F");
135  _alignTree->Branch("dphi", &_dphiVal, "dphi/F");
136  _alignTree->Branch("dalpha", &_dalphaVal, "dalpha/F");
137  _alignTree->Branch("dbeta", &_dbetaVal, "dbeta/F");
138  _alignTree->Branch("dgamma", &_dgammaVal, "dgamma/F");
139  _alignTree->Branch("du", &_duVal, "du/F");
140  _alignTree->Branch("dv", &_dvVal, "dv/F");
141  _alignTree->Branch("dw", &_dwVal, "dw/F");
142  _alignTree->Branch("da", &_daVal, "da/F");
143  _alignTree->Branch("db", &_dbVal, "db/F");
144  _alignTree->Branch("dg", &_dgVal, "dg/F");
145  _alignTree->Branch("useDetId", &_useDetId, "useDetId/I");
146  _alignTree->Branch("detDim", &_detDim, "detDim/I");
147  _alignTree->Branch("surW", &_surWidth, "surW/F");
148  _alignTree->Branch("surL", &_surLength, "surL/F");
149  _alignTree->Branch("surRot", &_surRot, "surRot[9]/D");
150  _alignTree->Branch("identifiers", &_identifiers, "identifiers[6]/I");
151 
152 
153 }
154 
156  firstEvent_ = true;
157 }
158 
160 
161  if (firstEvent_) {
162 
163  //upload the ROOT geometries
164  createROOTGeometry(iSetup);
165 
166  //set common tracker system first
167  // if setting the tracker common system
168  if (_setCommonTrackerSystem != "NONE"){
170  }
171 
172 
173  //compare the goemetries
175 
176  //write out ntuple
177  //might be better to do within output module
178  _theFile->cd();
179  _alignTree->Write();
180  _theFile->Close();
181 
182 
183  if (_writeToDB){
184  Alignments* myAlignments = currentTracker->alignments();
185  AlignmentErrors* myAlignmentErrors = currentTracker->alignmentErrors();
186 
187  // 2. Store alignment[Error]s to DB
189  // Call service
190  if( !poolDbService.isAvailable() ) // Die if not available
191  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
192 
193  poolDbService->writeOne<Alignments>(&(*myAlignments), poolDbService->beginOfTime(), "TrackerAlignmentRcd");
194  poolDbService->writeOne<AlignmentErrors>(&(*myAlignmentErrors), poolDbService->beginOfTime(), "TrackerAlignmentErrorRcd");
195 
196  }
197 
198  firstEvent_ = false;
199  }
200 }
201 
203 
204  int inputRawId1, inputRawId2;
205  double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
206  double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
207 
208  //declare alignments
209  Alignments* alignments1 = new Alignments();
210  AlignmentErrors* alignmentErrors1 = new AlignmentErrors();
211  if (_inputFilename1 != "IDEAL"){
212  _inputRootFile1 = new TFile(_inputFilename1.c_str());
213  TTree* _inputTree1 = (TTree*) _inputRootFile1->Get(_inputTreename.c_str());
214  _inputTree1->SetBranchAddress("rawid", &inputRawId1);
215  _inputTree1->SetBranchAddress("x", &inputX1);
216  _inputTree1->SetBranchAddress("y", &inputY1);
217  _inputTree1->SetBranchAddress("z", &inputZ1);
218  _inputTree1->SetBranchAddress("alpha", &inputAlpha1);
219  _inputTree1->SetBranchAddress("beta", &inputBeta1);
220  _inputTree1->SetBranchAddress("gamma", &inputGamma1);
221 
222  int nEntries1 = _inputTree1->GetEntries();
223  //fill alignments
224  for (int i = 0; i < nEntries1; ++i){
225 
226  _inputTree1->GetEntry(i);
227  CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
228  CLHEP::HepEulerAngles eulerangles1(inputAlpha1,inputBeta1,inputGamma1);
229  uint32_t detid1 = inputRawId1;
230  AlignTransform transform1(translation1, eulerangles1, detid1);
231  alignments1->m_align.push_back(transform1);
232 
233  //dummy errors
234  CLHEP::HepSymMatrix clhepSymMatrix(3,0);
235  AlignTransformError transformError(clhepSymMatrix, detid1);
236  alignmentErrors1->m_alignError.push_back(transformError);
237  }
238 
239  // to get the right order
240  std::sort( alignments1->m_align.begin(), alignments1->m_align.end(), lessAlignmentDetId<AlignTransform>() );
241  std::sort( alignmentErrors1->m_alignError.begin(), alignmentErrors1->m_alignError.end(), lessAlignmentDetId<AlignTransformError>() );
242  }
243  //------------------
244  Alignments* alignments2 = new Alignments();
245  AlignmentErrors* alignmentErrors2 = new AlignmentErrors();
246  if (_inputFilename2 != "IDEAL"){
247  _inputRootFile2 = new TFile(_inputFilename2.c_str());
248  TTree* _inputTree2 = (TTree*) _inputRootFile2->Get(_inputTreename.c_str());
249  _inputTree2->SetBranchAddress("rawid", &inputRawId2);
250  _inputTree2->SetBranchAddress("x", &inputX2);
251  _inputTree2->SetBranchAddress("y", &inputY2);
252  _inputTree2->SetBranchAddress("z", &inputZ2);
253  _inputTree2->SetBranchAddress("alpha", &inputAlpha2);
254  _inputTree2->SetBranchAddress("beta", &inputBeta2);
255  _inputTree2->SetBranchAddress("gamma", &inputGamma2);
256 
257  int nEntries2 = _inputTree2->GetEntries();
258  //fill alignments
259  for (int i = 0; i < nEntries2; ++i){
260 
261  _inputTree2->GetEntry(i);
262  CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
263  CLHEP::HepEulerAngles eulerangles2(inputAlpha2,inputBeta2,inputGamma2);
264  uint32_t detid2 = inputRawId2;
265  AlignTransform transform2(translation2, eulerangles2, detid2);
266  alignments2->m_align.push_back(transform2);
267 
268  //dummy errors
269  CLHEP::HepSymMatrix clhepSymMatrix(3,0);
270  AlignTransformError transformError(clhepSymMatrix, detid2);
271  alignmentErrors2->m_alignError.push_back(transformError);
272  }
273 
274  //to get the right order
275  std::sort( alignments2->m_align.begin(), alignments2->m_align.end(), lessAlignmentDetId<AlignTransform>() );
276  std::sort( alignmentErrors2->m_alignError.begin(), alignmentErrors2->m_alignError.end(), lessAlignmentDetId<AlignTransformError>() );
277  }
278 
279  //accessing the initial geometry
281  iSetup.get<IdealGeometryRecord>().get(cpv);
282  edm::ESHandle<GeometricDet> theGeometricDet;
283  iSetup.get<IdealGeometryRecord>().get(theGeometricDet);
284  TrackerGeomBuilderFromGeometricDet trackerBuilder;
285 
286  edm::ESHandle<Alignments> globalPositionRcd;
287  iSetup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get(globalPositionRcd);
288 
289  //reference tracker
290  TrackerGeometry* theRefTracker = trackerBuilder.build(&*theGeometricDet);
291  if (_inputFilename1 != "IDEAL"){
292  GeometryAligner aligner1;
293  aligner1.applyAlignments<TrackerGeometry>( &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
294  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
295  }
296  referenceTracker = new AlignableTracker(&(*theRefTracker));
297 
298  //currernt tracker
299  TrackerGeometry* theCurTracker = trackerBuilder.build(&*theGeometricDet);
300  if (_inputFilename2 != "IDEAL"){
301  GeometryAligner aligner2;
302  aligner2.applyAlignments<TrackerGeometry>( &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
303  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
304  }
305  currentTracker = new AlignableTracker(&(*theCurTracker));
306 
307 
308 }
309 
311 
312  const std::vector<Alignable*>& refComp = refAli->components();
313  const std::vector<Alignable*>& curComp = curAli->components();
314 
315  unsigned int nComp = refComp.size();
316  //only perform for designate levels
317  bool useLevel = false;
318  for (unsigned int i = 0; i < theLevels.size(); ++i){
319  if (refAli->alignableObjectId() == theLevels[i]) useLevel = true;
320  }
321 
322  //another added level for difference between det and detunit
323  //if ((refAli->alignableObjectId()==2)&&(nComp == 1)) useLevel = false;
324 
325  //coordinate matching, etc etc
326  if (useLevel){
327  //std::cout << "ali identifiers: " << refAli->id() << ", " << refAli->alignableObjectId() << std::endl;
328  //std::cout << "diff pos" << (refAli->globalPosition() - curAli->globalPosition()) << std::endl;
329  //std::cout <<"z";
330 
331  CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
332 
333  Rtotal.set(0.,0.,0.); Wtotal.set(0.,0.,0.);
334  lRtotal.set(0.,0.,0.); lWtotal.set(0.,0.,0.);
335  for (int i = 0; i < 100; i++){
337  CLHEP::Hep3Vector dR(diff[0],diff[1],diff[2]);
338  Rtotal+=dR;
339  CLHEP::Hep3Vector dW(diff[3],diff[4],diff[5]);
340  CLHEP::HepRotation rot(Wtotal.unit(),Wtotal.mag());
341  CLHEP::HepRotation drot(dW.unit(),dW.mag());
342  rot*=drot;
343  Wtotal.set(rot.axis().x()*rot.delta(), rot.axis().y()*rot.delta(), rot.axis().z()*rot.delta());
344  // local coordinates
345  lRtotal.set(diff[6],diff[7],diff[8]);
346  lWtotal.set(diff[9],diff[10],diff[11]);
347  //std::cout << "a";
348  //if (refAli->alignableObjectId() == 1) std::cout << "DIFF: " << diff << std::endl;
349  align::moveAlignable(curAli, diff);
350  float tolerance = 1e-7;
352  align::GlobalVector checkR(check[0],check[1],check[2]);
353  align::GlobalVector checkW(check[3],check[4],check[5]);
354  DetId detid(refAli->id());
355  if ((checkR.mag() > tolerance)||(checkW.mag() > tolerance)){
356  edm::LogInfo("TrackerGeometryCompare") << "Tolerance Exceeded!(alObjId: " << refAli->alignableObjectId()
357  << ", rawId: " << refAli->geomDetId().rawId()
358  << ", subdetId: "<< detid.subdetId() << "): " << diff;
359  throw cms::Exception("Tolerance in TrackerGeometryCompare exceeded");
360  }
361  else{
362  break;
363  }
364  }
365 
366  AlgebraicVector TRtot(12);
367  // global
368  TRtot(1) = Rtotal.x(); TRtot(2) = Rtotal.y(); TRtot(3) = Rtotal.z();
369  TRtot(4) = Wtotal.x(); TRtot(5) = Wtotal.y(); TRtot(6) = Wtotal.z();
370  // local
371  TRtot(7) = lRtotal.x(); TRtot(8) = lRtotal.y(); TRtot(9) = lRtotal.z();
372  TRtot(10) = lWtotal.x(); TRtot(11) = lWtotal.y(); TRtot(12) = lWtotal.z();
373  fillTree(refAli, TRtot);
374  }
375 
376  //another added level for difference between det and detunit
377  for (unsigned int i = 0; i < nComp; ++i)
378  compareGeometries(refComp[i],curComp[i]);
379 }
380 
382 
383  edm::LogInfo("TrackerGeometryCompare") << "Setting Common Tracker System....";
384 
385  AlignableObjectId dummy;
387 
389 
390  align::EulerAngles dOmega(3); dOmega[0] = _TrackerCommonR.x() ; dOmega[1] = _TrackerCommonR.y(); dOmega[2] = _TrackerCommonR.z();
391  align::RotationType rot = align::toMatrix( dOmega );
393 
394  std::cout << "what we get from overlaying the pixels..." << theR << ", " << rot << std::endl;
395 
396  //transform to the Tracker System
398  align::GlobalVector cmDiff( trackerCM.x()-_TrackerCommonCM.x(), trackerCM.y()-_TrackerCommonCM.y(), trackerCM.z()-_TrackerCommonCM.z() );
399 
400  std::cout << "Pixel CM: " << _TrackerCommonCM << ", tracker CM: " << trackerCM << std::endl;
401 
402  //adjust translational difference factoring in different rotational CM
403  //needed because rotateInGlobalFrame is about CM of alignable, not Tracker
404  align::GlobalVector::BasicVectorType lpvgf = cmDiff.basicVector();
405  align::GlobalVector moveV( rot.multiplyInverse(lpvgf) - lpvgf);
406  align::GlobalVector theRprime(theR + moveV);
407 
408  AlgebraicVector TrackerCommonTR(6);
409  TrackerCommonTR(1) = theRprime.x(); TrackerCommonTR(2) = theRprime.y(); TrackerCommonTR(3) = theRprime.z();
410  TrackerCommonTR(4) = _TrackerCommonR.x(); TrackerCommonTR(5) = _TrackerCommonR.y(); TrackerCommonTR(6) = _TrackerCommonR.z();
411 
412  std::cout << "and after the transformation: " << TrackerCommonTR << std::endl;
413 
414  align::moveAlignable(currentTracker, TrackerCommonTR );
415 
416 }
417 
419 
420  const std::vector<Alignable*>& refComp = refAli->components();
421  const std::vector<Alignable*>& curComp = curAli->components();
422 
423  unsigned int nComp = refComp.size();
424  //only perform for designate levels
425  bool useLevel = false;
426  if (refAli->alignableObjectId() == _commonTrackerLevel) useLevel = true;
427 
428  //useLevel = false;
429  if (useLevel){
430  CLHEP::Hep3Vector Rtotal, Wtotal;
431  Rtotal.set(0.,0.,0.); Wtotal.set(0.,0.,0.);
432 
434  CLHEP::Hep3Vector dR(diff[0],diff[1],diff[2]);
435  Rtotal+=dR;
436  CLHEP::Hep3Vector dW(diff[3],diff[4],diff[5]);
437  CLHEP::HepRotation rot(Wtotal.unit(),Wtotal.mag());
438  CLHEP::HepRotation drot(dW.unit(),dW.mag());
439  rot*=drot;
440  Wtotal.set(rot.axis().x()*rot.delta(), rot.axis().y()*rot.delta(), rot.axis().z()*rot.delta());
441  /*
442  //std::cout << "a";
443  //if (refAli->alignableObjectId() == 1) std::cout << "DIFF: " << diff << std::endl;
444  align::moveAlignable(curAli, diff);
445  float tolerance = 1e-7;
446  AlgebraicVector check = align::diffAlignables(refAli,curAli, _weightBy, _weightById, _weightByIdVector);
447  align::GlobalVector checkR(check[0],check[1],check[2]);
448  align::GlobalVector checkW(check[3],check[4],check[5]);
449  DetId detid(refAli->id());
450  if ((checkR.mag() > tolerance)||(checkW.mag() > tolerance)){
451  edm::LogInfo("TrackerGeometryCompare") << "Tolerance Exceeded!(alObjId: " << refAli->alignableObjectId()
452  << ", rawId: " << refAli->geomDetId().rawId()
453  << ", subdetId: "<< detid.subdetId() << "): " << diff;
454  }
455  else{
456  break;
457  }
458  }
459  */
460 
461  //_TrackerCommonT.set(Rtotal.x(), Rtotal.y(), Rtotal.z());
462  _TrackerCommonT = align::GlobalVector(Rtotal.x(), Rtotal.y(), Rtotal.z());
463  _TrackerCommonR = align::GlobalVector(Wtotal.x(), Wtotal.y(), Wtotal.z());
464  _TrackerCommonCM = curAli->globalPosition();
465  //_TrackerCommonTR(1) = Rtotal.x(); _TrackerCommonTR(2) = Rtotal.y(); _TrackerCommonTR(3) = Rtotal.z();
466  //_TrackerCommonTR(4) = Wtotal.x(); _TrackerCommonTR(5) = Wtotal.y(); _TrackerCommonTR(6) = Wtotal.z();
467 
468 
469  }
470  else{
471  for (unsigned int i = 0; i < nComp; ++i) diffCommonTrackerSystem(refComp[i],curComp[i]);
472  }
473 
474 
475 }
476 
478 
479 
480  _id = refAli->id();
481  _level = refAli->alignableObjectId();
482  //need if ali has no mother
483  if (refAli->mother()){
484  _mid = refAli->mother()->geomDetId().rawId();
485  _mlevel = refAli->mother()->alignableObjectId();
486  }
487  else{
488  _mid = -1;
489  _mlevel = -1;
490  }
491  DetId detid(_id);
492  _sublevel = detid.subdetId();
494  _xVal = refAli->globalPosition().x();
495  _yVal = refAli->globalPosition().y();
496  _zVal = refAli->globalPosition().z();
498  _rVal = vec.perp();
499  _phiVal = vec.phi();
500  _etaVal = vec.eta();
501  align::RotationType rot = refAli->globalRotation();
502  align::EulerAngles eulerAngles = align::toAngles(rot);
503  _alphaVal = eulerAngles[0];
504  _betaVal = eulerAngles[1];
505  _gammaVal = eulerAngles[2];
506  // global
507  _dxVal = diff[0];
508  _dyVal = diff[1];
509  _dzVal = diff[2];
510  // local
511  _duVal = diff[6];
512  _dvVal = diff[7];
513  _dwVal = diff[8];
514  //...TODO...
516  align::LocalVector l = refAli->surface().toLocal(g);
517  //getting dR and dPhi
520  _drVal = vCur.perp() - vRef.perp();
521  _dphiVal = vCur.phi() - vRef.phi();
522  // global
523  _dalphaVal = diff[3];
524  _dbetaVal = diff[4];
525  _dgammaVal = diff[5];
526  // local
527  _daVal = diff[9];
528  _dbVal = diff[10];
529  _dgVal = diff[11];
530 
531  //detIdFlag
532  if (refAli->alignableObjectId() == align::AlignableDetUnit){
533  if (_detIdFlag){
534  if ((passIdCut(refAli->id()))||(passIdCut(refAli->mother()->id()))){
535  _useDetId = 1;
536  }
537  else{
538  _useDetId = 0;
539  }
540  }
541  }
542  // det module dimension
543  if (refAli->alignableObjectId() == align::AlignableDetUnit){
544  if (refAli->mother()->alignableObjectId() != align::AlignableDet) _detDim = 1;
545  else if (refAli->mother()->alignableObjectId() == align::AlignableDet) _detDim = 2;
546  }
547  else _detDim = 0;
548 
549 
550 
551 
552  _surWidth = refAli->surface().width();
553  _surLength = refAli->surface().length();
554  align::RotationType rt = refAli->globalRotation();
555  _surRot[0] = rt.xx(); _surRot[1] = rt.xy(); _surRot[2] = rt.xz();
556  _surRot[3] = rt.yx(); _surRot[4] = rt.yy(); _surRot[5] = rt.yz();
557  _surRot[6] = rt.zx(); _surRot[7] = rt.zy(); _surRot[8] = rt.zz();
558 
559 
560  //Fill
561  _alignTree->Fill();
562 
563 }
564 
566 
567  //getting the right alignables for the alignment record
568  std::vector<Alignable*> detPB = ali->pixelHalfBarrelGeomDets();
569  std::vector<Alignable*> detPEC = ali->pixelEndcapGeomDets();
570  std::vector<Alignable*> detTIB = ali->innerBarrelGeomDets();
571  std::vector<Alignable*> detTID = ali->TIDGeomDets();
572  std::vector<Alignable*> detTOB = ali->outerBarrelGeomDets();
573  std::vector<Alignable*> detTEC = ali->endcapGeomDets();
574 
575  std::vector<Alignable*> allGeomDets;
576  std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
577  std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
578  std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
579  std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
580  std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
581  std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
582 
583  std::vector<Alignable*> rcdAlis;
584  for (std::vector<Alignable*>::iterator i = allGeomDets.begin(); i!= allGeomDets.end(); i++){
585  if ((*i)->components().size() == 1){
586  rcdAlis.push_back((*i));
587  }
588  else if ((*i)->components().size() > 1){
589  rcdAlis.push_back((*i));
590  std::vector<Alignable*> comp = (*i)->components();
591  for (std::vector<Alignable*>::iterator j = comp.begin(); j != comp.end(); j++){
592  rcdAlis.push_back((*j));
593  }
594  }
595  }
596 
597  //turning them into alignments
598  for(std::vector<Alignable*>::iterator k = rcdAlis.begin(); k != rcdAlis.end(); k++){
599 
600  const SurveyDet* surveyInfo = (*k)->survey();
601  align::PositionType pos(surveyInfo->position());
602  align::RotationType rot(surveyInfo->rotation());
603  CLHEP::Hep3Vector clhepVector(pos.x(),pos.y(),pos.z());
604  CLHEP::HepRotation clhepRotation( CLHEP::HepRep3x3(rot.xx(),rot.xy(),rot.xz(),rot.yx(),rot.yy(),rot.yz(),rot.zx(),rot.zy(),rot.zz()));
605  AlignTransform transform(clhepVector, clhepRotation, (*k)->id());
606  AlignTransformError transformError(CLHEP::HepSymMatrix(3,1), (*k)->id());
607  alignVals->m_align.push_back(transform);
608  alignErrors->m_alignError.push_back(transformError);
609  }
610 
611  //to get the right order
612  std::sort( alignVals->m_align.begin(), alignVals->m_align.end(), lessAlignmentDetId<AlignTransform>() );
613  std::sort( alignErrors->m_alignError.begin(), alignErrors->m_alignError.end(), lessAlignmentDetId<AlignTransformError>() );
614 
615 }
616 
618 
619  const std::vector<Alignable*>& comp = ali->components();
620 
621  unsigned int nComp = comp.size();
622 
623  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
624 
626 
627  if ( ali->geomDetId().rawId() != error.rawId() ||
628  ali->alignableObjectId() != error.structureType() )
629  {
630  throw cms::Exception("DatabaseError")
631  << "Error reading survey info from DB. Mismatched id!";
632  }
633 
634  const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation();
635  const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation();
636 
637  AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ),
638  align::RotationType( rot.xx(), rot.xy(), rot.xz(),
639  rot.yx(), rot.yy(), rot.yz(),
640  rot.zx(), rot.zy(), rot.zz() ) );
641 
642  surf.setWidth( ali->surface().width() );
643  surf.setLength( ali->surface().length() );
644 
645  ali->setSurvey( new SurveyDet( surf, error.matrix() ) );
646 
647  ++theSurveyIndex;
648 
649 }
650 
652 
653  bool pass = false;
654  int nEntries = _detIdFlagVector.size();
655 
656  for (int i = 0; i < nEntries; i++){
657  if (_detIdFlagVector[i] == id) pass = true;
658  }
659 
660  return pass;
661 
662 }
663 
664 void TrackerGeometryCompare::fillIdentifiers( int subdetlevel, int rawid ){
665 
666 
667  switch( subdetlevel ){
668 
669  case 1:
670  {
671  PXBDetId pxbid( rawid );
672  _identifiers[0] = pxbid.module();
673  _identifiers[1] = pxbid.ladder();
674  _identifiers[2] = pxbid.layer();
675  _identifiers[3] = 999;
676  _identifiers[4] = 999;
677  _identifiers[5] = 999;
678  break;
679  }
680  case 2:
681  {
682  PXFDetId pxfid( rawid );
683  _identifiers[0] = pxfid.module();
684  _identifiers[1] = pxfid.panel();
685  _identifiers[2] = pxfid.blade();
686  _identifiers[3] = pxfid.disk();
687  _identifiers[4] = pxfid.side();
688  _identifiers[5] = 999;
689  break;
690  }
691  case 3:
692  {
693  TIBDetId tibid( rawid );
694  _identifiers[0] = tibid.module();
695  _identifiers[1] = tibid.string()[0];
696  _identifiers[2] = tibid.string()[1];
697  _identifiers[3] = tibid.string()[2];
698  _identifiers[4] = tibid.layer();
699  _identifiers[5] = 999;
700  break;
701  }
702  case 4:
703  {
704  TIDDetId tidid( rawid );
705  _identifiers[0] = tidid.module()[0];
706  _identifiers[1] = tidid.module()[1];
707  _identifiers[2] = tidid.ring();
708  _identifiers[3] = tidid.wheel();
709  _identifiers[4] = tidid.side();
710  _identifiers[5] = 999;
711  break;
712  }
713  case 5:
714  {
715  TOBDetId tobid( rawid );
716  _identifiers[0] = tobid.module();
717  _identifiers[1] = tobid.rod()[0];
718  _identifiers[2] = tobid.rod()[1];
719  _identifiers[3] = tobid.layer();
720  _identifiers[4] = 999;
721  _identifiers[5] = 999;
722  break;
723  }
724  case 6:
725  {
726  TECDetId tecid( rawid );
727  _identifiers[0] = tecid.module();
728  _identifiers[1] = tecid.ring();
729  _identifiers[2] = tecid.petal()[0];
730  _identifiers[3] = tecid.petal()[1];
731  _identifiers[4] = tecid.wheel();
732  _identifiers[5] = tecid.side();
733  break;
734  }
735  default:
736  {
737  std::cout << "Error: bad subdetid!!" << std::endl;
738  break;
739  }
740 
741  }
742 }
743 
744 
T xx() const
align::Scalar width() const
void compareGeometries(Alignable *refAli, Alignable *curAli)
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
unsigned int panel() const
panel id
Definition: PXFDetId.h:52
align::GlobalVector _TrackerCommonR
std::vector< align::StructureType > theLevels
T perp() const
Definition: PV3DBase.h:66
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
Vector3DBase< Scalar, GlobalTag > GlobalVector
Definition: Definitions.h:33
Class to update a given geometry with a set of alignments.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ErrorMatrix matrix() const
Definition: SurveyError.h:72
const Alignments * theSurveyValues
void addSurveyInfo(Alignable *ali)
std::vector< AlignTransformError > m_alignError
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
align::GlobalVector _TrackerCommonT
T y() const
Definition: PV3DBase.h:57
T yx() const
AlgebraicVector diffAlignables(Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
Definition: AlignTools.cc:10
void diffCommonTrackerSystem(Alignable *refAli, Alignable *curAli)
unsigned int ladder() const
ladder id
Definition: PXBDetId.h:39
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
void setWidth(align::Scalar width)
uint8_t structureType() const
Definition: SurveyError.h:62
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< AlignTransform > m_align
Definition: Alignments.h:14
std::vector< unsigned int > string() const
string id
Definition: TIBDetId.h:53
unsigned int module() const
det id
Definition: TECDetId.h:75
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
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
unsigned int side() const
positive or negative id
Definition: TECDetId.h:47
std::vector< unsigned int > rod() const
rod id
Definition: TOBDetId.h:49
unsigned int blade() const
blade id
Definition: PXFDetId.h:48
const align::RotationType & rotation() const
Definition: SurveyDet.h:68
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
void setLength(align::Scalar length)
T zx() const
T xy() const
const align::PositionType & position() const
Definition: SurveyDet.h:63
std::vector< unsigned int > petal() const
petal id
Definition: TECDetId.h:61
T zz() const
T mag() const
Definition: PV3DBase.h:61
virtual void beginJob()
Read from DB and print survey info.
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
T z() const
Definition: PV3DBase.h:58
void fillTree(Alignable *refAli, AlgebraicVector diff)
Alignables & TIDGeomDets()
Return TID GeomDets.
std::vector< uint32_t > _detIdFlagVector
void get(HolderT &iHolder) const
unsigned int ring() const
ring id
Definition: TIDDetId.h:55
bool isAvailable() const
Definition: Service.h:47
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignmentErrors * alignmentErrors() const
Return alignment errors, sorted by DetId.
unsigned int module() const
det id
Definition: PXBDetId.h:43
T zy() const
int j
Definition: DBlmapReader.cc:9
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)
Allows conversion between type and name, and vice-versa.
align::ID rawId() const
Definition: SurveyError.h:67
unsigned int module() const
det id
Definition: PXFDetId.h:56
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
std::vector< unsigned int > module() const
det id
Definition: TIDDetId.h:64
TrackerGeometryCompare(const edm::ParameterSet &)
Do nothing. Required by framework.
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const align::StructureType nameToType(const std::string &name) const
Convert name to type.
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
align::StructureType _commonTrackerLevel
T yy() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
unsigned int disk() const
disk id
Definition: PXFDetId.h:43
Alignables & endcapGeomDets()
Return endcap GeomDets.
align::PositionType _TrackerCommonCM
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
Alignables & pixelEndcapGeomDets()
Return pixel endcap GeomDets.
int k[5][pyjets_maxn]
Definition: DetId.h:20
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
align::Scalar length() const
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
AlignableTracker * currentTracker
unsigned int module() const
detector id
Definition: TIBDetId.h:61
unsigned int side() const
positive or negative id
Definition: TIDDetId.h:45
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:243
const T & get() const
Definition: EventSetup.h:55
TrackerGeometry * build(const GeometricDet *gd)
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
T eta() const
Definition: PV3DBase.h:70
AlignableTracker * referenceTracker
void fillIdentifiers(int subdetlevel, int rawid)
void createROOTGeometry(const edm::EventSetup &iSetup)
T xz() const
unsigned int ring() const
ring id
Definition: TECDetId.h:71
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:38
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
const SurveyErrors * theSurveyErrors
tuple cout
Definition: gather_cfg.py:41
unsigned int module() const
detector id
Definition: TOBDetId.h:58
std::vector< unsigned int > _weightByIdVector
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
Alignments * alignments() const
Return alignments, sorted by DetId.
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:21
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
T x() const
Definition: PV3DBase.h:56
void moveAlignable(Alignable *ali, AlgebraicVector diff)
Moves the alignable by the AlgebraicVector.
Definition: AlignTools.cc:81
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:85
T yz() const
const DetId & geomDetId() const
Definition: Alignable.h:177
void surveyToTracker(AlignableTracker *ali, Alignments *alignVals, AlignmentErrors *alignErrors)
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50