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