]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMD.cxx
84ff0b8f7f89a9b1a639e4206e4416f847675e00
[u/mrichter/AliRoot.git] / FMD / AliFMD.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 //                                                                           //
17 //  Forward Multiplicity Detector based on Silicon plates                    //
18 //  This class contains the base procedures for the Forward Multiplicity     //
19 //  detector                                                                 //
20 //  Detector consists of 6 Si volumes covered pseudorapidity interval         //
21 //  from 1.6 to 6.0.                                                         //
22 //                                                                           //
23 //Begin_Html
24 /*
25 <img src="gif/AliFMDClass.gif">
26 </pre>
27 <br clear=left>
28 <font size=+2 color=red>
29 <p>The responsible person for this module is
30 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
31 </font>
32 <pre>
33 */
34 //End_Html
35 //                                                                           //
36 //                                                                           //
37 ///////////////////////////////////////////////////////////////////////////////
38
39 #define DEBUG
40 #include <TMath.h>
41 #include <TGeometry.h>
42 #include <TTUBE.h>
43 #include <TTree.h>
44 #include <TNode.h>
45
46 #include <TClonesArray.h>
47 #include <TLorentzVector.h>
48 #include "AliFMDv1.h"
49 #include "AliRun.h"
50 #include "AliMC.h"
51 #include <iostream.h>
52 #include <fstream.h>
53 #include "AliMagF.h"
54 #include "AliFMDhit.h"
55 #include "AliFMDdigit.h"
56 #include <stdlib.h>
57
58
59 ClassImp(AliFMD)
60  
61   //_____________________________________________________________________________
62   AliFMD::AliFMD(): AliDetector()
63 {
64   //
65   // Default constructor for class AliFMD
66   //
67   fIshunt   = 0;
68 }
69  
70 //_____________________________________________________________________________
71 AliFMD::AliFMD(const char *name, const char *title)
72   : AliDetector(name,title)
73 {
74   //
75   // Standard constructor for Forward Multiplicity Detector
76   //
77  
78   //
79   // Initialise Hit array
80   fHits     = new TClonesArray("AliFMDhit", 1000);
81   // Digits for each Si disk
82   fDigits   = new TClonesArray("AliFMDdigit", 1000);
83   fSDigits  = new TClonesArray("AliFMDdigit", 1000) ; 
84   gAlice->AddHitList(fHits);
85
86   fIshunt     =  0;
87   fIdSens1    =  0;
88
89   SetMarkerColor(kRed);
90 }
91  
92
93 AliFMD::~AliFMD()
94 {
95   if (fHits) {
96       fHits->Delete();
97       delete fHits;
98       fHits = 0;
99   }
100   if (fDigits) {
101       fDigits->Delete();
102       delete fDigits;
103       fDigits = 0;
104   }
105   if (fSDigits) {
106       fSDigits->Delete();
107       delete fSDigits;
108       fSDigits = 0;
109   }
110    
111 }
112 //_____________________________________________________________________________
113 void AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
114 {
115   //
116   // Add a hit to the list
117   //
118   TClonesArray &lhits = *fHits;
119   new(lhits[fNhits++]) AliFMDhit(fIshunt,track,vol,hits);
120 }
121 //_____________________________________________________________________________
122 void AliFMD::AddDigit( Int_t *digits) 
123 {
124   // add a real digit - as coming from data
125
126   // printf("AddDigit\n");
127
128    TClonesArray &ldigits = *fDigits;
129    new(ldigits[fNdigits++]) AliFMDdigit(digits);
130
131 }
132 //_____________________________________________________________________________
133 void AliFMD::BuildGeometry()
134 {
135   //
136   // Build simple ROOT TNode geometry for event display
137   //
138   TNode *node, *top;
139   const int kColorFMD  = 7;
140   //
141   top=gAlice->GetGeometry()->GetNode("alice");
142
143   // FMD define the different volumes
144   new TRotMatrix("rot901","rot901",  90, 0, 90, 90, 180, 0);
145
146   new TTUBE("S_FMD0","FMD  volume 0","void",4.73,17.7,1.5);
147   top->cd();
148   node = new TNode("FMD0","FMD0","S_FMD0",0,0,64,"");
149   node->SetLineColor(kColorFMD);
150   fNodes->Add(node);
151
152   new TTUBE("S_FMD1","FMD  volume 1","void",23.4,36.,1.5);
153   top->cd();
154   node = new TNode("FMD1","FMD1","S_FMD1",0,0,85,"");
155   node->SetLineColor(kColorFMD);
156   fNodes->Add(node);
157   
158   new TTUBE("S_FMD2","FMD  volume 2","void",4.73,17.7,1.5);
159   top->cd();
160   node = new TNode("FMD2","FMD2","S_FMD2",0,0,-64,"");
161   node->SetLineColor(kColorFMD);
162   fNodes->Add(node);
163
164   new TTUBE("S_FMD3","FMD  volume 3","void",23.4,36.,1.5);
165   top->cd();
166   node = new TNode("FMD3","FMD3","S_FMD3",0,0,-85,"");
167   node->SetLineColor(kColorFMD);
168   fNodes->Add(node);
169
170   new TTUBE("S_FMD4","FMD  volume 4","void",5,15,0.015);
171   top->cd();
172   node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
173   node->SetLineColor(kColorFMD);
174   fNodes->Add(node);
175   
176   
177   new TTUBE("S_FMD5","FMD  volume 5","void",5,14,0.015);
178   top->cd();
179   node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,"");
180   node->SetLineColor(kColorFMD);
181   fNodes->Add(node);
182
183 }
184  
185 //_____________________________________________________________________________
186 Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py)
187 {
188   //
189   // Calculate the distance from the mouse to the FMD on the screen
190   // Dummy routine
191   //
192   return 9999;
193 }
194 //___________________________________________
195 void AliFMD::ResetHits()
196 {
197   // Reset number of clusters and the cluster array for this detector
198   AliDetector::ResetHits();
199 }
200
201 //____________________________________________
202 void AliFMD::ResetDigits()
203 {
204     //
205     // Reset number of digits and the digits array for this detector
206    AliDetector::ResetHits();
207    //
208 }
209
210 //-------------------------------------------------------------------------
211 void AliFMD::Init()
212 {
213   //
214   // Initialis the FMD after it has been built
215   Int_t i;
216   AliMC* pMC = AliMC::GetMC();
217   //
218   if(fDebug) {
219     printf("\n%s: ",ClassName());
220     for(i=0;i<35;i++) printf("*");
221     printf(" FMD_INIT ");
222     for(i=0;i<35;i++) printf("*");
223     printf("\n%s: ",ClassName());
224     //
225     // Here the FMD initialisation code (if any!)
226     for(i=0;i<80;i++) printf("*");
227     printf("\n");
228   }
229   //
230   //
231   if (IsVersion()!=0)
232     fIdSens1=pMC->VolId("GRIN"); //Si sensetive volume
233   else
234     fIdSens1=pMC->VolId("GFSI"); //Si sensetive volume
235
236 }
237 //---------------------------------------------------------------------
238 void AliFMD::MakeBranch(Option_t* option, const char *file)
239 {
240   // Create Tree branches for the FMD.
241   const Int_t kBufferSize = 4000;
242   char branchname[10];
243   sprintf(branchname,"%s",GetName());
244
245   AliDetector::MakeBranch(option,file);
246
247   const char *cD = strstr(option,"D");
248  
249   if (cD) {
250     
251     MakeBranchInTree(gAlice->TreeD(), 
252                      branchname, &fDigits, kBufferSize, file);
253
254     printf("Making Branch %s for digits\n",branchname);
255     gAlice->TreeD()->Print();
256   }
257 }
258  
259 //_____________________________________________________________________________
260 void AliFMD::SetTreeAddress()
261 {
262   // Set branch address for the Hits and Digits Tree.
263   char branchname[30];
264   AliDetector::SetTreeAddress();
265
266   TBranch *branch;
267   TTree *treeD = gAlice->TreeD();
268
269
270   if (treeD) {
271         if (fDigits) {
272               branch = treeD->GetBranch(branchname);
273               if (branch) branch->SetAddress(&fDigits);
274         }
275       
276   }
277   if(fSDigits)
278     fSDigits->Clear();
279
280   if (gAlice->TreeS()  && fSDigits ) {
281     branch = gAlice->TreeS()->GetBranch("FMD");
282     if (branch) branch->SetAddress(&fSDigits) ;
283   } 
284
285
286 }
287
288 //---------------------------------------------------------------------
289 /*
290 void AliFMD::SDigits2Digits() 
291 {
292      Int_t  ibg=0, bgr=0;
293     Int_t nbgr_ev= 0;
294        
295     if (ibg) {
296          printf("nbgr_ev %d\n",nbgr_ev);
297  //        Hit2Digits(nbgr_ev,"Add"," ","galice_bgr.root");
298     } 
299        else {
300    //      Hit2Digits(nbgr_ev,"rien","",""); 
301     }
302
303 }
304 */
305 //---------------------------------------------------------------------
306
307
308
309 void AliFMD::Eta2Radius(Float_t eta, Float_t zDisk, Float_t *radius)
310 {
311   Float_t expEta=TMath::Exp(-eta);
312   Float_t theta=TMath::ATan(expEta);
313   theta=2.*theta;
314   Float_t rad=zDisk*(TMath::Tan(theta));
315   *radius=rad;
316    
317   if(fDebug) printf("%s: eta %f radius %f\n", ClassName(), eta, rad);
318 }
319
320 //---------------------------------------------------------------------
321
322 void AliFMD::Hits2SDigits(){
323   if(fDebug) cout << ClassName() << ": ALiFMD::Hits2SDigits> start...\n";
324   //  char * fileSDigits = 0 ;
325   // char * fileHeader=0 ;
326   AliFMDSDigitizer * sd = new AliFMDSDigitizer("mgalice.root","FMD.SDigit.root") ;
327   sd->Exec("") ;
328   sd->Print("");
329   
330   delete sd ;
331 }
332
333
334