]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMD.cxx
FMD geometry with pad and SDigits
[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   }
99   delete fDigits ;
100   delete fSDigits ;
101    
102 }
103 //_____________________________________________________________________________
104 void AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
105 {
106   //
107   // Add a hit to the list
108   //
109   TClonesArray &lhits = *fHits;
110   new(lhits[fNhits++]) AliFMDhit(fIshunt,track,vol,hits);
111 }
112 //_____________________________________________________________________________
113 void AliFMD::AddDigit( Int_t *digits) 
114 {
115   // add a real digit - as coming from data
116
117   // printf("AddDigit\n");
118
119    TClonesArray &ldigits = *fDigits;
120    // new((*fDigits)[fNdigits++]) AliFMDdigit(digits);
121   new(ldigits[fNdigits++]) AliFMDdigit(digits);
122
123 }
124 //_____________________________________________________________________________
125 void AliFMD::BuildGeometry()
126 {
127   //
128   // Build simple ROOT TNode geometry for event display
129   //
130   TNode *node, *top;
131   const int kColorFMD  = 7;
132   //
133   top=gAlice->GetGeometry()->GetNode("alice");
134
135   // FMD define the different volumes
136   new TRotMatrix("rot901","rot901",  90, 0, 90, 90, 180, 0);
137
138   new TTUBE("S_FMD0","FMD  volume 0","void",4.73,17.7,1.5);
139   top->cd();
140   node = new TNode("FMD0","FMD0","S_FMD0",0,0,64,"");
141   node->SetLineColor(kColorFMD);
142   fNodes->Add(node);
143
144   new TTUBE("S_FMD1","FMD  volume 1","void",23.4,36.,1.5);
145   top->cd();
146   node = new TNode("FMD1","FMD1","S_FMD1",0,0,85,"");
147   node->SetLineColor(kColorFMD);
148   fNodes->Add(node);
149   
150   new TTUBE("S_FMD2","FMD  volume 2","void",4.73,17.7,1.5);
151   top->cd();
152   node = new TNode("FMD2","FMD2","S_FMD2",0,0,-64,"");
153   node->SetLineColor(kColorFMD);
154   fNodes->Add(node);
155
156   new TTUBE("S_FMD3","FMD  volume 3","void",23.4,36.,1.5);
157   top->cd();
158   node = new TNode("FMD3","FMD3","S_FMD3",0,0,-85,"");
159   node->SetLineColor(kColorFMD);
160   fNodes->Add(node);
161
162   new TTUBE("S_FMD4","FMD  volume 4","void",5,15,0.015);
163   top->cd();
164   node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
165   node->SetLineColor(kColorFMD);
166   fNodes->Add(node);
167   
168   
169   new TTUBE("S_FMD5","FMD  volume 5","void",5,14,0.015);
170   top->cd();
171   node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,"");
172   node->SetLineColor(kColorFMD);
173   fNodes->Add(node);
174
175 }
176  
177 //_____________________________________________________________________________
178 Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py)
179 {
180   //
181   // Calculate the distance from the mouse to the FMD on the screen
182   // Dummy routine
183   //
184   return 9999;
185 }
186 //___________________________________________
187 void AliFMD::ResetHits()
188 {
189   // Reset number of clusters and the cluster array for this detector
190   AliDetector::ResetHits();
191 }
192
193 //____________________________________________
194 void AliFMD::ResetDigits()
195 {
196     //
197     // Reset number of digits and the digits array for this detector
198    AliDetector::ResetHits();
199    //
200 }
201
202 //-------------------------------------------------------------------------
203 void AliFMD::Init()
204 {
205   //
206   // Initialis the FMD after it has been built
207   Int_t i;
208   AliMC* pMC = AliMC::GetMC();
209   //
210   printf("\n");
211   for(i=0;i<35;i++) printf("*");
212   printf(" FMD_INIT ");
213   for(i=0;i<35;i++) printf("*");
214   printf("\n");
215   //
216   // Here the FMD initialisation code (if any!)
217   for(i=0;i<80;i++) printf("*");
218   printf("\n");
219   //
220   //
221   fIdSens1=pMC->VolId("GRIN"); //Si sensetive volume
222
223 }
224 //---------------------------------------------------------------------
225 void AliFMD::MakeBranch(Option_t* option, char *file)
226 {
227   // Create Tree branches for the FMD.
228   const Int_t kBufferSize = 4000;
229   char branchname[10];
230   sprintf(branchname,"%s",GetName());
231
232   AliDetector::MakeBranch(option,file);
233
234   const char *cD = strstr(option,"D");
235  
236   if (cD) {
237     
238      gAlice->MakeBranchInTree(gAlice->TreeD(), 
239                                    branchname, &fDigits, kBufferSize, file) ;     
240
241     printf("Making Branch %s for digits\n",branchname);
242     gAlice->TreeD()->Print();
243   }
244 }
245  
246 //_____________________________________________________________________________
247 void AliFMD::SetTreeAddress()
248 {
249   // Set branch address for the Hits and Digits Tree.
250   char branchname[30];
251   AliDetector::SetTreeAddress();
252
253   TBranch *branch;
254   TTree *treeD = gAlice->TreeD();
255
256
257   if (treeD) {
258         if (fDigits) {
259               branch = treeD->GetBranch(branchname);
260               if (branch) branch->SetAddress(&fDigits);
261         }
262       
263   }
264   if(fSDigits)
265     fSDigits->Clear();
266
267   if (gAlice->TreeS()  && fSDigits ) {
268     branch = gAlice->TreeS()->GetBranch("FMD");
269     if (branch) branch->SetAddress(&fSDigits) ;
270   } 
271
272
273 }
274
275 //---------------------------------------------------------------------
276 /*
277 void AliFMD::SDigits2Digits() 
278 {
279      Int_t  ibg=0, bgr=0;
280     Int_t nbgr_ev= 0;
281        
282     if (ibg) {
283          printf("nbgr_ev %d\n",nbgr_ev);
284  //        Hit2Digits(nbgr_ev,"Add"," ","galice_bgr.root");
285     } 
286        else {
287    //      Hit2Digits(nbgr_ev,"rien","",""); 
288     }
289
290 }
291 */
292 //---------------------------------------------------------------------
293
294
295
296 void AliFMD::Eta2Radius(Float_t eta, Float_t zDisk, Float_t *radius)
297 {
298   Float_t expEta=TMath::Exp(-eta);
299   Float_t theta=TMath::ATan(expEta);
300   theta=2.*theta;
301   Float_t rad=zDisk*(TMath::Tan(theta));
302   *radius=rad;
303    
304   printf(" eta %f radius %f\n", eta, rad);
305 }
306
307 //---------------------------------------------------------------------
308
309 void AliFMD::Hits2SDigits(){
310 #ifdef DEBUG
311   cout<<"ALiFMD::Hits2SDigits> start...\n";
312 #endif
313   char * fileSDigits = 0 ;
314   char * fileHeader=0 ;
315   AliFMDSDigitizer * sd = new AliFMDSDigitizer("mgalice.root","FMD.SDigit.root") ;
316   sd->Exec("") ;
317   sd->Print("");
318   
319   delete sd ;
320 }
321
322
323