3 #include "CLHEP/Vector/RotationInterfaces.h"
35 #include "CLHEP/Vector/ThreeVector.h"
65 const std::vector<std::string>& levels = cfg.
getUntrackedParameter< std::vector<std::string> > (
"levels");
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];
86 fin.open( _detIdFlagFile.c_str() );
88 while (!fin.eof() && fin.good() ){
100 inFile.open( _weightByIdFile.c_str() );
102 while ( !inFile.eof() ){
106 inFile.ignore(256,
'\n');
115 _theFile =
new TFile(_filename.c_str(),
"RECREATE");
116 _alignTree =
new TTree(
"alignTree",
"alignTree");
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");
191 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
204 int inputRawId1, inputRawId2;
205 double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
206 double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
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);
222 int nEntries1 = _inputTree1->GetEntries();
224 for (
int i = 0;
i < nEntries1; ++
i){
226 _inputTree1->GetEntry(
i);
227 CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
228 CLHEP::HepEulerAngles eulerangles1(inputAlpha1,inputBeta1,inputGamma1);
229 uint32_t detid1 = inputRawId1;
231 alignments1->
m_align.push_back(transform1);
234 CLHEP::HepSymMatrix clhepSymMatrix(3,0);
236 alignmentErrors1->
m_alignError.push_back(transformError);
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);
257 int nEntries2 = _inputTree2->GetEntries();
259 for (
int i = 0;
i < nEntries2; ++
i){
261 _inputTree2->GetEntry(
i);
262 CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
263 CLHEP::HepEulerAngles eulerangles2(inputAlpha2,inputBeta2,inputGamma2);
264 uint32_t detid2 = inputRawId2;
266 alignments2->
m_align.push_back(transform2);
269 CLHEP::HepSymMatrix clhepSymMatrix(3,0);
271 alignmentErrors2->
m_alignError.push_back(transformError);
312 const std::vector<Alignable*>& refComp = refAli->
components();
313 const std::vector<Alignable*>& curComp = curAli->
components();
315 unsigned int nComp = refComp.size();
317 bool useLevel =
false;
331 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
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]);
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());
343 Wtotal.set(rot.axis().x()*rot.delta(), rot.axis().y()*rot.delta(), rot.axis().z()*rot.delta());
345 lRtotal.set(diff[6],diff[7],diff[8]);
346 lWtotal.set(diff[9],diff[10],diff[11]);
350 float tolerance = 1
e-7;
355 if ((checkR.
mag() > tolerance)||(checkW.
mag() > tolerance)){
358 <<
", subdetId: "<<
detid.subdetId() <<
"): " <<
diff;
359 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
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();
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();
377 for (
unsigned int i = 0;
i < nComp; ++
i)
383 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
394 std::cout <<
"what we get from overlaying the pixels..." << theR <<
", " << rot << std::endl;
409 TrackerCommonTR(1) = theRprime.x(); TrackerCommonTR(2) = theRprime.y(); TrackerCommonTR(3) = theRprime.z();
412 std::cout <<
"and after the transformation: " << TrackerCommonTR << std::endl;
420 const std::vector<Alignable*>& refComp = refAli->
components();
421 const std::vector<Alignable*>& curComp = curAli->
components();
423 unsigned int nComp = refComp.size();
425 bool useLevel =
false;
430 CLHEP::Hep3Vector Rtotal, Wtotal;
431 Rtotal.set(0.,0.,0.); Wtotal.set(0.,0.,0.);
434 CLHEP::Hep3Vector dR(diff[0],diff[1],diff[2]);
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());
440 Wtotal.set(rot.axis().x()*rot.delta(), rot.axis().y()*rot.delta(), rot.axis().z()*rot.delta());
571 std::vector<Alignable*> detTID = ali->
TIDGeomDets();
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));
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));
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));
598 for(std::vector<Alignable*>::iterator
k = rcdAlis.begin();
k != rcdAlis.end();
k++){
600 const SurveyDet* surveyInfo = (*k)->survey();
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()));
607 alignVals->
m_align.push_back(transform);
619 const std::vector<Alignable*>& comp = ali->
components();
621 unsigned int nComp = comp.size();
631 <<
"Error reading survey info from DB. Mismatched id!";
639 rot.yx(), rot.yy(), rot.yz(),
640 rot.zx(), rot.zy(), rot.zz() ) );
656 for (
int i = 0;
i < nEntries;
i++){
667 switch( subdetlevel ){
737 std::cout <<
"Error: bad subdetid!!" << std::endl;
align::Scalar width() const
void compareGeometries(Alignable *refAli, Alignable *curAli)
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
std::string _inputFilename2
T getUntrackedParameter(std::string const &, T const &) const
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
unsigned int panel() const
panel id
align::GlobalVector _TrackerCommonR
std::vector< align::StructureType > theLevels
unsigned int layer() const
layer id
Vector3DBase< Scalar, GlobalTag > GlobalVector
Class to update a given geometry with a set of alignments.
#define DEFINE_FWK_MODULE(type)
ErrorMatrix matrix() const
const Alignments * theSurveyValues
void addSurveyInfo(Alignable *ali)
std::vector< AlignTransformError > m_alignError
Geom::Phi< T > phi() const
align::GlobalVector _TrackerCommonT
AlgebraicVector diffAlignables(Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
std::string _detIdFlagFile
void diffCommonTrackerSystem(Alignable *refAli, Alignable *curAli)
unsigned int ladder() const
ladder id
const RotationType & globalRotation() const
Return the global orientation of the object.
void setWidth(align::Scalar width)
uint8_t structureType() const
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< AlignTransform > m_align
std::vector< unsigned int > string() const
string id
unsigned int module() const
det 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
unsigned int layer() const
layer id
unsigned int side() const
positive or negative id
std::vector< unsigned int > rod() const
rod id
unsigned int blade() const
blade id
const align::RotationType & rotation() const
uint32_t rawId() const
get the raw id
void setLength(align::Scalar length)
const align::PositionType & position() const
std::string _setCommonTrackerSystem
std::vector< unsigned int > petal() const
petal id
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)
cond::Time_t beginOfTime() const
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
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
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)
Allows conversion between type and name, and vice-versa.
unsigned int module() const
det id
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
std::vector< unsigned int > module() const
det id
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).
align::StructureType _commonTrackerLevel
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string _inputTreename
unsigned int disk() const
disk id
Alignables & endcapGeomDets()
Return endcap GeomDets.
align::PositionType _TrackerCommonCM
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Alignables & pixelEndcapGeomDets()
Return pixel endcap GeomDets.
std::string _inputFilename1
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
align::Scalar length() const
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
AlignableTracker * currentTracker
unsigned int module() const
detector id
unsigned int side() const
positive or negative id
void setSurvey(const SurveyDet *)
Set survey info.
void setCommonTrackerSystem()
TrackerGeometry * build(const GeometricDet *gd)
unsigned int wheel() const
wheel id
unsigned int theSurveyIndex
unsigned int layer() const
layer id
AlignableTracker * referenceTracker
void fillIdentifiers(int subdetlevel, int rawid)
void createROOTGeometry(const edm::EventSetup &iSetup)
unsigned int ring() const
ring id
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
unsigned int side() const
positive or negative id
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
const SurveyErrors * theSurveyErrors
unsigned int module() const
detector id
std::vector< unsigned int > _weightByIdVector
const PositionType & globalPosition() const
Return the global position of the object.
Alignments * alignments() const
Return alignments, sorted by DetId.
std::vector< SurveyError > m_surveyErrors
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
void moveAlignable(Alignable *ali, AlgebraicVector diff)
Moves the alignable by the AlgebraicVector.
Alignable * mother() const
Return pointer to container alignable (if any)
const DetId & geomDetId() const
std::string _weightByIdFile
void surveyToTracker(AlignableTracker *ali, Alignments *alignVals, AlignmentErrors *alignErrors)
unsigned int wheel() const
wheel id