1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
15 //////////////////////////////////////////////////////////////////////////////
17 // Forward Multiplicity Detector based on Silicon plates //
18 // This class contains the base procedures for the Forward Multiplicity //
20 // Detector consists of 6 Si volumes covered pseudorapidity interval //
21 // from 1.6 to 6.0. //
25 <img src="gif/AliFMDClass.gif">
28 <font size=+2 color=red>
29 <p>The responsible person for this module is
30 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
37 ///////////////////////////////////////////////////////////////////////////////
41 #include <TGeometry.h>
47 #include <TClonesArray.h>
48 #include <TLorentzVector.h>
52 #include "AliDetector.h"
56 #include "AliFMDhit.h"
57 #include "AliFMDdigit.h"
58 #include "AliFMDReconstruction.h"
63 //_____________________________________________________________________________
64 AliFMD::AliFMD ():AliDetector ()
67 // Default constructor for class AliFMD
76 //_____________________________________________________________________________
77 AliFMD::AliFMD (const char *name, const char *title):
78 AliDetector (name, title)
81 // Standard constructor for Forward Multiplicity Detector
85 // Initialise Hit array
86 fHits = new TClonesArray ("AliFMDhit", 1000);
87 // Digits for each Si disk
88 fDigits = new TClonesArray ("AliFMDdigit", 1000);
89 fSDigits = new TClonesArray ("AliFMDdigit", 1000);
90 gAlice->AddHitList (fHits);
95 SetMarkerColor (kRed);
98 //-----------------------------------------------------------------------------
121 fReconParticles->Delete ();
122 delete fReconParticles;
128 //_____________________________________________________________________________
129 void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits)
132 // Add a hit to the list
134 TClonesArray & lhits = *fHits;
135 new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits);
138 //_____________________________________________________________________________
139 void AliFMD::AddDigit (Int_t * digits)
141 // add a real digit - as coming from data
143 // printf("AddDigit\n");
145 TClonesArray & ldigits = *fDigits;
146 new (ldigits[fNdigits++]) AliFMDdigit (digits);
150 //_____________________________________________________________________________
151 void AliFMD::BuildGeometry ()
154 // Build simple ROOT TNode geometry for event display
157 const int kColorFMD = 7;
159 top = gAlice->GetGeometry ()->GetNode ("alice");
161 // FMD define the different volumes
162 new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0);
164 new TTUBE ("S_FMD0", "FMD volume 0", "void", 4.73, 17.7, 1.5);
166 node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, 64, "");
167 node->SetLineColor (kColorFMD);
170 new TTUBE ("S_FMD1", "FMD volume 1", "void", 23.4, 36., 1.5);
172 node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, 85, "");
173 node->SetLineColor (kColorFMD);
176 new TTUBE ("S_FMD2", "FMD volume 2", "void", 4.73, 17.7, 1.5);
178 node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, -64, "");
179 node->SetLineColor (kColorFMD);
182 new TTUBE ("S_FMD3", "FMD volume 3", "void", 23.4, 36., 1.5);
184 node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, -85, "");
185 node->SetLineColor (kColorFMD);
188 new TTUBE ("S_FMD4", "FMD volume 4", "void", 5, 15, 0.015);
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);
196 new TTUBE("S_FMD5","FMD volume 5","void",5,14,0.015);
198 node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,"");
199 node->SetLineColor(kColorFMD);
204 //_____________________________________________________________________________
205 Int_t AliFMD::DistanceToPrimitive (Int_t px, Int_t py)
208 // Calculate the distance from the mouse to the FMD on the screen
214 //___________________________________________
215 void AliFMD::ResetHits ()
217 // Reset number of clusters and the cluster array for this detector
218 AliDetector::ResetHits ();
221 //____________________________________________
222 void AliFMD::ResetDigits ()
225 // Reset number of digits and the digits array for this detector
226 AliDetector::ResetHits ();
230 //-------------------------------------------------------------------------
234 // Initialis the FMD after it has been built
236 AliMC *pMC = AliMC::GetMC ();
240 printf ("\n%s: ", ClassName ());
241 for (i = 0; i < 35; i++)
243 printf (" FMD_INIT ");
244 for (i = 0; i < 35; i++)
246 printf ("\n%s: ", ClassName ());
248 // Here the FMD initialisation code (if any!)
249 for (i = 0; i < 80; i++)
255 if (IsVersion () != 0)
256 fIdSens1 = pMC->VolId ("GRIN"); //Si sensetive volume
258 fIdSens1 = pMC->VolId ("GFSI"); //Si sensetive volume
262 //---------------------------------------------------------------------
263 void AliFMD::MakeBranch (Option_t * option, const char *file)
265 // Create Tree branches for the FMD.
267 const Int_t kBufferSize = 16000;
268 sprintf (branchname, "%s", GetName ());
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");
277 MakeBranchInTree(gAlice->TreeS(),
278 branchname,&fSDigits,
283 MakeBranchInTree(gAlice->TreeD(),
288 MakeBranchInTree(gAlice->TreeR(),
289 branchname,&fReconParticles,
295 //_____________________________________________________________________________
296 void AliFMD::SetTreeAddress ()
298 // Set branch address for the Hits and Digits Tree.
300 AliDetector::SetTreeAddress ();
303 TTree *treeD = gAlice->TreeD ();
310 branch = treeD->GetBranch (branchname);
312 branch->SetAddress (&fDigits);
319 if (gAlice->TreeS () && fSDigits)
321 branch = gAlice->TreeS ()->GetBranch ("FMD");
323 branch->SetAddress (&fSDigits);
327 fReconParticles->Clear();
330 branch = gAlice->TreeR()->GetBranch("FMD");
331 if (branch) branch->SetAddress(&fReconParticles) ;
336 //---------------------------------------------------------------------
338 void AliFMD::SDigits2Digits()
340 cout<<"AliFMD::SDigits2Digits"<<endl;
342 cout<<"AliFMD::SDigits2Digits fMerger"<<fMerger<<endl;
344 cout<<"AliFMD::SDigits2Digits Init"<<endl;
350 //---------------------------------------------------------------------
351 void AliFMD::SetMerger(AliFMDMerger* merger)
353 // Set pointer to merger
357 AliFMDMerger* AliFMD::Merger()
359 // Return pointer to merger
363 //---------------------------------------------------------------------
368 AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
370 Float_t expEta = TMath::Exp (-eta);
371 Float_t theta = TMath::ATan (expEta);
373 Float_t rad = zDisk * (TMath::Tan (theta));
377 printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
380 //---------------------------------------------------------------------
382 void AliFMD::Hits2SDigits ()
385 AliFMD *FMD = (AliFMD *) gAlice->GetDetector ("FMD");
388 fNevents = (Int_t) gAlice->TreeE ()->GetEntries ();
390 for (Int_t ievent = 0; ievent < fNevents; ievent++)
392 gAlice->GetEvent (ievent);
393 if (gAlice->TreeH () == 0)
395 if (gAlice->TreeS () == 0)
396 gAlice->MakeTree ("S");
404 sprintf (branchname, "%s", FMD->GetName ());
405 //Make branch for digits
406 FMD->MakeBranch ("S");
409 //Now made SDigits from hits, for PHOS it is the same
410 Int_t volume, sector, ring, charge;
412 Float_t de[10][20][150];
413 Int_t ivol, isec, iring;
417 TClonesArray *FMDhits = FMD->Hits ();
419 // Event ------------------------- LOOP
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;
428 FMDhits = FMD->Hits ();
429 TTree *TH = gAlice->TreeH ();
430 Stat_t ntracks = TH->GetEntries ();
431 for (Int_t track = 0; track < ntracks; track++)
433 gAlice->ResetHits ();
434 nbytes += TH->GetEvent (track);
435 particle = gAlice->Particle (track);
436 Int_t nhits = FMDhits->GetEntriesFast ();
438 for (hit = 0; hit < nhits; hit++)
440 fmdHit = (AliFMDhit *) FMDhits->UncheckedAt (hit);
442 volume = fmdHit->Volume ();
443 sector = fmdHit->NumberOfSector ();
444 ring = fmdHit->NumberOfRing ();
446 de[volume][sector][ring] = de[volume][sector][ring] + e;
453 Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6;
454 for (ivol = 1; ivol <= 5; ivol++)
456 for (isec = 1; isec <= 16; isec++)
458 for (iring = 1; iring <= 128; iring++)
463 charge = Int_t (de[ivol][isec][iring] / I);
465 // if (charge!=0) cout<<" charge "<<charge<<endl;
466 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
468 Float_t channelWidth = (22400 * 30) / 1024;
469 digit[4] = Int_t (digit[3] / channelWidth);
471 new ((*fSDigits)[nSdigits++]) AliFMDdigit (digit);
477 gAlice->TreeS ()->Fill ();
478 gAlice->TreeS ()->Print ();
483 //-----------------------------------------------------------------------
485 void AliFMD::Digits2Reco()
488 cout<<"ALiFMD::Digits2Reco> start...";
490 char * fileReconParticles=0;
492 AliFMDReconstruction * reconstruction =
493 new AliFMDReconstruction(fileHeader,fileReconParticles) ;
494 fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
495 reconstruction->Exec(fReconParticles,"");
496 delete reconstruction;