]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMD.cxx
Use default arguments only in the header file (Sun)
[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 }
76
77 //_____________________________________________________________________________
78 AliFMD::AliFMD (const char *name, const char *title):
79 AliDetector (name, title)
80 {
81   //
82   // Standard constructor for Forward Multiplicity Detector
83   //
84
85   //
86   // Initialise Hit array
87   fHits = new TClonesArray ("AliFMDhit", 1000);
88   // Digits for each Si disk
89   fDigits = new TClonesArray ("AliFMDdigit", 1000);
90   fSDigits = new TClonesArray ("AliFMDdigit", 1000);
91   fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
92   gAlice->AddHitList (fHits);
93
94   fIshunt = 0;
95   fIdSens1 = 0;
96   fIdSens2 = 0;
97   fIdSens3 = 0;
98   fIdSens4 = 0;
99   fIdSens5 = 0;
100   //  fMerger = 0;
101   SetMarkerColor (kRed);
102 }
103
104 //-----------------------------------------------------------------------------
105 AliFMD::~AliFMD ()
106 {
107   if (fHits)
108     {
109       fHits->Delete ();
110       delete fHits;
111       fHits = 0;
112     }
113   if (fDigits)
114     {
115       fDigits->Delete ();
116       delete fDigits;
117       fDigits = 0;
118     }
119   if (fSDigits)
120     {
121       fSDigits->Delete ();
122       delete fSDigits;
123       fSDigits = 0;
124     }
125   if (fReconParticles)
126     {
127       fReconParticles->Delete ();
128       delete fReconParticles;
129       fReconParticles = 0;
130     }
131
132 }
133
134 //_____________________________________________________________________________
135 void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits)
136 {
137   //
138   // Add a hit to the list
139   //
140   TClonesArray & lhits = *fHits;
141   new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits);
142 }
143
144 //_____________________________________________________________________________
145 void AliFMD::AddDigit (Int_t * digits)
146 {
147   // add a real digit - as coming from data
148
149
150   TClonesArray & ldigits = *fDigits;
151   new (ldigits[fNdigits++]) AliFMDdigit (digits);
152
153 }
154 //_____________________________________________________________________________
155 void AliFMD::AddSDigit (Int_t * digits)
156 {
157   // add a real digit - as coming from data
158
159   TClonesArray & ldigits = *fSDigits;
160   new (ldigits[fNdigits++]) AliFMDdigit (digits);
161
162 }
163 //_____________________________________________________________________________
164 void AliFMD::BuildGeometry ()
165 {
166   //
167   // Build simple ROOT TNode geometry for event display
168   //
169   TNode *node, *top;
170   const int kColorFMD = 5;
171   //
172   top = gAlice->GetGeometry ()->GetNode ("alice");
173
174   // FMD define the different volumes
175   new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0);
176
177   new TTUBE ("S_FMD0", "FMD  volume 0", "void", 4.2, 17.2, 1.5);
178   top->cd ();
179   node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, 62.8, "");
180   node->SetLineColor (kColorFMD);
181   fNodes->Add (node);
182
183   new TTUBE ("S_FMD1", "FMD  volume 1", "void", 15.4, 28.4, 1.5);
184   top->cd ();
185   node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, 75.2, "");
186   node->SetLineColor (kColorFMD);
187   fNodes->Add (node);
188
189   new TTUBE ("S_FMD2", "FMD  volume 2", "void", 4.2, 17.2, 1.5);
190   top->cd ();
191   node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, -83.2, "");
192   node->SetLineColor (kColorFMD);
193   fNodes->Add (node);
194
195   new TTUBE ("S_FMD3", "FMD  volume 3", "void", 15.4, 28.4, 1.5);
196   top->cd ();
197   node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, -75.2, "");
198   node->SetLineColor (kColorFMD);
199   fNodes->Add (node);
200
201   new TTUBE ("S_FMD4", "FMD  volume 4", "void", 4.2, 17.2, 1.5);
202   top->cd ();
203   //  node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
204   node = new TNode ("FMD4", "FMD4", "S_FMD4", 0, 0, -340, "");
205   node->SetLineColor (kColorFMD);
206   fNodes->Add (node);
207 }
208
209 //_____________________________________________________________________________
210 Int_t AliFMD::DistanceToPrimitive (Int_t px, Int_t py)
211 {
212   //
213   // Calculate the distance from the mouse to the FMD on the screen
214   // Dummy routine
215   //
216   return 9999;
217 }
218
219 //___________________________________________
220 void AliFMD::ResetHits ()
221 {
222   // Reset number of clusters and the cluster array for this detector
223   AliDetector::ResetHits ();
224 }
225
226 //____________________________________________
227 void AliFMD::ResetDigits ()
228 {
229   //
230   // Reset number of digits and the digits array for this detector
231   AliDetector::ResetDigits ();
232   //
233 }
234
235 //-------------------------------------------------------------------------
236 void  AliFMD::Init ()
237 {
238   //
239   // Initialis the FMD after it has been built
240   Int_t i;
241   AliMC *pMC = AliMC::GetMC ();
242   //
243   if (fDebug)
244     {
245       printf ("\n%s: ", ClassName ());
246       for (i = 0; i < 35; i++)
247         printf ("*");
248       printf (" FMD_INIT ");
249       for (i = 0; i < 35; i++)
250         printf ("*");
251       printf ("\n%s: ", ClassName ());
252       //
253       // Here the FMD initialisation code (if any!)
254       for (i = 0; i < 80; i++)
255         printf ("*");
256       printf ("\n");
257     }
258   //
259   //
260     fIdSens1 = pMC->VolId ("GRN1");     //Si sensetive volume
261     fIdSens2 = pMC->VolId ("GRN2");     //Si sensetive volume
262     fIdSens3 = pMC->VolId ("GRN3");     //Si sensetive volume
263     fIdSens4 = pMC->VolId ("GRN4");     //Si sensetive volume
264
265 }
266 //---------------------------------------------------------------------
267 void AliFMD::MakeBranch (Option_t * option, const char *file)
268 {
269   // Create Tree branches for the FMD.
270   char branchname[10];
271   const Int_t kBufferSize = 16000;
272   sprintf (branchname, "%s", GetName ());
273   
274   AliDetector::MakeBranch (option, file);
275   const char *cD = strstr(option,"D");
276   const char *cR = strstr(option,"R");
277   const char *cS = strstr(option,"S");
278   
279   if (cS){
280
281     MakeBranchInTree(gAlice->TreeS(), 
282                      branchname,&fSDigits, 
283                      kBufferSize, file);
284   }
285   if (cD){
286
287     MakeBranchInTree(gAlice->TreeD(), 
288                      branchname,&fDigits, 
289                      kBufferSize, file);
290     cout<<" tree "<<gAlice->TreeD()<<" "<<branchname<<" "<<&fDigits<<endl;
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
340 void AliFMD::SetRingsSi1(Int_t ringsSi1)
341 {
342   //  fRingsSi1=ringsSi1;
343   fRingsSi1=256;
344 }
345 void AliFMD::SetSectorsSi1(Int_t sectorsSi1)
346 {
347   fSectorsSi1=20;
348 }
349 void AliFMD::SetRingsSi2(Int_t ringsSi2)
350 {
351   fRingsSi2=128;
352 }
353 void AliFMD::SetSectorsSi2(Int_t sectorsSi2)
354 {
355   fSectorsSi2=40;
356 }
357
358 //---------------------------------------------------------------------
359 /*
360 void AliFMD::SDigits2Digits() 
361 {
362   cout<<"AliFMD::SDigits2Digits"<<endl; 
363     if (!fMerger) {
364       fMerger = new AliFMDMerger();
365     }
366     
367     fMerger ->SetRingsSi1(fRingsSi1);
368     fMerger->SetRingsSi2(fRingsSi2);
369     fMerger ->SetSectorsSi1(fSectorsSi1);
370     fMerger ->SetSectorsSi2(fSectorsSi2);
371      
372     fMerger->Init();
373     cout<<"AliFMD::SDigits2Digits Init"<<endl; 
374     fMerger->Digitise();
375     cout<<"AliFMD::SDigits2Digits Digitise() "<<endl; 
376  
377
378     }
379
380     //---------------------------------------------------------------------
381 void   AliFMD::SetMerger(AliFMDMerger* merger)
382 {
383 // Set pointer to merger
384     fMerger = merger;
385 }
386
387 AliFMDMerger*  AliFMD::Merger()
388 {
389 // Return pointer to merger
390     return fMerger;
391 }
392 */
393 //---------------------------------------------------------------------
394
395
396
397 void
398 AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
399 {
400   Float_t expEta = TMath::Exp (-eta);
401   Float_t theta = TMath::ATan (expEta);
402   theta = 2. * theta;
403   Float_t rad = zDisk * (TMath::Tan (theta));
404   *radius = rad;
405
406   if (fDebug)
407     printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
408 }
409
410 //---------------------------------------------------------------------
411
412 void AliFMD::Hits2SDigits ()
413 {
414
415   //#ifdef DEBUG
416   cout<<"ALiFMD::Hits2SDigits> start...\n";
417   //#endif
418   
419   char * fileSDigits = "FMD.SDigits.root";
420   char * fileHeader = 0;
421   AliFMDSDigitizer * sd = new AliFMDSDigitizer(fileHeader,fileSDigits) ;
422   sd->SetRingsSi1(fRingsSi1);
423   sd->SetRingsSi2(fRingsSi2);
424   sd->SetSectorsSi1(fSectorsSi1);
425   sd->SetSectorsSi2(fSectorsSi2);
426   //  sd->SetEventNumber(fEvNrSig);
427   sd->Exec("") ;
428   
429   delete sd ;
430   
431 }
432 //-----------------------------------------------------------------------
433
434 void AliFMD::Digits2Reco()
435 {
436   char * fileReconParticles=0;
437   char * fileHeader=0;
438   AliFMDReconstruction * reconstruction =
439     new AliFMDReconstruction(fileHeader,fileReconParticles) ;
440   //  fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
441   reconstruction->Exec("");
442   delete  reconstruction;
443 }
444 //-----------------------------------------------------------------------
445
446 void AliFMD::MakeBranchInTreeD(TTree *treeD, const char *file)
447 {
448     //
449     // Create TreeD branches for the MUON.
450     //
451
452     const Int_t kBufferSize = 4000;
453     char branchname[20];
454     
455
456     sprintf(branchname,"%s",GetName()); 
457     if(treeD){
458     MakeBranchInTree(treeD, 
459                      branchname,&fDigits, 
460                      kBufferSize, file);
461     }
462 }
463