]>
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 "TBenchmark.h" |
e957fea8 | 55 | #include "TRandom.h" |
106fc2fa | 56 | |
990119d6 | 57 | // --- Standard library --- |
58 | ||
59 | // --- AliRoot header files --- | |
e957fea8 | 60 | #include "AliPHOSGeometry.h" |
990119d6 | 61 | #include "AliPHOSDigit.h" |
7b7c1533 | 62 | #include "AliPHOSGetter.h" |
990119d6 | 63 | #include "AliPHOSHit.h" |
990119d6 | 64 | #include "AliPHOSSDigitizer.h" |
65 | ||
990119d6 | 66 | ClassImp(AliPHOSSDigitizer) |
67 | ||
68 | ||
69 | //____________________________________________________________________________ | |
88cb7938 | 70 | AliPHOSSDigitizer::AliPHOSSDigitizer():TTask("","") |
548f0134 | 71 | { |
990119d6 | 72 | // ctor |
d7d3b67b | 73 | fFirstEvent = fLastEvent = 0 ; |
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 |
d7d3b67b | 85 | fFirstEvent = fLastEvent = 0 ; // runs one event by defaut |
8d0f3f77 | 86 | InitParameters() ; |
2bd5457f | 87 | Init(); |
92f521a9 | 88 | fDefaultInit = kFALSE ; |
990119d6 | 89 | } |
90 | ||
bdc147a9 | 91 | //____________________________________________________________________________ |
a8c47ab6 | 92 | AliPHOSSDigitizer::AliPHOSSDigitizer(const AliPHOSSDigitizer & sd) |
93 | : TTask(sd) | |
94 | { | |
bdc147a9 | 95 | //cpy ctor |
96 | ||
d7d3b67b | 97 | fFirstEvent = sd.fFirstEvent ; |
98 | fLastEvent = sd.fLastEvent ; | |
bdc147a9 | 99 | fA = sd.fA ; |
100 | fB = sd.fB ; | |
101 | fPrimThreshold = sd.fPrimThreshold ; | |
102 | fSDigitsInRun = sd.fSDigitsInRun ; | |
88cb7938 | 103 | SetName(sd.GetName()) ; |
104 | SetTitle(sd.GetTitle()) ; | |
105 | fEventFolderName = sd.fEventFolderName; | |
bdc147a9 | 106 | } |
107 | ||
7b7c1533 | 108 | |
7acf6008 | 109 | //____________________________________________________________________________ |
797e311f | 110 | AliPHOSSDigitizer::~AliPHOSSDigitizer() { |
111 | //dtor | |
112 | AliPHOSGetter * gime = | |
113 | AliPHOSGetter::Instance(GetTitle(),fEventFolderName.Data()); | |
114 | gime->PhosLoader()->CleanSDigitizer(); | |
115 | } | |
116 | //____________________________________________________________________________ | |
a4e98857 | 117 | void AliPHOSSDigitizer::Init() |
118 | { | |
88cb7938 | 119 | // Uses the getter to access the required files |
7b7c1533 | 120 | |
88cb7938 | 121 | fInit = kTRUE ; |
122 | ||
123 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()); | |
7b7c1533 | 124 | if ( gime == 0 ) { |
88cb7938 | 125 | Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ; |
7b7c1533 | 126 | return ; |
127 | } | |
128 | ||
88cb7938 | 129 | TString opt("SDigits") ; |
130 | if(gime->VersionExists(opt) ) { | |
131 | Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ; | |
132 | fInit = kFALSE ; | |
fbf811ec | 133 | } |
134 | ||
88cb7938 | 135 | gime->PostSDigitizer(this); |
136 | gime->PhosLoader()->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); | |
137 | ||
7acf6008 | 138 | } |
7b7c1533 | 139 | |
8d0f3f77 | 140 | //____________________________________________________________________________ |
141 | void AliPHOSSDigitizer::InitParameters() | |
142 | { | |
88cb7938 | 143 | // initializes the parameters for digitization |
8d0f3f77 | 144 | fA = 0; |
145 | fB = 10000000.; | |
146 | fPrimThreshold = 0.01 ; | |
147 | fSDigitsInRun = 0 ; | |
8d0f3f77 | 148 | } |
149 | ||
990119d6 | 150 | //____________________________________________________________________________ |
a4e98857 | 151 | void AliPHOSSDigitizer::Exec(Option_t *option) |
152 | { | |
212d1c0f | 153 | // Steering method to produce summable digits for events |
154 | // in the range from fFirstEvent to fLastEvent. | |
155 | // This range is optionally set by SetEventRange(). | |
156 | // if fLastEvent=-1 (by default), then process events until the end. | |
157 | // | |
158 | // Summable digit is a sum of all hits in the same active | |
159 | // volume into digit | |
7b7c1533 | 160 | |
161 | if (strstr(option, "print") ) { | |
88cb7938 | 162 | Print() ; |
7b7c1533 | 163 | return ; |
164 | } | |
990119d6 | 165 | |
7acf6008 | 166 | if(strstr(option,"tim")) |
167 | gBenchmark->Start("PHOSSDigitizer"); | |
fbf811ec | 168 | |
d7d3b67b | 169 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; |
88cb7938 | 170 | |
171 | //switch off reloading of this task while getting event | |
172 | if (!fInit) { // to prevent overwrite existing file | |
173 | Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ; | |
174 | return ; | |
175 | } | |
176 | ||
212d1c0f | 177 | if (fLastEvent == -1) |
178 | fLastEvent = gime->MaxEvent() - 1 ; | |
179 | else | |
d7d3b67b | 180 | fLastEvent = TMath::Min(fFirstEvent, gime->MaxEvent()); // only ine event at the time |
212d1c0f | 181 | Int_t nEvents = fLastEvent - fFirstEvent + 1; |
182 | ||
990119d6 | 183 | Int_t ievent ; |
212d1c0f | 184 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { |
5ad40cd6 | 185 | gime->Event(ievent,"H") ; |
88cb7938 | 186 | TTree * treeS = gime->TreeS(); |
187 | TClonesArray * hits = gime->Hits() ; | |
188 | TClonesArray * sdigits = gime->SDigits() ; | |
7b7c1533 | 189 | sdigits->Clear(); |
990119d6 | 190 | Int_t nSdigits = 0 ; |
7b7c1533 | 191 | //Now make SDigits from hits, for PHOS it is the same, so just copy |
88cb7938 | 192 | Int_t nPrim = static_cast<Int_t>((gime->TreeH())->GetEntries()) ; |
fbf811ec | 193 | // Attention nPrim is the number of primaries tracked by Geant |
194 | // and this number could be different to the number of Primaries in TreeK; | |
195 | Int_t iprim ; | |
88cb7938 | 196 | |
fbf811ec | 197 | for (iprim = 0 ; iprim < nPrim ; iprim ++) { |
3962b6a1 | 198 | //=========== Get the PHOS branch from Hits Tree for the Primary iprim |
199 | gime->Track(iprim) ; | |
990119d6 | 200 | Int_t i; |
7b7c1533 | 201 | for ( i = 0 ; i < hits->GetEntries() ; i++ ) { |
7a9d98f9 | 202 | AliPHOSHit * hit = dynamic_cast<AliPHOSHit *>(hits->At(i)) ; |
990119d6 | 203 | // Assign primary number only if contribution is significant |
9688c1dd | 204 | |
990119d6 | 205 | if( hit->GetEnergy() > fPrimThreshold) |
9688c1dd | 206 | new((*sdigits)[nSdigits]) AliPHOSDigit(hit->GetPrimary(),hit->GetId(), |
fbf811ec | 207 | Digitize(hit->GetEnergy()), hit->GetTime()) ; |
990119d6 | 208 | else |
9688c1dd | 209 | new((*sdigits)[nSdigits]) AliPHOSDigit( -1 , hit->GetId(), |
fbf811ec | 210 | Digitize(hit->GetEnergy()), hit->GetTime()) ; |
9688c1dd | 211 | nSdigits++ ; |
990119d6 | 212 | |
9688c1dd | 213 | } |
88cb7938 | 214 | |
3962b6a1 | 215 | } // loop over iprim |
88cb7938 | 216 | |
7b7c1533 | 217 | sdigits->Sort() ; |
88cb7938 | 218 | |
7b7c1533 | 219 | nSdigits = sdigits->GetEntriesFast() ; |
88cb7938 | 220 | |
69866bef | 221 | fSDigitsInRun += nSdigits ; |
7b7c1533 | 222 | sdigits->Expand(nSdigits) ; |
88cb7938 | 223 | |
3962b6a1 | 224 | Int_t i ; |
990119d6 | 225 | for (i = 0 ; i < nSdigits ; i++) { |
7a9d98f9 | 226 | AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit *>(sdigits->At(i)) ; |
990119d6 | 227 | digit->SetIndexInList(i) ; |
228 | } | |
3962b6a1 | 229 | |
fbf811ec | 230 | //Now write SDigits |
fbf811ec | 231 | |
88cb7938 | 232 | |
7acf6008 | 233 | //First list of sdigits |
88cb7938 | 234 | |
fbf811ec | 235 | Int_t bufferSize = 32000 ; |
88cb7938 | 236 | TBranch * sdigitsBranch = treeS->Branch("PHOS",&sdigits,bufferSize); |
237 | ||
fbf811ec | 238 | sdigitsBranch->Fill() ; |
fbf811ec | 239 | |
88cb7938 | 240 | gime->WriteSDigits("OVERWRITE"); |
241 | ||
242 | //Next - SDigitizer | |
243 | ||
244 | gime->WriteSDigitizer("OVERWRITE"); | |
245 | ||
7acf6008 | 246 | if(strstr(option,"deb")) |
247 | PrintSDigits(option) ; | |
990119d6 | 248 | } |
fbf811ec | 249 | |
88cb7938 | 250 | Unload(); |
251 | ||
252 | gime->PhosLoader()->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); | |
253 | ||
7acf6008 | 254 | if(strstr(option,"tim")){ |
255 | gBenchmark->Stop("PHOSSDigitizer"); | |
21cd0c07 | 256 | Info("Exec"," took %f seconds for SDigitizing %f seconds per event", |
212d1c0f | 257 | gBenchmark->GetCpuTime("PHOSSDigitizer"), gBenchmark->GetCpuTime("PHOSSDigitizer")/nEvents) ; |
7acf6008 | 258 | } |
990119d6 | 259 | } |
106fc2fa | 260 | |
990119d6 | 261 | //__________________________________________________________________ |
88cb7938 | 262 | void AliPHOSSDigitizer::Print()const |
a4e98857 | 263 | { |
264 | // Prints parameters of SDigitizer | |
88cb7938 | 265 | Info("Print", "\n------------------- %s -------------", GetName() ) ; |
266 | printf(" Writing SDigits to branch with title %s\n", fEventFolderName.Data()) ; | |
267 | printf(" with digitization parameters A = %f\n", fA) ; | |
268 | printf(" B = %f\n", fB) ; | |
269 | printf(" Threshold for Primary assignment= %f\n", fPrimThreshold) ; | |
270 | printf("---------------------------------------------------\n") ; | |
7acf6008 | 271 | |
990119d6 | 272 | } |
548f0134 | 273 | |
990119d6 | 274 | //__________________________________________________________________ |
a4e98857 | 275 | Bool_t AliPHOSSDigitizer::operator==( AliPHOSSDigitizer const &sd )const |
276 | { | |
3de072dc | 277 | // Equal operator. |
278 | // SDititizers are equal if their pedestal, slope and threshold are equal | |
279 | ||
990119d6 | 280 | if( (fA==sd.fA)&&(fB==sd.fB)&&(fPrimThreshold==sd.fPrimThreshold)) |
281 | return kTRUE ; | |
282 | else | |
283 | return kFALSE ; | |
284 | } | |
548f0134 | 285 | |
a6eedfad | 286 | //__________________________________________________________________ |
a4e98857 | 287 | void AliPHOSSDigitizer::PrintSDigits(Option_t * option) |
288 | { | |
289 | // Prints list of digits produced in the current pass of AliPHOSDigitizer | |
7b7c1533 | 290 | |
a6eedfad | 291 | |
88cb7938 | 292 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
293 | const TClonesArray * sdigits = gime->SDigits() ; | |
21cd0c07 | 294 | |
71dfb0d8 | 295 | Info( "\nPrintSDigits", "event # %d %d sdigits", gAlice->GetEvNumber(), sdigits->GetEntriesFast() ) ; |
296 | ||
a6eedfad | 297 | if(strstr(option,"all")||strstr(option,"EMC")){ |
7acf6008 | 298 | |
299 | //loop over digits | |
300 | AliPHOSDigit * digit; | |
71dfb0d8 | 301 | printf("\nEMC sdigits\n") ; |
a6eedfad | 302 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; |
7acf6008 | 303 | Int_t index ; |
a6eedfad | 304 | for (index = 0 ; (index < sdigits->GetEntriesFast()) && |
fbf811ec | 305 | ((dynamic_cast<AliPHOSDigit *> (sdigits->At(index)))->GetId() <= maxEmc) ; index++) { |
306 | digit = dynamic_cast<AliPHOSDigit *>( sdigits->At(index) ) ; | |
71dfb0d8 | 307 | // if(digit->GetNprimary() == 0) |
308 | // continue; | |
d7d3b67b | 309 | printf("%6d %8d %6.5e %4d %2d :\n", |
71dfb0d8 | 310 | digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; |
7acf6008 | 311 | Int_t iprimary; |
11f9c5ff | 312 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
71dfb0d8 | 313 | printf("%d ",digit->GetPrimary(iprimary+1) ) ; |
11f9c5ff | 314 | } |
a6eedfad | 315 | } |
a6eedfad | 316 | } |
317 | ||
318 | if(strstr(option,"all")||strstr(option,"CPV")){ | |
7acf6008 | 319 | |
a6eedfad | 320 | //loop over CPV digits |
321 | AliPHOSDigit * digit; | |
71dfb0d8 | 322 | printf("\nCPV sdigits\n") ; |
a6eedfad | 323 | Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ; |
324 | Int_t index ; | |
325 | for (index = 0 ; index < sdigits->GetEntriesFast(); index++) { | |
fbf811ec | 326 | digit = dynamic_cast<AliPHOSDigit *>( sdigits->At(index) ) ; |
a6eedfad | 327 | if(digit->GetId() > maxEmc){ |
71dfb0d8 | 328 | printf("\n%6d %8d %4d %2d :", |
11f9c5ff | 329 | digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ; |
a6eedfad | 330 | Int_t iprimary; |
21cd0c07 | 331 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
71dfb0d8 | 332 | printf("%d ",digit->GetPrimary(iprimary+1) ) ; |
21cd0c07 | 333 | } |
a6eedfad | 334 | } |
335 | } | |
7acf6008 | 336 | } |
337 | } | |
7b7c1533 | 338 | |
339 | //____________________________________________________________________________ | |
88cb7938 | 340 | void AliPHOSSDigitizer::Unload() const |
7b7c1533 | 341 | { |
e957fea8 | 342 | // Unloads the objects from the folder |
88cb7938 | 343 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
344 | AliPHOSLoader * loader = gime->PhosLoader() ; | |
345 | loader->UnloadHits() ; | |
346 | loader->UnloadSDigits() ; | |
7b7c1533 | 347 | } |