]>
Commit | Line | Data |
---|---|---|
990119d6 | 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 | ||
c093f031 | 16 | |
990119d6 | 17 | /* $Id$ */ |
18 | ||
19 | //_________________________________________________________________________ | |
7acf6008 | 20 | // This is a TTask that makes SDigits out of Hits |
7b7c1533 | 21 | // The name of the TTask is also the title of the branch that will contain |
22 | // the created SDigits | |
23 | // The title of the TTAsk is the name of the file that contains the hits from | |
24 | // which the SDigits are created | |
7acf6008 | 25 | // A Summable Digits is the sum of all hits originating |
26 | // from one primary in one active cell | |
27 | // A threshold for assignment of the primary to SDigit is applied | |
28 | // SDigits are written to TreeS, branch "PHOS" | |
29 | // AliPHOSSDigitizer with all current parameters is written | |
30 | // to TreeS branch "AliPHOSSDigitizer". | |
f035f6ce | 31 | // Both branches have the same title. If necessary one can produce |
32 | // another set of SDigits with different parameters. Two versions | |
33 | // can be distunguished using titles of the branches. | |
34 | // User case: | |
a4e98857 | 35 | // root [0] AliPHOSSDigitizer * s = new AliPHOSSDigitizer("galice.root") |
36 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
37 | // root [1] s->ExecuteTask() | |
f035f6ce | 38 | // // Makes SDigitis for all events stored in galice.root |
a4e98857 | 39 | // root [2] s->SetPedestalParameter(0.001) |
f035f6ce | 40 | // // One can change parameters of digitization |
3de072dc | 41 | // root [3] s->SetSDigitsBranch("Pedestal 0.001") |
f035f6ce | 42 | // // and write them into the new branch |
3de072dc | 43 | // root [4] s->ExecuteTask("deb all tim") |
f035f6ce | 44 | // // available parameters: |
45 | // deb - print # of produced SDigitis | |
46 | // deb all - print # and list of produced SDigits | |
47 | // tim - print benchmarking information | |
990119d6 | 48 | // |
49 | //*-- Author : Dmitri Peressounko (SUBATECH & KI) | |
50 | ////////////////////////////////////////////////////////////////////////////// | |
51 | ||
f035f6ce | 52 | |
990119d6 | 53 | // --- ROOT system --- |
7acf6008 | 54 | #include "TFile.h" |
7acf6008 | 55 | #include "TROOT.h" |
7acf6008 | 56 | #include "TBenchmark.h" |
106fc2fa | 57 | |
990119d6 | 58 | // --- Standard library --- |
59 | ||
60 | // --- AliRoot header files --- | |
7acf6008 | 61 | #include "AliRun.h" |
990119d6 | 62 | #include "AliPHOSDigit.h" |
7b7c1533 | 63 | #include "AliPHOSGetter.h" |
990119d6 | 64 | #include "AliPHOSHit.h" |
990119d6 | 65 | #include "AliPHOSSDigitizer.h" |
66 | ||
990119d6 | 67 | ClassImp(AliPHOSSDigitizer) |
68 | ||
69 | ||
70 | //____________________________________________________________________________ | |
88cb7938 | 71 | AliPHOSSDigitizer::AliPHOSSDigitizer():TTask("","") |
548f0134 | 72 | { |
990119d6 | 73 | // ctor |
92f521a9 | 74 | InitParameters() ; |
75 | fDefaultInit = kTRUE ; | |
990119d6 | 76 | } |
7acf6008 | 77 | |
990119d6 | 78 | //____________________________________________________________________________ |
88cb7938 | 79 | AliPHOSSDigitizer::AliPHOSSDigitizer(const char * alirunFileName, const char * eventFolderName): |
80 | TTask("PHOS"+AliConfig::fgkSDigitizerTaskName, alirunFileName), | |
81 | fEventFolderName(eventFolderName) | |
990119d6 | 82 | { |
88cb7938 | 83 | |
990119d6 | 84 | // ctor |
8d0f3f77 | 85 | InitParameters() ; |
2bd5457f | 86 | Init(); |
92f521a9 | 87 | fDefaultInit = kFALSE ; |
990119d6 | 88 | } |
89 | ||
bdc147a9 | 90 | //____________________________________________________________________________ |
91 | AliPHOSSDigitizer::AliPHOSSDigitizer(const AliPHOSSDigitizer & sd) { | |
92 | //cpy ctor | |
93 | ||
94 | fA = sd.fA ; | |
95 | fB = sd.fB ; | |
96 | fPrimThreshold = sd.fPrimThreshold ; | |
97 | fSDigitsInRun = sd.fSDigitsInRun ; | |
88cb7938 | 98 | SetName(sd.GetName()) ; |
99 | SetTitle(sd.GetTitle()) ; | |
100 | fEventFolderName = sd.fEventFolderName; | |
bdc147a9 | 101 | } |
102 | ||
7b7c1533 | 103 | |
7acf6008 | 104 | //____________________________________________________________________________ |
a4e98857 | 105 | void AliPHOSSDigitizer::Init() |
106 | { | |
88cb7938 | 107 | // Uses the getter to access the required files |
7b7c1533 | 108 | |
88cb7938 | 109 | fInit = kTRUE ; |
110 | ||
111 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()); | |
7b7c1533 | 112 | if ( gime == 0 ) { |
88cb7938 | 113 | Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ; |
7b7c1533 | 114 | return ; |
115 | } | |
116 | ||
88cb7938 | 117 | TString opt("SDigits") ; |
118 | if(gime->VersionExists(opt) ) { | |
119 | Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ; | |
120 | fInit = kFALSE ; | |
fbf811ec | 121 | } |
122 | ||
88cb7938 | 123 | gime->PostSDigitizer(this); |
124 | gime->PhosLoader()->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); | |
125 | ||
7acf6008 | 126 | } |
7b7c1533 | 127 | |
8d0f3f77 | 128 | //____________________________________________________________________________ |
129 | void AliPHOSSDigitizer::InitParameters() | |
130 | { | |
88cb7938 | 131 | // initializes the parameters for digitization |
8d0f3f77 | 132 | fA = 0; |
133 | fB = 10000000.; | |
134 | fPrimThreshold = 0.01 ; | |
135 | fSDigitsInRun = 0 ; | |
8d0f3f77 | 136 | } |
137 | ||
990119d6 | 138 | //____________________________________________________________________________ |
a4e98857 | 139 | void AliPHOSSDigitizer::Exec(Option_t *option) |
140 | { | |
141 | // Collects all hits in the same active volume into digit | |
7b7c1533 | 142 | |
143 | if (strstr(option, "print") ) { | |
88cb7938 | 144 | Print() ; |
7b7c1533 | 145 | return ; |
146 | } | |
990119d6 | 147 | |
7acf6008 | 148 | if(strstr(option,"tim")) |
149 | gBenchmark->Start("PHOSSDigitizer"); | |
fbf811ec | 150 | |
88cb7938 | 151 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
152 | ||
153 | //switch off reloading of this task while getting event | |
154 | if (!fInit) { // to prevent overwrite existing file | |
155 | Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ; | |
156 | return ; | |
157 | } | |
158 | ||
159 | ||
fbf811ec | 160 | Int_t nevents = gime->MaxEvent() ; |
990119d6 | 161 | Int_t ievent ; |
7b7c1533 | 162 | for(ievent = 0; ievent < nevents; ievent++){ |
88cb7938 | 163 | |
5ad40cd6 | 164 | gime->Event(ievent,"H") ; |
88cb7938 | 165 | |
166 | TTree * treeS = gime->TreeS(); | |
167 | TClonesArray * hits = gime->Hits() ; | |
168 | TClonesArray * sdigits = gime->SDigits() ; | |
7b7c1533 | 169 | sdigits->Clear(); |
990119d6 | 170 | Int_t nSdigits = 0 ; |
7b7c1533 | 171 | //Now make SDigits from hits, for PHOS it is the same, so just copy |
88cb7938 | 172 | Int_t nPrim = static_cast<Int_t>((gime->TreeH())->GetEntries()) ; |
fbf811ec | 173 | // Attention nPrim is the number of primaries tracked by Geant |
174 | // and this number could be different to the number of Primaries in TreeK; | |
175 | Int_t iprim ; | |
88cb7938 | 176 | |
fbf811ec | 177 | for (iprim = 0 ; iprim < nPrim ; iprim ++) { |
3962b6a1 | 178 | //=========== Get the PHOS branch from Hits Tree for the Primary iprim |
179 | gime->Track(iprim) ; | |
990119d6 | 180 | Int_t i; |
7b7c1533 | 181 | for ( i = 0 ; i < hits->GetEntries() ; i++ ) { |
7a9d98f9 | 182 | AliPHOSHit * hit = dynamic_cast<AliPHOSHit *>(hits->At(i)) ; |
990119d6 | 183 | // Assign primary number only if contribution is significant |
9688c1dd | 184 | |
990119d6 | 185 | if( hit->GetEnergy() > fPrimThreshold) |
9688c1dd | 186 | new((*sdigits)[nSdigits]) AliPHOSDigit(hit->GetPrimary(),hit->GetId(), |
fbf811ec | 187 | Digitize(hit->GetEnergy()), hit->GetTime()) ; |
990119d6 | 188 | else |
9688c1dd | 189 | new((*sdigits)[nSdigits]) AliPHOSDigit( -1 , hit->GetId(), |
fbf811ec | 190 | Digitize(hit->GetEnergy()), hit->GetTime()) ; |
9688c1dd | 191 | nSdigits++ ; |
990119d6 | 192 | |
9688c1dd | 193 | } |
88cb7938 | 194 | |
3962b6a1 | 195 | } // loop over iprim |
88cb7938 | 196 | |
7b7c1533 | 197 | sdigits->Sort() ; |
88cb7938 | 198 | |
7b7c1533 | 199 | nSdigits = sdigits->GetEntriesFast() ; |
88cb7938 | 200 | |
69866bef | 201 | fSDigitsInRun += nSdigits ; |
7b7c1533 | 202 | sdigits->Expand(nSdigits) ; |
88cb7938 | 203 | |
3962b6a1 | 204 | Int_t i ; |
990119d6 | 205 | for (i = 0 ; i < nSdigits ; i++) { |
7a9d98f9 | 206 | AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit *>(sdigits->At(i)) ; |
990119d6 | 207 | digit->SetIndexInList(i) ; |
208 | } | |
3962b6a1 | 209 | |
fbf811ec | 210 | //Now write SDigits |
fbf811ec | 211 | |
88cb7938 | 212 | |
7acf6008 | 213 | //First list of sdigits |
88cb7938 | 214 | |
fbf811ec | 215 | Int_t bufferSize = 32000 ; |
88cb7938 | 216 | TBranch * sdigitsBranch = treeS->Branch("PHOS",&sdigits,bufferSize); |
217 | ||
fbf811ec | 218 | sdigitsBranch->Fill() ; |
fbf811ec | 219 | |
88cb7938 | 220 | gime->WriteSDigits("OVERWRITE"); |
221 | ||
222 | //Next - SDigitizer | |
223 | ||
224 | gime->WriteSDigitizer("OVERWRITE"); | |
225 | ||
7acf6008 | 226 | if(strstr(option,"deb")) |
227 | PrintSDigits(option) ; | |
990119d6 | 228 | } |
fbf811ec | 229 | |
88cb7938 | 230 | Unload(); |
231 | ||
232 | gime->PhosLoader()->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); | |
233 | ||
7acf6008 | 234 | if(strstr(option,"tim")){ |
235 | gBenchmark->Stop("PHOSSDigitizer"); | |
21cd0c07 | 236 | Info("Exec"," took %f seconds for SDigitizing %f seconds per event", |
237 | gBenchmark->GetCpuTime("PHOSSDigitizer"), gBenchmark->GetCpuTime("PHOSSDigitizer")/nevents) ; | |
7acf6008 | 238 | } |
990119d6 | 239 | } |
106fc2fa | 240 | |
990119d6 | 241 | //__________________________________________________________________ |
88cb7938 | 242 | void AliPHOSSDigitizer::Print()const |
a4e98857 | 243 | { |
244 | // Prints parameters of SDigitizer | |
88cb7938 | 245 | Info("Print", "\n------------------- %s -------------", GetName() ) ; |
246 | printf(" Writing SDigits to branch with title %s\n", fEventFolderName.Data()) ; | |
247 | printf(" with digitization parameters A = %f\n", fA) ; | |
248 | printf(" B = %f\n", fB) ; | |
249 | printf(" Threshold for Primary assignment= %f\n", fPrimThreshold) ; | |
250 | printf("---------------------------------------------------\n") ; | |
7acf6008 | 251 | |
990119d6 | 252 | } |
548f0134 | 253 | |
990119d6 | 254 | //__________________________________________________________________ |
a4e98857 | 255 | Bool_t AliPHOSSDigitizer::operator==( AliPHOSSDigitizer const &sd )const |
256 | { | |
3de072dc | 257 | // Equal operator. |
258 | // SDititizers are equal if their pedestal, slope and threshold are equal | |
259 | ||
990119d6 | 260 | if( (fA==sd.fA)&&(fB==sd.fB)&&(fPrimThreshold==sd.fPrimThreshold)) |
261 | return kTRUE ; | |
262 | else | |
263 | return kFALSE ; | |
264 | } | |
548f0134 | 265 | |
a6eedfad | 266 | //__________________________________________________________________ |
a4e98857 | 267 | void AliPHOSSDigitizer::PrintSDigits(Option_t * option) |
268 | { | |
269 | // Prints list of digits produced in the current pass of AliPHOSDigitizer | |
7b7c1533 | 270 | |
a6eedfad | 271 | |
88cb7938 | 272 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
273 | const TClonesArray * sdigits = gime->SDigits() ; | |
7b7c1533 | 274 | |
21cd0c07 | 275 | TString message ; |
276 | message = "\nAliPHOSSDigitiser: event " ; | |
277 | message += gAlice->GetEvNumber(); | |
278 | message += "\n Number of entries in SDigits list " ; | |
279 | message += sdigits->GetEntriesFast() ; | |
11f9c5ff | 280 | char * tempo = new char[8192]; |
21cd0c07 | 281 | |
a6eedfad | 282 | if(strstr(option,"all")||strstr(option,"EMC")){ |
7acf6008 | 283 | |
284 | //loop over digits | |
285 | AliPHOSDigit * digit; | |
21cd0c07 | 286 | message += "\nEMC sdigits\n" ; |
11f9c5ff | 287 | message += "\n Id Amplitude Time Index Nprim: Primaries list \n" ; |
a6eedfad | 288 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; |
7acf6008 | 289 | Int_t index ; |
a6eedfad | 290 | for (index = 0 ; (index < sdigits->GetEntriesFast()) && |
fbf811ec | 291 | ((dynamic_cast<AliPHOSDigit *> (sdigits->At(index)))->GetId() <= maxEmc) ; index++) { |
292 | digit = dynamic_cast<AliPHOSDigit *>( sdigits->At(index) ) ; | |
21cd0c07 | 293 | if(digit->GetNprimary() == 0) |
294 | continue; | |
11f9c5ff | 295 | sprintf(tempo, "\n%6d %8d %6.5e %4d %2d :", |
296 | digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; | |
297 | message += tempo ; | |
7acf6008 | 298 | Int_t iprimary; |
11f9c5ff | 299 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
300 | sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ; | |
301 | message += tempo ; | |
302 | } | |
a6eedfad | 303 | } |
a6eedfad | 304 | } |
305 | ||
306 | if(strstr(option,"all")||strstr(option,"CPV")){ | |
7acf6008 | 307 | |
a6eedfad | 308 | //loop over CPV digits |
309 | AliPHOSDigit * digit; | |
21cd0c07 | 310 | |
311 | message += "CPV sdigits\n" ; | |
11f9c5ff | 312 | message += "\n Id Amplitude Index Nprim: Primaries list \n" ; |
a6eedfad | 313 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; |
314 | Int_t index ; | |
315 | for (index = 0 ; index < sdigits->GetEntriesFast(); index++) { | |
fbf811ec | 316 | digit = dynamic_cast<AliPHOSDigit *>( sdigits->At(index) ) ; |
a6eedfad | 317 | if(digit->GetId() > maxEmc){ |
11f9c5ff | 318 | sprintf(tempo, "\n%6d %8d %4d %2d :", |
319 | digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ; | |
320 | message += tempo ; | |
a6eedfad | 321 | Int_t iprimary; |
21cd0c07 | 322 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
11f9c5ff | 323 | sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ; |
324 | message += tempo ; | |
21cd0c07 | 325 | } |
a6eedfad | 326 | } |
327 | } | |
7acf6008 | 328 | } |
88cb7938 | 329 | delete []tempo ; |
21cd0c07 | 330 | Info("PrintSDigits", message.Data() ) ; |
7acf6008 | 331 | } |
7b7c1533 | 332 | |
333 | //____________________________________________________________________________ | |
88cb7938 | 334 | void AliPHOSSDigitizer::Unload() const |
7b7c1533 | 335 | { |
88cb7938 | 336 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
337 | AliPHOSLoader * loader = gime->PhosLoader() ; | |
338 | loader->UnloadHits() ; | |
339 | loader->UnloadSDigits() ; | |
7b7c1533 | 340 | } |