]>
Commit | Line | Data |
---|---|---|
ffa6d63b | 1 | /************************************************************************* |
61e0abb5 | 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // This is a TTask that makes SDigits out of Hits | |
20 | // A Summable Digits is the sum of all hits originating | |
ffa6d63b | 21 | // from one in one tower of the EMCAL |
61e0abb5 | 22 | // A threshold for assignment of the primary to SDigit is applied |
23 | // SDigits are written to TreeS, branch "EMCAL" | |
24 | // AliEMCALSDigitizer with all current parameters is written | |
25 | // to TreeS branch "AliEMCALSDigitizer". | |
26 | // Both branches have the same title. If necessary one can produce | |
27 | // another set of SDigits with different parameters. Two versions | |
28 | // can be distunguished using titles of the branches. | |
29 | // User case: | |
30 | // root [0] AliEMCALSDigitizer * s = new AliEMCALSDigitizer("galice.root") | |
31 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated | |
32 | // root [1] s->ExecuteTask() | |
33 | // // Makes SDigitis for all events stored in galice.root | |
34 | // root [2] s->SetPedestalParameter(0.001) | |
35 | // // One can change parameters of digitization | |
36 | // root [3] s->SetSDigitsBranch("Redestal 0.001") | |
37 | // // and write them into the new branch | |
38 | // root [4] s->ExeciteTask("deb all tim") | |
39 | // // available parameters: | |
40 | // deb - print # of produced SDigitis | |
41 | // deb all - print # and list of produced SDigits | |
42 | // tim - print benchmarking information | |
43 | // | |
ffa6d63b | 44 | //*-- Author : Sahal Yacoob (LBL) |
45 | // based on : AliPHOSSDigitzer | |
61e0abb5 | 46 | ////////////////////////////////////////////////////////////////////////////// |
47 | ||
48 | ||
49 | // --- ROOT system --- | |
50 | #include "TFile.h" | |
51 | #include "TTask.h" | |
52 | #include "TTree.h" | |
53 | #include "TSystem.h" | |
54 | #include "TROOT.h" | |
55 | #include "TFolder.h" | |
106fc2fa | 56 | #include "TGeometry.h" |
61e0abb5 | 57 | #include "TBenchmark.h" |
58 | // --- Standard library --- | |
59 | #include <iomanip.h> | |
60 | ||
61 | // --- AliRoot header files --- | |
62 | #include "AliRun.h" | |
106fc2fa | 63 | #include "AliHeader.h" |
61e0abb5 | 64 | #include "AliEMCALDigit.h" |
65 | #include "AliEMCALHit.h" | |
66 | #include "AliEMCALSDigitizer.h" | |
67 | #include "AliEMCALGeometry.h" | |
68 | #include "AliEMCALv1.h" | |
814ad4bf | 69 | #include "AliEMCALGetter.h" |
61e0abb5 | 70 | |
71 | ClassImp(AliEMCALSDigitizer) | |
72 | ||
73 | ||
74 | //____________________________________________________________________________ | |
75 | AliEMCALSDigitizer::AliEMCALSDigitizer():TTask("AliEMCALSDigitizer","") | |
76 | { | |
77 | // ctor | |
839828a6 | 78 | InitParameters() ; |
92f521a9 | 79 | fDefaultInit = kTRUE ; |
61e0abb5 | 80 | } |
81 | ||
82 | //____________________________________________________________________________ | |
814ad4bf | 83 | AliEMCALSDigitizer::AliEMCALSDigitizer(const char* headerFile, const char *sDigitsTitle):TTask(sDigitsTitle, headerFile) |
61e0abb5 | 84 | { |
85 | // ctor | |
839828a6 | 86 | InitParameters() ; |
814ad4bf | 87 | Init(); |
92f521a9 | 88 | fDefaultInit = kFALSE ; |
61e0abb5 | 89 | } |
90 | ||
91 | //____________________________________________________________________________ | |
92 | AliEMCALSDigitizer::~AliEMCALSDigitizer() | |
93 | { | |
94 | // dtor | |
92f521a9 | 95 | // fDefaultInit = kTRUE if SDigitizer created by default ctor (to get just the parameters) |
96 | ||
97 | if (!fDefaultInit) { | |
98 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; | |
99 | ||
839828a6 | 100 | // remove the task from the folder list |
101 | gime->RemoveTask("S",GetName()) ; | |
102 | ||
103 | TString name(GetName()) ; | |
104 | if (! name.IsNull() ) | |
105 | if (name.Index(":") > 0) | |
106 | name.Remove(name.Index(":")) ; | |
107 | ||
108 | // remove the Hits from the folder list | |
109 | gime->RemoveObjects("H",name) ; | |
110 | ||
111 | // remove the SDigits from the folder list | |
112 | gime->RemoveObjects("S", name) ; | |
113 | ||
114 | // Close the root file | |
115 | gime->CloseFile() ; | |
116 | ||
117 | } | |
118 | fSplitFile = 0 ; | |
61e0abb5 | 119 | } |
36657114 | 120 | |
61e0abb5 | 121 | //____________________________________________________________________________ |
122 | void AliEMCALSDigitizer::Init(){ | |
61e0abb5 | 123 | |
814ad4bf | 124 | // Initialization: open root-file, allocate arrays for hits and sdigits, |
36657114 | 125 | // attach task SDigitizer to the list of EMCAL tasks |
814ad4bf | 126 | // |
127 | // Initialization can not be done in the default constructor | |
128 | //============================================================= YS | |
129 | // The initialisation is now done by the getter | |
61e0abb5 | 130 | |
36657114 | 131 | if( strcmp(GetTitle(), "") == 0 ) |
814ad4bf | 132 | SetTitle("galice.root") ; |
36657114 | 133 | |
814ad4bf | 134 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance(GetTitle(), GetName(), "update") ; |
135 | if ( gime == 0 ) { | |
136 | cerr << "ERROR: AliEMCALSDigitizer::Init -> Could not obtain the Getter object !" << endl ; | |
137 | return ; | |
138 | } | |
139 | ||
140 | gime->PostSDigits( GetName(), GetTitle() ) ; | |
61e0abb5 | 141 | |
814ad4bf | 142 | TString sdname(GetName() ); |
143 | sdname.Append(":") ; | |
144 | sdname.Append(GetTitle() ) ; | |
97f3344e | 145 | SetName(sdname.Data()) ; |
814ad4bf | 146 | gime->PostSDigitizer(this) ; |
147 | ||
814ad4bf | 148 | |
839828a6 | 149 | } |
150 | ||
151 | //____________________________________________________________________________ | |
152 | void AliEMCALSDigitizer::InitParameters(){ | |
153 | fA = 0; | |
154 | fB = 10000000.; | |
155 | fTowerPrimThreshold = 0.01 ; | |
156 | fPreShowerPrimThreshold = 0.0001 ; | |
157 | fNevents = 0 ; | |
158 | fPhotonElectronFactor = 5000. ; // photoelectrons per GeV | |
159 | fSplitFile = 0 ; | |
160 | ||
161 | } | |
162 | ||
61e0abb5 | 163 | //____________________________________________________________________________ |
164 | void AliEMCALSDigitizer::Exec(Option_t *option) { | |
61e0abb5 | 165 | |
814ad4bf | 166 | // Collects all hits in the same active volume into digit |
167 | ||
168 | if( strcmp(GetName(), "") == 0 ) | |
169 | Init() ; | |
61e0abb5 | 170 | |
814ad4bf | 171 | if (strstr(option, "print") ) { |
172 | Print("") ; | |
173 | return ; | |
174 | } | |
61e0abb5 | 175 | |
814ad4bf | 176 | if(strstr(option,"tim")) |
177 | gBenchmark->Start("EMCALSDigitizer"); | |
97f3344e | 178 | |
179 | ||
814ad4bf | 180 | //Check, if this branch already exits |
181 | gAlice->GetEvent(0) ; | |
97f3344e | 182 | |
183 | TString sdname(GetName()) ; | |
184 | sdname.Remove(sdname.Index(GetTitle())-1) ; | |
185 | ||
814ad4bf | 186 | if(gAlice->TreeS() ) { |
187 | TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeS()->GetListOfBranches()) ; | |
188 | TIter next(lob) ; | |
189 | TBranch * branch = 0 ; | |
190 | Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ; | |
61e0abb5 | 191 | |
97f3344e | 192 | while ( (branch = (static_cast<TBranch*>(next()))) && (!emcalfound || !sdigitizerfound) ) { |
36657114 | 193 | TString thisName( GetName() ) ; |
194 | TString branchName( branch->GetTitle() ) ; | |
195 | branchName.Append(":") ; | |
196 | if ( (strcmp(branch->GetName(), "EMCAL")==0) && thisName.BeginsWith(branchName) ) | |
814ad4bf | 197 | emcalfound = kTRUE ; |
198 | ||
36657114 | 199 | else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && thisName.BeginsWith(branchName) ) |
814ad4bf | 200 | sdigitizerfound = kTRUE ; |
61e0abb5 | 201 | } |
202 | ||
814ad4bf | 203 | if ( emcalfound || sdigitizerfound ) { |
204 | cerr << "WARNING: AliEMCALSDigitizer::Exec -> SDigits and/or SDigitizer branch with name " << GetName() | |
205 | << " already exits" << endl ; | |
206 | return ; | |
207 | } | |
208 | } | |
97f3344e | 209 | |
814ad4bf | 210 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
814ad4bf | 211 | Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; |
212 | ||
213 | Int_t ievent ; | |
214 | for(ievent = 0; ievent < nevents; ievent++){ | |
215 | gime->Event(ievent,"H") ; | |
216 | const TClonesArray * fHits = gime->Hits() ; | |
217 | TClonesArray * sdigits = gime->SDigits(sdname.Data()) ; | |
218 | sdigits->Clear(); | |
61e0abb5 | 219 | Int_t nSdigits = 0 ; |
814ad4bf | 220 | |
221 | //Collects all hits in the same active volume into digit | |
222 | ||
223 | ||
61e0abb5 | 224 | |
225 | ||
226 | //Now made SDigits from hits, for EMCAL it is the same, so just copy | |
814ad4bf | 227 | // Int_t itrack ; |
228 | // for (itrack=0; itrack < gAlice->GetNtrack(); itrack++){ | |
229 | //gime->Track(itrack); | |
61e0abb5 | 230 | //=========== Get the EMCAL branch from Hits Tree for the Primary track itrack |
89e103bd | 231 | |
61e0abb5 | 232 | Int_t i; |
e1f60236 | 233 | for ( i = 0 ; i < fHits->GetEntries() ; i++ ) { // loop over all hits (hit = deposited energy/layer/entering particle) |
234 | AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(i)) ; | |
235 | AliEMCALDigit * curSDigit = 0 ; | |
236 | AliEMCALDigit * sdigit = 0 ; | |
ffa6d63b | 237 | Bool_t newsdigit = kTRUE; |
e1f60236 | 238 | |
89e103bd | 239 | |
240 | ||
e1f60236 | 241 | // Assign primary number only if deposited energy is significant |
242 | ||
89e103bd | 243 | if( (!hit->IsInPreShower() && hit->GetEnergy() > fTowerPrimThreshold) || |
244 | (hit->IsInPreShower() && hit->GetEnergy() > fPreShowerPrimThreshold)) { | |
245 | curSDigit = new AliEMCALDigit( hit->GetPrimary(), | |
e1f60236 | 246 | hit->GetIparent(),Layer2TowerID(hit->GetId(),hit->IsInPreShower()), |
89e103bd | 247 | Digitize(hit->GetEnergy()), |
814ad4bf | 248 | hit->GetTime()) ; |
89e103bd | 249 | } else { |
814ad4bf | 250 | curSDigit = new AliEMCALDigit( -1 , |
251 | -1 , | |
e1f60236 | 252 | Layer2TowerID(hit->GetId(),hit->IsInPreShower()), |
89e103bd | 253 | Digitize(hit->GetEnergy()), |
e1f60236 | 254 | hit->GetTime() ) ; |
89e103bd | 255 | } |
e1f60236 | 256 | Int_t check = 0 ; |
257 | for(check= 0; check < nSdigits ; check++) { | |
814ad4bf | 258 | sdigit = (AliEMCALDigit *)sdigits->At(check); |
e1f60236 | 259 | if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same tower or the same preshower ? |
260 | *sdigit = *sdigit + *curSDigit; | |
261 | ||
262 | newsdigit = kFALSE; | |
263 | } | |
814ad4bf | 264 | } |
e1f60236 | 265 | if (newsdigit) { |
266 | new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit); | |
ffa6d63b | 267 | nSdigits++ ; |
e1f60236 | 268 | } |
269 | } // loop over all hits (hit = deposited energy/layer/entering particle) | |
814ad4bf | 270 | // } // loop over tracks |
e1f60236 | 271 | |
814ad4bf | 272 | sdigits->Sort() ; |
61e0abb5 | 273 | |
814ad4bf | 274 | nSdigits = sdigits->GetEntriesFast() ; |
106fc2fa | 275 | if (nSdigits > 0) { |
276 | sdigits->Expand(nSdigits) ; | |
277 | ||
278 | // Int_t i ; | |
279 | const AliEMCALGeometry * geom = gime->EMCALGeometry() ; | |
280 | ||
281 | Int_t lastPreShowerIndex = nSdigits - 1 ; | |
282 | if (!(dynamic_cast<AliEMCALDigit *>(sdigits->At(lastPreShowerIndex))->IsInPreShower())) | |
283 | lastPreShowerIndex = -2; | |
284 | Int_t firstPreShowerIndex = 100000 ; | |
285 | Int_t index ; | |
286 | AliEMCALDigit * sdigit = 0 ; | |
287 | for ( index = 0; index < nSdigits ; index++) { | |
288 | sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(index) ) ; | |
289 | if (sdigit->IsInPreShower() ){ | |
290 | firstPreShowerIndex = index ; | |
291 | break ; | |
292 | } | |
293 | } | |
294 | ||
295 | AliEMCALDigit * preshower ; | |
296 | AliEMCALDigit * tower ; | |
297 | Int_t lastIndex = lastPreShowerIndex +1 ; | |
298 | ||
299 | ||
300 | for (index = firstPreShowerIndex ; index <= lastPreShowerIndex; index++) { | |
301 | preshower = dynamic_cast<AliEMCALDigit *>(sdigits->At(index) ); | |
302 | Bool_t towerFound = kFALSE ; | |
303 | Int_t jndex ; | |
304 | for (jndex = 0; jndex < firstPreShowerIndex; jndex++) { | |
305 | tower = dynamic_cast<AliEMCALDigit *>(sdigits->At(jndex) ); | |
306 | if ( (preshower->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) == tower->GetId() ) { | |
307 | Float_t towerEnergy = static_cast<Float_t>(tower->GetAmp()) ; | |
308 | Float_t preshoEnergy = static_cast<Float_t>(preshower->GetAmp()) ; | |
309 | towerEnergy +=preshoEnergy ; | |
310 | *tower = *tower + *preshower ; // and add preshower multiplied by layer ratio to tower | |
311 | tower->SetAmp(static_cast<Int_t>(TMath::Ceil(towerEnergy))) ; | |
312 | towerFound = kTRUE ; | |
313 | } | |
314 | } | |
315 | if ( !towerFound ) { | |
316 | ||
317 | new((*sdigits)[lastIndex]) AliEMCALDigit(*preshower); | |
318 | AliEMCALDigit * temp = dynamic_cast<AliEMCALDigit *>(sdigits->At(lastIndex)) ; | |
319 | temp->SetId(temp->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) ; | |
320 | lastIndex++ ; | |
321 | } | |
322 | } | |
323 | ||
324 | sdigits->Sort() ; | |
325 | Int_t NPrimarymax = -1 ; | |
326 | for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { | |
327 | sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(i)) ; | |
328 | sdigit->SetIndexInList(i) ; | |
329 | } | |
330 | ||
331 | for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { | |
332 | if (((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) > NPrimarymax) | |
333 | NPrimarymax = ((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) ; | |
e1f60236 | 334 | } |
335 | } | |
106fc2fa | 336 | if(gAlice->TreeS() == 0) |
36657114 | 337 | gAlice->MakeTree("S",fSplitFile); |
338 | ||
814ad4bf | 339 | //First list of sdigits |
340 | Int_t bufferSize = 32000 ; | |
341 | TBranch * sdigitsBranch = gAlice->TreeS()->Branch("EMCAL",&sdigits,bufferSize); | |
342 | sdigitsBranch->SetTitle(sdname); | |
814ad4bf | 343 | |
814ad4bf | 344 | //second - SDigitizer |
345 | Int_t splitlevel = 0 ; | |
346 | AliEMCALSDigitizer * sd = this ; | |
347 | TBranch * sdigitizerBranch = gAlice->TreeS()->Branch("AliEMCALSDigitizer","AliEMCALSDigitizer", | |
348 | &sd,bufferSize,splitlevel); | |
349 | sdigitizerBranch->SetTitle(sdname); | |
814ad4bf | 350 | |
36657114 | 351 | sdigitsBranch->Fill() ; |
352 | sdigitizerBranch->Fill() ; | |
106fc2fa | 353 | gAlice->TreeS()->AutoSave() ; |
36657114 | 354 | |
814ad4bf | 355 | if(strstr(option,"deb")) |
356 | PrintSDigits(option) ; | |
357 | ||
61e0abb5 | 358 | } |
359 | ||
360 | if(strstr(option,"tim")){ | |
361 | gBenchmark->Stop("EMCALSDigitizer"); | |
362 | cout << "AliEMCALSDigitizer:" << endl ; | |
363 | cout << " took " << gBenchmark->GetCpuTime("EMCALSDigitizer") << " seconds for SDigitizing " | |
364 | << gBenchmark->GetCpuTime("EMCALSDigitizer")/fNevents << " seconds per event " << endl ; | |
365 | cout << endl ; | |
366 | } | |
367 | ||
368 | ||
369 | } | |
370 | //__________________________________________________________________ | |
371 | void AliEMCALSDigitizer::SetSDigitsBranch(const char * title ){ | |
814ad4bf | 372 | |
373 | // Setting title to branch SDigits | |
374 | ||
375 | TString stitle(title) ; | |
376 | ||
377 | // check if branch with title already exists | |
378 | TBranch * sdigitsBranch = | |
379 | static_cast<TBranch*>(gAlice->TreeS()->GetListOfBranches()->FindObject("EMCAL")) ; | |
380 | TBranch * sdigitizerBranch = | |
381 | static_cast<TBranch*>(gAlice->TreeS()->GetListOfBranches()->FindObject("AliEMCALSDigitizer")) ; | |
382 | const char * sdigitsTitle = sdigitsBranch ->GetTitle() ; | |
383 | const char * sdigitizerTitle = sdigitizerBranch ->GetTitle() ; | |
384 | if ( stitle.CompareTo(sdigitsTitle)==0 || stitle.CompareTo(sdigitizerTitle)==0 ){ | |
385 | cerr << "ERROR: AliEMCALSdigitizer::SetSDigitsBranch -> Cannot overwrite existing branch with title " << title << endl ; | |
386 | return ; | |
387 | } | |
388 | ||
389 | cout << "AliEMCALSdigitizer::SetSDigitsBranch -> Changing SDigits file from " << GetName() << " to " << title << endl ; | |
390 | ||
391 | SetName(title) ; | |
392 | ||
393 | // Post to the WhiteBoard | |
394 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; | |
395 | gime->PostSDigits( title, GetTitle()) ; | |
396 | ||
397 | ||
61e0abb5 | 398 | } |
106fc2fa | 399 | |
400 | //__________________________________________________________________ | |
36657114 | 401 | void AliEMCALSDigitizer::SetSplitFile(const TString splitFileName) |
106fc2fa | 402 | { |
403 | // Diverts the SDigits in a file separate from the hits file | |
404 | ||
405 | TDirectory * cwd = gDirectory ; | |
36657114 | 406 | |
407 | if ( !(gAlice->GetTreeSFileName() == splitFileName) ) { | |
408 | if (gAlice->GetTreeSFile() ) | |
409 | gAlice->GetTreeSFile()->Close() ; | |
410 | } | |
411 | ||
412 | fSplitFile = gAlice->InitTreeFile("S",splitFileName.Data()); | |
413 | fSplitFile->cd() ; | |
839828a6 | 414 | gAlice->Write(0, TObject::kOverwrite); |
415 | ||
106fc2fa | 416 | TTree *treeE = gAlice->TreeE(); |
417 | if (!treeE) { | |
36657114 | 418 | cerr << "ERROR: AliEMCALSDigitizer::SetSPlitFile -> No TreeE found "<<endl; |
419 | abort() ; | |
106fc2fa | 420 | } |
421 | ||
422 | // copy TreeE | |
839828a6 | 423 | |
424 | AliHeader *header = new AliHeader(); | |
425 | treeE->SetBranchAddress("Header", &header); | |
426 | treeE->SetBranchStatus("*",1); | |
427 | TTree *treeENew = treeE->CloneTree(); | |
428 | treeENew->Write(0, TObject::kOverwrite); | |
106fc2fa | 429 | |
430 | // copy AliceGeom | |
839828a6 | 431 | TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom")); |
432 | if (!AliceGeom) { | |
433 | cerr << "ERROR: AliEMCALSDigitizer::SetSPlitFile -> AliceGeom was not found in the input file "<<endl; | |
434 | abort() ; | |
106fc2fa | 435 | } |
839828a6 | 436 | AliceGeom->Write(0, TObject::kOverwrite) ; |
36657114 | 437 | |
438 | gAlice->MakeTree("S",fSplitFile); | |
106fc2fa | 439 | cwd->cd() ; |
36657114 | 440 | cout << "INFO: AliEMCALSDigitizer::SetSPlitFile -> SDigits will be stored in " << splitFileName.Data() << endl ; |
106fc2fa | 441 | } |
442 | ||
61e0abb5 | 443 | //__________________________________________________________________ |
444 | void AliEMCALSDigitizer::Print(Option_t* option)const{ | |
445 | cout << "------------------- "<< GetName() << " -------------" << endl ; | |
814ad4bf | 446 | cout << " Writing SDigitis to branch with title " << GetName() << endl ; |
89e103bd | 447 | cout << " with digitization parameters A = " << fA << endl ; |
448 | cout << " B = " << fB << endl ; | |
449 | cout << " Threshold for Primary assignment in Tower = " << fTowerPrimThreshold << endl ; | |
450 | cout << " Threshold for Primary assignment in PreShower = " << fPreShowerPrimThreshold << endl ; | |
61e0abb5 | 451 | cout << "---------------------------------------------------"<<endl ; |
452 | ||
453 | } | |
454 | //__________________________________________________________________ | |
455 | Bool_t AliEMCALSDigitizer::operator==( AliEMCALSDigitizer const &sd )const{ | |
89e103bd | 456 | if( (fA==sd.fA)&&(fB==sd.fB)&& |
457 | (fTowerPrimThreshold==sd.fTowerPrimThreshold) && | |
458 | (fPreShowerPrimThreshold==sd.fPreShowerPrimThreshold)) | |
61e0abb5 | 459 | return kTRUE ; |
460 | else | |
461 | return kFALSE ; | |
462 | } | |
463 | //__________________________________________________________________ | |
464 | void AliEMCALSDigitizer::PrintSDigits(Option_t * option){ | |
465 | //Prints list of digits produced at the current pass of AliEMCALDigitizer | |
466 | ||
814ad4bf | 467 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
468 | TString sdname(GetName()) ; | |
469 | sdname.Remove(sdname.Index(GetTitle())-1) ; | |
470 | const TClonesArray * sdigits = gime->SDigits(sdname.Data()) ; | |
61e0abb5 | 471 | |
814ad4bf | 472 | cout << "AliEMCALSDigitiser: event " << gAlice->GetEvNumber() << endl ; |
473 | cout << " Number of entries in SDigits list " << sdigits->GetEntriesFast() << endl ; | |
474 | cout << endl ; | |
475 | if(strstr(option,"all")||strstr(option,"EMC")){ | |
476 | ||
61e0abb5 | 477 | //loop over digits |
478 | AliEMCALDigit * digit; | |
e1f60236 | 479 | cout << "SDigit Id " << " Amplitude " << " Time " << " Index " << " Nprim " << " Primaries list " << endl; |
61e0abb5 | 480 | Int_t index ; |
814ad4bf | 481 | for (index = 0 ; index < sdigits->GetEntries() ; index++) { |
482 | digit = (AliEMCALDigit * ) sdigits->At(index) ; | |
483 | cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " " << digit->GetTime() | |
484 | << setw(6) << digit->GetIndexInList() << " " | |
485 | << setw(5) << digit->GetNprimary() <<" "; | |
61e0abb5 | 486 | |
487 | Int_t iprimary; | |
488 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) | |
814ad4bf | 489 | cout << " " << digit->GetPrimary(iprimary+1) << " "; |
61e0abb5 | 490 | cout << endl; |
491 | } | |
814ad4bf | 492 | cout <<endl; |
61e0abb5 | 493 | } |
494 | } | |
814ad4bf | 495 | //________________________________________________________________________ |
229f77c4 | 496 | Int_t AliEMCALSDigitizer::Layer2TowerID(Int_t ihit, Bool_t preshower){ |
497 | // Method to Transform from Hit Id to Digit Id | |
498 | // This function should be one to one | |
814ad4bf | 499 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
500 | const AliEMCALGeometry * geom = gime->EMCALGeometry(); | |
f063936c | 501 | Int_t ieta = ((ihit-1)/geom->GetNPhi())%geom->GetNZ(); // eta Tower Index |
229f77c4 | 502 | Int_t iphi = (ihit-1)%(geom->GetNPhi())+1; //phi Tower Index |
503 | Int_t it = -10; | |
504 | Int_t ipre = 0; | |
814ad4bf | 505 | |
229f77c4 | 506 | if (preshower)ipre = 1; |
507 | if (iphi > 0 && ieta >= 0){ | |
508 | it = iphi+ieta*geom->GetNPhi() + ipre*geom->GetNPhi()*geom->GetNZ(); | |
509 | return it; | |
510 | }else{ | |
511 | cerr << " AliEMCALSDigitizer::Layer2TowerID() -- there is an error "<< endl << "Eta number = " | |
512 | << ieta << "Phi number = " << iphi << endl ; | |
513 | return it; | |
514 | } // end if iphi>0 && ieta>0 | |
814ad4bf | 515 | } |
229f77c4 | 516 | //_______________________________________________________________________________________ |
89e103bd | 517 | // void AliEMCALSDigitizer::TestTowerID(void) |
518 | // { | |
519 | // Int_t j; | |
229f77c4 | 520 | |
89e103bd | 521 | // Bool_t preshower = kFALSE; |
522 | // for (j = 0 ; j < 10 ; j++){ // loop over hit id | |
523 | // Int_t i; | |
524 | // for (i = 0 ; i <= 2 ; i++){ // loop over | |
525 | // Int_t k = i*96*144+j*144+1; | |
526 | // cout << " Hit Index = " << k << " " << j*10 << " TOWERID = " << Layer2TowerID(k, preshower) << endl ; | |
527 | // } | |
528 | // } | |
529 | // } |