]>
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 * | |
c65c502a | 10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * | |
990119d6 | 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$ | |
04236e67 | 22 | * Revision 1.56 2007/10/19 18:04:29 schutz |
23 | * The standalone QA data maker is called from AliSimulation and AliReconstruction outside the event loop; i.e. re-reading the data. The QA data making in the event loop has been commented out. | |
24 | * | |
c65c502a | 25 | * Revision 1.55 2007/10/14 21:08:10 schutz |
26 | * Introduced the checking of QA results from previous step before entering the event loop | |
27 | * | |
8661738e | 28 | * Revision 1.54 2007/10/10 09:05:10 schutz |
29 | * Changing name QualAss to QA | |
30 | * | |
b8274834 | 31 | * Revision 1.53 2007/09/30 17:08:20 schutz |
32 | * Introducing the notion of QA data acquisition cycle (needed by online) | |
33 | * | |
5b188f2f | 34 | * Revision 1.52 2007/09/26 14:22:18 cvetan |
35 | * Important changes to the reconstructor classes. Complete elimination of the run-loaders, which are now steered only from AliReconstruction. Removal of the corresponding Reconstruct() and FillESD() methods. | |
36 | * | |
d76c31f4 | 37 | * Revision 1.51 2007/08/07 14:12:03 kharlov |
38 | * Quality assurance added (Yves Schutz) | |
702ab87e | 39 | */ |
40 | ||
990119d6 | 41 | //_________________________________________________________________________ |
7acf6008 | 42 | // This is a TTask that makes SDigits out of Hits |
7b7c1533 | 43 | // The name of the TTask is also the title of the branch that will contain |
44 | // the created SDigits | |
45 | // The title of the TTAsk is the name of the file that contains the hits from | |
46 | // which the SDigits are created | |
7acf6008 | 47 | // A Summable Digits is the sum of all hits originating |
48 | // from one primary in one active cell | |
49 | // A threshold for assignment of the primary to SDigit is applied | |
50 | // SDigits are written to TreeS, branch "PHOS" | |
51 | // AliPHOSSDigitizer with all current parameters is written | |
52 | // to TreeS branch "AliPHOSSDigitizer". | |
f035f6ce | 53 | // Both branches have the same title. If necessary one can produce |
54 | // another set of SDigits with different parameters. Two versions | |
55 | // can be distunguished using titles of the branches. | |
56 | // User case: | |
a4e98857 | 57 | // root [0] AliPHOSSDigitizer * s = new AliPHOSSDigitizer("galice.root") |
58 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
59 | // root [1] s->ExecuteTask() | |
f035f6ce | 60 | // // Makes SDigitis for all events stored in galice.root |
a4e98857 | 61 | // root [2] s->SetPedestalParameter(0.001) |
f035f6ce | 62 | // // One can change parameters of digitization |
3de072dc | 63 | // root [3] s->SetSDigitsBranch("Pedestal 0.001") |
f035f6ce | 64 | // // and write them into the new branch |
3de072dc | 65 | // root [4] s->ExecuteTask("deb all tim") |
f035f6ce | 66 | // // available parameters: |
67 | // deb - print # of produced SDigitis | |
68 | // deb all - print # and list of produced SDigits | |
69 | // tim - print benchmarking information | |
990119d6 | 70 | // |
6c8cd883 | 71 | //-- Author : Dmitri Peressounko (SUBATECH & KI) |
990119d6 | 72 | ////////////////////////////////////////////////////////////////////////////// |
73 | ||
f035f6ce | 74 | |
990119d6 | 75 | // --- ROOT system --- |
7acf6008 | 76 | #include "TBenchmark.h" |
9d6866ec | 77 | //#include "TObjectTable.h" |
106fc2fa | 78 | |
990119d6 | 79 | // --- Standard library --- |
80 | ||
81 | // --- AliRoot header files --- | |
9d6866ec | 82 | #include "AliLog.h" |
e957fea8 | 83 | #include "AliPHOSGeometry.h" |
990119d6 | 84 | #include "AliPHOSDigit.h" |
7b7c1533 | 85 | #include "AliPHOSGetter.h" |
990119d6 | 86 | #include "AliPHOSHit.h" |
990119d6 | 87 | #include "AliPHOSSDigitizer.h" |
88 | ||
990119d6 | 89 | ClassImp(AliPHOSSDigitizer) |
90 | ||
91 | ||
92 | //____________________________________________________________________________ | |
3663622c | 93 | AliPHOSSDigitizer::AliPHOSSDigitizer() : |
94 | TTask("",""), | |
3663622c | 95 | fPrimThreshold(0.f), |
96 | fDefaultInit(kTRUE), | |
97 | fEventFolderName(""), | |
98 | fInit(kFALSE), | |
99 | fSDigitsInRun(0), | |
100 | fFirstEvent(0), | |
c65c502a | 101 | fLastEvent(0) |
548f0134 | 102 | { |
990119d6 | 103 | // ctor |
ddd1a39c | 104 | // Intialize the quality assurance data maker |
990119d6 | 105 | } |
7acf6008 | 106 | |
990119d6 | 107 | //____________________________________________________________________________ |
e191bb57 | 108 | AliPHOSSDigitizer::AliPHOSSDigitizer(const char * alirunFileName, |
109 | const char * eventFolderName): | |
110 | TTask("PHOS"+AliConfig::Instance()->GetSDigitizerTaskName(), alirunFileName), | |
3663622c | 111 | fPrimThreshold(0.f), |
112 | fDefaultInit(kFALSE), | |
113 | fEventFolderName(eventFolderName), | |
114 | fInit(kFALSE), | |
115 | fSDigitsInRun(0), | |
116 | fFirstEvent(0), | |
c65c502a | 117 | fLastEvent(0) |
990119d6 | 118 | { |
119 | // ctor | |
8d0f3f77 | 120 | InitParameters() ; |
2bd5457f | 121 | Init(); |
92f521a9 | 122 | fDefaultInit = kFALSE ; |
ddd1a39c | 123 | } |
124 | ||
125 | //____________________________________________________________________________ | |
126 | AliPHOSSDigitizer::AliPHOSSDigitizer(const AliPHOSSDigitizer& sd) : | |
127 | TTask(sd.GetName(), sd.GetTitle()), | |
ddd1a39c | 128 | fPrimThreshold(sd.fPrimThreshold), |
129 | fDefaultInit(kFALSE), | |
130 | fEventFolderName(sd.fEventFolderName), | |
131 | fInit(kFALSE), | |
132 | fSDigitsInRun(sd.fSDigitsInRun), | |
133 | fFirstEvent(sd.fFirstEvent), | |
c65c502a | 134 | fLastEvent(sd.fLastEvent) |
ddd1a39c | 135 | { |
136 | // cpy ctor | |
ddd1a39c | 137 | } |
138 | ||
ddd1a39c | 139 | //_____________________________________________________________________________ |
140 | AliPHOSSDigitizer& AliPHOSSDigitizer::operator = (const AliPHOSSDigitizer& qa) | |
141 | { | |
142 | // assignment operator | |
143 | ||
144 | this->~AliPHOSSDigitizer(); | |
145 | new(this) AliPHOSSDigitizer(qa); | |
146 | return *this; | |
990119d6 | 147 | } |
148 | ||
7acf6008 | 149 | //____________________________________________________________________________ |
797e311f | 150 | AliPHOSSDigitizer::~AliPHOSSDigitizer() { |
151 | //dtor | |
152 | AliPHOSGetter * gime = | |
9d6866ec | 153 | AliPHOSGetter::Instance(); |
797e311f | 154 | gime->PhosLoader()->CleanSDigitizer(); |
155 | } | |
ddd1a39c | 156 | |
797e311f | 157 | //____________________________________________________________________________ |
a4e98857 | 158 | void AliPHOSSDigitizer::Init() |
159 | { | |
88cb7938 | 160 | // Uses the getter to access the required files |
7b7c1533 | 161 | |
88cb7938 | 162 | fInit = kTRUE ; |
163 | ||
164 | AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()); | |
7b7c1533 | 165 | if ( gime == 0 ) { |
88cb7938 | 166 | Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ; |
7b7c1533 | 167 | return ; |
168 | } | |
169 | ||
88cb7938 | 170 | TString opt("SDigits") ; |
171 | if(gime->VersionExists(opt) ) { | |
172 | Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ; | |
173 | fInit = kFALSE ; | |
fbf811ec | 174 | } |
175 | ||
88cb7938 | 176 | gime->PostSDigitizer(this); |
177 | gime->PhosLoader()->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); | |
9d6866ec | 178 | |
7acf6008 | 179 | } |
7b7c1533 | 180 | |
8d0f3f77 | 181 | //____________________________________________________________________________ |
182 | void AliPHOSSDigitizer::InitParameters() | |
183 | { | |
88cb7938 | 184 | // initializes the parameters for digitization |
8d0f3f77 | 185 | fPrimThreshold = 0.01 ; |
186 | fSDigitsInRun = 0 ; | |
8d0f3f77 | 187 | } |
188 | ||
990119d6 | 189 | //____________________________________________________________________________ |
a4e98857 | 190 | void AliPHOSSDigitizer::Exec(Option_t *option) |
191 | { | |
212d1c0f | 192 | // Steering method to produce summable digits for events |
193 | // in the range from fFirstEvent to fLastEvent. | |
194 | // This range is optionally set by SetEventRange(). | |
195 | // if fLastEvent=-1 (by default), then process events until the end. | |
196 | // | |
197 | // Summable digit is a sum of all hits in the same active | |
198 | // volume into digit | |
7b7c1533 | 199 | |
200 | if (strstr(option, "print") ) { | |
88cb7938 | 201 | Print() ; |
7b7c1533 | 202 | return ; |
203 | } | |
990119d6 | 204 | |
7acf6008 | 205 | if(strstr(option,"tim")) |
206 | gBenchmark->Start("PHOSSDigitizer"); | |
fbf811ec | 207 | |
04236e67 | 208 | /* |
209 | // check the QA result for RAWS | |
8661738e | 210 | AliQA * qa = AliQA::Instance(AliQA::kPHOS) ; |
211 | if ( qa->IsSet(AliQA::kPHOS, AliQA::kRAW, AliQA::kFATAL)) { | |
212 | AliFatal("QA status in RAW was Fatal") ; | |
213 | } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kRAW, AliQA::kERROR)) { | |
214 | AliError("QA status in RAW was Error") ; | |
215 | } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kRAW, AliQA::kWARNING) ) { | |
216 | AliWarning("QA status in RAW was Warning") ; | |
217 | } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kRAW, AliQA::kINFO) ) { | |
218 | AliInfo("QA status in RAW was Info") ; | |
219 | } | |
04236e67 | 220 | */ |
9d6866ec | 221 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
88cb7938 | 222 | |
223 | //switch off reloading of this task while getting event | |
224 | if (!fInit) { // to prevent overwrite existing file | |
9d6866ec | 225 | AliError( Form("Give a version name different from %s", fEventFolderName.Data()) ) ; |
88cb7938 | 226 | return ; |
227 | } | |
228 | ||
212d1c0f | 229 | if (fLastEvent == -1) |
230 | fLastEvent = gime->MaxEvent() - 1 ; | |
231 | else | |
d7d3b67b | 232 | fLastEvent = TMath::Min(fFirstEvent, gime->MaxEvent()); // only ine event at the time |
212d1c0f | 233 | Int_t nEvents = fLastEvent - fFirstEvent + 1; |
234 | ||
e3310962 | 235 | Int_t ievent, i; |
9d6866ec | 236 | |
9d6866ec | 237 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { |
238 | gime->Event(ievent,"H") ; | |
88cb7938 | 239 | TTree * treeS = gime->TreeS(); |
240 | TClonesArray * hits = gime->Hits() ; | |
241 | TClonesArray * sdigits = gime->SDigits() ; | |
7b7c1533 | 242 | sdigits->Clear(); |
990119d6 | 243 | Int_t nSdigits = 0 ; |
7b7c1533 | 244 | //Now make SDigits from hits, for PHOS it is the same, so just copy |
e3310962 | 245 | for ( i = 0 ; i < hits->GetEntries() ; i++ ) { |
246 | AliPHOSHit * hit = dynamic_cast<AliPHOSHit *>(hits->At(i)) ; | |
247 | // Assign primary number only if contribution is significant | |
248 | ||
249 | if( hit->GetEnergy() > fPrimThreshold) | |
250 | new((*sdigits)[nSdigits]) AliPHOSDigit(hit->GetPrimary(),hit->GetId(), | |
251 | hit->GetEnergy() ,hit->GetTime()) ; | |
252 | else | |
253 | new((*sdigits)[nSdigits]) AliPHOSDigit(-1 ,hit->GetId(), | |
254 | hit->GetEnergy() ,hit->GetTime()) ; | |
255 | nSdigits++ ; | |
256 | ||
257 | } | |
88cb7938 | 258 | |
7b7c1533 | 259 | sdigits->Sort() ; |
88cb7938 | 260 | |
7b7c1533 | 261 | nSdigits = sdigits->GetEntriesFast() ; |
88cb7938 | 262 | |
69866bef | 263 | fSDigitsInRun += nSdigits ; |
7b7c1533 | 264 | sdigits->Expand(nSdigits) ; |
88cb7938 | 265 | |
990119d6 | 266 | for (i = 0 ; i < nSdigits ; i++) { |
7a9d98f9 | 267 | AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit *>(sdigits->At(i)) ; |
990119d6 | 268 | digit->SetIndexInList(i) ; |
269 | } | |
3962b6a1 | 270 | |
c65c502a | 271 | // // make Quality Assurance data |
272 | // | |
273 | // if (GetQADataMaker()->IsCycleDone() ) { | |
274 | // GetQADataMaker()->EndOfCycle(AliQA::kHITS) ; | |
275 | // GetQADataMaker()->EndOfCycle(AliQA::kSDIGITS) ; | |
276 | // GetQADataMaker()->StartOfCycle(AliQA::kHITS) ; | |
277 | // GetQADataMaker()->StartOfCycle(AliQA::kSDIGITS, kTRUE) ; | |
278 | // } | |
279 | // GetQADataMaker()->Exec(AliQA::kHITS, hits) ; | |
280 | // GetQADataMaker()->Exec(AliQA::kSDIGITS, sdigits) ; | |
281 | // GetQADataMaker()->Increment() ; | |
5b188f2f | 282 | |
fbf811ec | 283 | //Now write SDigits |
fbf811ec | 284 | |
88cb7938 | 285 | |
7acf6008 | 286 | //First list of sdigits |
88cb7938 | 287 | |
fbf811ec | 288 | Int_t bufferSize = 32000 ; |
88cb7938 | 289 | TBranch * sdigitsBranch = treeS->Branch("PHOS",&sdigits,bufferSize); |
290 | ||
fbf811ec | 291 | sdigitsBranch->Fill() ; |
fbf811ec | 292 | |
88cb7938 | 293 | gime->WriteSDigits("OVERWRITE"); |
294 | ||
295 | //Next - SDigitizer | |
296 | ||
297 | gime->WriteSDigitizer("OVERWRITE"); | |
9d6866ec | 298 | //gObjectTable->Print() ; |
299 | ||
7acf6008 | 300 | if(strstr(option,"deb")) |
301 | PrintSDigits(option) ; | |
9d6866ec | 302 | |
9d6866ec | 303 | }// event loop |
fbf811ec | 304 | |
c65c502a | 305 | // //Write the quality assurance data |
306 | // GetQADataMaker()->EndOfCycle(AliQA::kHITS) ; | |
307 | // GetQADataMaker()->EndOfCycle(AliQA::kSDIGITS) ; | |
308 | // GetQADataMaker()->Finish() ; | |
ddd1a39c | 309 | |
88cb7938 | 310 | Unload(); |
311 | ||
9d6866ec | 312 | // gime->PhosLoader()->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); |
88cb7938 | 313 | |
7acf6008 | 314 | if(strstr(option,"tim")){ |
315 | gBenchmark->Stop("PHOSSDigitizer"); | |
21cd0c07 | 316 | Info("Exec"," took %f seconds for SDigitizing %f seconds per event", |
212d1c0f | 317 | gBenchmark->GetCpuTime("PHOSSDigitizer"), gBenchmark->GetCpuTime("PHOSSDigitizer")/nEvents) ; |
7acf6008 | 318 | } |
9d6866ec | 319 | |
990119d6 | 320 | } |
106fc2fa | 321 | |
990119d6 | 322 | //__________________________________________________________________ |
702ab87e | 323 | void AliPHOSSDigitizer::Print(const Option_t *)const |
a4e98857 | 324 | { |
325 | // Prints parameters of SDigitizer | |
88cb7938 | 326 | Info("Print", "\n------------------- %s -------------", GetName() ) ; |
327 | printf(" Writing SDigits to branch with title %s\n", fEventFolderName.Data()) ; | |
88cb7938 | 328 | printf(" Threshold for Primary assignment= %f\n", fPrimThreshold) ; |
329 | printf("---------------------------------------------------\n") ; | |
7acf6008 | 330 | |
990119d6 | 331 | } |
548f0134 | 332 | |
990119d6 | 333 | //__________________________________________________________________ |
a4e98857 | 334 | Bool_t AliPHOSSDigitizer::operator==( AliPHOSSDigitizer const &sd )const |
335 | { | |
3de072dc | 336 | // Equal operator. |
337 | // SDititizers are equal if their pedestal, slope and threshold are equal | |
338 | ||
f898e0f3 | 339 | if(fPrimThreshold==sd.fPrimThreshold) |
990119d6 | 340 | return kTRUE ; |
341 | else | |
342 | return kFALSE ; | |
343 | } | |
548f0134 | 344 | |
a6eedfad | 345 | //__________________________________________________________________ |
a4e98857 | 346 | void AliPHOSSDigitizer::PrintSDigits(Option_t * option) |
347 | { | |
348 | // Prints list of digits produced in the current pass of AliPHOSDigitizer | |
7b7c1533 | 349 | |
a6eedfad | 350 | |
88cb7938 | 351 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
6c8cd883 | 352 | |
353 | // Get PHOS Geometry object | |
354 | AliPHOSGeometry *geom; | |
355 | if (!(geom = AliPHOSGeometry::GetInstance())) | |
356 | geom = AliPHOSGeometry::GetInstance("IHEP",""); | |
357 | ||
88cb7938 | 358 | const TClonesArray * sdigits = gime->SDigits() ; |
21cd0c07 | 359 | |
71dfb0d8 | 360 | Info( "\nPrintSDigits", "event # %d %d sdigits", gAlice->GetEvNumber(), sdigits->GetEntriesFast() ) ; |
361 | ||
a6eedfad | 362 | if(strstr(option,"all")||strstr(option,"EMC")){ |
7acf6008 | 363 | |
364 | //loop over digits | |
365 | AliPHOSDigit * digit; | |
71dfb0d8 | 366 | printf("\nEMC sdigits\n") ; |
6c8cd883 | 367 | Int_t maxEmc = geom->GetNModules() * geom->GetNCristalsInModule() ; |
7acf6008 | 368 | Int_t index ; |
a6eedfad | 369 | for (index = 0 ; (index < sdigits->GetEntriesFast()) && |
fbf811ec | 370 | ((dynamic_cast<AliPHOSDigit *> (sdigits->At(index)))->GetId() <= maxEmc) ; index++) { |
371 | digit = dynamic_cast<AliPHOSDigit *>( sdigits->At(index) ) ; | |
71dfb0d8 | 372 | // if(digit->GetNprimary() == 0) |
373 | // continue; | |
27a73a5d | 374 | // printf("%6d %8d %6.5e %4d %2d :\n", // YVK |
375 | printf("%6d %.4f %6.5e %4d %2d :\n", | |
376 | digit->GetId(), digit->GetEnergy(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; | |
7acf6008 | 377 | Int_t iprimary; |
11f9c5ff | 378 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
71dfb0d8 | 379 | printf("%d ",digit->GetPrimary(iprimary+1) ) ; |
11f9c5ff | 380 | } |
a6eedfad | 381 | } |
a6eedfad | 382 | } |
383 | ||
384 | if(strstr(option,"all")||strstr(option,"CPV")){ | |
7acf6008 | 385 | |
a6eedfad | 386 | //loop over CPV digits |
387 | AliPHOSDigit * digit; | |
71dfb0d8 | 388 | printf("\nCPV sdigits\n") ; |
6c8cd883 | 389 | Int_t maxEmc = geom->GetNModules() * geom->GetNCristalsInModule() ; |
a6eedfad | 390 | Int_t index ; |
391 | for (index = 0 ; index < sdigits->GetEntriesFast(); index++) { | |
fbf811ec | 392 | digit = dynamic_cast<AliPHOSDigit *>( sdigits->At(index) ) ; |
a6eedfad | 393 | if(digit->GetId() > maxEmc){ |
71dfb0d8 | 394 | printf("\n%6d %8d %4d %2d :", |
11f9c5ff | 395 | digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ; |
a6eedfad | 396 | Int_t iprimary; |
21cd0c07 | 397 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) { |
71dfb0d8 | 398 | printf("%d ",digit->GetPrimary(iprimary+1) ) ; |
21cd0c07 | 399 | } |
a6eedfad | 400 | } |
401 | } | |
7acf6008 | 402 | } |
403 | } | |
7b7c1533 | 404 | |
405 | //____________________________________________________________________________ | |
88cb7938 | 406 | void AliPHOSSDigitizer::Unload() const |
7b7c1533 | 407 | { |
e957fea8 | 408 | // Unloads the objects from the folder |
88cb7938 | 409 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
410 | AliPHOSLoader * loader = gime->PhosLoader() ; | |
411 | loader->UnloadHits() ; | |
412 | loader->UnloadSDigits() ; | |
7b7c1533 | 413 | } |