reconstruction working now under AliReconstruction
[u/mrichter/AliRoot.git] / FMD / AliFMD.cxx
CommitLineData
4c039060 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 **************************************************************************/
88cb7938 15
16/* $Id$ */
17
d28dcc0d 18 //////////////////////////////////////////////////////////////////////////////
37c55dc0 19// //
d28dcc0d 20// Forward Multiplicity Detector based on Silicon plates //
fe4da5cc 21// This class contains the base procedures for the Forward Multiplicity //
22// detector //
383238cf 23// Detector consists of 5 Si volumes covered pseudorapidity interval //
24// from 1.7 to 5.1. //
fe4da5cc 25// //
26//Begin_Html
27/*
d28dcc0d 28<img src="gif/AliFMDClass.gif">
fe4da5cc 29</pre>
30<br clear=left>
31<font size=+2 color=red>
32<p>The responsible person for this module is
d28dcc0d 33<a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
fe4da5cc 34</font>
35<pre>
36*/
37//End_Html
38// //
39// //
40///////////////////////////////////////////////////////////////////////////////
41
b9a2d5e4 42#define DEBUG
88cb7938 43
44#include <Riostream.h>
45#include <stdlib.h>
46
47#include <TClonesArray.h>
48#include <TFile.h>
94de3818 49#include <TGeometry.h>
88cb7938 50#include <TLorentzVector.h>
51#include <TMath.h>
52#include <TNode.h>
b9a2d5e4 53#include <TTUBE.h>
d28dcc0d 54#include <TTree.h>
88cb7938 55#include <TVirtualMC.h>
b9a2d5e4 56
dc8af42e 57#include "AliDetector.h"
37c55dc0 58#include "AliFMDReconstParticles.h"
88cb7938 59#include "AliFMDReconstruction.h"
60#include "AliFMDdigit.h"
61#include "AliFMDhit.h"
62#include "AliFMDv1.h"
63#include "AliLoader.h"
64#include "AliMagF.h"
65#include "AliRun.h"
5d12ce38 66#include "AliMC.h"
85a5290f 67#include "AliFMDDigitizer.h"
b9a2d5e4 68
dc8af42e 69ClassImp (AliFMD)
b9a2d5e4 70 //_____________________________________________________________________________
dc8af42e 71AliFMD::AliFMD ():AliDetector ()
fe4da5cc 72{
73 //
74 // Default constructor for class AliFMD
75 //
dc8af42e 76 fIshunt = 0;
77 fHits = 0;
78 fDigits = 0;
cccf369e 79 fReconParticles=0;
fe4da5cc 80}
dc8af42e 81
fe4da5cc 82//_____________________________________________________________________________
dc8af42e 83AliFMD::AliFMD (const char *name, const char *title):
84AliDetector (name, title)
fe4da5cc 85{
86 //
87 // Standard constructor for Forward Multiplicity Detector
88 //
dc8af42e 89
fe4da5cc 90 //
91 // Initialise Hit array
dc8af42e 92 fHits = new TClonesArray ("AliFMDhit", 1000);
b9a2d5e4 93 // Digits for each Si disk
dc8af42e 94 fDigits = new TClonesArray ("AliFMDdigit", 1000);
37c55dc0 95 fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
5d12ce38 96 gAlice->GetMCApp()->AddHitList (fHits);
d1280e40 97
dc8af42e 98 fIshunt = 0;
4110645f 99 // fMerger = 0;
dc8af42e 100 SetMarkerColor (kRed);
fe4da5cc 101}
d28dcc0d 102
dc8af42e 103//-----------------------------------------------------------------------------
104AliFMD::~AliFMD ()
d28dcc0d 105{
dc8af42e 106 if (fHits)
107 {
108 fHits->Delete ();
b9a2d5e4 109 delete fHits;
cae27883 110 fHits = 0;
dc8af42e 111 }
112 if (fDigits)
113 {
114 fDigits->Delete ();
cae27883 115 delete fDigits;
116 fDigits = 0;
dc8af42e 117 }
88cb7938 118 if (fReconParticles)
dc8af42e 119 {
120 fReconParticles->Delete ();
121 delete fReconParticles;
122 fReconParticles = 0;
123 }
124
d28dcc0d 125}
dc8af42e 126
fe4da5cc 127//_____________________________________________________________________________
dc8af42e 128void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits)
fe4da5cc 129{
130 //
d28dcc0d 131 // Add a hit to the list
fe4da5cc 132 //
dc8af42e 133 TClonesArray & lhits = *fHits;
134 new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits);
fe4da5cc 135}
dc8af42e 136
fe4da5cc 137//_____________________________________________________________________________
dc8af42e 138void AliFMD::AddDigit (Int_t * digits)
b9a2d5e4 139{
140 // add a real digit - as coming from data
141
88cb7938 142 if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);
dc8af42e 143 TClonesArray & ldigits = *fDigits;
144 new (ldigits[fNdigits++]) AliFMDdigit (digits);
37c55dc0 145}
88cb7938 146
b9a2d5e4 147//_____________________________________________________________________________
dc8af42e 148void AliFMD::BuildGeometry ()
fe4da5cc 149{
150 //
151 // Build simple ROOT TNode geometry for event display
152 //
d28dcc0d 153 TNode *node, *top;
37c55dc0 154 const int kColorFMD = 5;
fe4da5cc 155 //
dc8af42e 156 top = gAlice->GetGeometry ()->GetNode ("alice");
fe4da5cc 157
158 // FMD define the different volumes
dc8af42e 159 new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0);
160
4110645f 161 new TTUBE ("S_FMD0", "FMD volume 0", "void", 4.2, 17.2, 1.5);
dc8af42e 162 top->cd ();
1663993c 163 node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, -62.8, "");
dc8af42e 164 node->SetLineColor (kColorFMD);
165 fNodes->Add (node);
166
4110645f 167 new TTUBE ("S_FMD1", "FMD volume 1", "void", 15.4, 28.4, 1.5);
dc8af42e 168 top->cd ();
1663993c 169 node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, -75.2, "");
dc8af42e 170 node->SetLineColor (kColorFMD);
171 fNodes->Add (node);
172
4110645f 173 new TTUBE ("S_FMD2", "FMD volume 2", "void", 4.2, 17.2, 1.5);
dc8af42e 174 top->cd ();
1663993c 175 node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, 83.2, "");
dc8af42e 176 node->SetLineColor (kColorFMD);
177 fNodes->Add (node);
178
4110645f 179 new TTUBE ("S_FMD3", "FMD volume 3", "void", 15.4, 28.4, 1.5);
dc8af42e 180 top->cd ();
1663993c 181 node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, 75.2, "");
dc8af42e 182 node->SetLineColor (kColorFMD);
183 fNodes->Add (node);
184
4110645f 185 new TTUBE ("S_FMD4", "FMD volume 4", "void", 4.2, 17.2, 1.5);
dc8af42e 186 top->cd ();
1663993c 187 node = new TNode ("FMD4", "FMD4", "S_FMD4", 0, 0, 340, "");
dc8af42e 188 node->SetLineColor (kColorFMD);
189 fNodes->Add (node);
fe4da5cc 190}
dc8af42e 191
fe4da5cc 192//_____________________________________________________________________________
46501dfb 193Int_t AliFMD::DistanceToPrimitive (Int_t /*px*/, Int_t /*py*/)
fe4da5cc 194{
195 //
196 // Calculate the distance from the mouse to the FMD on the screen
197 // Dummy routine
198 //
199 return 9999;
200}
dc8af42e 201
b9a2d5e4 202//___________________________________________
dc8af42e 203void AliFMD::ResetHits ()
b9a2d5e4 204{
205 // Reset number of clusters and the cluster array for this detector
dc8af42e 206 AliDetector::ResetHits ();
b9a2d5e4 207}
208
209//____________________________________________
dc8af42e 210void AliFMD::ResetDigits ()
b9a2d5e4 211{
dc8af42e 212 //
213 // Reset number of digits and the digits array for this detector
37c55dc0 214 AliDetector::ResetDigits ();
dc8af42e 215 //
b9a2d5e4 216}
fe4da5cc 217
d28dcc0d 218//-------------------------------------------------------------------------
dc8af42e 219void AliFMD::Init ()
fe4da5cc 220{
221 //
222 // Initialis the FMD after it has been built
223 Int_t i;
224 //
dc8af42e 225 if (fDebug)
226 {
227 printf ("\n%s: ", ClassName ());
228 for (i = 0; i < 35; i++)
229 printf ("*");
230 printf (" FMD_INIT ");
231 for (i = 0; i < 35; i++)
232 printf ("*");
233 printf ("\n%s: ", ClassName ());
234 //
235 // Here the FMD initialisation code (if any!)
236 for (i = 0; i < 80; i++)
237 printf ("*");
238 printf ("\n");
239 }
b9a2d5e4 240 //
241 //
46501dfb 242
fe4da5cc 243}
d28dcc0d 244//---------------------------------------------------------------------
88cb7938 245void AliFMD::MakeBranch (Option_t * option)
d28dcc0d 246{
247 // Create Tree branches for the FMD.
d28dcc0d 248 char branchname[10];
dc8af42e 249 const Int_t kBufferSize = 16000;
250 sprintf (branchname, "%s", GetName ());
251
88cb7938 252 const char *cH = strstr(option,"H");
dc8af42e 253 const char *cD = strstr(option,"D");
254 const char *cR = strstr(option,"R");
dc8af42e 255
88cb7938 256 if (cH && (fHits == 0x0)) fHits = new TClonesArray ("AliFMDhit", 1000);
b9a2d5e4 257
88cb7938 258 AliDetector::MakeBranch (option);
259
260 if (cD){
261 if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);
262 MakeBranchInTree(fLoader->TreeD(), branchname,&fDigits, kBufferSize, 0);
dc8af42e 263 }
88cb7938 264
dc8af42e 265 if (cR){
88cb7938 266 if (fReconParticles == 0x0)
267 fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
268 MakeBranchInTree(fLoader->TreeR(), branchname,&fReconParticles, kBufferSize, 0);
d28dcc0d 269 }
dc8af42e 270
d28dcc0d 271}
dc8af42e 272
b9a2d5e4 273//_____________________________________________________________________________
dc8af42e 274void AliFMD::SetTreeAddress ()
b9a2d5e4 275{
276 // Set branch address for the Hits and Digits Tree.
277 char branchname[30];
88cb7938 278
279 if (fLoader->TreeH() && (fHits == 0x0))
280 fHits = new TClonesArray ("AliFMDhit", 1000);
281
dc8af42e 282 AliDetector::SetTreeAddress ();
b9a2d5e4 283
284 TBranch *branch;
88cb7938 285 TTree *treeD = fLoader->TreeD();
b9a2d5e4 286
dc8af42e 287 if (treeD)
288 {
88cb7938 289 if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);
290 branch = treeD->GetBranch (branchname);
291 if (branch)
292 branch->SetAddress (&fDigits);
dc8af42e 293 }
88cb7938 294
295 if (fLoader->TreeR() && fReconParticles)
dc8af42e 296 {
88cb7938 297 if (fReconParticles == 0x0)
298 fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
299 branch = fLoader->TreeR()->GetBranch("FMD");
dc8af42e 300 if (branch) branch->SetAddress(&fReconParticles) ;
37c55dc0 301 }
b9a2d5e4 302}
303
b9a2d5e4 304
305
dc8af42e 306void
307AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
fe4da5cc 308{
dc8af42e 309 Float_t expEta = TMath::Exp (-eta);
310 Float_t theta = TMath::ATan (expEta);
311 theta = 2. * theta;
312 Float_t rad = zDisk * (TMath::Tan (theta));
313 *radius = rad;
314
315 if (fDebug)
316 printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
fe4da5cc 317}
d28dcc0d 318
4110645f 319//-----------------------------------------------------------------------
320
321void AliFMD::MakeBranchInTreeD(TTree *treeD, const char *file)
322{
323 //
88cb7938 324 // Create TreeD branches for the FMD
4110645f 325 //
4110645f 326 const Int_t kBufferSize = 4000;
327 char branchname[20];
4110645f 328 sprintf(branchname,"%s",GetName());
88cb7938 329 if(treeD)
330 {
331 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
332 }
4110645f 333}
37c55dc0 334
85a5290f 335//____________________________________________________________________________
c92eb8ad 336AliDigitizer* AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 337{
338 return new AliFMDDigitizer(manager);
339}