]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDSDigitizer.cxx
Minor changes
[u/mrichter/AliRoot.git] / FMD / AliFMDSDigitizer.cxx
CommitLineData
963d4d30 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 **************************************************************************/
15
88cb7938 16/* $Id$ */
17
963d4d30 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
22//
23//-- Author: Alla Maevskaia(INR)
24//////////////////////////////////////////////////////////////////////////////
25
963d4d30 26// --- Standard library ---
88cb7938 27#include <Riostream.h>
28#include <stdlib.h>
963d4d30 29
88cb7938 30// --- ROOT system ---
31#include <TFile.h>
32#include <TFolder.h>
33#include <TROOT.h>
34#include <TSystem.h>
35#include <TTask.h>
36#include <TTree.h>
37#include <TVirtualMC.h>
963d4d30 38
88cb7938 39// --- AliRoot header files ---
40#include "AliConfig.h"
41#include "AliDetector.h"
42#include "AliFMD.h"
43#include "AliFMDSDigitizer.h"
963d4d30 44#include "AliFMDdigit.h"
45#include "AliFMDhit.h"
963d4d30 46#include "AliFMDv1.h"
88cb7938 47#include "AliLoader.h"
963d4d30 48#include "AliRun.h"
88cb7938 49#include "AliRunLoader.h"
50#include "AliStack.h"
963d4d30 51
52ClassImp(AliFMDSDigitizer)
53
963d4d30 54//____________________________________________________________________________
55 AliFMDSDigitizer::AliFMDSDigitizer():TTask("AliFMDSDigitizer","")
56{
37c55dc0 57 // ctor
58 fNevents = 0 ;
59 fSDigits = 0 ;
60 fHits = 0 ;
88cb7938 61 fRunLoader = 0;
963d4d30 62}
37c55dc0 63
963d4d30 64//____________________________________________________________________________
88cb7938 65AliFMDSDigitizer::AliFMDSDigitizer(char* HeaderFile,char *SdigitsFile ):TTask("AliFMDSDigitizer","")
963d4d30 66{
37c55dc0 67 fNevents = 0 ; // Number of events to digitize, 0 means all evens in current file
68 // add Task to //root/Tasks folder
88cb7938 69 fRunLoader = AliRunLoader::Open(HeaderFile);//Load event in default folder
70 if (fRunLoader == 0x0)
71 {
72 Fatal("AliFMDSDigitizer","Can not open session. Header File is %s ",HeaderFile);
73 return;//never reached
74 }
75 AliLoader* gime = fRunLoader->GetLoader("FMDLoader");
76 if (gime == 0x0)
77 {
78 Fatal("AliFMDSDigitizer","Can not find FMD (loader) in specified event");
79 return;//never reached
80 }
81 //add Task to //root/Tasks folder
82 gime->PostSDigitizer(this);
963d4d30 83}
84
85//____________________________________________________________________________
86 AliFMDSDigitizer::~AliFMDSDigitizer()
87{
88 // dtor
89}
90
37c55dc0 91//---------------------------------------------------------------------
92void AliFMDSDigitizer::SetRingsSi1(Int_t ringsSi1)
93{
94 fRingsSi1=ringsSi1;
95}
96void AliFMDSDigitizer::SetSectorsSi1(Int_t sectorsSi1)
97{
98 fSectorsSi1=sectorsSi1;
99}
100void AliFMDSDigitizer::SetRingsSi2(Int_t ringsSi2)
101{
102 fRingsSi2=ringsSi2;
103}
104void AliFMDSDigitizer::SetSectorsSi2(Int_t sectorsSi2)
105{
106 fSectorsSi2=sectorsSi2;
107}
963d4d30 108
109//____________________________________________________________________________
88cb7938 110void AliFMDSDigitizer::Exec(Option_t *option)
111 {
37c55dc0 112 Int_t NumberOfRings[5]=
113 {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1};
114 Int_t NumberOfSectors[5]=
115 {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1};
116
88cb7938 117 if (fRunLoader)
118 {
119 Error("Exec","Run Loader loader is NULL - Session not opened");
120 return;
121 }
122 AliLoader* gime = fRunLoader->GetLoader("FMDLoader");
123 if (gime == 0x0)
124 {
125 Fatal("AliFMDReconstruction","Can not find FMD (loader) in specified event");
126 return;//never reached
127 }
128
129 fRunLoader->LoadgAlice();
130 fRunLoader->LoadHeader();
131 fRunLoader->LoadKinematics("READ");
132
133 Int_t retval;
134
135 retval = gime->LoadHits("READ");
136 if (retval)
137 {
138 Error("Exec","Error occured while loading hits. Exiting.");
139 return;
140 }
141
142
37c55dc0 143 // Initialise Hit array
144 fHits = new TClonesArray ("AliFMDhit", 1000);
145 fSDigits = new TClonesArray ("AliFMDdigit", 1000);
146
147 AliFMD *FMD = (AliFMD *) gAlice->GetDetector ("FMD");
148
149 if (fNevents == 0)
88cb7938 150 fNevents = (Int_t) fRunLoader->TreeE ()->GetEntries ();
37c55dc0 151
152 for (Int_t ievent = 0; ievent < fNevents; ievent++)
153 {
88cb7938 154 fRunLoader->GetEvent (ievent);
37c55dc0 155
88cb7938 156 TTree* TH = gime->TreeH();
157 if (TH == 0x0)
158 {
159 Error("Exec","Can not get TreeH");
160 return;
161 }
162 if (gime->TreeS () == 0) gime->MakeTree("S");
37c55dc0 163
37c55dc0 164 //Make branch for digits
88cb7938 165 FMD->MakeBranch ("S");
166 //Now made SDigits from hits, for PHOS it is the same
37c55dc0 167 Int_t volume, sector, ring, charge;
168 Float_t e;
169 Float_t de[10][50][150];
170 Int_t ivol, isec, iring;
171 Int_t hit, nbytes;
172 TParticle *particle;
173 AliFMDhit *fmdHit;
174 TClonesArray *FMDhits = FMD->Hits ();
175
176 // Event ------------------------- LOOP
177
178 for (ivol = 0; ivol < 10; ivol++)
88cb7938 179 for (isec = 0; isec < 50; isec++)
180 for (iring = 0; iring < 150; iring++)
181 de[ivol][isec][iring] = 0;
37c55dc0 182
183 if (FMD)
88cb7938 184 {
185 FMDhits = FMD->Hits ();
186
187
188 Stat_t ntracks = TH->GetEntries ();
189 for (Int_t track = 0; track < ntracks; track++)
190 {
191 gAlice->ResetHits ();
192 nbytes += TH->GetEvent(track);
193 particle = fRunLoader->Stack()->Particle (track);
194 Int_t nhits = FMDhits->GetEntriesFast ();
195
196 for (hit = 0; hit < nhits; hit++)
197 {
198 fmdHit = (AliFMDhit *) FMDhits->UncheckedAt (hit);
199
200 volume = fmdHit->Volume ();
201 sector = fmdHit->NumberOfSector ();
202 ring = fmdHit->NumberOfRing ();
203 e = fmdHit->Edep ();
204 de[volume][sector][ring] += e;
205 } //hit loop
206 } //track loop
207 } //if FMD
37c55dc0 208
209
210 Int_t digit[5];
88cb7938 211 Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6;
37c55dc0 212 for (ivol = 1; ivol < 6; ivol++)
88cb7938 213 {
214 for (isec = 1; isec <= NumberOfSectors[ivol-1]; isec++)
215 {
216 for (iring = 1; iring <= NumberOfRings[ivol-1]; iring++)
217 {
218 digit[0] = ivol;
219 digit[1] = isec;
220 digit[2] = iring;
221 charge = Int_t (de[ivol][isec][iring] / I);
222
223 digit[3] = charge;
224 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
225 //1024 ADC channels
226 Float_t channelWidth = (22400 * 30) / 1024;
227
228 digit[4] = Int_t (digit[3] / channelWidth);
229 FMD->AddSDigit(digit);
230
231 } // iring loop
232 } //sector loop
233 } // volume loop
37c55dc0 234
88cb7938 235 gime->TreeS()->Reset();
236 gime->TreeS()->Fill();
237 gime->WriteSDigits("OVERWRITE");
238 } //event loop
37c55dc0 239
963d4d30 240
241}
37c55dc0 242
963d4d30 243//__________________________________________________________________
244void AliFMDSDigitizer::SetSDigitsFile(char * file ){
245 if(!fSDigitsFile.IsNull())
246 cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ;
247 fSDigitsFile=file ;
248}
249//__________________________________________________________________
37c55dc0 250void AliFMDSDigitizer::Print(Option_t* option)const
251{
963d4d30 252 cout << "------------------- "<< GetName() << " -------------" << endl ;
253 if(fSDigitsFile.IsNull())
254 cout << " Writing SDigitis to file galice.root "<< endl ;
255 else
256 cout << " Writing SDigitis to file " << (char*) fSDigitsFile.Data() << endl ;
257
258}