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