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