Ion pump and bellows moved out by 15 cm to make space for forward
[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>
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"
b9a2d5e4 59#include <stdlib.h>
60
d28dcc0d 61
dc8af42e 62ClassImp (AliFMD)
b9a2d5e4 63 //_____________________________________________________________________________
dc8af42e 64AliFMD::AliFMD ():AliDetector ()
fe4da5cc 65{
66 //
67 // Default constructor for class AliFMD
68 //
dc8af42e 69 fIshunt = 0;
70 fHits = 0;
71 fDigits = 0;
72 fSDigits = 0;
73 fReconParticles=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);
89 fSDigits = new TClonesArray ("AliFMDdigit", 1000);
90 gAlice->AddHitList (fHits);
d1280e40 91
dc8af42e 92 fIshunt = 0;
93 fIdSens1 = 0;
d28dcc0d 94
dc8af42e 95 SetMarkerColor (kRed);
fe4da5cc 96}
d28dcc0d 97
dc8af42e 98//-----------------------------------------------------------------------------
99AliFMD::~AliFMD ()
d28dcc0d 100{
dc8af42e 101 if (fHits)
102 {
103 fHits->Delete ();
b9a2d5e4 104 delete fHits;
cae27883 105 fHits = 0;
dc8af42e 106 }
107 if (fDigits)
108 {
109 fDigits->Delete ();
cae27883 110 delete fDigits;
111 fDigits = 0;
dc8af42e 112 }
113 if (fSDigits)
114 {
115 fSDigits->Delete ();
cae27883 116 delete fSDigits;
117 fSDigits = 0;
dc8af42e 118 }
119 if (fReconParticles)
120 {
121 fReconParticles->Delete ();
122 delete fReconParticles;
123 fReconParticles = 0;
124 }
125
d28dcc0d 126}
dc8af42e 127
fe4da5cc 128//_____________________________________________________________________________
dc8af42e 129void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits)
fe4da5cc 130{
131 //
d28dcc0d 132 // Add a hit to the list
fe4da5cc 133 //
dc8af42e 134 TClonesArray & lhits = *fHits;
135 new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits);
fe4da5cc 136}
dc8af42e 137
fe4da5cc 138//_____________________________________________________________________________
dc8af42e 139void AliFMD::AddDigit (Int_t * digits)
b9a2d5e4 140{
141 // add a real digit - as coming from data
142
9e1a0ddb 143 // printf("AddDigit\n");
b9a2d5e4 144
dc8af42e 145 TClonesArray & ldigits = *fDigits;
146 new (ldigits[fNdigits++]) AliFMDdigit (digits);
b9a2d5e4 147
148}
dc8af42e 149
b9a2d5e4 150//_____________________________________________________________________________
dc8af42e 151void AliFMD::BuildGeometry ()
fe4da5cc 152{
153 //
154 // Build simple ROOT TNode geometry for event display
155 //
d28dcc0d 156 TNode *node, *top;
dc8af42e 157 const int kColorFMD = 7;
fe4da5cc 158 //
dc8af42e 159 top = gAlice->GetGeometry ()->GetNode ("alice");
fe4da5cc 160
161 // FMD define the different volumes
dc8af42e 162 new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0);
163
164 new TTUBE ("S_FMD0", "FMD volume 0", "void", 4.73, 17.7, 1.5);
165 top->cd ();
166 node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, 64, "");
167 node->SetLineColor (kColorFMD);
168 fNodes->Add (node);
169
170 new TTUBE ("S_FMD1", "FMD volume 1", "void", 23.4, 36., 1.5);
171 top->cd ();
172 node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, 85, "");
173 node->SetLineColor (kColorFMD);
174 fNodes->Add (node);
175
176 new TTUBE ("S_FMD2", "FMD volume 2", "void", 4.73, 17.7, 1.5);
177 top->cd ();
178 node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, -64, "");
179 node->SetLineColor (kColorFMD);
180 fNodes->Add (node);
181
182 new TTUBE ("S_FMD3", "FMD volume 3", "void", 23.4, 36., 1.5);
183 top->cd ();
184 node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, -85, "");
185 node->SetLineColor (kColorFMD);
186 fNodes->Add (node);
187
188 new TTUBE ("S_FMD4", "FMD volume 4", "void", 5, 15, 0.015);
189 top->cd ();
190 // node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
191 node = new TNode ("FMD4", "FMD4", "S_FMD4", 0, 0, -270, "");
192 node->SetLineColor (kColorFMD);
193 fNodes->Add (node);
194
195 /*
196 new TTUBE("S_FMD5","FMD volume 5","void",5,14,0.015);
197 top->cd();
198 node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,"");
199 node->SetLineColor(kColorFMD);
200 fNodes->Add(node);
201 */
fe4da5cc 202}
dc8af42e 203
fe4da5cc 204//_____________________________________________________________________________
dc8af42e 205Int_t AliFMD::DistanceToPrimitive (Int_t px, Int_t py)
fe4da5cc 206{
207 //
208 // Calculate the distance from the mouse to the FMD on the screen
209 // Dummy routine
210 //
211 return 9999;
212}
dc8af42e 213
b9a2d5e4 214//___________________________________________
dc8af42e 215void AliFMD::ResetHits ()
b9a2d5e4 216{
217 // Reset number of clusters and the cluster array for this detector
dc8af42e 218 AliDetector::ResetHits ();
b9a2d5e4 219}
220
221//____________________________________________
dc8af42e 222void AliFMD::ResetDigits ()
b9a2d5e4 223{
dc8af42e 224 //
225 // Reset number of digits and the digits array for this detector
226 AliDetector::ResetHits ();
227 //
b9a2d5e4 228}
fe4da5cc 229
d28dcc0d 230//-------------------------------------------------------------------------
dc8af42e 231void AliFMD::Init ()
fe4da5cc 232{
233 //
234 // Initialis the FMD after it has been built
235 Int_t i;
dc8af42e 236 AliMC *pMC = AliMC::GetMC ();
fe4da5cc 237 //
dc8af42e 238 if (fDebug)
239 {
240 printf ("\n%s: ", ClassName ());
241 for (i = 0; i < 35; i++)
242 printf ("*");
243 printf (" FMD_INIT ");
244 for (i = 0; i < 35; i++)
245 printf ("*");
246 printf ("\n%s: ", ClassName ());
247 //
248 // Here the FMD initialisation code (if any!)
249 for (i = 0; i < 80; i++)
250 printf ("*");
251 printf ("\n");
252 }
b9a2d5e4 253 //
254 //
dc8af42e 255 if (IsVersion () != 0)
256 fIdSens1 = pMC->VolId ("GRIN"); //Si sensetive volume
0ac554ca 257 else
dc8af42e 258 fIdSens1 = pMC->VolId ("GFSI"); //Si sensetive volume
d28dcc0d 259
fe4da5cc 260}
dc8af42e 261
d28dcc0d 262//---------------------------------------------------------------------
dc8af42e 263void AliFMD::MakeBranch (Option_t * option, const char *file)
d28dcc0d 264{
265 // Create Tree branches for the FMD.
d28dcc0d 266 char branchname[10];
dc8af42e 267 const Int_t kBufferSize = 16000;
268 sprintf (branchname, "%s", GetName ());
269
270 AliDetector::MakeBranch (option, file);
271 const char *cD = strstr(option,"D");
272 const char *cR = strstr(option,"R");
273 const char *cS = strstr(option,"S");
274
275 if (cS){
fe4da5cc 276
dc8af42e 277 MakeBranchInTree(gAlice->TreeS(),
278 branchname,&fSDigits,
279 kBufferSize, file);
280 }
281 if (cD){
b9a2d5e4 282
9e1a0ddb 283 MakeBranchInTree(gAlice->TreeD(),
dc8af42e 284 branchname,&fDigits,
285 kBufferSize, file);
286 }
287 if (cR){
288 MakeBranchInTree(gAlice->TreeR(),
289 branchname,&fReconParticles,
290 kBufferSize, file);
d28dcc0d 291 }
dc8af42e 292
d28dcc0d 293}
dc8af42e 294
b9a2d5e4 295//_____________________________________________________________________________
dc8af42e 296void AliFMD::SetTreeAddress ()
b9a2d5e4 297{
298 // Set branch address for the Hits and Digits Tree.
299 char branchname[30];
dc8af42e 300 AliDetector::SetTreeAddress ();
b9a2d5e4 301
302 TBranch *branch;
dc8af42e 303 TTree *treeD = gAlice->TreeD ();
b9a2d5e4 304
305
dc8af42e 306 if (treeD)
307 {
308 if (fDigits)
309 {
310 branch = treeD->GetBranch (branchname);
311 if (branch)
312 branch->SetAddress (&fDigits);
313 }
b9a2d5e4 314
dc8af42e 315 }
316 if (fSDigits)
317 fSDigits->Clear ();
318
319 if (gAlice->TreeS () && fSDigits)
320 {
321 branch = gAlice->TreeS ()->GetBranch ("FMD");
322 if (branch)
323 branch->SetAddress (&fSDigits);
324 }
b9a2d5e4 325
dc8af42e 326 if(fReconParticles)
327 fReconParticles->Clear();
328 if (gAlice->TreeR())
329 {
330 branch = gAlice->TreeR()->GetBranch("FMD");
331 if (branch) branch->SetAddress(&fReconParticles) ;
332 }
b9a2d5e4 333
334}
335
336//---------------------------------------------------------------------
dc8af42e 337
b9a2d5e4 338void AliFMD::SDigits2Digits()
339{
dc8af42e 340 cout<<"AliFMD::SDigits2Digits"<<endl;
341 if (fMerger) {
342 cout<<"AliFMD::SDigits2Digits fMerger"<<fMerger<<endl;
343 fMerger->Init();
344 cout<<"AliFMD::SDigits2Digits Init"<<endl;
345
346 fMerger->Digitise();
b9a2d5e4 347 }
348
349}
dc8af42e 350//---------------------------------------------------------------------
351void AliFMD::SetMerger(AliFMDMerger* merger)
352{
353// Set pointer to merger
354 fMerger = merger;
355}
356
357AliFMDMerger* AliFMD::Merger()
358{
359// Return pointer to merger
360 return fMerger;
361}
362
d28dcc0d 363//---------------------------------------------------------------------
364
b9a2d5e4 365
366
dc8af42e 367void
368AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
fe4da5cc 369{
dc8af42e 370 Float_t expEta = TMath::Exp (-eta);
371 Float_t theta = TMath::ATan (expEta);
372 theta = 2. * theta;
373 Float_t rad = zDisk * (TMath::Tan (theta));
374 *radius = rad;
375
376 if (fDebug)
377 printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
fe4da5cc 378}
d28dcc0d 379
b9a2d5e4 380//---------------------------------------------------------------------
381
dc8af42e 382void AliFMD::Hits2SDigits ()
383{
384
385 AliFMD *FMD = (AliFMD *) gAlice->GetDetector ("FMD");
386
387 if (fNevents == 0)
388 fNevents = (Int_t) gAlice->TreeE ()->GetEntries ();
389
390 for (Int_t ievent = 0; ievent < fNevents; ievent++)
391 {
392 gAlice->GetEvent (ievent);
393 if (gAlice->TreeH () == 0)
394 return;
395 if (gAlice->TreeS () == 0)
396 gAlice->MakeTree ("S");
397
398
b9a2d5e4 399
dc8af42e 400 Int_t nSdigits = 0;
401
402 //Make branches
403 char branchname[20];
404 sprintf (branchname, "%s", FMD->GetName ());
405 //Make branch for digits
406 FMD->MakeBranch ("S");
407
408
409 //Now made SDigits from hits, for PHOS it is the same
410 Int_t volume, sector, ring, charge;
411 Float_t e;
412 Float_t de[10][20][150];
413 Int_t ivol, isec, iring;
414 Int_t hit, nbytes;
415 TParticle *particle;
416 AliFMDhit *fmdHit;
417 TClonesArray *FMDhits = FMD->Hits ();
418
419 // Event ------------------------- LOOP
420
421 for (ivol = 1; ivol <= 5; ivol++)
422 for (isec = 1; isec <= 16; isec++)
423 for (iring = 1; iring <= 128; iring++)
424 de[ivol][isec][iring] = 0;
425
426 if (FMD)
427 {
428 FMDhits = FMD->Hits ();
429 TTree *TH = gAlice->TreeH ();
430 Stat_t ntracks = TH->GetEntries ();
431 for (Int_t track = 0; track < ntracks; track++)
432 {
433 gAlice->ResetHits ();
434 nbytes += TH->GetEvent (track);
435 particle = gAlice->Particle (track);
436 Int_t nhits = FMDhits->GetEntriesFast ();
437
438 for (hit = 0; hit < nhits; hit++)
439 {
440 fmdHit = (AliFMDhit *) FMDhits->UncheckedAt (hit);
441
442 volume = fmdHit->Volume ();
443 sector = fmdHit->NumberOfSector ();
444 ring = fmdHit->NumberOfRing ();
445 e = fmdHit->Edep ();
446 de[volume][sector][ring] = de[volume][sector][ring] + e;
447 } //hit loop
448 } //track loop
449 } //if FMD
450
451
452 Int_t digit[5];
453 Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6;
454 for (ivol = 1; ivol <= 5; ivol++)
455 {
456 for (isec = 1; isec <= 16; isec++)
457 {
458 for (iring = 1; iring <= 128; iring++)
459 {
460 digit[0] = ivol;
461 digit[1] = isec;
462 digit[2] = iring;
463 charge = Int_t (de[ivol][isec][iring] / I);
464 digit[3] = charge;
465 // if (charge!=0) cout<<" charge "<<charge<<endl;
466 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
467 //1024 ADC channels
468 Float_t channelWidth = (22400 * 30) / 1024;
469 digit[4] = Int_t (digit[3] / channelWidth);
470
471 new ((*fSDigits)[nSdigits++]) AliFMDdigit (digit);
472
473 } // iring loop
474 } //sector loop
475 } // volume loop
476
477 gAlice->TreeS ()->Fill ();
478 gAlice->TreeS ()->Print ();
479
480 } //event loop
b9a2d5e4 481
dc8af42e 482}
483//-----------------------------------------------------------------------
484
485void AliFMD::Digits2Reco()
486{
487#ifdef DEBUG
488 cout<<"ALiFMD::Digits2Reco> start...";
489#endif
490 char * fileReconParticles=0;
491 char * fileHeader=0;
492 AliFMDReconstruction * reconstruction =
493 new AliFMDReconstruction(fileHeader,fileReconParticles) ;
494 fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
495 reconstruction->Exec(fReconParticles,"");
496 delete reconstruction;
497}
b9a2d5e4 498