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