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