]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDv0.cxx
Added method FillFromParticles()
[u/mrichter/AliRoot.git] / TRD / AliTRDv0.cxx
index 649a6ff8e3360967d6a8a62cd97c6dad8ffda2cb..9ff5e021263734b1633d5021afe63106be458d59 100644 (file)
 
 /*
 $Log$
+Revision 1.20  2002/02/13 16:58:37  cblume
+Bug fix reported by Jiri. Make atoi input zero terminated in StepManager()
+
+Revision 1.19  2002/02/11 14:25:27  cblume
+Geometry update, compressed hit structure
+
+Revision 1.18  2000/11/30 17:38:08  cblume
+Changes to get in line with new STEER and EVGEN
+
+Revision 1.17  2000/11/01 14:53:21  cblume
+Merge with TRD-develop
+
+Revision 1.14.2.3  2000/10/06 16:49:46  cblume
+Made Getters const
+
+Revision 1.14.2.2  2000/10/04 16:34:58  cblume
+Replace include files by forward declarations
+
+Revision 1.14.2.1  2000/09/18 13:48:18  cblume
+Adapt to new AliTRDhit
+
+Revision 1.16  2000/06/08 18:32:58  cblume
+Make code compliant to coding conventions
+
+Revision 1.15  2000/06/07 16:25:37  cblume
+Try to remove compiler warnings on Sun and HP
+
+Revision 1.14  2000/02/28 19:10:26  cblume
+Include the new TRD classes
+
+Revision 1.13.4.1  2000/02/28 18:01:53  cblume
+Change to new hit version and introduce geometry class
+
+Revision 1.13  1999/11/05 22:50:28  fca
+Do not use Atan, removed from ROOT too
+
+Revision 1.12  1999/11/02 16:35:56  fca
+New version of TRD introduced
+
+Revision 1.11  1999/11/01 20:41:51  fca
+Added protections against using the wrong version of FRAME
+
 Revision 1.10  1999/09/29 09:24:35  fca
 Introduction of the Copyright and cvs Log
 
@@ -22,29 +64,44 @@ Introduction of the Copyright and cvs Log
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
-//  Transition Radiation Detector version 0 -- coarse simulation             //
+//  Transition Radiation Detector version 0 -- fast simulator                //
 //                                                                           //
 //Begin_Html
 /*
-<img src="picts/AliTRDv0Class.gif">
+<img src="picts/AliTRDfullClass.gif">
 */
 //End_Html
 //                                                                           //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <stdlib.h>
+#include <stdlib.h> 
 
 #include <TMath.h>
 #include <TRandom.h>
-#include <TVector.h>
+#include <TVector.h> 
+#include <TLorentzVector.h>
 
-#include "AliTRDv0.h"
 #include "AliRun.h"
 #include "AliMC.h"
 #include "AliConst.h"
   
+#include "AliTRDv0.h"
+#include "AliTRDhit.h"
+#include "AliTRDgeometry.h"
+
 ClassImp(AliTRDv0)
+  
+//_____________________________________________________________________________
+AliTRDv0::AliTRDv0():AliTRD() 
+{
+  //
+  // AliTRDv0 default constructor
+  //
+
+  fHitsOn     = 0;
+
+}
 
 //_____________________________________________________________________________
 AliTRDv0::AliTRDv0(const char *name, const char *title) 
@@ -54,19 +111,19 @@ AliTRDv0::AliTRDv0(const char *name, const char *title)
   // Standard constructor for Transition Radiation Detector version 0
   //
 
-  fIdSens     = 0;
   fHitsOn     = 0;
 
-  fIdSpace1   = 0;
-  fIdSpace2   = 0;
-  fIdSpace3   = 0;
+}
 
-  fIdChamber1 = 0;
-  fIdChamber2 = 0;
-  fIdChamber3 = 0;
+//_____________________________________________________________________________
+AliTRDv0::~AliTRDv0()
+{
+  //
+  // AliTRDv0 destructor
+  //
 
 }
+
 //_____________________________________________________________________________
 void AliTRDv0::CreateGeometry()
 {
@@ -74,26 +131,14 @@ void AliTRDv0::CreateGeometry()
   // Create the GEANT geometry for the Transition Radiation Detector - Version 0
   // This version covers the full azimuth. 
   //
-  // Author:  Christoph Blume (C.Blume@gsi.de) 20/07/99 
-  //
-
-  Float_t xpos, ypos, zpos;
 
   // Check that FRAME is there otherwise we have no place where to put the TRD
-  AliModule* FRAME = gAlice->GetModule("FRAME");
-  if (!FRAME) return;
+  AliModule* frame = gAlice->GetModule("FRAME");
+  if (!frame) return;
 
   // Define the chambers
   AliTRD::CreateGeometry();
 
-  // Position the the TRD-sectors in all TRD-volumes in the spaceframe
-  xpos     = 0.;
-  ypos     = 0.;
-  zpos     = 0.;
-  gMC->Gspos("TRD ",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
-  gMC->Gspos("TRD ",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
-  gMC->Gspos("TRD ",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
-
 }
 
 //_____________________________________________________________________________
@@ -111,49 +156,15 @@ void AliTRDv0::CreateMaterials()
 void AliTRDv0::Init() 
 {
   //
-  // Initialise Transition Radiation Detector after geometry is built
+  // Initialize Transition Radiation Detector after geometry is built
   //
 
   AliTRD::Init();
 
-  printf("**************************************"
-        "  TRD  "
-        "**************************************\n");
-  printf("\n     Version 0 of TRD initialing, "
-        "symmetric TRD\n\n");
-
-  //
-  // Check that FRAME is there otherwise we have no place where to
-  // put TRD
-  AliModule* FRAME=gAlice->GetModule("FRAME");
-  if(!FRAME) {
-    Error("Ctor","TRD needs FRAME to be present\n");
-    exit(1);
-  } else 
-    if(FRAME->IsVersion()!=1) {
-      Error("Ctor","FRAME version 1 needed with this version of TRD\n");
-      exit(1);
-    }
-
+  printf("          Fast simulator\n\n");
   for (Int_t i = 0; i < 80; i++) printf("*");
   printf("\n");
   
-  // Identifier of the sensitive volume (amplification region)
-  fIdSens     = gMC->VolId("UL06");
-
-  // Identifier of the TRD-spaceframe volumina
-  fIdSpace1   = gMC->VolId("B028");
-  fIdSpace2   = gMC->VolId("B029");
-  fIdSpace3   = gMC->VolId("B030");
-
-  // Identifier of the TRD-driftchambers
-  fIdChamber1 = gMC->VolId("UCIO");
-  fIdChamber2 = gMC->VolId("UCIM");
-  fIdChamber3 = gMC->VolId("UCII");
-
-  printf("**************************************"
-        "  TRD  "
-        "**************************************\n");
 }
 
 //_____________________________________________________________________________
@@ -165,64 +176,55 @@ void AliTRDv0::StepManager()
   // crosses the border between amplification region and pad plane.
   //
 
-  Int_t   vol[3]; 
-  Int_t   iIdSens, icSens; 
-  Int_t   iIdSpace, icSpace;
-  Int_t   iIdChamber, icChamber;
-
-  Int_t   secMap1[10] = {  3,  7,  8,  9, 10, 11,  2,  1, 18, 17 };
-  Int_t   secMap2[ 5] = { 16, 15, 14, 13, 12 };
-  Int_t   secMap3[ 3] = {  5,  6,  4 };
+  Int_t   pla = 0; 
+  Int_t   cha = 0;
+  Int_t   sec = 0; 
 
-  Float_t hits[4];
+  Float_t hits[3];
+  Int_t   det;
 
   TLorentzVector p;
-  TClonesArray  &lhits = *fHits;
+
+  // Use pad plane as sensitive volume
+  TString  cIdSens = "L";
+  TString  cIdCurrent;
+  Char_t   cIdChamber[3];
+           cIdChamber[2] = 0;
+
+  const Int_t kNplan = AliTRDgeometry::Nplan();
 
   // Writing out hits enabled?
   if (!(fHitsOn)) return;
 
   // Use only charged tracks and count them only once per volume
   if (gMC->TrackCharge()    && 
-      gMC->IsTrackExiting()) {
+      gMC->IsTrackEntering()) {
     
     // Check on sensitive volume
-    iIdSens = gMC->CurrentVolID(icSens);
-    if (iIdSens == fIdSens) { 
+    cIdCurrent = gMC->CurrentVolName();
+    if (cIdSens == cIdCurrent[1]) {
 
       gMC->TrackPosition(p);
       for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
-      // No charge created
-      hits[3] = 0;
-
-      iIdSpace   = gMC->CurrentVolOffID(4,icSpace  );
-      iIdChamber = gMC->CurrentVolOffID(1,icChamber);
-
-      // The sector number
-      if      (iIdSpace == fIdSpace1) 
-        vol[0] = secMap1[icSpace-1];
-      else if (iIdSpace == fIdSpace2) 
-        vol[0] = secMap2[icSpace-1];
-      else if (iIdSpace == fIdSpace3) 
-        vol[0] = secMap3[icSpace-1];
-
-      // The chamber number 
-      //   1: outer left
-      //   2: middle left
-      //   3: inner
-      //   4: middle right
-      //   5: outer right
-      if      (iIdChamber == fIdChamber1)
-        vol[1] = (hits[2] < 0 ? 1 : 5);
-      else if (iIdChamber == fIdChamber2)       
-        vol[1] = (hits[2] < 0 ? 2 : 4);
-      else if (iIdChamber == fIdChamber3)       
-        vol[1] = 3;
-
-      // The plane number
-      vol[2] = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6;
-
-      new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
+
+      // The sector number (0 - 17)
+      // The numbering goes clockwise and starts at y = 0
+      Float_t phi = kRaddeg*TMath::ATan2(hits[0],hits[1]);
+      if (phi < 90.) 
+        phi = phi + 270.;
+      else
+        phi = phi -  90.;
+      sec = ((Int_t) (phi / 20));
+
+      // The plane and chamber number
+      cIdChamber[0] = cIdCurrent[2];
+      cIdChamber[1] = cIdCurrent[3];
+      Int_t idChamber = atoi(cIdChamber);
+      cha = ((Int_t) idChamber / kNplan);
+      pla = ((Int_t) idChamber % kNplan);
+      det = fGeometry->GetDetector(pla,cha,sec);
+
+      AddHit(gAlice->CurrentTrack(),det,hits,0,kTRUE);       
 
     }