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 **************************************************************************/
18 //_________________________________________________________________________
19 // This is a TTask that constructs SDigits out of Hits
20 // A Summable Digits is the sum of all hits in a cell
21 // A threshold is applied
23 //-- Author: Alla Maevskaia(INR)
24 //////////////////////////////////////////////////////////////////////////////
26 // --- Standard library ---
27 #include <Riostream.h>
30 // --- ROOT system ---
37 #include <TVirtualMC.h>
39 // --- AliRoot header files ---
40 #include "AliConfig.h"
41 #include "AliDetector.h"
43 #include "AliFMDSDigitizer.h"
44 #include "AliFMDdigit.h"
45 #include "AliFMDhit.h"
47 #include "AliLoader.h"
49 #include "AliRunLoader.h"
52 ClassImp(AliFMDSDigitizer)
54 //____________________________________________________________________________
55 AliFMDSDigitizer::AliFMDSDigitizer():TTask("AliFMDSDigitizer","")
64 //____________________________________________________________________________
65 AliFMDSDigitizer::AliFMDSDigitizer(char* HeaderFile,char *SdigitsFile ):TTask("AliFMDSDigitizer","")
67 fNevents = 0 ; // Number of events to digitize, 0 means all evens in current file
68 // add Task to //root/Tasks folder
69 fRunLoader = AliRunLoader::Open(HeaderFile);//Load event in default folder
70 if (fRunLoader == 0x0)
72 Fatal("AliFMDSDigitizer","Can not open session. Header File is %s ",HeaderFile);
73 return;//never reached
75 AliLoader* gime = fRunLoader->GetLoader("FMDLoader");
78 Fatal("AliFMDSDigitizer","Can not find FMD (loader) in specified event");
79 return;//never reached
81 //add Task to //root/Tasks folder
82 gime->PostSDigitizer(this);
85 //____________________________________________________________________________
86 AliFMDSDigitizer::~AliFMDSDigitizer()
91 //---------------------------------------------------------------------
92 void AliFMDSDigitizer::SetRingsSi1(Int_t ringsSi1)
96 void AliFMDSDigitizer::SetSectorsSi1(Int_t sectorsSi1)
98 fSectorsSi1=sectorsSi1;
100 void AliFMDSDigitizer::SetRingsSi2(Int_t ringsSi2)
104 void AliFMDSDigitizer::SetSectorsSi2(Int_t sectorsSi2)
106 fSectorsSi2=sectorsSi2;
109 //____________________________________________________________________________
110 void AliFMDSDigitizer::Exec(Option_t *option)
112 Int_t NumberOfRings[5]=
113 {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1};
114 Int_t NumberOfSectors[5]=
115 {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1};
119 Error("Exec","Run Loader loader is NULL - Session not opened");
122 AliLoader* gime = fRunLoader->GetLoader("FMDLoader");
125 Fatal("AliFMDReconstruction","Can not find FMD (loader) in specified event");
126 return;//never reached
129 fRunLoader->LoadgAlice();
130 fRunLoader->LoadHeader();
131 fRunLoader->LoadKinematics("READ");
135 retval = gime->LoadHits("READ");
138 Error("Exec","Error occured while loading hits. Exiting.");
143 // Initialise Hit array
144 fHits = new TClonesArray ("AliFMDhit", 1000);
145 fSDigits = new TClonesArray ("AliFMDdigit", 1000);
147 AliFMD *FMD = (AliFMD *) gAlice->GetDetector ("FMD");
150 fNevents = (Int_t) fRunLoader->TreeE ()->GetEntries ();
152 for (Int_t ievent = 0; ievent < fNevents; ievent++)
154 fRunLoader->GetEvent (ievent);
156 TTree* TH = gime->TreeH();
159 Error("Exec","Can not get TreeH");
162 if (gime->TreeS () == 0) gime->MakeTree("S");
164 //Make branch for digits
165 FMD->MakeBranch ("S");
166 //Now made SDigits from hits, for PHOS it is the same
167 Int_t volume, sector, ring, charge;
169 Float_t de[10][50][150];
170 Int_t ivol, isec, iring;
174 TClonesArray *FMDhits = FMD->Hits ();
176 // Event ------------------------- LOOP
178 for (ivol = 0; ivol < 10; ivol++)
179 for (isec = 0; isec < 50; isec++)
180 for (iring = 0; iring < 150; iring++)
181 de[ivol][isec][iring] = 0;
185 FMDhits = FMD->Hits ();
188 Stat_t ntracks = TH->GetEntries ();
189 for (Int_t track = 0; track < ntracks; track++)
191 gAlice->ResetHits ();
192 nbytes += TH->GetEvent(track);
193 particle = fRunLoader->Stack()->Particle (track);
194 Int_t nhits = FMDhits->GetEntriesFast ();
196 for (hit = 0; hit < nhits; hit++)
198 fmdHit = (AliFMDhit *) FMDhits->UncheckedAt (hit);
200 volume = fmdHit->Volume ();
201 sector = fmdHit->NumberOfSector ();
202 ring = fmdHit->NumberOfRing ();
204 de[volume][sector][ring] += e;
211 Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6;
212 for (ivol = 1; ivol < 6; ivol++)
214 for (isec = 1; isec <= NumberOfSectors[ivol-1]; isec++)
216 for (iring = 1; iring <= NumberOfRings[ivol-1]; iring++)
221 charge = Int_t (de[ivol][isec][iring] / I);
224 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
226 Float_t channelWidth = (22400 * 30) / 1024;
228 digit[4] = Int_t (digit[3] / channelWidth);
229 FMD->AddSDigit(digit);
235 gime->TreeS()->Reset();
236 gime->TreeS()->Fill();
237 gime->WriteSDigits("OVERWRITE");
243 //__________________________________________________________________
244 void AliFMDSDigitizer::SetSDigitsFile(char * file ){
245 if(!fSDigitsFile.IsNull())
246 cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ;
249 //__________________________________________________________________
250 void AliFMDSDigitizer::Print(Option_t* option)const
252 cout << "------------------- "<< GetName() << " -------------" << endl ;
253 if(fSDigitsFile.IsNull())
254 cout << " Writing SDigitis to file galice.root "<< endl ;
256 cout << " Writing SDigitis to file " << (char*) fSDigitsFile.Data() << endl ;