]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONChamber.cxx
From Laurent:
[u/mrichter/AliRoot.git] / MUON / AliMUONChamber.cxx
index d65ac80e013e557a69a7b11417806ef6e273d8bf..6b298994e3c46b2ceb6ca3a8d1330d86e7f50cda 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-/*
-$Log$
-Revision 1.10  2001/03/20 13:17:30  egangler
-fChargeCorrel moved from AliMUONChamber to AliMUONResponse as decided by
-January meeting.
-Setters and Getters are modified accordingly.
-This modification is transparent to the user code
-
-Revision 1.9  2001/01/26 21:35:54  morsch
-All pointers set to 0 in default constructor.
-
-Revision 1.8  2001/01/17 20:53:40  hristov
-Destructors corrected to avoid memory leaks
-
-Revision 1.7  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.6  2000/10/09 14:01:12  morsch
-Double inclusion of AliResponse removed.
-
-Revision 1.5  2000/07/03 11:54:57  morsch
-AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
-The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
-
-Revision 1.4  2000/06/29 12:34:09  morsch
-AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
-it usable with any other geometry class. The link to the object to which it belongs is
-established via an index. This assumes that there exists a global geometry manager
-from which the pointer to the parent object can be obtained (in our case gAlice).
-
-Revision 1.3  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.2  2000/06/15 07:58:48  morsch
-Code from MUON-dev joined
-
-Revision 1.1.2.5  2000/06/09 21:27:01  morsch
-Most coding rule violations corrected.
-
-Revision 1.1.2.4  2000/05/05 11:34:12  morsch
-Log inside comments.
-
-Revision 1.1.2.3  2000/05/05 10:09:52  morsch
-Log messages included
-*/
 
-// --- MUON includes ---
-#include "AliMUONChamber.h"
+/* $Id$ */
 
 // --- ROOT includes ---
+#include <TRandom.h>
+#include <TMath.h>
+#include "AliRun.h"
+
 
-#include "TRandom.h"
-#include "TMath.h"
+// --- MUON includes ---
+#include "AliMUON.h"
+#include "AliMUONChamber.h"
+#include "AliMUONGeometryModule.h"
+#include "AliMUONHit.h"
+#include "AliLog.h"
 
 ClassImp(AliMUONChamber)       
 
-    AliMUONChamber::AliMUONChamber()
+AliMUONChamber::AliMUONChamber()
+  : TObject(), 
+    fId(0),
+    fdGas(0.),
+    fdAlu(0.),
+    fZ(0.),
+    frMin(0.),
+    frMax(0.),
+    fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
+    fSegmentation2(0),
+    fResponse(0),
+    fGeometry(0),
+    fMUON(0)
 {
 // Default constructor
-    fSegmentation = 0;
-    fResponse=0;
-    fnsec=1;
-    fReconstruction=0;
-    fId=0;
-    // to avoid mistakes if ChargeCorrelInit is not called
-    fCurrentCorrel =1;
 }
 
-    AliMUONChamber::AliMUONChamber(Int_t id) 
+//_______________________________________________________
+AliMUONChamber::AliMUONChamber(Int_t id) 
+  : TObject(), 
+    fId(id),
+    fdGas(0.),
+    fdAlu(0.),
+    fZ(0.),
+    frMin(0.),
+    frMax(0.),
+    fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
+    fSegmentation2(0),
+    fResponse(0),
+    fGeometry(0),
+    fMUON(0)
+{
+
+    // muon
+    fMUON = (AliMUON*)gAlice->GetModule("MUON");
+    if (!fMUON) {
+      AliFatal("MUON detector not defined.");
+      return;
+    }  
+
+    // new segmentation
+    fSegmentation2 = new TObjArray(2);
+    fSegmentation2->AddAt(0,0);
+    fSegmentation2->AddAt(0,1);
+    fGeometry = new AliMUONGeometryModule(fId);
+
+}
+
+//_______________________________________________________
+AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
+  : TObject(rChamber)
 {
-// Construtor with chamber id 
-    fSegmentation = new TObjArray(2);
-    fSegmentation->AddAt(0,0);
-    fSegmentation->AddAt(0,1);
-    fResponse=0;
-    fnsec=1;
-    fReconstruction=0;
-    fId=id;
-    // to avoid mistakes if ChargeCorrelInit is not called
-    fCurrentCorrel =1;
+  // Protected copy constructor
+
+  AliFatal("Not implemented.");
+  // Dummy copy constructor
 }
 
+//_______________________________________________________
 AliMUONChamber::~AliMUONChamber() 
 {
-// Destructor
-  if (fSegmentation) {
-    fSegmentation->Delete();
-    delete fSegmentation;
+  // Destructor
+
+  if (fSegmentation2) {
+    fSegmentation2->Delete();
+    delete fSegmentation2;
   }
+  
+  delete fGeometry;
 }
 
-AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
+//_______________________________________________________
+AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
 {
-// Dummy copy constructor
-    ;
-}
+  // Protected assignement operator
 
+  if (this == &rhs) return *this;
 
-void AliMUONChamber::Init()
-{
-// Initalisation ..
-//
-// ... for chamber segmentation
-    if ((*fSegmentation)[0]) 
-    ((AliSegmentation *) (*fSegmentation)[0])->Init(fId);
-
-    if (fnsec==2) {
-       if ((*fSegmentation)[1])
-       ((AliSegmentation *) (*fSegmentation)[1])->Init(fId);
-    }
+  AliFatal("Not implemented.");
+    
+  return *this;  
 }
 
-Int_t   AliMUONChamber::SigGenCond(Float_t x, Float_t y, Float_t z)
+//_______________________________________________________
+Bool_t  AliMUONChamber::IsSensId(Int_t volId) const 
 {
-// Ask segmentation if signal should be generated 
-    if (fnsec==1) {
-       return ((AliSegmentation*) (*fSegmentation)[0])
-           ->SigGenCond(x, y, z) ;
-    } else {
-       return (((AliSegmentation*) (*fSegmentation)[0])
-               ->SigGenCond(x, y, z)) ||
-           (((AliSegmentation*) (*fSegmentation)[1])
-            ->SigGenCond(x, y, z)) ;
-    }
-}
+  // Returns true if the volume specified by volId is in the list
+  // of sesitive volumes for this chamber
 
+  return fGeometry->IsSensitiveVolume(volId);
+}  
 
-void    AliMUONChamber::SigGenInit(Float_t x, Float_t y, Float_t z)
-{
-//
-// Initialisation of segmentation for hit
-//  
-    if (fnsec==1) {
-       ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
-    } else {
-       ((AliSegmentation*) (*fSegmentation)[0])->SigGenInit(x, y, z) ;
-       ((AliSegmentation*) (*fSegmentation)[1])->SigGenInit(x, y, z) ;
-    }
-}
 
+//_____________________________________________________
 void AliMUONChamber::ChargeCorrelationInit() {
-// Initialisation of charge correlation for current hit
-// the value is stored, and then used by Disintegration
-if (fnsec==1) 
-    fCurrentCorrel =1;
-else 
-    // exponential is here to avoid eventual problems in 0 
-    // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
+  // Initialisation of charge correlation for current hit
+  // the value is stored, and then used by Disintegration
+
+  // exponential is here to avoid eventual problems in 0 
+  // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
 }
 
-void AliMUONChamber::DisIntegration(Float_t eloss, Float_t tof, 
-                                   Float_t xhit, Float_t yhit, Float_t zhit,
+//_______________________________________________________
+void AliMUONChamber::InitGeo(Float_t /*zpos*/)
+{
+  //    sensitive gas gap
+  fdGas= 0.5;
+  //    3% radiation length of aluminum (X0=8.9 cm)      
+  fdAlu= 3.0/100*8.9;
+}
+//_______________________________________________________
+//
+//                  NEW SEGMENTATION
+//_______________________________________________________
+void AliMUONChamber::Init(Int_t flag)
+{
+  // Initalisation ..
+  //
+  // ... for chamber segmentation
+
+  if (!flag)    AliFatal("wrong segmentation type.");
+
+  if (fSegmentation2->At(0)) 
+    ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->Init(fId);
+  if (fSegmentation2->At(1))
+    ((AliMUONGeometrySegmentation*) fSegmentation2->At(1))->Init(fId);
+}
+// //_________________________________________________________________
+// void    AliMUONChamber::SigGenInit(AliMUONHit *hit)
+// {
+//   //
+//   // Initialisation of segmentation for hit
+//   //  
+//   Float_t x = hit->X();
+//   Float_t y = hit->Y();
+//   Float_t z = hit->Z();
+//   Int_t  id = hit->DetElemId();
+
+//   ((AliMUONGeometrySegmentation*) fSegmentation2->At(0))->SigGenInit(id, x, y, z) ;
+//   ((AliMUONGeometrySegmentation*) fSegmentation2->At(1))->SigGenInit(id, x, y, z) ;
+
+// }
+
+//_______________________________________________________
+void AliMUONChamber::DisIntegration(AliMUONHit *hit, 
                                    Int_t& nnew,Float_t newclust[6][500]) 
 {
-//    
-//  Generates pad hits (simulated cluster) 
-//  using the segmentation and the response model 
-    Float_t dx, dy;
-    //
-    // Width of the integration area
-    //
-    dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
-    dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
-    //
-    // Get pulse height from energy loss
-    Float_t qtot = fResponse->IntPH(eloss);
-    //
-    // Loop Over Pads
+  //    
+  //  Generates pad hits (simulated cluster) 
+  //  using the segmentation and the response model 
+  Float_t dx, dy;
+
+  Float_t  xhit = hit->X();
+  Float_t  yhit = hit->Y();
+  Float_t  zhit = hit->Z();
+  Int_t      id = hit->DetElemId();
+  Float_t eloss = hit->Eloss();
+
+  //
+  // Width of the integration area
+  //
+  dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
+  dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
+  //
+  // Get pulse height from energy loss
+  Float_t qtot = fResponse->IntPH(eloss);
+  //
+  // Loop Over Pads
     
-    Float_t qcheck=0, qp;
-    nnew=0;
+  Float_t qp; 
+  nnew=0;
     
-    // Cathode plane loop
-    for (Int_t i=1; i<=fnsec; i++) {
-       qcheck=0;
-       Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
-       AliSegmentation * segmentation=
-           (AliSegmentation *) (*fSegmentation)[i-1];
-       for (segmentation->FirstPad(xhit, yhit, zhit, dx, dy); 
-            segmentation->MorePads(); 
-            segmentation->NextPad()) 
-       {
-           qp=fResponse->IntXY(segmentation);
-           qp=TMath::Abs(qp);
-//
-//
-           if (qp > 1.e-4) {
-               qcheck+=qp*qcath;
+  // Cathode plane loop
+  for (Int_t i = 1; i <= 2; i++) {
+    Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
+
+    AliMUONGeometrySegmentation* segmentation=
+      (AliMUONGeometrySegmentation*) fSegmentation2->At(i-1);
+
+    for (segmentation->FirstPad(id, xhit, yhit, zhit, dx, dy); 
+        segmentation->MorePads(id); 
+        segmentation->NextPad(id)) 
+      {
+       qp=fResponse->IntXY(id, segmentation);
+       qp=TMath::Abs(qp);
+       //
+       //
+       if (qp > 1.e-4) 
+         {
+           if (nnew >= 500) // Perform a bounds check on nnew since it is assumed
+             // newclust only contains 500 elements.
+             {
+               AliError("Limit of 500 pad responses reached.");
+               return;
+             };
            //
            // --- store signal information
-               newclust[0][nnew]=qcath;                     // total charge
-               newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
-               newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
-               newclust[3][nnew]=qp * qcath;                // charge on pad
-               newclust[4][nnew]=segmentation->ISector();  // sector id
-               newclust[5][nnew]=(Float_t) i;              // counter
-               nnew++;
-//             if (i==2) printf("\n i, nnew, q %d %d %f", i, nnew, qp*qcath);
+           newclust[0][nnew]=qcath;                     // total charge
+           newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
+           newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
+           newclust[3][nnew]=qp * qcath;                // charge on pad
+           newclust[4][nnew]=segmentation->ISector();  // sector id
+           newclust[5][nnew]=(Float_t) i;              // counter
+           nnew++;
                
-           }
-       } // Pad loop
-       
-    } // Cathode plane loop
-}
-
-
-
-void AliMUONChamber::InitGeo(Float_t zpos)
-{
-//    sensitive gas gap
-      fdGas= 0.5;
-//    3% radiation length of aluminum (X0=8.9 cm)      
-      fdAlu= 3.0/100*8.9;
-}
-
-
-AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
-{
-// Dummy assignment operator
-    return *this;
+         }
+      } // Pad loop
+  } // Cathode plane loop
 }