]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDv1.cxx
60d04c26dc6712af94022c59aa3008896edd6bed
[u/mrichter/AliRoot.git] / FMD / AliFMDv1.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 //                                                                          
20 // Forward Multiplicity Detector based on Silicon wafers. This class
21 // contains the base procedures for the Forward Multiplicity detector
22 // Detector consists of 5 Si volumes covered pseudorapidity interval
23 // from 1.7 to 5.1.
24 //
25 // This class contains the detailed version of the FMD - that is, hits
26 // are produced during simulation. 
27 //                                                                           
28 // The actual code is done by various separate classes.   Below is
29 // diagram showing the relationship between the various FMD classes
30 // that handles the geometry 
31 //
32 //
33 //       +----------+   +----------+   
34 //       | AliFMDv1 |   | AliFMDv1 |   
35 //       +----------+   +----------+   
36 //            |              |
37 //       +----+--------------+
38 //       |
39 //       |           +------------+ 1  +---------------+
40 //       |        +- | AliFMDRing |<>--| AliFMDPolygon | 
41 //       V     2  |  +------------+    +---------------+   
42 //  +--------+<>--+        |
43 //  | AliFMD |             ^                       
44 //  +--------+<>--+        V 1..2                     
45 //             3  | +-------------------+ 
46 //                +-| AliFMDSubDetector | 
47 //                  +-------------------+
48 //                           ^              
49 //                           |
50 //             +-------------+-------------+
51 //             |             |             |          
52 //        +---------+   +---------+   +---------+
53 //        | AliFMD1 |   | AliFMD2 |   | AliFMD3 |
54 //        +---------+   +---------+   +---------+
55 //      
56 //
57 // See also the class AliFMD for a more detailed explanation of the
58 // various componets. 
59 #ifndef ROOT_TVirtualMC
60 # include <TVirtualMC.h>
61 #endif
62 #ifndef ALIFMDV1_H
63 # include "AliFMDv1.h"
64 #endif
65 #ifndef ALIRUN_H
66 # include "AliRun.h"
67 #endif
68 #ifndef ALIMC_H
69 # include "AliMC.h"
70 #endif
71 #ifndef ALILOG_H
72 # include "AliLog.h"
73 #endif
74
75 //____________________________________________________________________
76 ClassImp(AliFMDv1);
77
78
79 //____________________________________________________________________
80 void 
81 AliFMDv1::StepManager()
82 {
83   //
84   // Called for every step in the Forward Multiplicity Detector
85   //
86   // The procedure is as follows: 
87   // 
88   //   - IF NOT track is alive THEN RETURN ENDIF
89   //   - IF NOT particle is charged THEN RETURN ENDIF
90   //   - IF NOT volume name is "STRI" or "STRO" THEN RETURN ENDIF 
91   //   - Get strip number (volume copy # minus 1)
92   //   - Get phi division number (mother volume copy #)
93   //   - Get module number (grand-mother volume copy #)
94   //   - section # = 2 * module # + phi division # - 1
95   //   - Get ring Id from volume name 
96   //   - Get detector # from grand-grand-grand-mother volume name 
97   //   - Get pointer to sub-detector object. 
98   //   - Get track position 
99   //   - IF track is entering volume AND track is inside real shape THEN
100   //   -   Reset energy deposited 
101   //   -   Get track momentum 
102   //   -   Get particle ID # 
103   ///  - ENDIF
104   //   - IF track is inside volume AND inside real shape THEN 
105   ///  -   Update energy deposited 
106   //   - ENDIF 
107   //   - IF track is inside real shape AND (track is leaving volume,
108   //         or it died, or it is stopped  THEN
109   //   -   Create a hit 
110   //   - ENDIF
111   //     
112   //
113   // DebugGuard guard("AliFMDv1::StepManager");
114   AliDebug(10, "AliFMDv1::StepManager");
115   // return;
116
117   // If the track is gone, return
118   if (!gMC->IsTrackAlive()) return;
119   
120   // Only process charged particles 
121   if(TMath::Abs(gMC->TrackCharge()) <= 0) return; 
122
123   TString vol(gMC->CurrentVolName());
124   std::cout << "Is inside " << vol << " ... " << std::endl;
125   // Only do stuff is the track is in one of the strips. 
126   // TString vol(gMC->CurrentVolName());
127   // if (!vol.Contains("STR")) return;
128   Int_t copy;
129   Int_t volumeId = gMC->CurrentVolID(copy);
130   if (volumeId != fInner->GetStripId() || volumeId != fOuter->GetStripId()) {
131     std::cout << "Not a FMD strip volume: " 
132               << volumeId << " != " << fInner->GetStripId() << " or " 
133               << fOuter->GetStripId() << std::endl;
134     return;
135   }
136   std::cout << "OK, an FMD strip volume!" << std::endl;
137   
138   // Get the strip number.  Note, that GEANT numbers divisions from 1,
139   // so we subtract one 
140   Int_t strip = copy - 1;
141
142   // Get the phi division of the module 
143   Int_t phiDiv;                         // * The phi division number (1 or 2)
144   gMC->CurrentVolOffID(1, phiDiv);      //   in the module  
145
146   // Active volume number - not used. 
147   // Int_t active;                         
148   // gMC->CurrentVolOffID(2, active);      
149
150   // Get the module number in the ring. 
151   Int_t module;                    
152   gMC->CurrentVolOffID(3, module); 
153   
154   // Ring copy number - the same as the detector number - not used
155   // Int_t ringCopy;                       // * Ring copy number
156   // gMC->CurrentVolOffID(4, ringCopy);    //   Same as detector number 
157   
158   // Get the detector number from the path name 
159   Int_t detector = Int_t((gMC->CurrentVolOffName(5)[3]) - 48);
160
161   // The sector number, calculated from module and phi division # 
162   Int_t  sector =  2 * module + phiDiv - 1;
163
164   // The ring ID is encoded in the volume name 
165   Char_t ring = vol[3];
166
167   // Get a pointer to the sub detector structure 
168   AliFMDSubDetector* det = 0;
169   switch (detector) {
170   case 1: det = fFMD1; break;
171   case 2: det = fFMD2; break;
172   case 3: det = fFMD3; break;
173   }
174   if (!det) return;
175
176   // Get the current track position 
177   TLorentzVector v;
178   gMC->TrackPosition(v);
179   // Check that the track is actually within the active area 
180   Bool_t isWithin = det->CheckHit(ring, module, v.X(), v.Y());
181   Bool_t entering = gMC->IsTrackEntering() && isWithin;
182   Bool_t inside   = gMC->IsTrackInside()   && isWithin;
183   Bool_t out      = (gMC->IsTrackExiting() 
184                      || gMC->IsTrackDisappeared() 
185                      || gMC->IsTrackStop() 
186                      || !isWithin);
187 // Reset the energy deposition for this track, and update some of
188   // our parameters.
189   if (entering) {
190     fCurrentDeltaE = 0;
191
192     // Get production vertex and momentum of the track 
193     fCurrentV = v;
194     gMC->TrackMomentum(fCurrentP);
195     fCurrentPdg = gMC->IdFromPDG(gMC->TrackPid());
196
197     // if (fAnalyser) 
198     //   fAnalyser->Update(detector, ring, isWithin, v.X(), v.Y());
199   }
200   
201   // If the track is inside, then update the energy deposition
202   if (inside && fCurrentDeltaE >= 0) 
203     fCurrentDeltaE += 1000 * gMC->Edep();
204
205   // The track exits the volume, or it disappeared in the volume, or
206   // the track is stopped because it no longer fulfills the cuts
207   // defined, then we create a hit. 
208   if (out && fCurrentDeltaE >= 0) {
209     fCurrentDeltaE += 1000 * gMC->Edep();
210
211     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),
212            detector, ring,  sector, strip,
213            fCurrentV.X(), fCurrentV.Y(), fCurrentV.Z(),
214            fCurrentP.X(), fCurrentP.Y(), fCurrentP.Z(), 
215            fCurrentDeltaE, fCurrentPdg, fCurrentV.T());
216     fCurrentDeltaE = -1;
217   }
218 }
219 //___________________________________________________________________
220 //
221 // EOF
222 //