2 void MakePipeMisalignment(Int_t inputRun=0,
3 const char* ocdbPath="local://$ALICE_ROOT/OCDB",
5 const char* outFileName=0)
7 // Creates misalignment of the beam pipe, frame and FMD2&3.
9 // The misalignment is based on the ITS global alignment object with
10 // the exception of the beam pipe where only the translations are
11 // used ignoring the rotation matrix.
12 AliCDBManager* cdb = AliCDBManager::Instance();
13 cdb->SetDefaultStorage("alien://Folder=/alice/data/2010/OCDB");
14 cdb->SetRun(inputRun);
18 AliGeomManager::LoadGeometry();
21 AliCDBEntry* itsEntry = cdb->Get("ITS/Align/Data");
23 Error("MakePipeMisalignment", "Couldn't get ITS alignment data");
26 TClonesArray* itsArray = static_cast<TClonesArray*>(itsEntry->GetObject());
28 Error("MakePipeMisalignment", "No array in CDB entry");
31 AliAlignObjParams* itsAlign =
32 static_cast<AliAlignObjParams*>(itsArray->At(0));
34 Error("MakePipeMisalignment", "No alignment object in CDB entry");
39 Info("MakePipeMisalignment", "ITS alignment:");
45 itsAlign->GetTranslation(itsTrans);
46 itsAlign->GetAngles(itsRot);
48 Double_t local[] = { 0, 0, 0 };
50 if (!gGeoManager->cd("/ALIC_1/CP_1/Cp1_1/CpSupC_1")) return;
52 gGeoManager->LocalToMaster(local, pCpSupCA);
54 if (!gGeoManager->cd("/ALIC_1/CP_1/Cp3_1/CpSupC_3")) return;
56 gGeoManager->LocalToMaster(local, pCpSupCC);
58 if (!gGeoManager->cd("/ALIC_1/CP_1/Cp1_1")) return;
60 gGeoManager->LocalToMaster(local, pCp1);
62 if (!gGeoManager->cd("/ALIC_1/CP_1/Cp1_1/CP1MO_1/CP1AT_1")) return;
64 TGeoNode* node = gGeoManager->GetCurrentNode();
66 TGeoVolume* volume = node->GetVolume();
68 TGeoBBox* bbox = static_cast<TGeoBBox*>(volume->GetShape());
70 local[2] = -bbox->GetDZ();
73 Error("MakePipeMisalignement", "Failed to find end of CP1 section");
77 gGeoManager->LocalToMaster(local, pCP1AT);
81 // Now, we need to misalign the C-side collar according to the ITS
83 TGeoHMatrix* itsMat = new TGeoHMatrix();
84 itsAlign->GetMatrix(*itsMat);
86 // itsMat->SetTranslation(itsTrans);
88 itsMat->LocalToMaster(pCpSupCA, tCpSupCA);
90 itsMat->LocalToMaster(pCpSupCC, tCpSupCC);
92 Info("MakePipeMisalignment", "\n"
93 "\tCollar A-side (%f,%f,%f)\n"
94 "\tCollar C-side (%f,%f,%f)\n"
95 "\tBeam pipe center (%f,%f,%f)\n"
96 "\tEnd of CP1 A-side (%f,%f,%f)\n"
97 "\tCollar A-side after (%f,%f,%f)\n"
98 "\tCollar C-side after (%f,%f,%f)",
99 pCpSupCA[0], pCpSupCA[1], pCpSupCA[2],
100 pCpSupCC[0], pCpSupCC[1], pCpSupCC[2],
101 pCp1[0], pCp1[1], pCp1[2],
102 pCP1AT[0], pCP1AT[1], pCP1AT[2],
103 tCpSupCA[0], tCpSupCA[1], tCpSupCA[2],
104 tCpSupCC[0], tCpSupCC[1], tCpSupCC[2]);
106 // Distance from A-side end to mis-aligned C-side Collar
107 Double_t dX = - tCpSupCC[0] + pCP1AT[0] ;
108 Double_t dY = - tCpSupCC[1] + pCP1AT[1] ;
109 Double_t dZ = - tCpSupCC[2] + pCP1AT[2] ;
111 // Rotation angle around X and Y
112 Double_t rotX = TMath::ATan2(dY, dZ);
113 Double_t rotY = TMath::ATan2(dX, dZ);
116 Double_t dZc = pCp1[2] - pCP1AT[2];
117 Double_t dXc = TMath::Tan(rotY) * dZc;
118 Double_t dYc = TMath::Tan(rotX) * dZc;
121 Double_t dZt = pCpSupCC[2] - pCP1AT[2] + itsTrans[2];
123 Info("MakePipeMisalignment", "\n"
124 "\tDistances (%f,%f,%f)\n"
125 "\trotX=%f rotY=%f\n"
126 "\tCP1 displacement (x,y)=(%f,%f) dZ=%f\n"
127 "\tCpSubCA displacement (x,y)=(%f,%f) dZ=%f",
129 rotX * TMath::RadToDeg(), rotY * TMath::RadToDeg(),
131 TMath::Tan(rotY)*dZt, TMath::Tan(rotX)*dZt, dZt);
134 TGeoRotation* rot = new TGeoRotation();
135 rot->RotateX(rotX*TMath::RadToDeg());
136 rot->RotateY(rotY*TMath::RadToDeg());
137 TGeoCombiTrans* trans = new TGeoCombiTrans(dXc, dYc, 0, rot);
141 TClonesArray* structArray = new TClonesArray("AliAlignObjParams", 20);
145 AliGeomManager::LayerToVolUID(AliGeomManager::kInvalidLayer,0);
147 //base of symbolic name corresponding to base of path "ALIC_1/B077_1/BSEGMO";
148 const char* baseSymName = "FRAME/Sector";
149 for(Int_t sm=0; sm<18; sm++){
150 TString symname = baseSymName;
152 new((*structArray)[sm]) AliAlignObjParams(symname.Data(),dvoluid,
153 0.,0.,0.,0.,0.,0.,kTRUE);
156 // --- Beam pipe ---------------------------------------------------
157 AliAlignObjParams* c1Align =
158 new((*structArray)[18]) AliAlignObjParams("CP1",dvoluid,
159 dXc, dYc, 0, rotX, rotY, 0,kTRUE);
162 // --- C side Collar -----------------------------------------------
163 AliAlignObjParams* cSupCAlign =
164 new((*structArray)[19]) AliAlignObjParams("CPSUPC",
166 tCpSupCC[0]-pCpSupCC[0],
167 tCpSupCC[1]-pCpSupCC[1],
168 tCpSupCC[2]-pCpSupCC[2],
172 // --- save in CDB storage -----------------------------------------
173 Info("MakeForwardMisAlignment",
174 "Saving alignment objects in CDB storage %s", ocdbPath);
175 AliCDBStorage* storage = cdb->GetStorage(ocdbPath);
177 Error("MakeForwardMisAlignment","Unable to open storage %s\n",ocdbPath);
182 // --- Make objects and store --------------------------------------
183 AliCDBMetaData* md = new AliCDBMetaData();
184 md->SetResponsible("Grosso Raffaele");
185 md->SetComment("Misalignment for FRAME and beam pipe");
186 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
187 AliCDBId id("GRP/Align/Data",0,AliCDBRunRange::Infinity());
188 storage->Put(structArray,id,md);
190 gGeoManager->Export("myGeom.root");