+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::AddAlignableVolumes() const
+{
+ //
+ // Creates entries for alignable volumes associating the symbolic volume
+ // name with the corresponding volume path.
+ //
+ // Records in the alignable entries the transformation matrices converting
+ // TGeo local coordinates (in the RS of alignable volumes) to the tracking
+ // system
+ // For this, this function has to run before the misalignment because we
+ // are using the ideal positions in the AliITSgeom object.
+
+ AliInfo("Add ITS alignable volumes");
+
+ if (!gGeoManager) {
+ AliFatal("TGeoManager doesn't exist !");
+ return;
+ }
+
+ AliGeomManager::ELayerID layerId;
+ Int_t modUID, modnum;
+
+ if( !gGeoManager->SetAlignableEntry("ITS","ALIC_1/ITSV_1") )
+ AliFatal("Unable to set alignable entry!!");
+
+ Double_t al, *gtrans, rotMatrix[9];
+
+ TString strSPD = "ITS/SPD";
+ TString strSDD = "ITS/SDD";
+ TString strSSD = "ITS/SSD";
+ TString strStave = "/Stave";
+ TString strHalfStave = "/HalfStave";
+ TString strLadder = "/Ladder";
+ TString strSector = "/Sector";
+ TString strSensor = "/Sensor";
+ TString strEntryName1;
+ TString strEntryName2;
+ TString strEntryName3;
+ TString strEntryName4;
+
+ //===== SPD layer1 =====
+ {
+ layerId = AliGeomManager::kSPD1;
+ modnum = 0;
+ TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_";
+ TString str1 = "/I10B_";
+ TString str1Bis = "/L1H-STAVE";
+ TString str1Tierce = "_1";
+ TString str2 = "/I107_";
+
+ TString sector;
+ TString stave;
+ TString halfStave;
+ TString module;
+
+ for(Int_t cSect = 0; cSect<10; cSect++)
+ {
+ sector = str0;
+ sector += cSect+1; // this is one full sector
+ strEntryName1 = strSPD;
+ strEntryName1 += 0;
+ strEntryName1 += strSector;
+ strEntryName1 += cSect;
+ //printf("%s == %s\n",strEntryName1.Data(),sector.Data());
+ if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),sector.Data()))
+ AliFatal("Unable to set alignable entry!!");
+
+ for(Int_t cStave = 0; cStave<2; cStave++)
+ {
+ stave = sector;
+ stave += str1;
+ stave += cStave+1;
+ strEntryName2 = strEntryName1;
+ strEntryName2 += strStave;
+ strEntryName2 += cStave;
+ //printf("%s == %s\n",strEntryName2.Data(),stave.Data()); // this is a stave
+
+ for(Int_t cHS=0; cHS<2; cHS++)
+ {
+ halfStave = stave;
+ halfStave += str1Bis;
+ halfStave += cHS;
+ halfStave += str1Tierce;
+ strEntryName3 = strEntryName2;
+ strEntryName3 += strHalfStave;
+ strEntryName3 += cHS;
+ //printf("%s == %s\n",strEntryName3.Data(),halfStave.Data()); // this is a half-stave
+ if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),halfStave.Data()))
+ AliFatal("Unable to set alignable entry!!");
+
+ for(Int_t cLadder = 0; cLadder<2; cLadder++)
+ {
+ modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+ module = halfStave;
+ module += str2;
+ module += cLadder+cHS*2+1;
+ strEntryName4 = strEntryName3;
+ strEntryName4 += strLadder;
+ strEntryName4 += cLadder+cHS*2;
+ //printf("%s == %s\n",strEntryName4.Data(),module.Data());
+ if(!gGeoManager->SetAlignableEntry(strEntryName4.Data(),module.Data(),modUID))
+ AliFatal("Unable to set alignable entry!!");
+
+ // Creates the TGeo Local to Tracking transformation matrix ...
+ TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+ TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+ gtrans = globMatrix->GetTranslation();
+ memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+ al = TMath::ATan2(rotMatrix[1],rotMatrix[0]);
+ TGeoHMatrix *matLtoT = new TGeoHMatrix;
+ matLtoT->SetDx( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) ); // translation
+ al += TMath::Pi()/2;
+
+ matLtoT->SetDy(-fChip1*0.0001/2.);
+ matLtoT->SetDz(-gtrans[2]);
+ rotMatrix[0]= 0; rotMatrix[1]=-1; rotMatrix[2]= 0; // + rotation
+ rotMatrix[3]=-1; rotMatrix[4]= 0; rotMatrix[5]= 0; // ! flip in y for the SPD1 only
+ rotMatrix[6]= 0; rotMatrix[7]= 0; rotMatrix[8]=-1;
+ TGeoRotation rot;
+ rot.SetMatrix(rotMatrix);
+ matLtoT->MultiplyLeft(&rot);
+ TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+ delete matLtoT;
+ alignableEntry->SetMatrix(matTtoL);
+ }
+ }
+ }
+ }
+
+ //===== SPD layer2 =====
+ layerId = AliGeomManager::kSPD2;
+ modnum = 0;
+ str1Bis = "/L2H-STAVE";
+ str1 = "/I20B_";
+ str2 = "/I1D7_";
+
+ for(Int_t cSect = 0; cSect<10; cSect++)
+ {
+ sector = str0;
+ sector += cSect+1; // this is one full sector
+ strEntryName1 = strSPD;
+ strEntryName1 += 1;
+ strEntryName1 += strSector;
+ strEntryName1 += cSect;
+ // if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),sector.Data()))
+ // AliFatal("Unable to set alignable entry!!");
+ // we don't need the previous lines because the whole sector is already define
+ // with first layer ...
+
+ for(Int_t cStave =0; cStave<4; cStave++)
+ {
+ stave = sector;
+ stave += str1;
+ stave += cStave+1;
+ strEntryName2 = strEntryName1;
+ strEntryName2 += strStave;
+ strEntryName2 += cStave;
+
+ for(Int_t cHS=0; cHS<2; cHS++)
+ {
+ halfStave = stave;
+ halfStave += str1Bis;
+ halfStave += cHS;
+ halfStave += str1Tierce;
+ strEntryName3 = strEntryName2;
+ strEntryName3 += strHalfStave;
+ strEntryName3 += cHS;
+ //printf("%s == %s\n",strEntryName3.Data(),halfStave.Data()); // this is a half-stave
+ if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),halfStave.Data()))
+ AliFatal("Unable to set alignable entry!!");
+
+ for(Int_t cLad =0; cLad<2; cLad++)
+ {
+ modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+ module = halfStave;
+ module += str2;
+ module += cLad+cHS*2+1;
+ strEntryName4 = strEntryName3;
+ strEntryName4 += strLadder;
+ strEntryName4 += cLad+cHS*2;
+ //printf("%s == %s\n",strEntryName4.Data(),module.Data());
+ if(!gGeoManager->SetAlignableEntry(strEntryName4.Data(),module.Data(),modUID))
+ AliFatal("Unable to set alignable entry!!");
+
+ // Creates the TGeo Local to Tracking transformation matrix ...
+ TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+ TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+ gtrans = globMatrix->GetTranslation();
+ memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+ al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+ TGeoHMatrix *matLtoT = new TGeoHMatrix;
+ matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+ al += TMath::Pi()/2;
+
+ matLtoT->SetDy(-fChip2*0.0001/2.);
+ matLtoT->SetDz(-gtrans[2]);
+ rotMatrix[0]= 0; rotMatrix[1]= 1; rotMatrix[2]= 0; // + rotation
+ rotMatrix[3]= 1; rotMatrix[4]= 0; rotMatrix[5]= 0;
+ rotMatrix[6]= 0; rotMatrix[7]= 0; rotMatrix[8]=-1;
+ TGeoRotation rot;
+ rot.SetMatrix(rotMatrix);
+ matLtoT->MultiplyLeft(&rot);
+ TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+ delete matLtoT;
+ alignableEntry->SetMatrix(matTtoL);
+ }
+ }
+ }
+ }
+ }
+
+ //===== SDD layer1 =====
+ {
+ layerId = AliGeomManager::kSDD1;
+ modnum = 0;
+ TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_";
+ TString str1 = "/I302_";
+
+ TString ladder;
+ TString wafer;
+
+ for(Int_t c1 = 1; c1<=14; c1++)
+ {
+ ladder = str0;
+ ladder += c1; // the set of wafers from one ladder
+ strEntryName1 = strSDD;
+ strEntryName1 += 2;
+ strEntryName1 +=strLadder;
+ strEntryName1 += (c1-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),ladder.Data()))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName1.Data(),ladder.Data());
+
+ for(Int_t c2 =1; c2<=6; c2++)
+ {
+ modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+ wafer = ladder;
+ wafer += str1;
+ wafer += c2; // one wafer
+ strEntryName2 = strEntryName1;
+ strEntryName2 += strSensor;
+ strEntryName2 += (c2-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName2.Data(),wafer.Data());
+
+ // Creates the TGeo Local to Tracking transformation matrix ...
+ TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+ TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+ gtrans = globMatrix->GetTranslation();
+ memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+ al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+ TGeoHMatrix *matLtoT = new TGeoHMatrix;
+ matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+ al += TMath::Pi()/2;
+ // matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+ matLtoT->SetDy( 0 );
+ matLtoT->SetDz(-gtrans[2]);
+ rotMatrix[0]=0; rotMatrix[1]=1; rotMatrix[2]=0; // + rotation
+ rotMatrix[3]=1; rotMatrix[4]=0; rotMatrix[5]=0;
+ rotMatrix[6]=0; rotMatrix[7]=0; rotMatrix[8]=-1;
+ TGeoRotation rot;
+ rot.SetMatrix(rotMatrix);
+ matLtoT->MultiplyLeft(&rot);
+ TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+ delete matLtoT;
+ alignableEntry->SetMatrix(matTtoL);
+ }
+ }
+ }
+
+ //===== SDD layer2 =====
+ {
+ layerId = AliGeomManager::kSDD2;
+ modnum = 0;
+ TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_";
+ TString str1 = "/I402_";
+
+ TString ladder;
+ TString wafer;
+
+ for(Int_t c1 = 1; c1<=22; c1++)
+ {
+ ladder = str0;
+ ladder += c1; // the set of wafers from one ladder
+ strEntryName1 = strSDD;
+ strEntryName1 += 3;
+ strEntryName1 +=strLadder;
+ strEntryName1 += (c1-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),ladder.Data()))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName1.Data(),ladder.Data());
+
+ for(Int_t c2 =1; c2<=8; c2++)
+ {
+ modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+ wafer = ladder;
+ wafer += str1;
+ wafer += c2; // one wafer
+ strEntryName2 = strEntryName1;
+ strEntryName2 += strSensor;
+ strEntryName2 += (c2-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName2.Data(),wafer.Data());
+
+ // Creates the TGeo Local to Tracking transformation matrix ...
+ TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+ TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+ gtrans = globMatrix->GetTranslation();
+ memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+ al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+ TGeoHMatrix *matLtoT = new TGeoHMatrix;
+ matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+ al += TMath::Pi()/2;
+ // matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+ matLtoT->SetDy( 0 );
+ matLtoT->SetDz(-gtrans[2]);
+ rotMatrix[0]=0; rotMatrix[1]=1; rotMatrix[2]=0; // + rotation
+ rotMatrix[3]=1; rotMatrix[4]=0; rotMatrix[5]=0;
+ rotMatrix[6]=0; rotMatrix[7]=0; rotMatrix[8]=-1;
+ TGeoRotation rot;
+ rot.SetMatrix(rotMatrix);
+ matLtoT->MultiplyLeft(&rot);
+ TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+ delete matLtoT;
+ alignableEntry->SetMatrix(matTtoL);
+ }
+ }
+ }
+
+ //===== SSD layer1 =====
+ {
+ layerId = AliGeomManager::kSSD1;
+ modnum = 0;
+ TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_";
+ TString str1 = "/I562_";
+
+ TString ladder;
+ TString wafer;
+
+ for(Int_t c1 = 1; c1<=34; c1++)
+ {
+ ladder = str0;
+ ladder += c1; // the set of wafers from one ladder
+ strEntryName1 = strSSD;
+ strEntryName1 += 4;
+ strEntryName1 +=strLadder;
+ strEntryName1 += (c1-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),ladder.Data()))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName1.Data(),ladder.Data());
+
+ for(Int_t c2 = 1; c2<=22; c2++)
+ {
+ modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+ wafer = ladder;
+ wafer += str1;
+ wafer += c2; // one wafer
+ strEntryName2 = strEntryName1;
+ strEntryName2 += strSensor;
+ strEntryName2 += (c2-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName2.Data(),wafer.Data());
+
+ // Creates the TGeo Local to Tracking transformation matrix ...
+ TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+ TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+ gtrans = globMatrix->GetTranslation();
+ memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+ al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+ TGeoHMatrix *matLtoT = new TGeoHMatrix;
+ matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+ al += TMath::Pi()/2;
+ // matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+ matLtoT->SetDy( 0 );
+ matLtoT->SetDz(-gtrans[2]);
+ rotMatrix[0]=0; rotMatrix[1]=1; rotMatrix[2]=0; // + rotation
+ rotMatrix[3]=1; rotMatrix[4]=0; rotMatrix[5]=0;
+ rotMatrix[6]=0; rotMatrix[7]=0; rotMatrix[8]=-1;
+ TGeoRotation rot;
+ rot.SetMatrix(rotMatrix);
+ matLtoT->MultiplyLeft(&rot);
+ TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+ delete matLtoT;
+ alignableEntry->SetMatrix(matTtoL);
+ }
+ }
+ }
+
+ //===== SSD layer2 =====
+ {
+ layerId = AliGeomManager::kSSD2;
+ modnum = 0;
+ TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_";
+ TString str1 = "/I566_";
+
+ TString ladder;
+ TString wafer;
+
+ for(Int_t c1 = 1; c1<=38; c1++)
+ {
+ ladder = str0;
+ ladder += c1; // the set of wafers from one ladder
+ strEntryName1 = strSSD;
+ strEntryName1 += 5;
+ strEntryName1 +=strLadder;
+ strEntryName1 += (c1-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),ladder.Data()))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName1.Data(),ladder.Data());
+
+ for(Int_t c2 = 1; c2<=25; c2++)
+ {
+ modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+ wafer = ladder;
+ wafer += str1;
+ wafer += c2; // one wafer
+ strEntryName2 = strEntryName1;
+ strEntryName2 += strSensor;
+ strEntryName2 += (c2-1);
+ if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
+ AliFatal("Unable to set alignable entry!!");
+ //printf("%s == %s\n",strEntryName2.Data(),wafer.Data());
+
+ // Creates the TGeo Local to Tracking transformation matrix ...
+ TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+ TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+ gtrans = globMatrix->GetTranslation();
+ memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+ al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+ TGeoHMatrix *matLtoT = new TGeoHMatrix;
+ matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+ al += TMath::Pi()/2;
+ // matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+ matLtoT->SetDy( 0 );
+ matLtoT->SetDz(-gtrans[2]);
+ rotMatrix[0]=0; rotMatrix[1]=1; rotMatrix[2]=0; // + rotation
+ rotMatrix[3]=1; rotMatrix[4]=0; rotMatrix[5]=0;
+ rotMatrix[6]=0; rotMatrix[7]=0; rotMatrix[8]=-1;
+ TGeoRotation rot;
+ rot.SetMatrix(rotMatrix);
+ matLtoT->MultiplyLeft(&rot);
+ TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+ delete matLtoT;
+ alignableEntry->SetMatrix(matTtoL);
+ }
+ }
+ }
+}
+