fIdSens1 after check
[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;
98 }
99 delete fDigits ;
100 delete fSDigits ;
101
d28dcc0d 102}
fe4da5cc 103//_____________________________________________________________________________
104void AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
105{
106 //
d28dcc0d 107 // Add a hit to the list
fe4da5cc 108 //
109 TClonesArray &lhits = *fHits;
110 new(lhits[fNhits++]) AliFMDhit(fIshunt,track,vol,hits);
111}
fe4da5cc 112//_____________________________________________________________________________
b9a2d5e4 113void AliFMD::AddDigit( Int_t *digits)
114{
115 // add a real digit - as coming from data
116
b9a2d5e4 117
118 TClonesArray &ldigits = *fDigits;
0ac554ca 119 new(ldigits[fNdigits++]) AliFMDdigit(digits);
b9a2d5e4 120
121}
122//_____________________________________________________________________________
fe4da5cc 123void AliFMD::BuildGeometry()
124{
125 //
126 // Build simple ROOT TNode geometry for event display
127 //
d28dcc0d 128 TNode *node, *top;
fe4da5cc 129 const int kColorFMD = 7;
130 //
d28dcc0d 131 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 132
133 // FMD define the different volumes
d28dcc0d 134 new TRotMatrix("rot901","rot901", 90, 0, 90, 90, 180, 0);
135
136 new TTUBE("S_FMD0","FMD volume 0","void",4.73,17.7,1.5);
137 top->cd();
138 node = new TNode("FMD0","FMD0","S_FMD0",0,0,64,"");
139 node->SetLineColor(kColorFMD);
140 fNodes->Add(node);
141
142 new TTUBE("S_FMD1","FMD volume 1","void",23.4,36.,1.5);
143 top->cd();
144 node = new TNode("FMD1","FMD1","S_FMD1",0,0,85,"");
145 node->SetLineColor(kColorFMD);
146 fNodes->Add(node);
fe4da5cc 147
d28dcc0d 148 new TTUBE("S_FMD2","FMD volume 2","void",4.73,17.7,1.5);
149 top->cd();
150 node = new TNode("FMD2","FMD2","S_FMD2",0,0,-64,"");
151 node->SetLineColor(kColorFMD);
152 fNodes->Add(node);
153
154 new TTUBE("S_FMD3","FMD volume 3","void",23.4,36.,1.5);
155 top->cd();
156 node = new TNode("FMD3","FMD3","S_FMD3",0,0,-85,"");
157 node->SetLineColor(kColorFMD);
158 fNodes->Add(node);
159
160 new TTUBE("S_FMD4","FMD volume 4","void",5,15,0.015);
161 top->cd();
162 node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
163 node->SetLineColor(kColorFMD);
164 fNodes->Add(node);
fe4da5cc 165
fe4da5cc 166
d28dcc0d 167 new TTUBE("S_FMD5","FMD volume 5","void",5,14,0.015);
168 top->cd();
169 node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,"");
170 node->SetLineColor(kColorFMD);
171 fNodes->Add(node);
172
fe4da5cc 173}
174
175//_____________________________________________________________________________
d28dcc0d 176Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py)
fe4da5cc 177{
178 //
179 // Calculate the distance from the mouse to the FMD on the screen
180 // Dummy routine
181 //
182 return 9999;
183}
b9a2d5e4 184//___________________________________________
185void AliFMD::ResetHits()
186{
187 // Reset number of clusters and the cluster array for this detector
188 AliDetector::ResetHits();
189}
190
191//____________________________________________
192void AliFMD::ResetDigits()
193{
194 //
195 // Reset number of digits and the digits array for this detector
196 AliDetector::ResetHits();
197 //
198}
fe4da5cc 199
d28dcc0d 200//-------------------------------------------------------------------------
fe4da5cc 201void AliFMD::Init()
202{
203 //
204 // Initialis the FMD after it has been built
205 Int_t i;
d28dcc0d 206 AliMC* pMC = AliMC::GetMC();
fe4da5cc 207 //
208 printf("\n");
209 for(i=0;i<35;i++) printf("*");
210 printf(" FMD_INIT ");
211 for(i=0;i<35;i++) printf("*");
212 printf("\n");
213 //
214 // Here the FMD initialisation code (if any!)
215 for(i=0;i<80;i++) printf("*");
216 printf("\n");
b9a2d5e4 217 //
218 //
0ac554ca 219 if (IsVersion()!=0)
220 fIdSens1=pMC->VolId("GRIN"); //Si sensetive volume
221 else
222 fIdSens1=pMC->VolId("GFSI"); //Si sensetive volume
d28dcc0d 223
fe4da5cc 224}
d28dcc0d 225//---------------------------------------------------------------------
b9a2d5e4 226void AliFMD::MakeBranch(Option_t* option, char *file)
d28dcc0d 227{
228 // Create Tree branches for the FMD.
b9a2d5e4 229 const Int_t kBufferSize = 4000;
d28dcc0d 230 char branchname[10];
231 sprintf(branchname,"%s",GetName());
fe4da5cc 232
b9a2d5e4 233 AliDetector::MakeBranch(option,file);
234
235 const char *cD = strstr(option,"D");
236
237 if (cD) {
238
239 gAlice->MakeBranchInTree(gAlice->TreeD(),
240 branchname, &fDigits, kBufferSize, file) ;
d28dcc0d 241
d28dcc0d 242 printf("Making Branch %s for digits\n",branchname);
b9a2d5e4 243 gAlice->TreeD()->Print();
d28dcc0d 244 }
245}
fe4da5cc 246
b9a2d5e4 247//_____________________________________________________________________________
248void AliFMD::SetTreeAddress()
249{
250 // Set branch address for the Hits and Digits Tree.
251 char branchname[30];
252 AliDetector::SetTreeAddress();
253
254 TBranch *branch;
255 TTree *treeD = gAlice->TreeD();
256
257
258 if (treeD) {
259 if (fDigits) {
260 branch = treeD->GetBranch(branchname);
261 if (branch) branch->SetAddress(&fDigits);
262 }
263
264 }
265 if(fSDigits)
266 fSDigits->Clear();
267
268 if (gAlice->TreeS() && fSDigits ) {
269 branch = gAlice->TreeS()->GetBranch("FMD");
270 if (branch) branch->SetAddress(&fSDigits) ;
271 }
272
273
274}
275
276//---------------------------------------------------------------------
277/*
278void AliFMD::SDigits2Digits()
279{
280 Int_t ibg=0, bgr=0;
281 Int_t nbgr_ev= 0;
282
283 if (ibg) {
284 printf("nbgr_ev %d\n",nbgr_ev);
285 // Hit2Digits(nbgr_ev,"Add"," ","galice_bgr.root");
286 }
287 else {
288 // Hit2Digits(nbgr_ev,"rien","","");
289 }
290
291}
292*/
d28dcc0d 293//---------------------------------------------------------------------
294
b9a2d5e4 295
296
d28dcc0d 297void AliFMD::Eta2Radius(Float_t eta, Float_t zDisk, Float_t *radius)
fe4da5cc 298{
b9a2d5e4 299 Float_t expEta=TMath::Exp(-eta);
300 Float_t theta=TMath::ATan(expEta);
301 theta=2.*theta;
302 Float_t rad=zDisk*(TMath::Tan(theta));
303 *radius=rad;
d28dcc0d 304
b9a2d5e4 305 printf(" eta %f radius %f\n", eta, rad);
fe4da5cc 306}
d28dcc0d 307
b9a2d5e4 308//---------------------------------------------------------------------
309
310void AliFMD::Hits2SDigits(){
311#ifdef DEBUG
312 cout<<"ALiFMD::Hits2SDigits> start...\n";
313#endif
314 char * fileSDigits = 0 ;
315 char * fileHeader=0 ;
316 AliFMDSDigitizer * sd = new AliFMDSDigitizer("mgalice.root","FMD.SDigit.root") ;
317 sd->Exec("") ;
318 sd->Print("");
319
320 delete sd ;
321}
322
323
324