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