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