]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
New TGeo features allow us to avoid the use of MANY.
[u/mrichter/AliRoot.git] / MUON / AliMUONChamber.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 // --- ROOT includes ---
19 #include <TRandom.h>
20 #include <TMath.h>
21 #include "AliRun.h"
22
23
24 // --- MUON includes ---
25 #include "AliMUON.h"
26 #include "AliMUONChamber.h"
27 #include "AliMUONSegmentation.h"
28 #include "AliMUONHit.h"
29 #include "AliLog.h"
30
31 ClassImp(AliMUONChamber)        
32
33 AliMUONChamber::AliMUONChamber()
34   : TObject(), 
35     fId(0),
36     fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
37     fResponse(0),
38     fMUON(0)
39 {
40 // Default constructor
41
42   AliDebug(1, Form("default (empty) ctor this = %p", this));
43 }
44
45 //_______________________________________________________
46 AliMUONChamber::AliMUONChamber(Int_t id) 
47   : TObject(), 
48     fId(id),
49     fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
50     fResponse(0),
51     fMUON(0)
52 {
53
54     // muon
55     fMUON = (AliMUON*)gAlice->GetModule("MUON");
56     if (!fMUON) {
57       AliFatal("MUON detector not defined.");
58       return;
59     }  
60
61   AliDebug(1, Form("ctor this = %p", this) ); 
62 }
63
64 //_______________________________________________________
65 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
66   : TObject(rChamber)
67 {
68   // Protected copy constructor
69
70   AliFatal("Not implemented.");
71   // Dummy copy constructor
72 }
73
74 //_______________________________________________________
75 AliMUONChamber::~AliMUONChamber() 
76 {
77   // Destructor
78
79   AliDebug(1, Form("dtor this = %p", this));
80 }
81
82 //_______________________________________________________
83 AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
84 {
85   // Protected assignement operator
86
87   if (this == &rhs) return *this;
88
89   AliFatal("Not implemented.");
90     
91   return *this;  
92 }
93
94 //_____________________________________________________
95 void AliMUONChamber::ChargeCorrelationInit() {
96   // Initialisation of charge correlation for current hit
97   // the value is stored, and then used by Disintegration
98
99   // exponential is here to avoid eventual problems in 0 
100   // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
101     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
102 }
103
104 //_______________________________________________________
105 void AliMUONChamber::DisIntegration(AliMUONHit *hit, 
106                                     Int_t& nnew,Float_t newclust[6][500]) 
107 {
108   //    
109   //  Generates pad hits (simulated cluster) 
110   //  using the segmentation and the response model 
111   Float_t dx, dy;
112
113   Float_t  xhit = hit->X();
114   Float_t  yhit = hit->Y();
115   Float_t  zhit = hit->Z();
116   Int_t      id = hit->DetElemId();
117   Float_t eloss = hit->Eloss();
118
119   //
120   // Width of the integration area
121   //
122   dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
123   dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
124   //
125   // Get pulse height from energy loss
126   Float_t qtot = fResponse->IntPH(eloss);
127   //
128   // Loop Over Pads
129     
130   Float_t qp; 
131   nnew=0;
132     
133   // Cathode plane loop
134   for (Int_t i = 1; i <= 2; i++) {
135     Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
136     
137     AliMUONGeometrySegmentation* segmentation=
138       fMUON->GetSegmentation()->GetModuleSegmentation(fId, i-1); 
139
140     for (segmentation->FirstPad(id, xhit, yhit, zhit, dx, dy); 
141          segmentation->MorePads(id); 
142          segmentation->NextPad(id)) 
143       {
144         qp=fResponse->IntXY(id, segmentation);
145         qp=TMath::Abs(qp);
146         //
147         //
148         if (qp > 1.e-4) 
149           {
150             if (nnew >= 500) // Perform a bounds check on nnew since it is assumed
151               // newclust only contains 500 elements.
152               {
153                 AliError("Limit of 500 pad responses reached.");
154                 return;
155               };
156             //
157             // --- store signal information
158             newclust[0][nnew]=qcath;                     // total charge
159             newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
160             newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
161             newclust[3][nnew]=qp * qcath;                // charge on pad
162             newclust[4][nnew]=segmentation->ISector();  // sector id
163             newclust[5][nnew]=(Float_t) i;              // counter
164             nnew++;
165                 
166           }
167       } // Pad loop
168   } // Cathode plane loop
169 }