]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONv1.cxx
New MUON data container AliMUONData implementation
[u/mrichter/AliRoot.git] / MUON / AliMUONv1.cxx
index a04ebd21728bec49effcac4c3af73fdf95e333ab..0729cb69f201fca700598dfe6393fd928c6b2743 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.38  2002/11/21 17:01:56  alibrary
-Removing AliMCProcess and AliMC
-
-Revision 1.37  2002/10/23 07:24:57  alibrary
-Introducing Riostream.h
-
-Revision 1.36  2002/10/14 14:57:29  hristov
-Merging the VirtualMC branch to the main development branch (HEAD)
-
-Revision 1.31.4.3  2002/10/11 06:56:48  hristov
-Updating VirtualMC to v3-09-02
-
-Revision 1.35  2002/09/02 15:51:48  morsch
-Gsbool calls added to resolve MANY. (I. Hrivnacova)
-
-Revision 1.31.4.2  2002/07/24 10:07:21  alibrary
-Updating VirtualMC
-
-Revision 1.33  2002/07/23 10:02:46  morsch
-All volume names start with "S".
-
-Revision 1.32  2002/05/02 12:51:10  morsch
-For G4: gMC->VolId(...) replaced by gAlice->GetModule(...).
-
-Revision 1.31  2002/03/13 07:55:04  jchudoba
-Correction of the errourness last commit.
-
-Revision 1.29  2001/06/21 14:54:37  morsch
-Put volumes of station 3 into DIPO if present. (A. de Falco)
-
-Revision 1.28  2001/05/16 14:57:17  alibrary
-New files for folders and Stack
-
-Revision 1.27  2001/04/06 11:24:43  morsch
-Dependency on implementations of AliSegmentation and AliMUONResponse moved to AliMUONFactory class.
-Static method Build() builds the MUON system out of chambers, segmentation and response.
-
-Revision 1.26  2001/03/17 10:07:20  morsch
-Correct inconsistent variable name / method name / comments.
-
-Revision 1.25  2001/03/16 15:32:06  morsch
-Corrections of overlap with beam shield and dipole (A. de Falco)
-
-Revision 1.24  2001/03/14 17:22:15  pcrochet
-Geometry of the trigger chambers : a vertical gap of has been introduced around x=0 according fig.3.27 of the TDR (P.Dupieux)
-
-Revision 1.23  2001/01/18 15:23:49  egangler
-Bug correction in StepManager :
-Now the systematic offset with angle is cured
-
-Revision 1.22  2001/01/17 21:01:21  hristov
-Unused variable removed
-
-Revision 1.21  2000/12/20 13:00:22  egangler
-
-Added charge correlation between cathods.
-In Config_slat.C, use
- MUON->Chamber(chamber-1).SetChargeCorrel(0.11); to set the RMS of
- q1/q2 to 11 % (number from Alberto)
- This is stored in AliMUONChamber fChargeCorrel member.
- At generation time, when a tracks enters the volume,
- AliMUONv1::StepManager calls
- AliMUONChamber::ChargeCorrelationInit() to set the current value of
- fCurrentCorrel which is then used at Disintegration level to scale
- appropriately the PadHit charges.
-
-Revision 1.20  2000/12/04 17:48:23  gosset
-Modifications for stations 1 et 2 mainly:
-* station 1 with 4 mm gas gap and smaller cathode segmentation...
-* stations 1 and 2 with "grey" frame crosses
-* mean noise at 1.5 ADC channel
-* Ar-CO2 gas (80%+20%)
-
-Revision 1.19  2000/12/02 17:15:46  morsch
-Correction of dead zones in inner regions of stations 3-5
-Correction of length of slats 3 and 9 of station 4.
-
-Revision 1.17  2000/11/24 12:57:10  morsch
-New version of geometry for stations 3-5 "Slats" (A. de Falco)
- - sensitive region at station 3 inner radius
- - improved volume tree structure
-
-Revision 1.16  2000/11/08 13:01:40  morsch
-Chamber half-planes of stations 3-5 at different z-positions.
-
-Revision 1.15  2000/11/06 11:39:02  morsch
-Bug in StepManager() corrected.
-
-Revision 1.14  2000/11/06 09:16:50  morsch
-Avoid overlap of slat volumes.
-
-Revision 1.13  2000/10/26 07:33:44  morsch
-Correct x-position of slats in station 5.
-
-Revision 1.12  2000/10/25 19:55:35  morsch
-Switches for each station individually for debug and lego.
-
-Revision 1.11  2000/10/22 16:44:01  morsch
-Update of slat geometry for stations 3,4,5 (A. deFalco)
-
-Revision 1.10  2000/10/12 16:07:04  gosset
-StepManager:
-* SigGenCond only called for tracking chambers,
-  hence no more division by 0,
-  and may use last ALIROOT/dummies.C with exception handling;
-* "10" replaced by "AliMUONConstants::NTrackingCh()".
-
-Revision 1.9  2000/10/06 15:37:22  morsch
-Problems with variable redefinition in for-loop solved.
-Variable names starting with u-case letters changed to l-case.
-
-Revision 1.8  2000/10/06 09:06:31  morsch
-Include Slat chambers (stations 3-5) into geometry (A. de Falco)
-
-Revision 1.7  2000/10/02 21:28:09  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.6  2000/10/02 17:20:45  egangler
-Cleaning of the code (continued ) :
--> coding conventions
--> void Streamers
--> some useless includes removed or replaced by "class" statement
-
-Revision 1.5  2000/06/28 15:16:35  morsch
-(1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
-to allow development of slat-muon chamber simulation and reconstruction code in the MUON
-framework. The changes should have no side effects (mostly dummy arguments).
-(2) Hit disintegration uses 3-dim hit coordinates to allow simulation
-of chambers with overlapping modules (MakePadHits, Disintegration).
-
-Revision 1.4  2000/06/26 14:02:38  morsch
-Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
-
-Revision 1.3  2000/06/22 14:10:05  morsch
-HP scope problems corrected (PH)
-
-Revision 1.2  2000/06/15 07:58:49  morsch
-Code from MUON-dev joined
-
-Revision 1.1.2.14  2000/06/14 14:37:25  morsch
-Initialization of TriggerCircuit added (PC)
-
-Revision 1.1.2.13  2000/06/09 21:55:47  morsch
-Most coding rule violations corrected.
-
-Revision 1.1.2.12  2000/05/05 11:34:29  morsch
-Log inside comments.
-
-Revision 1.1.2.11  2000/05/05 10:06:48  morsch
-Coding Rule violations regarding trigger section corrected (CP)
-Log messages included.
-*/
+/* $Id$ */
 
 /////////////////////////////////////////////////////////
 //  Manager and hits classes for set:MUON version 0    //
@@ -178,18 +25,19 @@ Log messages included.
 #include <TNode.h> 
 #include <TRandom.h> 
 #include <TTUBE.h>
+#include <TVirtualMC.h>
 
-#include "AliMUONv1.h"
-#include "AliRun.h"
-#include "AliMagF.h"
 #include "AliCallf77.h"
 #include "AliConst.h" 
 #include "AliMUONChamber.h"
+#include "AliMUONConstants.h"
+#include "AliMUONFactory.h"
 #include "AliMUONHit.h"
 #include "AliMUONPadHit.h"
-#include "AliMUONConstants.h"
 #include "AliMUONTriggerCircuit.h"
-#include "AliMUONFactory.h"
+#include "AliMUONv1.h"
+#include "AliMagF.h"
+#include "AliRun.h"
 
 ClassImp(AliMUONv1)
  
@@ -198,14 +46,26 @@ AliMUONv1::AliMUONv1() : AliMUON()
 {
 // Constructor
     fChambers = 0;
+    fStations = 0;
+    fStepManagerVersionOld = kFALSE;
+    fStepMaxInActiveGas = 0.6;
 }
+
  
 //___________________________________________
 AliMUONv1::AliMUONv1(const char *name, const char *title)
        : AliMUON(name,title)
 {
 // Constructor
-    AliMUONFactory::Build(this, title);
+    // By default include all stations
+    fStations = new Int_t[5];
+    for (Int_t i=0; i<5; i++) fStations[i] = 1;
+
+    AliMUONFactory factory;
+    factory.Build(this, title);
+
+    fStepManagerVersionOld = kFALSE;
+    fStepMaxInActiveGas = 0.6;
 }
 
 //___________________________________________
@@ -270,9 +130,8 @@ void AliMUONv1::CreateGeometry()
      
 
      AliMUONChamber *iChamber, *iChamber1, *iChamber2;
-     Int_t stations[5] = {1, 1, 1, 1, 1};
-     
-     if (stations[0]) {
+
+     if (fStations[0]) {
         
 //********************************************************************
 //                            Station 1                             **
@@ -431,7 +290,7 @@ void AliMUONv1::CreateGeometry()
 //                 idrotm[1101],"ONLY");
 //      }
      }
-     if (stations[1]) {
+     if (fStations[1]) {
         
 //********************************************************************
 //                            Station 2                             **
@@ -685,7 +544,7 @@ void AliMUONv1::CreateGeometry()
      Float_t xxmax = (bFrameLength - nulocLength)/2.; 
      Int_t index=0;
      
-     if (stations[2]) {
+     if (fStations[2]) {
         
 //********************************************************************
 //                            Station 3                             **
@@ -966,7 +825,7 @@ void AliMUONv1::CreateGeometry()
      }
      }
      
- if (stations[3]) {
+ if (fStations[3]) {
 
 //********************************************************************
 //                            Station 4                             **
@@ -1173,7 +1032,7 @@ void AliMUONv1::CreateGeometry()
 
  }
 
- if (stations[4]) {
+ if (fStations[4]) {
      
 
 //********************************************************************
@@ -2076,9 +1935,85 @@ void AliMUONv1::Init()
    //cp
 
 }
-
 //___________________________________________
 void AliMUONv1::StepManager()
+{
+  if (fStepManagerVersionOld) {
+    StepManagerOld();
+    return;
+  }
+  // Volume id
+  Int_t   copy, id;
+  Int_t   idvol;
+  Int_t   iChamber=0;
+  // Particule id, pos and mom vectors, 
+  // theta, phi angles with respect the normal of the chamber, 
+  // spatial step, delta_energy and time of flight
+  Int_t          ipart;
+  TLorentzVector pos, mom;
+  Float_t        theta, phi, tof;
+  Float_t        destep, step;
+  const  Float_t kBig = 1.e10;
+
+  // Only charged tracks
+  if( !(gMC->TrackCharge()) ) return; 
+
+  // Only gas gap inside chamber
+  // Tag chambers and record hits when track enters 
+  idvol=-1;
+  id=gMC->CurrentVolID(copy);
+  for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++) {
+    if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) {
+      iChamber = i;
+      idvol  = i-1;
+    }
+  }
+  if (idvol == -1) return;
+
+
+  // record hits when track enters ...
+  if( gMC->IsTrackEntering()) gMC->SetMaxStep(fStepMaxInActiveGas);  
+
+  if (gMC->TrackStep() > 0.) {
+    // Get current particle id (ipart), track position (pos)  and momentum (mom)
+    gMC->TrackPosition(pos);
+    gMC->TrackMomentum(mom);
+    ipart    = gMC->TrackPid();
+    theta    = mom.Theta()*kRaddeg;     // theta of track
+    phi      = mom.Phi()  *kRaddeg;     // phi of the track
+    tof      = gMC->TrackTime();        // Time of flight
+    //
+    // momentum loss and steplength in last step
+    destep = gMC->Edep();
+    step   = gMC->TrackStep();
+    //new hit
+
+    GetMUONData()->AddHit(fIshunt, gAlice->GetCurrentTrackNumber(), iChamber, ipart, 
+                         pos.X(), pos.Y(), pos.Z(), tof, mom.P(), 
+                         theta, phi, step, destep);
+  }
+  // Track left chamber ...
+  if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
+    gMC->SetMaxStep(kBig);
+  }
+    
+}
+
+Int_t  AliMUONv1::GetChamberId(Int_t volId) const
+{
+// Check if the volume with specified  volId is a sensitive volume (gas) 
+// of some chamber and returns the chamber number;
+// if not sensitive volume - return 0.
+// ---
+
+  for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
+    if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
+
+  return 0;
+}
+
+//___________________________________________
+void AliMUONv1::StepManagerOld()
 {
   Int_t          copy, id;
   static Int_t   idvol;
@@ -2102,16 +2037,12 @@ void AliMUONv1::StepManager()
   //
   // Only gas gap inside chamber
   // Tag chambers and record hits when track enters 
-  idvol=-1;
   id=gMC->CurrentVolID(copy);
-  
-    for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++) {
-      if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
-         vol[0] = i; 
-         idvol  = i-1;
-      }
-    }
-    if (idvol == -1) return;
+  vol[0] = GetChamberId(id);
+  idvol = vol[0] -1;
+
+  if (idvol == -1) return;
+
   //
   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
   gMC->TrackPosition(pos);
@@ -2145,7 +2076,7 @@ void AliMUONv1::StepManager()
       hits[3] = pos[2]+s*tz;            // Z-position for hit
       hits[4] = theta;                  // theta angle of incidence
       hits[5] = phi;                    // phi angle of incidence 
-      hits[8] = (Float_t) fNPadHits;    // first padhit
+      hits[8] = 0;//PadHits does not exist anymore  (Float_t) fNPadHits;    // first padhit
       hits[9] = -1;                     // last pad hit
       hits[10] = mom[3];                // hit momentum P
       hits[11] = mom[0];                // Px
@@ -2204,21 +2135,21 @@ void AliMUONv1::StepManager()
       }
       
 
-      if (eloss >0)  MakePadHits(x0,y0,z0,eloss,tof,idvol);
+      //      if (eloss >0)  MakePadHits(x0,y0,z0,eloss,tof,idvol);
       
          
       hits[6] = tlength;   // track length
       hits[7] = eloss2;    // de/dx energy loss
 
-      if (fNPadHits > (Int_t)hits[8]) {
-         hits[8] = hits[8]+1;
-         hits[9] = (Float_t) fNPadHits;
-      }
+      //      if (fNPadHits > (Int_t)hits[8]) {
+      //         hits[8] = hits[8]+1;
+      //         hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
+      //}
 //
 //    new hit 
       
       new(lhits[fNhits++]) 
-         AliMUONHit(fIshunt, gAlice->CurrentTrack(), vol,hits);
+         AliMUONHit(fIshunt, gAlice->GetCurrentTrackNumber(), vol,hits);
       eloss = 0; 
       //
       // Check additional signal generation conditions 
@@ -2238,8 +2169,8 @@ void AliMUONv1::StepManager()
 
       eloss    += destep;
 
-      if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
-       MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
+      // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
+      //       MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
       xhit     = pos[0];
       yhit     = pos[1]; 
       zhit     = pos[2];