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