]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMD.cxx
2e74ed6d2b1f96e08661cf3b94e4831f3641c650
[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 #include <TFile.h>
46
47 #include <TClonesArray.h>
48 #include <TLorentzVector.h>
49 #include "AliFMDv1.h"
50 #include "AliRun.h"
51 #include "AliMC.h"
52 #include "AliDetector.h"
53 #include <iostream.h>
54 #include <fstream.h>
55 #include "AliMagF.h"
56 #include "AliFMDhit.h"
57 #include "AliFMDdigit.h"
58 #include "AliFMDReconstruction.h"
59 #include "AliFMDReconstParticles.h"
60 #include <stdlib.h>
61
62
63 ClassImp (AliFMD)
64   //_____________________________________________________________________________
65 AliFMD::AliFMD ():AliDetector ()
66 {
67   //
68   // Default constructor for class AliFMD
69   //
70   fIshunt = 0;
71   fHits     = 0;
72   fDigits   = 0;
73   fSDigits  = 0;
74   fReconParticles=0;
75   fMerger = 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   fSDigits = new TClonesArray ("AliFMDdigit", 1000);
92   fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
93   gAlice->AddHitList (fHits);
94
95   fIshunt = 0;
96   fIdSens1 = 0;
97   fIdSens2 = 0;
98   fIdSens3 = 0;
99   fIdSens4 = 0;
100   fIdSens5 = 0;
101
102   SetMarkerColor (kRed);
103 }
104
105 //-----------------------------------------------------------------------------
106 AliFMD::~AliFMD ()
107 {
108   if (fHits)
109     {
110       fHits->Delete ();
111       delete fHits;
112       fHits = 0;
113     }
114   if (fDigits)
115     {
116       fDigits->Delete ();
117       delete fDigits;
118       fDigits = 0;
119     }
120   if (fSDigits)
121     {
122       fSDigits->Delete ();
123       delete fSDigits;
124       fSDigits = 0;
125     }
126   if (fReconParticles)
127     {
128       fReconParticles->Delete ();
129       delete fReconParticles;
130       fReconParticles = 0;
131     }
132
133 }
134
135 //_____________________________________________________________________________
136 void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits)
137 {
138   //
139   // Add a hit to the list
140   //
141   TClonesArray & lhits = *fHits;
142   new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits);
143 }
144
145 //_____________________________________________________________________________
146 void AliFMD::AddDigit (Int_t * digits)
147 {
148   // add a real digit - as coming from data
149
150
151   TClonesArray & ldigits = *fDigits;
152   new (ldigits[fNdigits++]) AliFMDdigit (digits);
153
154 }
155 //_____________________________________________________________________________
156 void AliFMD::AddSDigit (Int_t * digits)
157 {
158   // add a real digit - as coming from data
159
160   TClonesArray & ldigits = *fSDigits;
161   new (ldigits[fNdigits++]) AliFMDdigit (digits);
162
163 }
164 //_____________________________________________________________________________
165 void AliFMD::BuildGeometry ()
166 {
167   //
168   // Build simple ROOT TNode geometry for event display
169   //
170   TNode *node, *top;
171   const int kColorFMD = 5;
172   //
173   top = gAlice->GetGeometry ()->GetNode ("alice");
174
175   // FMD define the different volumes
176   new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0);
177
178   new TTUBE ("S_FMD0", "FMD  volume 0", "void", 3.5, 16.8, 1.5);
179   top->cd ();
180   node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, 62.8, "");
181   node->SetLineColor (kColorFMD);
182   fNodes->Add (node);
183
184   new TTUBE ("S_FMD1", "FMD  volume 1", "void", 22., 34.9, 1.5);
185   top->cd ();
186   node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, 75.1, "");
187   node->SetLineColor (kColorFMD);
188   fNodes->Add (node);
189
190   new TTUBE ("S_FMD2", "FMD  volume 2", "void", 3.5, 16.8, 1.5);
191   top->cd ();
192   node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, -62.8, "");
193   node->SetLineColor (kColorFMD);
194   fNodes->Add (node);
195
196   new TTUBE ("S_FMD3", "FMD  volume 3", "void", 22., 34.9, 1.5);
197   top->cd ();
198   node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, -75.1, "");
199   node->SetLineColor (kColorFMD);
200   fNodes->Add (node);
201
202   new TTUBE ("S_FMD4", "FMD  volume 4", "void", 3.5, 16.8, 1.5);
203   top->cd ();
204   //  node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
205   node = new TNode ("FMD4", "FMD4", "S_FMD4", 0, 0, -345, "");
206   node->SetLineColor (kColorFMD);
207   fNodes->Add (node);
208 }
209
210 //_____________________________________________________________________________
211 Int_t AliFMD::DistanceToPrimitive (Int_t px, Int_t py)
212 {
213   //
214   // Calculate the distance from the mouse to the FMD on the screen
215   // Dummy routine
216   //
217   return 9999;
218 }
219
220 //___________________________________________
221 void AliFMD::ResetHits ()
222 {
223   // Reset number of clusters and the cluster array for this detector
224   AliDetector::ResetHits ();
225 }
226
227 //____________________________________________
228 void AliFMD::ResetDigits ()
229 {
230   //
231   // Reset number of digits and the digits array for this detector
232   AliDetector::ResetDigits ();
233   //
234 }
235
236 //-------------------------------------------------------------------------
237 void  AliFMD::Init ()
238 {
239   //
240   // Initialis the FMD after it has been built
241   Int_t i;
242   AliMC *pMC = AliMC::GetMC ();
243   //
244   if (fDebug)
245     {
246       printf ("\n%s: ", ClassName ());
247       for (i = 0; i < 35; i++)
248         printf ("*");
249       printf (" FMD_INIT ");
250       for (i = 0; i < 35; i++)
251         printf ("*");
252       printf ("\n%s: ", ClassName ());
253       //
254       // Here the FMD initialisation code (if any!)
255       for (i = 0; i < 80; i++)
256         printf ("*");
257       printf ("\n");
258     }
259   //
260   //
261     fIdSens1 = pMC->VolId ("GRN1");     //Si sensetive volume
262     fIdSens2 = pMC->VolId ("GRN2");     //Si sensetive volume
263     fIdSens3 = pMC->VolId ("GRN3");     //Si sensetive volume
264     fIdSens4 = pMC->VolId ("GRN4");     //Si sensetive volume
265
266 }
267 //---------------------------------------------------------------------
268 void AliFMD::MakeBranch (Option_t * option, const char *file)
269 {
270   // Create Tree branches for the FMD.
271   char branchname[10];
272   const Int_t kBufferSize = 16000;
273   sprintf (branchname, "%s", GetName ());
274   
275   AliDetector::MakeBranch (option, file);
276   const char *cD = strstr(option,"D");
277   const char *cR = strstr(option,"R");
278   const char *cS = strstr(option,"S");
279   
280   if (cS){
281
282     MakeBranchInTree(gAlice->TreeS(), 
283                      branchname,&fSDigits, 
284                      kBufferSize, file);
285   }
286   if (cD){
287
288     MakeBranchInTree(gAlice->TreeD(), 
289                      branchname,&fDigits, 
290                      kBufferSize, file);
291   }
292   if (cR){
293     MakeBranchInTree(gAlice->TreeR(), 
294                      branchname,&fReconParticles,
295                      kBufferSize, file);
296   }
297   
298 }
299
300 //_____________________________________________________________________________
301 void AliFMD::SetTreeAddress ()
302 {
303   // Set branch address for the Hits and Digits Tree.
304   char branchname[30];
305   AliDetector::SetTreeAddress ();
306
307   TBranch *branch;
308   TTree *treeD = gAlice->TreeD ();
309
310
311   if (treeD)
312     {
313       if (fDigits)
314         {
315           branch = treeD->GetBranch (branchname);
316           if (branch)
317             branch->SetAddress (&fDigits);
318         }
319
320     }
321   if (fSDigits)
322     //  fSDigits->Clear ();
323
324   if (gAlice->TreeS () && fSDigits)
325     {
326       branch = gAlice->TreeS ()->GetBranch ("FMD");
327       if (branch)
328         branch->SetAddress (&fSDigits);
329     }
330
331   if (gAlice->TreeR() && fReconParticles) 
332     {
333       branch = gAlice->TreeR()->GetBranch("FMD"); 
334       if (branch) branch->SetAddress(&fReconParticles) ;
335     }   
336 }
337
338 //---------------------------------------------------------------------
339 void AliFMD::SetRingsSi1(Int_t ringsSi1)
340 {
341   fRingsSi1=ringsSi1;
342 }
343 void AliFMD::SetSectorsSi1(Int_t sectorsSi1)
344 {
345   fSectorsSi1=sectorsSi1;
346 }
347 void AliFMD::SetRingsSi2(Int_t ringsSi2)
348 {
349   fRingsSi2=ringsSi2;
350 }
351 void AliFMD::SetSectorsSi2(Int_t sectorsSi2)
352 {
353   fSectorsSi2=sectorsSi2;
354 }
355 //---------------------------------------------------------------------
356
357 void AliFMD::SDigits2Digits() 
358 {
359   cout<<"AliFMD::SDigits2Digits"<<endl; 
360     if (fMerger) {
361       fMerger ->SetRingsSi1(fRingsSi1);
362       fMerger->SetRingsSi2(fRingsSi2);
363       fMerger ->SetSectorsSi1(fSectorsSi1);
364       fMerger ->SetSectorsSi2(fSectorsSi2);
365       fMerger->Init();
366       cout<<"AliFMD::SDigits2Digits Init"<<endl; 
367       fMerger->Digitise();
368       cout<<"AliFMD::SDigits2Digits Digitise() "<<endl; 
369      }
370
371 }
372 //---------------------------------------------------------------------
373 void   AliFMD::SetMerger(AliFMDMerger* merger)
374 {
375 // Set pointer to merger
376     fMerger = merger;
377 }
378
379 AliFMDMerger*  AliFMD::Merger()
380 {
381 // Return pointer to merger
382     return fMerger;
383 }
384
385 //---------------------------------------------------------------------
386
387
388
389 void
390 AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
391 {
392   Float_t expEta = TMath::Exp (-eta);
393   Float_t theta = TMath::ATan (expEta);
394   theta = 2. * theta;
395   Float_t rad = zDisk * (TMath::Tan (theta));
396   *radius = rad;
397
398   if (fDebug)
399     printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
400 }
401
402 //---------------------------------------------------------------------
403
404 void AliFMD::Hits2SDigits ()
405 {
406
407   //#ifdef DEBUG
408   cout<<"ALiFMD::Hits2SDigits> start...\n";
409   //#endif
410   
411   char * fileSDigits = 0 ;
412   char * fileHeader = 0;
413   AliFMDSDigitizer * sd = new AliFMDSDigitizer(fileHeader,fileSDigits) ;
414   sd->SetRingsSi1(fRingsSi1);
415   sd->SetRingsSi2(fRingsSi2);
416   sd->SetSectorsSi1(fSectorsSi1);
417   sd->SetSectorsSi2(fSectorsSi2);
418
419
420   sd->Exec("") ;
421   sd->Print("");
422
423   delete sd ;
424   
425 }
426 //-----------------------------------------------------------------------
427
428 void AliFMD::Digits2Reco()
429 {
430   char * fileReconParticles=0;
431   char * fileHeader=0;
432   AliFMDReconstruction * reconstruction =
433     new AliFMDReconstruction(fileHeader,fileReconParticles) ;
434   //  fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
435   reconstruction->Exec("");
436   delete  reconstruction;
437 }
438
439