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