]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFv5T0.cxx
Corrected a bug in kalman tracking (final parameters and covariances
[u/mrichter/AliRoot.git] / TOF / AliTOFv5T0.cxx
index b759de27de000ca8c311fc6c6fd5e2084d89af64..45d5a7b4d73e7236185b715261978aa46d046ca1 100644 (file)
 
 /*
 $Log$
+Revision 1.22  2007/10/07 19:40:46  decaro
+right handling of l2t matrices and alignable entries in case of TOF staging geometry
+
+Revision 1.21  2007/10/04 13:15:30  arcelli
+updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry
+
+Revision 1.20  2007/10/03 18:07:22  arcelli
+right handling of l2t matrices and alignable entries in case of TOF holes (Annalisa)
+
+Revision 1.19  2007/10/03 10:41:12  arcelli
+adding tracking-to-local matrices for new AliTOFcluster
+
+Revision 1.18  2007/07/27 08:14:48  morsch
+Write all track references into the same branch.
+
+Revision 1.17  2007/05/14 14:41:13  decaro
+Fix a bug in FTOA volume positionig inside BTOF13,14,15,16,17 in case of holes in 11th and 12th sectors
+
+Revision 1.16  2007/05/04 12:59:26  arcelli
+Change the TOF SM paths for misalignment (one layer up)
+
+Revision 1.15  2007/02/19 15:41:55  decaro
+Coding convention: few corrections
+
+Revision 1.14  2006/10/17 15:33:14  arcelli
+Moving some printout from Info to Debug level
+
+Revision 1.13  2006/10/12 16:35:43  arcelli
+definition of the alignable volumes symbolic names added
+
+Revision 1.12  2006/08/22 13:34:46  arcelli
+removal of effective c++ warnings (C.Zampolli)
+
+Revision 1.11  2006/07/12 16:03:44  arcelli
+updates to match the new numbering of the TOF/TRD mother volumes in FRAME (ALICE convention)
+
+Revision 1.10  2006/05/10 18:40:17  hristov
+Larger strings for the names
+
+Revision 1.9  2006/05/04 19:41:42  hristov
+Possibility for partial TOF geometry (S.Arcelli)
+
+Revision 1.8  2006/04/20 22:30:50  hristov
+Coding conventions (Annalisa)
+
+Revision 1.7  2006/04/16 22:29:05  hristov
+Coding conventions (Annalisa)
+
 Revision 1.6  2006/03/20 08:20:35  decaro
 Al layer: positioning correction
 
@@ -64,31 +112,43 @@ Revision 0.1 2004 November G. Cara Romeo and A. De Caro
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "Riostream.h"
-#include <stdlib.h>
-
+#include "TBRIK.h"
+#include "TGeometry.h"
+#include "TLorentzVector.h"
+#include "TNode.h"
 #include "TVirtualMC.h"
-#include <TBRIK.h>
-#include <TGeometry.h>
-#include <TLorentzVector.h>
-#include <TNode.h>
-#include <TObject.h>
-#include <TVirtualMC.h>
+#include "TGeoManager.h"
+#include <TGeoMatrix.h>
+#include <TGeoPhysicalNode.h>
+#include <TGeoVolume.h>
 
-#include "AliLog.h"
 #include "AliConst.h"
-#include "AliRun.h"
-#include "AliMC.h"
+#include "AliLog.h"
 #include "AliMagF.h"
+#include "AliMC.h"
+#include "AliRun.h"
+#include "AliTrackReference.h"
 
 #include "AliTOFGeometry.h"
-#include "AliTOFGeometryV5.h"
 #include "AliTOFv5T0.h"
 
+extern TDirectory *gDirectory;
+extern TVirtualMC *gMC;
+extern TGeoManager *gGeoManager;
+
+extern AliRun *gAlice;
+
 ClassImp(AliTOFv5T0)
 
 //_____________________________________________________________________________
-AliTOFv5T0::AliTOFv5T0()
+  AliTOFv5T0::AliTOFv5T0():
+  fIdFTOA(-1),
+  fIdFTOB(-1),
+  fIdFTOC(-1),
+  fIdFLTA(-1),
+  fIdFLTB(-1),
+  fIdFLTC(-1),
+  fTOFHoles(kFALSE)
 {
   //
   // Default constructor
@@ -96,8 +156,15 @@ AliTOFv5T0::AliTOFv5T0()
 }
  
 //_____________________________________________________________________________
-AliTOFv5T0::AliTOFv5T0(const char *name, const char *title)
-        : AliTOF(name,title,"tzero")
+AliTOFv5T0::AliTOFv5T0(const char *name, const char *title):
+  AliTOF(name,title,"tzero"),
+  fIdFTOA(-1),
+  fIdFTOB(-1),
+  fIdFTOC(-1),
+  fIdFLTA(-1),
+  fIdFLTB(-1),
+  fIdFLTC(-1),
+  fTOFHoles(kFALSE)
 {
   //
   // Standard constructor
@@ -107,21 +174,21 @@ AliTOFv5T0::AliTOFv5T0(const char *name, const char *title)
   // put TOF
 
 
-  AliModule* frame=gAlice->GetModule("FRAME");
+  AliModule* frame = (AliModule*)gAlice->GetModule("FRAME");
   if(!frame) {
     AliFatal("TOF needs FRAME to be present");
   } else{
     
     if (fTOFGeometry) delete fTOFGeometry;
-    fTOFGeometry = new AliTOFGeometryV5();
+    fTOFGeometry = new AliTOFGeometry();
 
     if(frame->IsVersion()==1) {
-      AliInfo(Form("Frame version %d", frame->IsVersion())); 
-      AliInfo("Full Coverage for TOF");
+      AliDebug(1,Form("Frame version %d", frame->IsVersion())); 
+      AliDebug(1,"Full Coverage for TOF");
       fTOFHoles=false;}    
     else {
-      AliInfo(Form("Frame version %d", frame->IsVersion())); 
-      AliInfo("TOF with Holes for PHOS");
+      AliDebug(1,Form("Frame version %d", frame->IsVersion())); 
+      AliDebug(1,"TOF with Holes for PHOS");
       fTOFHoles=true;}      
   }
   fTOFGeometry->SetHoles(fTOFHoles);
@@ -136,6 +203,134 @@ AliTOFv5T0::AliTOFv5T0(const char *name, const char *title)
 
 } 
 
+//_____________________________________________________________________________
+void AliTOFv5T0::AddAlignableVolumes() const
+{
+  //
+  // Create entries for alignable volumes associating the symbolic volume
+  // name with the corresponding volume path. Needs to be syncronized with
+  // eventual changes in the geometry.
+  //
+
+  TString volPath;
+  TString symName;
+
+  TString vpL0  = "ALIC_1/B077_1/BSEGMO";
+  TString vpL1 = "_1/BTOF";
+  TString vpL2 = "_1";
+  TString vpL3 = "/FTOA_0";
+  TString vpL4 = "/FLTA_0/FSTR_";
+
+  TString snSM  = "TOF/sm";
+  TString snSTRIP = "/strip";
+
+  Int_t nSectors=fTOFGeometry->NSectors();
+  Int_t nStrips =fTOFGeometry->NStripA()+
+                 2*fTOFGeometry->NStripB()+
+                 2*fTOFGeometry->NStripC();
+
+  //
+  // The TOF MRPC Strips
+  // The symbolic names are: TOF/sm00/strip01
+  //                           ...
+  //                         TOF/sm17/strip91
+  Int_t imod=0;
+
+  for (Int_t isect = 0; isect < nSectors; isect++) {
+    for (Int_t istr = 1; istr <= nStrips; istr++) {
+
+      //if (fTOFSectors[isect]==-1) continue;
+
+      if (fTOFHoles && (isect==13 || isect==14 || isect==15)) {
+       if (istr<39) {
+         vpL3 = "/FTOB_0";
+         vpL4 = "/FLTB_0/FSTR_";
+       }
+       else if (istr>53) {
+         vpL3 = "/FTOC_0";
+         vpL4 = "/FLTC_0/FSTR_";
+       }
+       else continue;
+      }
+      else {
+       vpL3 = "/FTOA_0";
+       vpL4 = "/FLTA_0/FSTR_";
+      }
+
+      volPath  = vpL0;
+      volPath += isect;
+      volPath += vpL1;
+      volPath += isect;
+      volPath += vpL2;
+      volPath += vpL3;
+      volPath += vpL4;
+      volPath += istr;
+
+      
+      symName  = snSM;
+      symName += Form("%02d",isect);
+      symName += snSTRIP;
+      symName += Form("%02d",istr);
+            
+      AliDebug(2,"--------------------------------------------"); 
+      AliDebug(2,Form("Alignable object %d", imod)); 
+      AliDebug(2,Form("volPath=%s\n",volPath.Data()));
+      AliDebug(2,Form("symName=%s\n",symName.Data()));
+      AliDebug(2,"--------------------------------------------"); 
+             
+      gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
+
+      //T2L matrices for alignment
+      TGeoPNEntry *e = gGeoManager->GetAlignableEntry(symName.Data());
+      if (e) {
+       const char *path = e->GetTitle();
+       if (!gGeoManager->cd(path)) {
+         AliFatal(Form("Volume path %s not valid!",path));
+       }
+       TGeoHMatrix *globMatrix = gGeoManager->GetCurrentMatrix();
+       Double_t phi = 20.0 * (isect % 18) + 10.0;
+       TGeoHMatrix *t2l  = new TGeoHMatrix();
+       t2l->RotateZ(phi);
+       t2l->MultiplyLeft(&(globMatrix->Inverse()));
+       e->SetMatrix(t2l);
+      }
+      else {
+       AliError(Form("Alignable entry %s is not valid!",symName.Data()));
+      }
+      imod++;
+    }
+  }
+
+
+  //
+  // The TOF supermodules
+  // The symbolic names are: TOF/sm00
+  //                           ...
+  //                         TOF/sm17
+  //
+  for (Int_t isect = 0; isect < nSectors; isect++) {
+
+    volPath  = vpL0;
+    volPath += isect;
+    volPath += vpL1;
+    volPath += isect;
+    volPath += vpL2;
+
+    symName  = snSM;
+    symName += Form("%02d",isect);
+
+      AliDebug(2,"--------------------------------------------"); 
+      AliDebug(2,Form("Alignable object %d", isect+imod)); 
+      AliDebug(2,Form("volPath=%s\n",volPath.Data()));
+      AliDebug(2,Form("symName=%s\n",symName.Data()));
+      AliDebug(2,"--------------------------------------------"); 
+             
+    gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
+
+  }
+  
+}
 //____________________________________________________________________________
 void AliTOFv5T0::BuildGeometry()
 {
@@ -145,8 +340,10 @@ void AliTOFv5T0::BuildGeometry()
   TNode *node, *top;
   const int kColorTOF  = 27;
   
+  TGeometry *globalGeometry = (TGeometry*)gAlice->GetGeometry();
+
   // Find top TNODE
-  top = gAlice->GetGeometry()->GetNode("alice");
+  top = globalGeometry->GetNode("alice");
   
   // Position the different copies
   const Float_t krTof  =(fTOFGeometry->Rmax()+fTOFGeometry->Rmin())/2.;
@@ -164,8 +361,8 @@ void AliTOFv5T0::BuildGeometry()
   Float_t zOffsetA = 0.;
   // Define TOF basic volume
   
-  char nodeName0[7], nodeName1[7], nodeName2[7];
-  char nodeName3[7], nodeName4[7], rotMatNum[7];
+  char nodeName0[16], nodeName1[16], nodeName2[16];
+  char nodeName3[16], nodeName4[16], rotMatNum[16];
 
   if (fTOFHoles) {
     new TBRIK("S_TOF_B","TOF box","void",
@@ -295,20 +492,28 @@ void AliTOFv5T0::TOFpc(Float_t xtof,  Float_t ytof, Float_t zlenA,
   xcoor = 0.;
   ycoor = 0.;
   zcoor = 0.;
-  gMC->Gspos("FTOA", 0, "BTO1", xcoor, ycoor, zcoor, idrotm[0], "ONLY");
-  gMC->Gspos("FTOA", 0, "BTO3", xcoor, ycoor, zcoor, idrotm[0], "ONLY");
+  for(Int_t isec=0;isec<18;isec++){
+    if(fTOFSectors[isec]==-1)continue;
+    char name[16];
+    sprintf(name, "BTOF%d",isec);
+    if (fTOFHoles && (isec==13 || isec==14 || isec==15)) {
+    //    if (fTOFHoles && (isec==16||isec==17)) { \\Old 6h convention
+      xcoor = 0.;
+      ycoor = (zlenA*0.5 + kInterCentrModBorder1)*0.5;
+      zcoor = 0.;
+      gMC->Gspos("FTOB", 0, name, xcoor, ycoor, zcoor, idrotm[0], "ONLY");
+      gMC->Gspos("FTOC", 0, name, xcoor,-ycoor, zcoor, idrotm[0], "ONLY");
+    }
+    else {
+      xcoor = 0.;
+      ycoor = 0.;
+      zcoor = 0.;
+      gMC->Gspos("FTOA", 0,name, xcoor, ycoor, zcoor, idrotm[0], "ONLY");
+    }
 
-  if (fTOFHoles) {
-    xcoor = 0.;
-    ycoor = (zlenA*0.5 + kInterCentrModBorder1)*0.5;
-    zcoor = 0.;
-    gMC->Gspos("FTOB", 0, "BTO2", xcoor, ycoor, zcoor, idrotm[0], "ONLY");
-    gMC->Gspos("FTOC", 0, "BTO2", xcoor,-ycoor, zcoor, idrotm[0], "ONLY");
   }
-  else gMC->Gspos("FTOA", 0, "BTO2", xcoor, ycoor, zcoor, idrotm[0], "ONLY");
-
   // Large not sensitive volumes with Insensitive Freon (FLTA, FLTB and FLTC)
-
+  
   Float_t xFLT, yFLT, zFLTA;
   
   xFLT  = xtof  - kModuleWallThickness*2.;
@@ -1183,12 +1388,14 @@ void AliTOFv5T0::CreateMaterials()
 
   //AliTOF::CreateMaterials();
 
-  Int_t   isxfld = gAlice->Field()->Integ();
-  Float_t sxmgmx = gAlice->Field()->Max();
+  AliMagF *magneticField = (AliMagF*)gAlice->Field();
+
+  Int_t   isxfld = magneticField->Integ();
+  Float_t sxmgmx = magneticField->Max();
+
   Float_t we[7], ae[7], na[7], fr[7], vl[7];
   Int_t i;
 
-  //
   //--- Quartz (SiO2) to simulate float glass
   //    density tuned to have correct float glass 
   //    radiation length
@@ -1367,9 +1574,6 @@ void AliTOFv5T0::StepManager()
   Int_t   *idtmed = fIdtmed->GetArray()-499;
   Float_t incidenceAngle;
 
-  const char * path71 = "B071";
-  const char * path75 = "B075";
-  const char * path74 = "B074";
   const char* volpath;
 
   Int_t index = 0;
@@ -1383,7 +1587,10 @@ void AliTOFv5T0::StepManager()
      )
   {
 
-    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+    AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+
+    AddTrackReference(mcApplication->GetCurrentTrackNumber(), AliTrackReference::kTOF);
+    //AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
 
     // getting information about hit volumes
     
@@ -1449,16 +1656,19 @@ void AliTOFv5T0::StepManager()
       strip = strip - fTOFGeometry->NStripC() - fTOFGeometry->NStripB() - fTOFGeometry->NStripA() - fTOFGeometry->NStripB();
     }
 
-    volpath=gMC->CurrentVolOffName(8);
-    index=gMC->CurrentVolOffID(8,copy);
-    index=copy;
-
+    volpath=gMC->CurrentVolOffName(7);
+    index=atoi(&volpath[4]);
     sector=-1;
-    if(strcmp(path71,volpath)==0 && index <6) sector=12+index;
-    if(strcmp(path71,volpath)==0 && index >=6) sector=index-3;
-    if(strcmp(path75,volpath)==0) sector=index-1;
-    if(strcmp(path74,volpath)==0) sector=10+index;
-
+    sector=index;
+
+    //Old 6h convention
+    // if(index<5){
+    //   sector=index+13;
+    // }
+    // else{
+    //   sector=index-5;
+    // } 
     for(i=0;i<3;++i) {
       hits[i]   = pos[i];
       hits[i+3] = pm[i];
@@ -1479,7 +1689,8 @@ void AliTOFv5T0::StepManager()
     vol[3]= padx;
     vol[4]= padz;    
 
-    AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
+    AddT0Hit(mcApplication->GetCurrentTrackNumber(),vol, hits);
+    //AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }
 //-------------------------------------------------------------------