]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFv1.cxx
MC-dependent part of AliRun extracted in AliMC (F.Carminati)
[u/mrichter/AliRoot.git] / TOF / AliTOFv1.cxx
index 895fe2d8f1f5b5af7ce5795ff55e45ec1323d6c7..8e0b8ee64b7a807f991deee904fe7890e6666193 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.29  2002/06/24 14:09:12  vicinanz
-review on materials and
-
-Revision 1.28  2002/05/08 13:24:50  vicinanz
-AliTOFanalyzeMatching.C macro added and minor changes to the AliTOF code
-
-Revision 1.27  2001/11/22 11:22:51  hristov
-Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
-
-
-Revision 1.26  2001/11/13 14:36:40  vicinanz
-Updated check for ppad[1] range
-
-Revision 1.24  2001/09/27 10:39:20  vicinanz
-SDigitizer and Merger added
-
-Revision 1.23  2001/09/20 15:54:22  vicinanz
-Updated Strip Structure (Double Stack)
-
-Revision 1.22  2001/08/28 08:45:59  vicinanz
-TTask and TFolder structures implemented
-
-Revision 1.21  2001/05/16 14:57:24  alibrary
-New files for folders and Stack
-Revision 1.20  2001/05/04 10:09:48  vicinanz
-Major upgrades to the strip structure
-
-Revision 1.19  2000/12/04 08:48:20  alibrary
-Fixing problems in the HEAD
-
-Revision 1.18  2000/10/02 21:28:17  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.17  2000/06/06 07:52:09  vicinanz
-NodeName array dimension enlarged
-
-Revision 1.16  2000/05/10 16:52:18  vicinanz
-New TOF version with holes for PHOS/RICH
-
-Revision 1.14.2.1  2000/05/10 09:37:16  vicinanz
-New version with Holes for PHOS/RICH
-
-Revision 1.14  1999/11/05 22:39:06  fca
-New hits structure
-
-Revision 1.13  1999/11/02 11:26:39  fca
-added stdlib.h for exit
-
-Revision 1.12  1999/11/01 20:41:57  fca
-Added protections against using the wrong version of FRAME
-
-Revision 1.11  1999/10/22 08:04:14  fca
-Correct improper use of negative parameters
-
-Revision 1.10  1999/10/16 19:30:06  fca
-Corrected Rotation Matrix and CVS log
-
-Revision 1.9  1999/10/15 15:35:20  fca
-New version for frame1099 with and without holes
-
-Revision 1.8  1999/09/29 09:24:33  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
-//
+//                                                                           //
 //  This class contains the functions for version 1 of the Time Of Flight    //
 //  detector.                                                                //
-//
-//  VERSION WITH 5 MODULES AND TILTED STRIPS 
-//
-//  HOLES FOR PHOS DETECTOR
-//
-//   Authors:
-//
-//   Alessio Seganti
-//   Domenico Vicinanza
-//
-//   University of Salerno - Italy
-//
-//   Fabrizio Pierella
-//   University of Bologna - Italy
-//
-//
-//Begin_Html
-/*
-<img src="picts/AliTOFv1Class.gif">
-*/
-//End_Html
+//                                                                           //
+//  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
+//                                                                           //
+//  HOLES FOR PHOS DETECTOR                                                  //
+//                                                                           //
+//   Authors:                                                                //
+//                                                                           //
+//   Alessio Seganti                                                         //
+//   Domenico Vicinanza                                                      //
+//                                                                           //
+//   University of Salerno - Italy                                           //
+//                                                                           //
+//   Fabrizio Pierella                                                       //
+//   University of Bologna - Italy                                           //
+//                                                                           //
+//                                                                           //
+//Begin_Html                                                                 //
+/*                                                                           //
+<img src="picts/AliTOFv1Class.gif">                                          //
+*/                                                                           //
+//End_Html                                                                   //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <iostream.h>
+#include <Riostream.h>
 #include <stdlib.h>
 
-#include "AliTOFv1.h"
-#include "TBRIK.h"
-#include "TGeometry.h"
-#include "TNode.h"
-#include "TObject.h"
+#include <TBRIK.h>
+#include <TGeometry.h>
 #include <TLorentzVector.h>
+#include <TNode.h>
+#include <TObject.h>
+#include <TVirtualMC.h>
+
+#include "AliConst.h"
+#include "AliMagF.h"
 #include "AliRun.h"
+#include "AliTOFv1.h"
+#include "AliTOFConstants.h" // AdC
 #include "AliMC.h"
-#include "AliMagF.h"
-#include "AliConst.h"
-
  
 ClassImp(AliTOFv1)
  
@@ -513,21 +449,25 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
   Float_t gap  = fGapA+0.5; //cm  updated distance between the strip axis
   Float_t zpos = 0;
   Float_t ang  = 0;
-  Int_t i=1,j=1;
+  Int_t j=1; // AdC
   nrot  = 0;
   zcoor = 0;
   ycoor = -14.5 + kspace ; //2 cm over front plate
   
   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);   
-  gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
-  
-  printf("%f,  St. %2i, Pl.3 ",ang*kRaddeg,i); 
-  printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
-  
+
+  Int_t centerLoc= (Int_t)(fNStripA/2.) + 1; // AdC
+
+  //gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
+  gMC->Gspos("FSTR",centerLoc,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY"); // AdC
+  if(fDebug>=1) {
+    printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
+    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+  }
   zcoor -= zSenStrip;
-  j++;
+  //j++; // AdC
   Int_t upDown = -1; // upDown=-1 -> Upper strip
-  // upDown=+1 -> Lower strip
+                     // upDown=+1 -> Lower strip
   do{
     ang = atan(zcoor/radius);
     ang *= kRaddeg;
@@ -536,13 +476,15 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
     ang /= kRaddeg;
     ycoor = -14.5+ kspace; //2 cm over front plate
     ycoor += (1-(upDown+1)/2)*gap;
-    gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
-    gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
-    
-    printf("%f,  St. %2i, Pl.3 ",ang*kRaddeg,i); 
-    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
-    
-    j += 2;
+    //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
+    //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
+    gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
+    gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
+    if(fDebug>=1) {
+      printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
+      printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+    }
+    j++; //j += 2; // AdC
     upDown*= -1; // Alternate strips 
     zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
       upDown*gap*TMath::Tan(ang)-
@@ -566,18 +508,20 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
   
   ycoor = -14.5+ kspace; //2 cm over front plate
   ycoor += (1-(upDown+1)/2)*gap;
-  gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
-  gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
-  
-  printf("%f,  St. %2i, Pl.3 ",ang*kRaddeg,i); 
-  printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
-  
+  //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
+  //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
+  gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
+  gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
+  if(fDebug>=1) {
+    printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
+    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+  }
   ycoor = -hTof/2.+ kspace;//2 cm over front plate
   
   // Plate  B
   
   nrot = 0;
-  i=1;
+  Int_t i=1; // AdC
   upDown = 1;
   Float_t deadRegion = 1.0;//cm
   
@@ -594,10 +538,10 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
   ycoor += (1-(upDown+1)/2)*gap;
   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
-  
-  printf("%f,  St. %2i, Pl.4 ",ang*kRaddeg,i); 
-  printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
-  
+  if(fDebug>=1) {
+    printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
+    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+  }
   i++;
   upDown*=-1;
   
@@ -615,10 +559,10 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
     ycoor += (1-(upDown+1)/2)*(gap+deltaGapinB);
     zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
     gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
-    
-    printf("%f,  St. %2i, Pl.4 ",ang*kRaddeg,i); 
-    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
-    
+    if(fDebug>=1) {
+      printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
+      printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+    }
     upDown*=-1;
     i++;
   } while (TMath::Abs(ang*kRaddeg)<22.5);
@@ -639,8 +583,10 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
     gMC->Gspos("FSTR",i, "FLTB", 0., ycoor+deltaMovingDown+deltaMovingUp, zcoor,idrotm[nrot], "ONLY");
     deltaMovingUp+=0.8; // update delta moving toward the end of the plate
     zpos = zpos - zSenStrip/TMath::Cos(ang);
-    printf("%f,  St. %2i, Pl.4 ",ang*kRaddeg,i); 
-    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+    if(fDebug>=1) {
+      printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
+      printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+    }
     i++;
     
   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
@@ -666,10 +612,10 @@ void AliTOFv1::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
     ang /= kRaddeg;
     zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
     gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
-    
-    printf("%f,  St. %2i, Pl.5 ",ang*kRaddeg,i); 
-    printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
-    
+    if(fDebug>=1) {
+      printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i); 
+      printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
+    }
     zpos = zpos - zSenStrip/TMath::Cos(ang);
   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
 
@@ -883,10 +829,8 @@ void AliTOFv1::DrawDetectorModules()
 // Draw a shaded view of the TOF detector version 1
 //
  
- AliMC* pMC = AliMC::GetMC();
 //Set ALIC mother transparent
pMC->Gsatt("ALIC","SEEN",0);
gMC->Gsatt("ALIC","SEEN",0);
 
 //
 //Set volumes visible
@@ -956,10 +900,8 @@ void AliTOFv1::DrawDetectorStrips()
 // Draw a shaded view of the TOF strips for version 1
 //
  
- AliMC* pMC = AliMC::GetMC();
 //Set ALIC mother transparent
pMC->Gsatt("ALIC","SEEN",0);
gMC->Gsatt("ALIC","SEEN",0);
 
 //
 //Set volumes visible 
@@ -1156,19 +1098,30 @@ void AliTOFv1::StepManager()
 
     z = pos[2];
 
-    plate = 0;   
-    if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 3;
+    plate = 0;
+    if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 2; //3; // AdC
     if (z < (fZlenA*0.5+fZlenB) && 
-        z >  fZlenA*0.5)               plate = 4;
+        z >  fZlenA*0.5)               plate = 1; //4; // AdC
     if (z >-(fZlenA*0.5+fZlenB) &&
-        z < -fZlenA*0.5)               plate = 2;
-    if (z > (fZlenA*0.5+fZlenB))       plate = 5;
-    if (z <-(fZlenA*0.5+fZlenB))       plate = 1;
+        z < -fZlenA*0.5)               plate = 3; //2; // AdC
+    if (z > (fZlenA*0.5+fZlenB))       plate = 0; //5; // AdC
+    if (z <-(fZlenA*0.5+fZlenB))       plate = 4; //1; // AdC
+
+    if (plate==0) strip=AliTOFConstants::fgkNStripC-strip; // AdC
+    else if (plate==1) strip=AliTOFConstants::fgkNStripB-strip; // AdC
+    else strip--; // AdC
+
+    if (z<=0.) padx=AliTOFConstants::fgkNpadX-padx; // AdC
+    else padx--; // AdC
+
+    if (plate==3 || plate==4) padz=AliTOFConstants::fgkNpadZ-padz; // AdC
+    else padz--; // AdC
 
     phi = pos.Phi();
-    phid = phi*kRaddeg+180.;
+    if (phi>=0.) phid = phi*kRaddeg; //+180.; // AdC
+    else phid = phi*kRaddeg + 360.; // AdC
     sector = Int_t (phid/20.);
-    sector++;
+    //sector++; // AdC
 
     for(i=0;i<3;++i) {
       hits[i]   = pos[i];
@@ -1189,7 +1142,7 @@ void AliTOFv1::StepManager()
     vol[3]= padx;
     vol[4]= padz;
     
-    AddHit(gAlice->CurrentTrack(),vol, hits);
+    AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
   }
 }