X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PHOS%2FAliPHOSv0.cxx;h=b7b491d1183656ddcc696f0053e53f689c2e2bd5;hb=95a38b7d7761c1c3bdb9741630eef4c0fbd480c3;hp=b8116fe2a2c6a9688c533e2c22432ce6af2a17da;hpb=ac7bf8796141c6a3f1d3a5692bbdb267a2ef912a;p=u%2Fmrichter%2FAliRoot.git diff --git a/PHOS/AliPHOSv0.cxx b/PHOS/AliPHOSv0.cxx index b8116fe2a2c..b7b491d1183 100644 --- a/PHOS/AliPHOSv0.cxx +++ b/PHOS/AliPHOSv0.cxx @@ -17,6 +17,22 @@ /* History of cvs commits: * * $Log$ + * Revision 1.94 2007/10/18 08:40:02 kharlov + * Misalignment-related bug fixed + * + * Revision 1.93 2007/10/06 22:24:40 kharlov + * Bug in strip unit geometry is corrected + * + * Revision 1.92 2007/07/04 16:38:19 policheh + * Tracking2LocalCS matrices corrected for CPV. + * + * Revision 1.91 2007/07/02 14:50:49 policheh + * Tracking2LocalCS matrices corrected. + * + * Revision 1.90 2007/05/24 13:04:05 policheh + * AddAlignableVolumes: local to tracking CS transformation matrices creates for each + * PHOS supermodule + * * Revision 1.89 2007/04/24 14:34:39 hristov * Additional protection: do not search for alignable object if the CPV is not in the geometry * @@ -62,17 +78,15 @@ // --- ROOT system --- -#include #include #include -#include #include #include -#include #include #include #include #include +#include #include // --- Standard library --- @@ -88,6 +102,7 @@ #include "AliPHOSv0.h" #include "AliRun.h" #include "AliLog.h" +#include "AliGeomManager.h" ClassImp(AliPHOSv0) @@ -99,237 +114,6 @@ AliPHOSv0::AliPHOSv0(const char *name, const char *title): GetGeometry() ; } -//____________________________________________________________________________ -void AliPHOSv0::BuildGeometry() -{ - // Build the PHOS geometry for the ROOT display - //BEGIN_HTML - /* -

- PHOS in ALICE displayed by root -

-
    -
  • All Views -

    -

    - All Views -

  • -
  • Front View -

    -

    - Front View -

  • -
  • 3D View 1 -

    -

    - 3D View 1 -

  • -
  • 3D View 2 -

    -

    - 3D View 2 -

  • -
- */ - //END_HTML - - this->BuildGeometryforEMC() ; - this->BuildGeometryforCPV() ; - -} - -//____________________________________________________________________________ -void AliPHOSv0:: BuildGeometryforEMC(void) -{ - // Build the PHOS-EMC geometry for the ROOT display - - const Int_t kColorPHOS = kRed ; - const Int_t kColorXTAL = kBlue ; - - Double_t const kRADDEG = 180.0 / TMath::Pi() ; - - AliPHOSGeometry * geom = GetGeometry() ; - AliPHOSEMCAGeometry * emcg = geom->GetEMCAGeometry() ; - Float_t * boxparams = emcg->GetEMCParams() ; - - new TTRD1("OuterBox", "PHOS box", "void",boxparams[0],boxparams[1],boxparams[2], boxparams[3] ); - - - // Crystals Box - - Float_t * cribox = emcg->GetInnerThermoHalfSize() ; - new TBRIK( "CrystalsBox", "PHOS crystals box", "void", cribox[0], cribox[2], cribox[1] ) ; - - // position PHOS into ALICE - - Float_t r = geom->GetIPtoOuterCoverDistance() + boxparams[3] ; - Int_t number = 988 ; - TNode * top = gAlice->GetGeometry()->GetNode("alice") ; - - char * nodename = new char[20] ; - char * rotname = new char[20] ; - - new TRotMatrix("cribox", "cribox", 90, 0, 90, 90, 0, 0); - - for( Int_t i = 1; i <= geom->GetNModules(); i++ ) { - - Float_t angle = geom->GetPHOSAngle(i) ; - sprintf(rotname, "%s%d", "rot", number++) ; - new TRotMatrix(rotname, rotname, 90, angle, 0, 0, 90, 270 + angle); - - top->cd(); - sprintf(nodename,"%s%d", "Module", i) ; - Float_t x = r * TMath::Sin( angle / kRADDEG ) ; - Float_t y = -r * TMath::Cos( angle / kRADDEG ) ; - TNode * outerboxnode = new TNode(nodename, nodename, "OuterBox", x, y, 0, rotname ) ; - outerboxnode->SetLineColor(kColorPHOS) ; - fNodes->Add(outerboxnode) ; - outerboxnode->cd() ; - - Float_t z = -boxparams[3] - geom->GetIPtoOuterCoverDistance() + - cribox[1] + geom->GetIPtoCrystalSurface() ; - TNode * crystalsboxnode = new TNode(nodename, nodename, "CrystalsBox", 0, 0, z) ; - crystalsboxnode->SetLineColor(kColorXTAL) ; - fNodes->Add(crystalsboxnode) ; - } - - delete[] rotname ; - delete[] nodename ; -} - - -//____________________________________________________________________________ -void AliPHOSv0:: BuildGeometryforCPV(void) -{ - // Build the PHOS-CPV geometry for the ROOT display - // Author: Yuri Kharlov 11 September 2000 - // - //BEGIN_HTML - /* -

- CPV displayed by root -

- - - - - - - - - - - - -
CPV perspective viewCPV front view
- - */ - //END_HTML - - const Double_t kRADDEG = 180.0 / TMath::Pi() ; - const Int_t kColorCPV = kGreen ; - const Int_t kColorFrame = kYellow ; - const Int_t kColorGassiplex = kRed; - const Int_t kColorPCB = kCyan; - - AliPHOSGeometry * geom = GetGeometry() ; - - // Box for a full PHOS module - - new TBRIK ("CPVBox", "CPV box", "void", geom->GetCPVBoxSize(0)/2, - geom->GetCPVBoxSize(1)/2, - geom->GetCPVBoxSize(2)/2 ); - new TBRIK ("CPVFrameLR", "CPV frame Left-Right", "void", geom->GetCPVFrameSize(0)/2, - geom->GetCPVFrameSize(1)/2, - geom->GetCPVBoxSize(2)/2 ); - new TBRIK ("CPVFrameUD", "CPV frame Up-Down", "void", geom->GetCPVBoxSize(0)/2 - geom->GetCPVFrameSize(0), - geom->GetCPVFrameSize(1)/2, - geom->GetCPVFrameSize(2)/2); - new TBRIK ("CPVPCB", "CPV PCB", "void", geom->GetCPVActiveSize(0)/2, - geom->GetCPVTextoliteThickness()/2, - geom->GetCPVActiveSize(1)/2); - new TBRIK ("CPVGassiplex", "CPV Gassiplex PCB", "void", geom->GetGassiplexChipSize(0)/2, - geom->GetGassiplexChipSize(1)/2, - geom->GetGassiplexChipSize(2)/2); - - // position CPV into ALICE - - char * nodename = new char[25] ; - char * rotname = new char[25] ; - - Float_t r = geom->GetIPtoCPVDistance() + geom->GetCPVBoxSize(1) / 2.0 ; - Int_t number = 988 ; - TNode * top = gAlice->GetGeometry()->GetNode("alice") ; - - Int_t lastModule = 0 ; - lastModule = geom->GetNModules(); - - for( Int_t i = 1; i <= lastModule; i++ ) { // the number of PHOS modules - - // One CPV module - - Float_t angle = geom->GetPHOSAngle(i) ; - sprintf(rotname, "%s%d", "rotg", number+i) ; - new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0); - top->cd(); - sprintf(nodename, "%s%d", "CPVModule", i) ; - Float_t x = r * TMath::Sin( angle / kRADDEG ) ; - Float_t y = -r * TMath::Cos( angle / kRADDEG ) ; - Float_t z; - TNode * cpvBoxNode = new TNode(nodename , nodename ,"CPVBox", x, y, 0, rotname ) ; - cpvBoxNode->SetLineColor(kColorCPV) ; - fNodes->Add(cpvBoxNode) ; - cpvBoxNode->cd() ; - - // inside each CPV box: - - // Frame around CPV - Int_t j; - for (j=0; j<=1; j++) { - sprintf(nodename, "CPVModule%d Frame%d", i, j+1) ; - x = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(0) - geom->GetCPVFrameSize(0)) / 2; - TNode * cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameLR", x, 0, 0) ; - cpvFrameNode->SetLineColor(kColorFrame) ; - fNodes->Add(cpvFrameNode) ; - - sprintf(nodename, "CPVModule%d Frame%d", i, j+3) ; - z = TMath::Sign(1,2*j-1) * (geom->GetCPVBoxSize(2) - geom->GetCPVFrameSize(2)) / 2; - cpvFrameNode = new TNode(nodename , nodename ,"CPVFrameUD", 0, 0, z) ; - cpvFrameNode->SetLineColor(kColorFrame) ; - fNodes->Add(cpvFrameNode) ; - } - - // 4 printed circuit boards - for (j=0; j<4; j++) { - sprintf(nodename, "CPVModule%d PCB%d", i, j+1) ; - y = geom->GetCPVFrameSize(1) / 2 - geom->GetFTPosition(j) + geom->GetCPVTextoliteThickness()/2; - TNode * cpvPCBNode = new TNode(nodename , nodename ,"CPVPCB", 0, y, 0) ; - cpvPCBNode->SetLineColor(kColorPCB) ; - fNodes->Add(cpvPCBNode) ; - } - - // Gassiplex chips - Float_t xStep = geom->GetCPVActiveSize(0) / (geom->GetNumberOfCPVChipsPhi() + 1); - Float_t zStep = geom->GetCPVActiveSize(1) / (geom->GetNumberOfCPVChipsZ() + 1); - y = geom->GetCPVFrameSize(1)/2 - geom->GetFTPosition(0) + - geom->GetCPVTextoliteThickness() / 2 + geom->GetGassiplexChipSize(1) / 2 + 0.1; - for (Int_t ix=0; ixGetNumberOfCPVChipsPhi(); ix++) { - x = xStep * (ix+1) - geom->GetCPVActiveSize(0)/2; - for (Int_t iz=0; izGetNumberOfCPVChipsZ(); iz++) { - z = zStep * (iz+1) - geom->GetCPVActiveSize(1)/2; - sprintf(nodename, "CPVModule%d Chip(%dx%d)", i, ix+1,iz+1) ; - TNode * cpvGassiplexNode = new TNode(nodename , nodename ,"CPVGassiplex", x, y, z) ; - cpvGassiplexNode->SetLineColor(kColorGassiplex) ; - fNodes->Add(cpvGassiplexNode) ; - } - } - - } // PHOS modules - - delete[] rotname ; - delete[] nodename ; -} - //____________________________________________________________________________ void AliPHOSv0::CreateGeometry() { @@ -361,11 +145,15 @@ void AliPHOSv0::CreateGeometry() this->CreateGeometryforSupport() ; // --- Position PHOS mdules in ALICE setup --- - Int_t idrotm[99] ; Int_t iXYZ,iAngle; - for (Int_t iModule = 0; iModule < geom->GetNModules(); iModule++ ) { - + char im[5] ; + Bool_t anyModuleCreated=0 ; + for (Int_t iModule = 0; iModule < 5 ; iModule++ ) { + snprintf(im,5,"%d",iModule+1) ; + if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0 && strcmp(GetTitle(),"noCPV")!=0) + continue ; + anyModuleCreated=1 ; Float_t angle[3][2]; for (iXYZ=0; iXYZ<3; iXYZ++) for (iAngle=0; iAngle<2; iAngle++) @@ -381,7 +169,8 @@ void AliPHOSv0::CreateGeometry() gMC->Gspos("PHOS", iModule+1, "ALIC", pos[0], pos[1], pos[2], idrotm[iModule], "ONLY") ; } - + if(!anyModuleCreated) + AliError("No one PHOS module was created") ; } //____________________________________________________________________________ @@ -410,216 +199,244 @@ void AliPHOSv0::CreateGeometryforEMC() AliPHOSGeometry * geom = GetGeometry() ; AliPHOSEMCAGeometry * emcg = geom->GetEMCAGeometry() ; + Float_t par[4]; + Int_t ipar; // ======= Define the strip =============== - gMC->Gsvolu("PSTR", "BOX ", idtmed[716], emcg->GetStripHalfSize(), 3) ; //Made of stell + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetStripHalfSize() + ipar); + gMC->Gsvolu("PSTR", "BOX ", idtmed[716], par, 3) ; //Made of steel - // --- define steel volume (cell of the strip unit) - gMC->Gsvolu("PCEL", "BOX ", idtmed[716], emcg->GetSteelCellHalfSize(), 3); - - // --- define wrapped crystal and put it into steel cell - - gMC->Gsvolu("PWRA", "BOX ", idtmed[702], emcg->GetWrappedHalfSize(), 3); - Float_t * pin = emcg->GetAPDHalfSize() ; - Float_t * preamp = emcg->GetPreampHalfSize() ; - Float_t y = (emcg->GetAirGapLed()-2*pin[1]-2*preamp[1])/2; - gMC->Gspos("PWRA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ; + // --- define steel volume (cell of the strip unit) + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetAirCellHalfSize() + ipar); + gMC->Gsvolu("PCEL", "BOX ", idtmed[798], par, 3); + + // --- define wrapped crystal and put it into steel cell + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetWrappedHalfSize() + ipar); + gMC->Gsvolu("PWRA", "BOX ", idtmed[702], par, 3); + const Float_t * pin = emcg->GetAPDHalfSize() ; + const Float_t * preamp = emcg->GetPreampHalfSize() ; + Float_t y = (emcg->GetAirGapLed()-2*pin[1]-2*preamp[1])/2; + gMC->Gspos("PWRA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ; - // --- Define crystal and put it into wrapped crystall --- - gMC->Gsvolu("PXTL", "BOX ", idtmed[699], emcg->GetCrystalHalfSize(), 3) ; - gMC->Gspos("PXTL", 1, "PWRA", 0.0, 0.0, 0.0, 0, "ONLY") ; + // --- Define crystal and put it into wrapped crystall --- + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetCrystalHalfSize() + ipar); + gMC->Gsvolu("PXTL", "BOX ", idtmed[699], par, 3) ; + gMC->Gspos("PXTL", 1, "PWRA", 0.0, 0.0, 0.0, 0, "ONLY") ; - // --- define APD/PIN preamp and put it into AirCell + // --- define APD/PIN preamp and put it into AirCell - gMC->Gsvolu("PPIN", "BOX ", idtmed[705], emcg->GetAPDHalfSize(), 3) ; - Float_t * crystal = emcg->GetCrystalHalfSize() ; - y = crystal[1] + emcg->GetAirGapLed() /2 - preamp[1]; - gMC->Gspos("PPIN", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ; - - gMC->Gsvolu("PREA", "BOX ", idtmed[711], emcg->GetPreampHalfSize(), 3) ; // Here I assumed preamp - // as a printed Circuit - y = crystal[1] + emcg->GetAirGapLed() /2 + pin[1] ; // May it should be changed - gMC->Gspos("PREA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ; // to ceramics? - - - // --- Fill strip with wrapped cristals in steel cells - - Float_t* splate = emcg->GetSupportPlateHalfSize(); - y = -splate[1] ; - Float_t* acel = emcg->GetSteelCellHalfSize() ; - - for(Int_t lev = 2, icel = 1; icel <= emcg->GetNCellsXInStrip()*emcg->GetNCellsZInStrip(); icel += 2, lev += 2){ - Float_t x = (2*(lev / 2) - 1 - emcg->GetNCellsXInStrip())* acel[0] ; - Float_t z = acel[2]; - gMC->Gspos("PCEL", icel, "PSTR", x, y, +z, 0, "ONLY") ; - gMC->Gspos("PCEL", icel + 1, "PSTR", x, y, -z, 0, "ONLY") ; - } - - // --- define the support plate, hole in it and position it in strip ---- - gMC->Gsvolu("PSUP", "BOX ", idtmed[701], emcg->GetSupportPlateHalfSize(), 3) ; - - gMC->Gsvolu("PSHO", "BOX ", idtmed[798], emcg->GetSupportPlateInHalfSize(), 3) ; - Float_t z = emcg->GetSupportPlateThickness()/2 ; - gMC->Gspos("PSHO", 1, "PSUP", 0.0, 0.0, z, 0, "ONLY") ; - - y = acel[1] ; - gMC->Gspos("PSUP", 1, "PSTR", 0.0, y, 0.0, 0, "ONLY") ; - - - // ========== Fill module with strips and put them into inner thermoinsulation============= - gMC->Gsvolu("PTII", "BOX ", idtmed[706], emcg->GetInnerThermoHalfSize(), 3) ; - - Float_t * inthermo = emcg->GetInnerThermoHalfSize() ; - Float_t * strip = emcg->GetStripHalfSize() ; - y = inthermo[1] - strip[1] ; - Int_t irow; - Int_t nr = 1 ; - Int_t icol ; - - for(irow = 0; irow < emcg->GetNStripX(); irow ++){ - Float_t x = (2*irow + 1 - emcg->GetNStripX())* strip[0] ; - for(icol = 0; icol < emcg->GetNStripZ(); icol ++){ - z = (2*icol + 1 - emcg->GetNStripZ()) * strip[2] ; - gMC->Gspos("PSTR", nr, "PTII", x, y, z, 0, "ONLY") ; - nr++ ; - } - } - - - // ------- define the air gap between thermoinsulation and cooler - gMC->Gsvolu("PAGA", "BOX ", idtmed[798], emcg->GetAirGapHalfSize(), 3) ; - Float_t * agap = emcg->GetAirGapHalfSize() ; - y = agap[1] - inthermo[1] ; - - gMC->Gspos("PTII", 1, "PAGA", 0.0, y, 0.0, 0, "ONLY") ; + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetAPDHalfSize() + ipar); + gMC->Gsvolu("PPIN", "BOX ", idtmed[705], par, 3) ; + const Float_t * crystal = emcg->GetCrystalHalfSize() ; + y = crystal[1] + emcg->GetAirGapLed() /2 - preamp[1]; + gMC->Gspos("PPIN", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ; + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetPreampHalfSize() + ipar); + gMC->Gsvolu("PREA", "BOX ", idtmed[711], par, 3) ; // Here I assumed preamp as a printed Circuit + y = crystal[1] + emcg->GetAirGapLed() /2 + pin[1] ; // May it should be changed + gMC->Gspos("PREA", 1, "PCEL", 0.0, y, 0.0, 0, "ONLY") ; // to ceramics? + + + // --- Fill strip with wrapped cristals in steel cells + + const Float_t* splate = emcg->GetSupportPlateHalfSize(); + y = -splate[1] ; + const Float_t* acel = emcg->GetAirCellHalfSize() ; + + for(Int_t lev = 2, icel = 1; + icel <= emcg->GetNCellsXInStrip()*emcg->GetNCellsZInStrip(); + icel += 2, lev += 2) { + Float_t x = (2*(lev / 2) - 1 - emcg->GetNCellsXInStrip())* acel[0] ; + Float_t z = acel[2]; + gMC->Gspos("PCEL", icel, "PSTR", x, y, +z, 0, "ONLY") ; + gMC->Gspos("PCEL", icel + 1, "PSTR", x, y, -z, 0, "ONLY") ; + } + // --- define the support plate, hole in it and position it in strip ---- + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetSupportPlateHalfSize() + ipar); + gMC->Gsvolu("PSUP", "BOX ", idtmed[701], par, 3) ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetSupportPlateInHalfSize() + ipar); + gMC->Gsvolu("PSHO", "BOX ", idtmed[798], par, 3) ; + Float_t z = emcg->GetSupportPlateThickness()/2 ; + gMC->Gspos("PSHO", 1, "PSUP", 0.0, 0.0, z, 0, "ONLY") ; + y = acel[1] ; + gMC->Gspos("PSUP", 1, "PSTR", 0.0, y, 0.0, 0, "ONLY") ; - // ------- define the Al passive cooler - gMC->Gsvolu("PCOR", "BOX ", idtmed[701], emcg->GetCoolerHalfSize(), 3) ; - Float_t * cooler = emcg->GetCoolerHalfSize() ; - y = cooler[1] - agap[1] ; - - gMC->Gspos("PAGA", 1, "PCOR", 0.0, y, 0.0, 0, "ONLY") ; + + // ========== Fill module with strips and put them into inner thermoinsulation============= + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetInnerThermoHalfSize() + ipar); + gMC->Gsvolu("PTII", "BOX ", idtmed[706], par, 3) ; + + const Float_t * inthermo = emcg->GetInnerThermoHalfSize() ; + const Float_t * strip = emcg->GetStripHalfSize() ; + y = inthermo[1] - strip[1] ; + Int_t irow; + Int_t nr = 1 ; + Int_t icol ; + + for(irow = 0; irow < emcg->GetNStripX(); irow ++){ + Float_t x = (2*irow + 1 - emcg->GetNStripX())* strip[0] ; + for(icol = 0; icol < emcg->GetNStripZ(); icol ++){ + z = (2*icol + 1 - emcg->GetNStripZ()) * strip[2] ; + gMC->Gspos("PSTR", nr, "PTII", x, y, z, 0, "ONLY") ; + nr++ ; + } + } + + + // ------- define the air gap between thermoinsulation and cooler + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetAirGapHalfSize() + ipar); + gMC->Gsvolu("PAGA", "BOX ", idtmed[798], par, 3) ; + const Float_t * agap = emcg->GetAirGapHalfSize() ; + y = agap[1] - inthermo[1] ; + + gMC->Gspos("PTII", 1, "PAGA", 0.0, y, 0.0, 0, "ONLY") ; - // ------- define the outer thermoinsulating cover - gMC->Gsvolu("PTIO", "TRD1", idtmed[706], emcg->GetOuterThermoParams(), 4) ; - Float_t * outparams = emcg->GetOuterThermoParams() ; - Int_t idrotm[99] ; - AliMatrix(idrotm[1], 90.0, 0.0, 0.0, 0.0, 90.0, 270.0) ; - // Frame in outer thermoinsulation and so on: z out of beam, y along beam, x across beam - - z = outparams[3] - cooler[1] ; - gMC->Gspos("PCOR", 1, "PTIO", 0., 0.0, z, idrotm[1], "ONLY") ; - + // ------- define the Al passive cooler + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetCoolerHalfSize() + ipar); + gMC->Gsvolu("PCOR", "BOX ", idtmed[701], par, 3) ; + const Float_t * cooler = emcg->GetCoolerHalfSize() ; + y = cooler[1] - agap[1] ; + + gMC->Gspos("PAGA", 1, "PCOR", 0.0, y, 0.0, 0, "ONLY") ; + + // ------- define the outer thermoinsulating cover + for (ipar=0; ipar<4; ipar++) par[ipar] = *(emcg->GetOuterThermoParams() + ipar); + gMC->Gsvolu("PTIO", "TRD1", idtmed[706], par, 4) ; + const Float_t * outparams = emcg->GetOuterThermoParams() ; + + Int_t idrotm[99] ; + AliMatrix(idrotm[1], 90.0, 0.0, 0.0, 0.0, 90.0, 270.0) ; + // Frame in outer thermoinsulation and so on: z out of beam, y along beam, x across beam + + z = outparams[3] - cooler[1] ; + gMC->Gspos("PCOR", 1, "PTIO", 0., 0.0, z, idrotm[1], "ONLY") ; + // -------- Define the outer Aluminium cover ----- - gMC->Gsvolu("PCOL", "TRD1", idtmed[701], emcg->GetAlCoverParams(), 4) ; - Float_t * covparams = emcg->GetAlCoverParams() ; - z = covparams[3] - outparams[3] ; - gMC->Gspos("PTIO", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ; - - // --------- Define front fiberglass cover ----------- - gMC->Gsvolu("PFGC", "BOX ", idtmed[717], emcg->GetFiberGlassHalfSize(), 3) ; - z = - outparams[3] ; - gMC->Gspos("PFGC", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ; - - //=============This is all with cold section============== - - - //------ Warm Section -------------- - gMC->Gsvolu("PWAR", "BOX ", idtmed[701], emcg->GetWarmAlCoverHalfSize(), 3) ; - Float_t * warmcov = emcg->GetWarmAlCoverHalfSize() ; - - // --- Define the outer thermoinsulation --- - gMC->Gsvolu("PWTI", "BOX ", idtmed[706], emcg->GetWarmThermoHalfSize(), 3) ; - Float_t * warmthermo = emcg->GetWarmThermoHalfSize() ; - z = -warmcov[2] + warmthermo[2] ; - - gMC->Gspos("PWTI", 1, "PWAR", 0., 0.0, z, 0, "ONLY") ; - - // --- Define cables area and put in it T-supports ---- - gMC->Gsvolu("PCA1", "BOX ", idtmed[718], emcg->GetTCables1HalfSize(), 3) ; - Float_t * cbox = emcg->GetTCables1HalfSize() ; - - gMC->Gsvolu("PBE1", "BOX ", idtmed[701], emcg->GetTSupport1HalfSize(), 3) ; - Float_t * beams = emcg->GetTSupport1HalfSize() ; - Int_t isup ; - for(isup = 0; isup < emcg->GetNTSuppots(); isup++){ - Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ; - gMC->Gspos("PBE1", isup, "PCA1", x, 0.0, 0.0, 0, "ONLY") ; - } - - z = -warmthermo[2] + cbox[2] ; - gMC->Gspos("PCA1", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ; - - gMC->Gsvolu("PCA2", "BOX ", idtmed[718], emcg->GetTCables2HalfSize(), 3) ; - Float_t * cbox2 = emcg->GetTCables2HalfSize() ; - - gMC->Gsvolu("PBE2", "BOX ", idtmed[701], emcg->GetTSupport2HalfSize(), 3) ; - for(isup = 0; isup < emcg->GetNTSuppots(); isup++){ - Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ; - gMC->Gspos("PBE2", isup, "PCA2", x, 0.0, 0.0, 0, "ONLY") ; - } - - z = -warmthermo[2] + 2*cbox[2] + cbox2[2]; - gMC->Gspos("PCA2", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ; - + for (ipar=0; ipar<4; ipar++) par[ipar] = *(emcg->GetAlCoverParams() + ipar); + gMC->Gsvolu("PCOL", "TRD1", idtmed[701], par, 4) ; + const Float_t * covparams = emcg->GetAlCoverParams() ; + z = covparams[3] - outparams[3] ; + gMC->Gspos("PTIO", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ; + + // --------- Define front fiberglass cover ----------- + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFiberGlassHalfSize() + ipar); + gMC->Gsvolu("PFGC", "BOX ", idtmed[717], par, 3) ; + z = - outparams[3] ; + gMC->Gspos("PFGC", 1, "PCOL", 0., 0.0, z, 0, "ONLY") ; + + //=============This is all with cold section============== + + //------ Warm Section -------------- + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetWarmAlCoverHalfSize() + ipar); + gMC->Gsvolu("PWAR", "BOX ", idtmed[701], par, 3) ; + const Float_t * warmcov = emcg->GetWarmAlCoverHalfSize() ; + + // --- Define the outer thermoinsulation --- + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetWarmThermoHalfSize() + ipar); + gMC->Gsvolu("PWTI", "BOX ", idtmed[706], par, 3) ; + const Float_t * warmthermo = emcg->GetWarmThermoHalfSize() ; + z = -warmcov[2] + warmthermo[2] ; + + gMC->Gspos("PWTI", 1, "PWAR", 0., 0.0, z, 0, "ONLY") ; + + // --- Define cables area and put in it T-supports ---- + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetTCables1HalfSize() + ipar); + gMC->Gsvolu("PCA1", "BOX ", idtmed[718], par, 3) ; + const Float_t * cbox = emcg->GetTCables1HalfSize() ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetTSupport1HalfSize() + ipar); + gMC->Gsvolu("PBE1", "BOX ", idtmed[701], par, 3) ; + const Float_t * beams = emcg->GetTSupport1HalfSize() ; + Int_t isup ; + for(isup = 0; isup < emcg->GetNTSuppots(); isup++){ + Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ; + gMC->Gspos("PBE1", isup, "PCA1", x, 0.0, 0.0, 0, "ONLY") ; + } + + z = -warmthermo[2] + cbox[2]; + gMC->Gspos("PCA1", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetTCables2HalfSize() + ipar); + gMC->Gsvolu("PCA2", "BOX ", idtmed[718], par, 3) ; + const Float_t * cbox2 = emcg->GetTCables2HalfSize() ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetTSupport2HalfSize() + ipar); + gMC->Gsvolu("PBE2", "BOX ", idtmed[701], par, 3) ; + for(isup = 0; isup < emcg->GetNTSuppots(); isup++){ + Float_t x = -cbox[0] + beams[0] + (2*beams[0]+emcg->GetTSupportDist())*isup ; + gMC->Gspos("PBE2", isup, "PCA2", x, 0.0, 0.0, 0, "ONLY") ; + } + + z = -warmthermo[2] + 2*cbox[2] + cbox2[2]; + gMC->Gspos("PCA2", 1, "PWTI", 0.0, 0.0, z, 0, "ONLY") ; + + // --- Define frame --- - gMC->Gsvolu("PFRX", "BOX ", idtmed[716], emcg->GetFrameXHalfSize(), 3) ; - Float_t * posit = emcg->GetFrameXPosition() ; - gMC->Gspos("PFRX", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - gMC->Gspos("PFRX", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ; - - gMC->Gsvolu("PFRZ", "BOX ", idtmed[716], emcg->GetFrameZHalfSize(), 3) ; - posit = emcg->GetFrameZPosition() ; - gMC->Gspos("PFRZ", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - gMC->Gspos("PFRZ", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ; + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFrameXHalfSize() + ipar); + gMC->Gsvolu("PFRX", "BOX ", idtmed[716], par, 3) ; + const Float_t * posit1 = emcg->GetFrameXPosition() ; + gMC->Gspos("PFRX", 1, "PWTI", posit1[0], posit1[1], posit1[2], 0, "ONLY") ; + gMC->Gspos("PFRX", 2, "PWTI", posit1[0], -posit1[1], posit1[2], 0, "ONLY") ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFrameZHalfSize() + ipar); + gMC->Gsvolu("PFRZ", "BOX ", idtmed[716], par, 3) ; + const Float_t * posit2 = emcg->GetFrameZPosition() ; + gMC->Gspos("PFRZ", 1, "PWTI", posit2[0], posit2[1], posit2[2], 0, "ONLY") ; + gMC->Gspos("PFRZ", 2, "PWTI", -posit2[0], posit2[1], posit2[2], 0, "ONLY") ; // --- Define Fiber Glass support --- - gMC->Gsvolu("PFG1", "BOX ", idtmed[717], emcg->GetFGupXHalfSize(), 3) ; - posit = emcg->GetFGupXPosition() ; - gMC->Gspos("PFG1", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - gMC->Gspos("PFG1", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ; - - gMC->Gsvolu("PFG2", "BOX ", idtmed[717], emcg->GetFGupZHalfSize(), 3) ; - posit = emcg->GetFGupZPosition() ; - gMC->Gspos("PFG2", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - gMC->Gspos("PFG2", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ; - - gMC->Gsvolu("PFG3", "BOX ", idtmed[717], emcg->GetFGlowXHalfSize(), 3) ; - posit = emcg->GetFGlowXPosition() ; - gMC->Gspos("PFG3", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - gMC->Gspos("PFG3", 2, "PWTI", posit[0], -posit[1], posit[2], 0, "ONLY") ; - - gMC->Gsvolu("PFG4", "BOX ", idtmed[717], emcg->GetFGlowZHalfSize(), 3) ; - posit = emcg->GetFGlowZPosition() ; - gMC->Gspos("PFG4", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - gMC->Gspos("PFG4", 2, "PWTI", -posit[0], posit[1], posit[2], 0, "ONLY") ; - - // --- Define Air Gap for FEE electronics ----- - - gMC->Gsvolu("PAFE", "BOX ", idtmed[798], emcg->GetFEEAirHalfSize(), 3) ; - posit = emcg->GetFEEAirPosition() ; - gMC->Gspos("PAFE", 1, "PWTI", posit[0], posit[1], posit[2], 0, "ONLY") ; - - // Define the EMC module volume and combine Cool and Warm sections - - gMC->Gsvolu("PEMC", "TRD1", idtmed[798], emcg->GetEMCParams(), 4) ; - - z = - warmcov[2] ; - gMC->Gspos("PCOL", 1, "PEMC", 0., 0., z, 0, "ONLY") ; - z = covparams[3] ; - gMC->Gspos("PWAR", 1, "PEMC", 0., 0., z, 0, "ONLY") ; - - - // Put created EMC geometry into PHOS volume - - z = geom->GetCPVBoxSize(1) / 2. ; - gMC->Gspos("PEMC", 1, "PHOS", 0., 0., z, 0, "ONLY") ; - + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFGupXHalfSize() + ipar); + gMC->Gsvolu("PFG1", "BOX ", idtmed[717], par, 3) ; + const Float_t * posit3 = emcg->GetFGupXPosition() ; + gMC->Gspos("PFG1", 1, "PWTI", posit3[0], posit3[1], posit3[2], 0, "ONLY") ; + gMC->Gspos("PFG1", 2, "PWTI", posit3[0], -posit3[1], posit3[2], 0, "ONLY") ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFGupZHalfSize() + ipar); + gMC->Gsvolu("PFG2", "BOX ", idtmed[717], par, 3) ; + const Float_t * posit4 = emcg->GetFGupZPosition(); + gMC->Gspos("PFG2", 1, "PWTI", posit4[0], posit4[1], posit4[2], 0, "ONLY") ; + gMC->Gspos("PFG2", 2, "PWTI", -posit4[0], posit4[1], posit4[2], 0, "ONLY") ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFGlowXHalfSize() + ipar); + gMC->Gsvolu("PFG3", "BOX ", idtmed[717], par, 3) ; + const Float_t * posit5 = emcg->GetFGlowXPosition() ; + gMC->Gspos("PFG3", 1, "PWTI", posit5[0], posit5[1], posit5[2], 0, "ONLY") ; + gMC->Gspos("PFG3", 2, "PWTI", posit5[0], -posit5[1], posit5[2], 0, "ONLY") ; + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFGlowZHalfSize() + ipar); + gMC->Gsvolu("PFG4", "BOX ", idtmed[717], par, 3) ; + const Float_t * posit6 = emcg->GetFGlowZPosition() ; + gMC->Gspos("PFG4", 1, "PWTI", posit6[0], posit6[1], posit6[2], 0, "ONLY") ; + gMC->Gspos("PFG4", 2, "PWTI", -posit6[0], posit6[1], posit6[2], 0, "ONLY") ; + + // --- Define Air Gap for FEE electronics ----- + + for (ipar=0; ipar<3; ipar++) par[ipar] = *(emcg->GetFEEAirHalfSize() + ipar); + gMC->Gsvolu("PAFE", "BOX ", idtmed[798], par, 3) ; + const Float_t * posit7 = emcg->GetFEEAirPosition() ; + gMC->Gspos("PAFE", 1, "PWTI", posit7[0], posit7[1], posit7[2], 0, "ONLY") ; + + // Define the EMC module volume and combine Cool and Warm sections + + for (ipar=0; ipar<4; ipar++) par[ipar] = *(emcg->GetEMCParams() + ipar); + gMC->Gsvolu("PEMC", "TRD1", idtmed[798], par, 4) ; + z = - warmcov[2] ; + gMC->Gspos("PCOL", 1, "PEMC", 0., 0., z, 0, "ONLY") ; + z = covparams[3] ; + gMC->Gspos("PWAR", 1, "PEMC", 0., 0., z, 0, "ONLY") ; + + + // Put created EMC geometry into PHOS volume + + z = geom->GetCPVBoxSize(1) / 2. ; + gMC->Gspos("PEMC", 1, "PHOS", 0., 0., z, 0, "ONLY") ; + } //____________________________________________________________________________ @@ -678,7 +495,7 @@ void AliPHOSv0::CreateGeometryforCPV() par[2] = geom->GetCPVBoxSize(2) / 2.0 ; gMC->Gsvolu("PCPV", "BOX ", idtmed[798], par, 3) ; - Float_t * emcParams = geom->GetEMCAGeometry()->GetEMCParams() ; + const Float_t * emcParams = geom->GetEMCAGeometry()->GetEMCParams() ; z = - emcParams[3] ; Int_t rotm ; AliMatrix(rotm, 90.,0., 0., 0., 90., 90.) ; @@ -909,48 +726,58 @@ void AliPHOSv0::AddAlignableVolumes() const // Alignable modules // Volume path /ALIC_1/PHOS_ => symbolic name /PHOS/Module, =1,2,3,4,5 - + + AliGeomManager::ELayerID idPHOS1 = AliGeomManager::kPHOS1; + AliGeomManager::ELayerID idPHOS2 = AliGeomManager::kPHOS2; + Int_t modUID, modnum = 0; TString physModulePath="/ALIC_1/PHOS_"; TString symbModuleName="PHOS/Module"; Int_t nModules = GetGeometry()->GetNModules(); - Double_t rotMatrix[9] ; - + + char im[5] ; for(Int_t iModule=1; iModule<=nModules; iModule++){ + snprintf(im,5,"%d",iModule) ; + modUID = AliGeomManager::LayerToVolUID(idPHOS1,modnum++); + if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0 && strcmp(GetTitle(),"noCPV")!=0) + continue ; volpath = physModulePath; volpath += iModule; + // volpath += "/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1"; + + // Check the volume path if not all 5 modules exist + if (!gGeoManager->CheckPath(volpath.Data())) { + AliError(Form("Volume path %s not valid!",volpath.Data())); + continue; + } + symname = symbModuleName; symname += iModule; - gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()); + if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID)) + continue ; +// AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data())); + + // Creates the Tracking to Local transformation matrix for PHOS modules + TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ; - // Creates the Local to Tracking transformation matrix for PHOS modules - TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data()) ; - const char *path = alignableEntry->GetTitle(); - if (!gGeoManager->cd(path)) - AliFatal(Form("Volume path %s not valid!",path)); - TGeoHMatrix *matLtoT = new TGeoHMatrix; - matLtoT->SetDx(0.) ; - matLtoT->SetDy(0.) ; - matLtoT->SetDz(0.) ; - //Local to Tracking transformation matrix for PHOS modules: - //rotation aroung global Z to -pi/2. x->-y, y->x, z->z. - //From PPR-II_1 Chapter 5 p.18 (36 in pdf): - // - It is a right handed-Cartesian coordinate system; - // - its origin and the z axis coincide with those of the global - // ALICE coordinate system; - // - the x axis is perpendicular to the sub-detector's `sensitive - // plane' (TPC pad row, ITS ladder etc). - rotMatrix[0]= 0; rotMatrix[1]=-1; rotMatrix[2]= 0; - 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); - alignableEntry->SetMatrix(matLtoT); - } + Float_t angle = GetGeometry()->GetPHOSAngle(iModule); + TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig(); + + TGeoHMatrix *matTtoL = new TGeoHMatrix; + matTtoL->RotateZ(-90.+angle); + matTtoL->MultiplyLeft(&(globMatrix->Inverse())); + alignableEntry->SetMatrix(matTtoL); + } //Aligning of CPV should be done for volume PCPV_1 symbModuleName="PHOS/Module"; + modnum=0; for(Int_t iModule=1; iModule<=nModules; iModule++){ + if(strstr(GetTitle(),"noCPV")) + continue ; + snprintf(im,5,"%d",iModule) ; + modUID = AliGeomManager::LayerToVolUID(idPHOS2,modnum++); + if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0) + continue ; volpath = physModulePath; volpath += iModule; volpath += "/PCPV_1"; @@ -963,26 +790,20 @@ void AliPHOSv0::AddAlignableVolumes() const symname = symbModuleName; symname += iModule; symname += "/CPV"; - gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()); + if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID)) + AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data())); // Creates the TGeo Local to Tracking transformation matrix ... - TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data()) ; - const char *path = alignableEntry->GetTitle(); - if (!gGeoManager->cd(path)) - AliFatal(Form("Volume path %s not valid!",path)); - TGeoHMatrix *matLtoT = new TGeoHMatrix; - matLtoT->SetDx(0.) ; - matLtoT->SetDy(0.) ; - matLtoT->SetDz(0.) ; - rotMatrix[0]= 1; rotMatrix[1]= 0; rotMatrix[2]= 0; // - rotMatrix[3]= 0; rotMatrix[4]= 0; rotMatrix[5]= 1; // - rotMatrix[6]= 0; rotMatrix[7]= 1; rotMatrix[8]= 0; - TGeoRotation rot; - rot.SetMatrix(rotMatrix); - matLtoT->MultiplyLeft(&rot); - TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse()); - delete matLtoT; + TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID) ; + + Float_t angle = GetGeometry()->GetPHOSAngle(iModule); + TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig(); + + TGeoHMatrix *matTtoL = new TGeoHMatrix; + matTtoL->RotateZ(-90.+angle); + matTtoL->MultiplyLeft(&(globMatrix->Inverse())); alignableEntry->SetMatrix(matTtoL); + } @@ -1026,6 +847,19 @@ void AliPHOSv0::AddAlignableVolumes() const TString fullSymbStripName(100); for(Int_t module = 1; module <= nModules; ++module){ + + snprintf(im,5,"%d",module) ; + if(strstr(GetTitle(),im)==0 && strcmp(GetTitle(),"IHEP")!=0 && strcmp(GetTitle(),"noCPV")!=0) + continue ; + + volpath = physModulePath; + volpath += module; + // Check the volume path if not all 5 modules exist + if (!gGeoManager->CheckPath(volpath.Data())) { + AliError(Form("Volume path %s does not exist",volpath.Data())) ; + continue; + } + partialPhysStripName = physModulePath; partialPhysStripName += module; partialPhysStripName += "/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_"; @@ -1057,7 +891,7 @@ void AliPHOSv0::AddAlignableVolumes() const TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT.Inverse()); char phosPath[50] ; - sprintf(phosPath,"/ALIC_1/PHOS_%d",module) ; + snprintf(phosPath,50,"/ALIC_1/PHOS_%d",module) ; if (!gGeoManager->cd(phosPath)){ AliFatal("Geo manager can not find path \n"); }