]>
Commit | Line | Data |
---|---|---|
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 | |
52 | ClassImp(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 | //____________________________________________________________________________ |
85a5290f | 65 | AliFMDSDigitizer::AliFMDSDigitizer(const 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 | |
1584c57e | 89 | AliLoader* gime = fRunLoader->GetLoader("FMDLoader"); |
90 | gime->CleanSDigitizer(); | |
963d4d30 | 91 | } |
92 | ||
37c55dc0 | 93 | //--------------------------------------------------------------------- |
94 | void AliFMDSDigitizer::SetRingsSi1(Int_t ringsSi1) | |
95 | { | |
96 | fRingsSi1=ringsSi1; | |
97 | } | |
98 | void AliFMDSDigitizer::SetSectorsSi1(Int_t sectorsSi1) | |
99 | { | |
100 | fSectorsSi1=sectorsSi1; | |
101 | } | |
102 | void AliFMDSDigitizer::SetRingsSi2(Int_t ringsSi2) | |
103 | { | |
104 | fRingsSi2=ringsSi2; | |
105 | } | |
106 | void AliFMDSDigitizer::SetSectorsSi2(Int_t sectorsSi2) | |
107 | { | |
108 | fSectorsSi2=sectorsSi2; | |
109 | } | |
963d4d30 | 110 | |
111 | //____________________________________________________________________________ | |
88cb7938 | 112 | void AliFMDSDigitizer::Exec(Option_t *option) |
113 | { | |
37c55dc0 | 114 | Int_t NumberOfRings[5]= |
115 | {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1}; | |
116 | Int_t NumberOfSectors[5]= | |
117 | {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1}; | |
118 | ||
88cb7938 | 119 | if (fRunLoader) |
120 | { | |
121 | Error("Exec","Run Loader loader is NULL - Session not opened"); | |
122 | return; | |
123 | } | |
124 | AliLoader* gime = fRunLoader->GetLoader("FMDLoader"); | |
125 | if (gime == 0x0) | |
126 | { | |
127 | Fatal("AliFMDReconstruction","Can not find FMD (loader) in specified event"); | |
128 | return;//never reached | |
129 | } | |
130 | ||
f540341d | 131 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); |
132 | if (!fRunLoader->TreeE()) fRunLoader->LoadHeader(); | |
133 | if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics("READ"); | |
88cb7938 | 134 | |
135 | Int_t retval; | |
136 | ||
137 | retval = gime->LoadHits("READ"); | |
138 | if (retval) | |
139 | { | |
140 | Error("Exec","Error occured while loading hits. Exiting."); | |
141 | return; | |
142 | } | |
143 | ||
144 | ||
37c55dc0 | 145 | // Initialise Hit array |
146 | fHits = new TClonesArray ("AliFMDhit", 1000); | |
147 | fSDigits = new TClonesArray ("AliFMDdigit", 1000); | |
148 | ||
149 | AliFMD *FMD = (AliFMD *) gAlice->GetDetector ("FMD"); | |
150 | ||
151 | if (fNevents == 0) | |
88cb7938 | 152 | fNevents = (Int_t) fRunLoader->TreeE ()->GetEntries (); |
37c55dc0 | 153 | |
154 | for (Int_t ievent = 0; ievent < fNevents; ievent++) | |
155 | { | |
88cb7938 | 156 | fRunLoader->GetEvent (ievent); |
37c55dc0 | 157 | |
88cb7938 | 158 | TTree* TH = gime->TreeH(); |
159 | if (TH == 0x0) | |
160 | { | |
161 | Error("Exec","Can not get TreeH"); | |
162 | return; | |
163 | } | |
164 | if (gime->TreeS () == 0) gime->MakeTree("S"); | |
37c55dc0 | 165 | |
37c55dc0 | 166 | //Make branch for digits |
88cb7938 | 167 | FMD->MakeBranch ("S"); |
168 | //Now made SDigits from hits, for PHOS it is the same | |
37c55dc0 | 169 | Int_t volume, sector, ring, charge; |
170 | Float_t e; | |
171 | Float_t de[10][50][150]; | |
172 | Int_t ivol, isec, iring; | |
173 | Int_t hit, nbytes; | |
174 | TParticle *particle; | |
175 | AliFMDhit *fmdHit; | |
176 | TClonesArray *FMDhits = FMD->Hits (); | |
177 | ||
178 | // Event ------------------------- LOOP | |
179 | ||
180 | for (ivol = 0; ivol < 10; ivol++) | |
88cb7938 | 181 | for (isec = 0; isec < 50; isec++) |
182 | for (iring = 0; iring < 150; iring++) | |
183 | de[ivol][isec][iring] = 0; | |
37c55dc0 | 184 | |
185 | if (FMD) | |
88cb7938 | 186 | { |
187 | FMDhits = FMD->Hits (); | |
188 | ||
189 | ||
190 | Stat_t ntracks = TH->GetEntries (); | |
191 | for (Int_t track = 0; track < ntracks; track++) | |
192 | { | |
193 | gAlice->ResetHits (); | |
194 | nbytes += TH->GetEvent(track); | |
195 | particle = fRunLoader->Stack()->Particle (track); | |
196 | Int_t nhits = FMDhits->GetEntriesFast (); | |
197 | ||
198 | for (hit = 0; hit < nhits; hit++) | |
199 | { | |
200 | fmdHit = (AliFMDhit *) FMDhits->UncheckedAt (hit); | |
201 | ||
202 | volume = fmdHit->Volume (); | |
203 | sector = fmdHit->NumberOfSector (); | |
204 | ring = fmdHit->NumberOfRing (); | |
205 | e = fmdHit->Edep (); | |
206 | de[volume][sector][ring] += e; | |
207 | } //hit loop | |
208 | } //track loop | |
209 | } //if FMD | |
37c55dc0 | 210 | |
211 | ||
212 | Int_t digit[5]; | |
88cb7938 | 213 | Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6; |
37c55dc0 | 214 | for (ivol = 1; ivol < 6; ivol++) |
88cb7938 | 215 | { |
216 | for (isec = 1; isec <= NumberOfSectors[ivol-1]; isec++) | |
217 | { | |
218 | for (iring = 1; iring <= NumberOfRings[ivol-1]; iring++) | |
219 | { | |
220 | digit[0] = ivol; | |
221 | digit[1] = isec; | |
222 | digit[2] = iring; | |
223 | charge = Int_t (de[ivol][isec][iring] / I); | |
224 | ||
225 | digit[3] = charge; | |
226 | //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV) | |
227 | //1024 ADC channels | |
228 | Float_t channelWidth = (22400 * 30) / 1024; | |
229 | ||
230 | digit[4] = Int_t (digit[3] / channelWidth); | |
231 | FMD->AddSDigit(digit); | |
232 | ||
233 | } // iring loop | |
234 | } //sector loop | |
235 | } // volume loop | |
37c55dc0 | 236 | |
88cb7938 | 237 | gime->TreeS()->Reset(); |
238 | gime->TreeS()->Fill(); | |
239 | gime->WriteSDigits("OVERWRITE"); | |
240 | } //event loop | |
37c55dc0 | 241 | |
963d4d30 | 242 | |
243 | } | |
37c55dc0 | 244 | |
963d4d30 | 245 | //__________________________________________________________________ |
246 | void AliFMDSDigitizer::SetSDigitsFile(char * file ){ | |
247 | if(!fSDigitsFile.IsNull()) | |
248 | cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ; | |
249 | fSDigitsFile=file ; | |
250 | } | |
251 | //__________________________________________________________________ | |
37c55dc0 | 252 | void AliFMDSDigitizer::Print(Option_t* option)const |
253 | { | |
963d4d30 | 254 | cout << "------------------- "<< GetName() << " -------------" << endl ; |
255 | if(fSDigitsFile.IsNull()) | |
256 | cout << " Writing SDigitis to file galice.root "<< endl ; | |
257 | else | |
258 | cout << " Writing SDigitis to file " << (char*) fSDigitsFile.Data() << endl ; | |
259 | ||
260 | } |