]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONChamber.cxx
Added test for existence of the vertex (fixes crash)
[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 // -----------------------
19 // Class AliMUONChamber
20 // -----------------------
21 // MUON tracking chamber class
22 // now only providing DisIntegration function
23
24 // --- ROOT includes ---
25 #include <TRandom.h>
26 #include <TMath.h>
27 #include "AliRun.h"
28
29
30 // --- MUON includes ---
31 #include "AliMUON.h"
32 #include "AliMUONChamber.h"
33 #include "AliMUONSegmentation.h"
34 #include "AliMUONHit.h"
35 #include "AliLog.h"
36
37 ClassImp(AliMUONChamber)        
38
39 AliMUONChamber::AliMUONChamber()
40   : TObject(), 
41     fId(0),
42     fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
43     fResponse(0),
44     fMUON(0)
45 {
46 /// Default constructor
47
48   AliDebug(1, Form("default (empty) ctor this = %p", this));
49 }
50
51 //_______________________________________________________
52 AliMUONChamber::AliMUONChamber(Int_t id) 
53   : TObject(), 
54     fId(id),
55     fCurrentCorrel(1), // to avoid mistakes if ChargeCorrelInit is not called
56     fResponse(0),
57     fMUON(0)
58 {
59 /// Standard constructor
60
61     // muon
62     fMUON = (AliMUON*)gAlice->GetModule("MUON");
63     if (!fMUON) {
64       AliFatal("MUON detector not defined.");
65       return;
66     }  
67
68   AliDebug(1, Form("ctor this = %p", this) ); 
69 }
70
71 //_______________________________________________________
72 AliMUONChamber::AliMUONChamber(const AliMUONChamber& rChamber)
73   : TObject(rChamber)
74 {
75 /// Protected copy constructor
76
77   AliFatal("Not implemented.");
78   // Dummy copy constructor
79 }
80
81 //_______________________________________________________
82 AliMUONChamber::~AliMUONChamber() 
83 {
84 /// Destructor
85
86   AliDebug(1, Form("dtor this = %p", this));
87 }
88
89 //_______________________________________________________
90 AliMUONChamber & AliMUONChamber::operator =(const AliMUONChamber& rhs)
91 {
92 /// Protected assignement operator
93
94   if (this == &rhs) return *this;
95
96   AliFatal("Not implemented.");
97     
98   return *this;  
99 }
100
101 //_____________________________________________________
102 void AliMUONChamber::ChargeCorrelationInit() 
103 {
104 /// Initialisation of charge correlation for current hit
105 /// the value is stored, and then used by Disintegration
106
107   // exponential is here to avoid eventual problems in 0 
108   // factor 2 because chargecorrel is q1/q2 and not q1/qtrue
109     fCurrentCorrel = TMath::Exp(gRandom->Gaus(0,fResponse->ChargeCorrel()/2));
110 }
111
112 //_______________________________________________________
113 void AliMUONChamber::DisIntegration(AliMUONHit *hit, 
114                                     Int_t& nnew,Float_t newclust[6][500]) 
115 {
116 ///  Generates pad hits (simulated cluster) 
117 ///  using the segmentation and the response model 
118
119   Float_t dx, dy;
120
121   Float_t  xhit = hit->X();
122   Float_t  yhit = hit->Y();
123   Float_t  zhit = hit->Z();
124   Int_t      id = hit->DetElemId();
125   Float_t eloss = hit->Eloss();
126
127   //
128   // Width of the integration area
129   //
130   dx=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
131   dy=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
132   //
133   // Get pulse height from energy loss
134   Float_t qtot = fResponse->IntPH(eloss);
135   //
136   // Loop Over Pads
137     
138   Float_t qp; 
139   nnew=0;
140     
141   // Cathode plane loop
142   for (Int_t i = 1; i <= 2; i++) {
143     Float_t qcath = qtot * (i==1? fCurrentCorrel : 1/fCurrentCorrel);
144     
145     AliMUONGeometrySegmentation* segmentation=
146       fMUON->GetSegmentation()->GetModuleSegmentation(fId, i-1); 
147
148     for (segmentation->FirstPad(id, xhit, yhit, zhit, dx, dy); 
149          segmentation->MorePads(id); 
150          segmentation->NextPad(id)) 
151       {
152         qp=fResponse->IntXY(id, segmentation);
153         qp=TMath::Abs(qp);
154         //
155         //
156         if (qp > 1.e-4) 
157           {
158             if (nnew >= 500) // Perform a bounds check on nnew since it is assumed
159               // newclust only contains 500 elements.
160               {
161                 AliError("Limit of 500 pad responses reached.");
162                 return;
163               };
164             //
165             // --- store signal information
166             newclust[0][nnew]=qcath;                     // total charge
167             newclust[1][nnew]=segmentation->Ix();       // ix-position of pad
168             newclust[2][nnew]=segmentation->Iy();       // iy-position of pad
169             newclust[3][nnew]=qp * qcath;                // charge on pad
170             newclust[4][nnew]=segmentation->ISector();  // sector id
171             newclust[5][nnew]=(Float_t) i;              // counter
172             nnew++;
173                 
174           }
175       } // Pad loop
176   } // Cathode plane loop
177 }