]>
Commit | Line | Data |
---|---|---|
61e0abb5 | 1 | /************************************************************************** |
692088ae | 2 | |
61e0abb5 | 3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
692088ae | 4 | |
61e0abb5 | 5 | * * |
692088ae | 6 | |
61e0abb5 | 7 | * Author: The ALICE Off-line Project. * |
692088ae | 8 | |
61e0abb5 | 9 | * Contributors are mentioned in the code where appropriate. * |
692088ae | 10 | |
61e0abb5 | 11 | * * |
692088ae | 12 | |
61e0abb5 | 13 | * Permission to use, copy, modify and distribute this software and its * |
692088ae | 14 | |
61e0abb5 | 15 | * documentation strictly for non-commercial purposes is hereby granted * |
692088ae | 16 | |
61e0abb5 | 17 | * without fee, provided that the above copyright notice appears in all * |
692088ae | 18 | |
61e0abb5 | 19 | * copies and that both the copyright notice and this permission notice * |
692088ae | 20 | |
61e0abb5 | 21 | * appear in the supporting documentation. The authors make no claims * |
692088ae | 22 | |
61e0abb5 | 23 | * about the suitability of this software for any purpose. It is * |
692088ae | 24 | |
61e0abb5 | 25 | * provided "as is" without express or implied warranty. * |
692088ae | 26 | |
61e0abb5 | 27 | **************************************************************************/ |
28 | ||
692088ae | 29 | |
30 | ||
61e0abb5 | 31 | /* $Id$ */ |
32 | ||
692088ae | 33 | |
34 | ||
61e0abb5 | 35 | //_________________________________________________________________________ |
692088ae | 36 | |
ffa6d63b | 37 | // |
692088ae | 38 | |
61e0abb5 | 39 | ////////////////////////////////////////////////////////////////////////////// |
692088ae | 40 | |
ffa6d63b | 41 | // Class performs digitization of Summable digits |
692088ae | 42 | |
ffa6d63b | 43 | // |
692088ae | 44 | |
61e0abb5 | 45 | // In addition it performs mixing of summable digits from different events. |
692088ae | 46 | |
61e0abb5 | 47 | // |
692088ae | 48 | |
61e0abb5 | 49 | // For each event two branches are created in TreeD: |
692088ae | 50 | |
61e0abb5 | 51 | // "EMCAL" - list of digits |
692088ae | 52 | |
61e0abb5 | 53 | // "AliEMCALDigitizer" - AliEMCALDigitizer with all parameters used in digitization |
692088ae | 54 | |
61e0abb5 | 55 | // |
692088ae | 56 | |
61e0abb5 | 57 | // Note, that one cset title for new digits branch, and repeat digitization with |
692088ae | 58 | |
61e0abb5 | 59 | // another set of parameters. |
692088ae | 60 | |
61e0abb5 | 61 | // |
692088ae | 62 | |
61e0abb5 | 63 | // Examples of use: |
692088ae | 64 | |
61e0abb5 | 65 | // root[0] AliEMCALDigitizer * d = new AliEMCALDigitizer() ; |
692088ae | 66 | |
61e0abb5 | 67 | // root[1] d->ExecuteTask() |
692088ae | 68 | |
61e0abb5 | 69 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
692088ae | 70 | |
61e0abb5 | 71 | // //Digitizes SDigitis in all events found in file galice.root |
692088ae | 72 | |
61e0abb5 | 73 | // |
692088ae | 74 | |
61e0abb5 | 75 | // root[2] AliEMCALDigitizer * d1 = new AliEMCALDigitizer("galice1.root") ; |
692088ae | 76 | |
61e0abb5 | 77 | // // Will read sdigits from galice1.root |
692088ae | 78 | |
61e0abb5 | 79 | // root[3] d1->MixWith("galice2.root") |
692088ae | 80 | |
61e0abb5 | 81 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
692088ae | 82 | |
61e0abb5 | 83 | // // Reads another portion of sdigits from galice2.root |
692088ae | 84 | |
61e0abb5 | 85 | // root[3] d1->MixWith("galice3.root") |
692088ae | 86 | |
61e0abb5 | 87 | // // Reads another portion of sdigits from galice3.root |
692088ae | 88 | |
61e0abb5 | 89 | // root[4] d->ExecuteTask("deb timing") |
692088ae | 90 | |
61e0abb5 | 91 | // // Reads SDigits from files galice1.root, galice2.root .... |
692088ae | 92 | |
61e0abb5 | 93 | // // mixes them and stores produced Digits in file galice1.root |
692088ae | 94 | |
61e0abb5 | 95 | // // deb - prints number of produced digits |
692088ae | 96 | |
61e0abb5 | 97 | // // deb all - prints list of produced digits |
692088ae | 98 | |
61e0abb5 | 99 | // // timing - prints time used for digitization |
692088ae | 100 | |
ffa6d63b | 101 | //////////////////////////////////////////////////////////////////////////////////// |
692088ae | 102 | |
61e0abb5 | 103 | // |
692088ae | 104 | |
ffa6d63b | 105 | //*-- Author: Sahal Yacoob (LBL) |
692088ae | 106 | |
814ad4bf | 107 | // based on : AliEMCALDigitizer |
692088ae | 108 | |
ffa6d63b | 109 | //_________________________________________________________________________________ |
61e0abb5 | 110 | |
692088ae | 111 | |
112 | ||
61e0abb5 | 113 | // --- ROOT system --- |
692088ae | 114 | |
61e0abb5 | 115 | #include "TFile.h" |
692088ae | 116 | |
61e0abb5 | 117 | #include "TTree.h" |
692088ae | 118 | |
61e0abb5 | 119 | #include "TSystem.h" |
692088ae | 120 | |
61e0abb5 | 121 | #include "TROOT.h" |
692088ae | 122 | |
61e0abb5 | 123 | #include "TFolder.h" |
692088ae | 124 | |
61e0abb5 | 125 | #include "TObjString.h" |
692088ae | 126 | |
61e0abb5 | 127 | #include "TBenchmark.h" |
692088ae | 128 | |
61e0abb5 | 129 | // --- Standard library --- |
692088ae | 130 | |
61e0abb5 | 131 | #include <iomanip.h> |
132 | ||
692088ae | 133 | |
134 | ||
61e0abb5 | 135 | // --- AliRoot header files --- |
136 | ||
692088ae | 137 | |
138 | ||
61e0abb5 | 139 | #include "AliRun.h" |
692088ae | 140 | |
61e0abb5 | 141 | #include "AliEMCALDigit.h" |
692088ae | 142 | |
61e0abb5 | 143 | #include "AliEMCALHit.h" |
692088ae | 144 | |
814ad4bf | 145 | #include "AliEMCALTick.h" |
692088ae | 146 | |
61e0abb5 | 147 | #include "AliEMCALv1.h" |
692088ae | 148 | |
61e0abb5 | 149 | #include "AliEMCALDigitizer.h" |
692088ae | 150 | |
61e0abb5 | 151 | #include "AliEMCALSDigitizer.h" |
692088ae | 152 | |
61e0abb5 | 153 | #include "AliEMCALGeometry.h" |
692088ae | 154 | |
814ad4bf | 155 | #include "AliEMCALGetter.h" |
692088ae | 156 | |
814ad4bf | 157 | #include "AliRunDigitizer.h" |
692088ae | 158 | |
61e0abb5 | 159 | ClassImp(AliEMCALDigitizer) |
160 | ||
161 | ||
692088ae | 162 | |
163 | ||
164 | ||
61e0abb5 | 165 | //____________________________________________________________________________ |
692088ae | 166 | |
814ad4bf | 167 | AliEMCALDigitizer::AliEMCALDigitizer() |
692088ae | 168 | |
61e0abb5 | 169 | { |
692088ae | 170 | |
61e0abb5 | 171 | // ctor |
172 | ||
692088ae | 173 | |
174 | ||
61e0abb5 | 175 | fSDigitizer = 0 ; |
61e0abb5 | 176 | |
692088ae | 177 | fNinputs = 0 ; |
178 | ||
179 | fPinNoise = 0. ; | |
180 | ||
181 | fTowerDigitThreshold = 0. ; | |
182 | ||
183 | fTimeResolution =0.; | |
184 | ||
185 | fTimeSignalLength =0.; | |
186 | ||
187 | fPreShowerDigitThreshold = 0. ; | |
188 | ||
189 | fADCchannelTower = 0.0; // width of one ADC channel in GeV | |
190 | ||
191 | fADCpedestalTower = 0.0 ; // pedestal of ADC | |
192 | ||
193 | fNADCTower = 0 ; | |
194 | ||
195 | fADCchannelPreSho = 0.0 ; // width of one ADC channel in Pre Shower | |
196 | ||
197 | fADCpedestalPreSho = 0.0 ; // pedestal of ADC | |
198 | ||
199 | fNADCPreSho = 0; // number of channels in Pre Shower ADC | |
200 | ||
201 | fTimeThreshold = 0.0 ; | |
202 | ||
814ad4bf | 203 | fManager = 0 ; |
61e0abb5 | 204 | |
61e0abb5 | 205 | |
61e0abb5 | 206 | |
692088ae | 207 | |
208 | ||
209 | ||
210 | ||
61e0abb5 | 211 | } |
692088ae | 212 | |
61e0abb5 | 213 | //____________________________________________________________________________ |
692088ae | 214 | |
814ad4bf | 215 | Bool_t AliEMCALDigitizer::Init() |
692088ae | 216 | |
61e0abb5 | 217 | { |
692088ae | 218 | |
814ad4bf | 219 | // Makes all memory allocations |
220 | ||
692088ae | 221 | |
222 | ||
814ad4bf | 223 | fSDigitizer = 0 ; |
692088ae | 224 | |
814ad4bf | 225 | fNinputs = 1 ; |
692088ae | 226 | |
d968cee0 | 227 | fPinNoise = 0.00001 ; |
692088ae | 228 | |
d968cee0 | 229 | fTowerDigitThreshold = 0.001 ; |
692088ae | 230 | |
814ad4bf | 231 | fTimeResolution = 0.5e-9 ; |
692088ae | 232 | |
814ad4bf | 233 | fTimeSignalLength = 1.0e-9 ; |
692088ae | 234 | |
d968cee0 | 235 | fPreShowerDigitThreshold = fTowerDigitThreshold/25. ; |
692088ae | 236 | |
814ad4bf | 237 | fInitialized = kFALSE ; |
692088ae | 238 | |
ec803232 | 239 | fADCchannelTower = 0.000160; // width of one ADC channel in GeV |
692088ae | 240 | |
d968cee0 | 241 | fADCpedestalTower = 0.005 ; // GeV |
692088ae | 242 | |
814ad4bf | 243 | fNADCTower = (Int_t) TMath::Power(2,16) ; // number of channels in Tower ADC |
244 | ||
692088ae | 245 | |
246 | ||
ec803232 | 247 | fADCchannelPreSho = 0.00000170; // width of one ADC channel in Pre Shower |
692088ae | 248 | |
814ad4bf | 249 | fADCpedestalPreSho = 0.005 ; // |
692088ae | 250 | |
d968cee0 | 251 | fNADCPreSho = (Int_t) TMath::Power(2,12); // number of channels in Pre ShowerADC |
814ad4bf | 252 | |
692088ae | 253 | |
254 | ||
814ad4bf | 255 | fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude |
692088ae | 256 | |
814ad4bf | 257 | |
258 | ||
259 | ||
692088ae | 260 | |
261 | ||
262 | ||
814ad4bf | 263 | if(fManager) |
692088ae | 264 | |
814ad4bf | 265 | SetTitle("aliroot") ; |
692088ae | 266 | |
814ad4bf | 267 | else if (strcmp(GetTitle(),"")==0) |
692088ae | 268 | |
814ad4bf | 269 | SetTitle("galice.root") ; |
270 | ||
692088ae | 271 | |
272 | ||
814ad4bf | 273 | if( strcmp(GetName(), "") == 0 ) |
692088ae | 274 | |
814ad4bf | 275 | SetName("Default") ; |
692088ae | 276 | |
61e0abb5 | 277 | |
692088ae | 278 | |
814ad4bf | 279 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance(GetTitle(), GetName(), "update") ; |
692088ae | 280 | |
814ad4bf | 281 | if ( gime == 0 ) { |
692088ae | 282 | |
814ad4bf | 283 | cerr << "ERROR: AliEMCALDigitizer::Init -> Could not obtain the Getter object !" << endl ; |
692088ae | 284 | |
814ad4bf | 285 | return kFALSE; |
692088ae | 286 | |
814ad4bf | 287 | } |
692088ae | 288 | |
61e0abb5 | 289 | |
692088ae | 290 | |
814ad4bf | 291 | //const AliEMCALGeometry * geom = gime->EMCALGeometry() ; |
692088ae | 292 | |
814ad4bf | 293 | //fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ; |
692088ae | 294 | |
61e0abb5 | 295 | |
692088ae | 296 | |
814ad4bf | 297 | // Post Digits to the white board |
692088ae | 298 | |
814ad4bf | 299 | gime->PostDigits(GetName() ) ; |
692088ae | 300 | |
61e0abb5 | 301 | |
692088ae | 302 | |
814ad4bf | 303 | // Post Digitizer to the white board |
692088ae | 304 | |
814ad4bf | 305 | gime->PostDigitizer(this) ; |
692088ae | 306 | |
61e0abb5 | 307 | |
692088ae | 308 | |
814ad4bf | 309 | //Mark that we will use current header file |
692088ae | 310 | |
814ad4bf | 311 | if(!fManager){ |
692088ae | 312 | |
814ad4bf | 313 | gime->PostSDigits(GetName(),GetTitle()) ; |
692088ae | 314 | |
814ad4bf | 315 | gime->PostSDigitizer(GetName(),GetTitle()) ; |
692088ae | 316 | |
814ad4bf | 317 | } |
692088ae | 318 | |
814ad4bf | 319 | return kTRUE ; |
692088ae | 320 | |
61e0abb5 | 321 | |
692088ae | 322 | |
814ad4bf | 323 | |
692088ae | 324 | |
61e0abb5 | 325 | |
692088ae | 326 | |
814ad4bf | 327 | } |
328 | ||
692088ae | 329 | |
330 | ||
814ad4bf | 331 | //____________________________________________________________________________ |
692088ae | 332 | |
814ad4bf | 333 | AliEMCALDigitizer::AliEMCALDigitizer(const char *headerFile,const char *name) |
692088ae | 334 | |
814ad4bf | 335 | { |
692088ae | 336 | |
814ad4bf | 337 | SetName(name) ; |
692088ae | 338 | |
814ad4bf | 339 | SetTitle(headerFile) ; |
692088ae | 340 | |
814ad4bf | 341 | fManager = 0 ; // We work in the standalong mode |
692088ae | 342 | |
814ad4bf | 343 | Init() ; |
692088ae | 344 | |
61e0abb5 | 345 | |
814ad4bf | 346 | |
692088ae | 347 | |
348 | ||
61e0abb5 | 349 | |
692088ae | 350 | |
814ad4bf | 351 | } |
692088ae | 352 | |
814ad4bf | 353 | //____________________________________________________________________________ |
692088ae | 354 | |
814ad4bf | 355 | AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * ard):AliDigitizer(ard) |
692088ae | 356 | |
814ad4bf | 357 | { |
692088ae | 358 | |
814ad4bf | 359 | // ctor |
692088ae | 360 | |
814ad4bf | 361 | SetName(""); //Will call init in the digitizing |
692088ae | 362 | |
814ad4bf | 363 | SetTitle("aliroot") ; |
692088ae | 364 | |
61e0abb5 | 365 | } |
366 | ||
692088ae | 367 | |
368 | ||
61e0abb5 | 369 | //____________________________________________________________________________ |
692088ae | 370 | |
61e0abb5 | 371 | AliEMCALDigitizer::~AliEMCALDigitizer() |
692088ae | 372 | |
61e0abb5 | 373 | { |
692088ae | 374 | |
61e0abb5 | 375 | // dtor |
376 | ||
692088ae | 377 | |
378 | ||
61e0abb5 | 379 | } |
692088ae | 380 | |
61e0abb5 | 381 | //____________________________________________________________________________ |
692088ae | 382 | |
61e0abb5 | 383 | void AliEMCALDigitizer::Reset() { |
692088ae | 384 | |
61e0abb5 | 385 | //sets current event number to the first simulated event |
692088ae | 386 | |
814ad4bf | 387 | if( strcmp(GetName(), "") == 0 ) |
692088ae | 388 | |
814ad4bf | 389 | Init() ; |
61e0abb5 | 390 | |
692088ae | 391 | |
392 | ||
814ad4bf | 393 | // Int_t inputs ; |
692088ae | 394 | |
814ad4bf | 395 | // for(inputs = 0; inputs < fNinputs ;inputs++) |
692088ae | 396 | |
814ad4bf | 397 | // fIevent->AddAt(-1, inputs ) ; |
692088ae | 398 | |
61e0abb5 | 399 | |
692088ae | 400 | |
61e0abb5 | 401 | } |
402 | ||
692088ae | 403 | |
404 | ||
61e0abb5 | 405 | //____________________________________________________________________________ |
692088ae | 406 | |
814ad4bf | 407 | void AliEMCALDigitizer::Digitize(const Int_t event) { |
61e0abb5 | 408 | |
692088ae | 409 | |
410 | ||
61e0abb5 | 411 | // Makes the digitization of the collected summable digits |
692088ae | 412 | |
61e0abb5 | 413 | // for this it first creates the array of all EMCAL modules |
692088ae | 414 | |
61e0abb5 | 415 | // filled with noise (different for EMC, CPV and PPSD) and |
692088ae | 416 | |
61e0abb5 | 417 | // after that adds contributions from SDigits. This design |
692088ae | 418 | |
61e0abb5 | 419 | // helps to avoid scanning over the list of digits to add |
692088ae | 420 | |
61e0abb5 | 421 | // contribution of any new SDigit. |
422 | ||
692088ae | 423 | |
424 | ||
814ad4bf | 425 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
692088ae | 426 | |
814ad4bf | 427 | TClonesArray * digits = gime->Digits(GetName()) ; |
692088ae | 428 | |
814ad4bf | 429 | |
692088ae | 430 | |
814ad4bf | 431 | digits->Clear() ; |
61e0abb5 | 432 | |
692088ae | 433 | |
434 | ||
814ad4bf | 435 | const AliEMCALGeometry *geom = gime->EMCALGeometry() ; |
61e0abb5 | 436 | |
61e0abb5 | 437 | |
692088ae | 438 | |
439 | ||
440 | ||
61e0abb5 | 441 | //Making digits with noise, first EMC |
692088ae | 442 | |
ffa6d63b | 443 | Int_t nEMC = 2*geom->GetNPhi()*geom->GetNZ(); |
692088ae | 444 | |
61e0abb5 | 445 | Int_t absID ; |
692088ae | 446 | |
61e0abb5 | 447 | TString name = geom->GetName() ; |
61e0abb5 | 448 | |
692088ae | 449 | |
450 | ||
814ad4bf | 451 | // get first the sdigitizer from the tasks list (must have same name as the digitizer) |
692088ae | 452 | |
814ad4bf | 453 | const AliEMCALSDigitizer * sDigitizer = gime->SDigitizer(GetName()); |
692088ae | 454 | |
814ad4bf | 455 | if ( !sDigitizer) { |
692088ae | 456 | |
814ad4bf | 457 | cerr << "ERROR: AliEMCALDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ; |
692088ae | 458 | |
814ad4bf | 459 | abort() ; |
692088ae | 460 | |
61e0abb5 | 461 | } |
462 | ||
692088ae | 463 | |
464 | ||
814ad4bf | 465 | // loop through the sdigits posted to the White Board and add them to the noise |
692088ae | 466 | |
814ad4bf | 467 | TCollection * folderslist = gime->SDigitsFolder()->GetListOfFolders() ; |
692088ae | 468 | |
814ad4bf | 469 | TIter next(folderslist) ; |
692088ae | 470 | |
814ad4bf | 471 | TFolder * folder = 0 ; |
692088ae | 472 | |
814ad4bf | 473 | TClonesArray * sdigits = 0 ; |
692088ae | 474 | |
814ad4bf | 475 | Int_t input = 0 ; |
692088ae | 476 | |
814ad4bf | 477 | TObjArray * sdigArray = new TObjArray(2) ; |
692088ae | 478 | |
814ad4bf | 479 | while ( (folder = (TFolder*)next()) ) |
692088ae | 480 | |
814ad4bf | 481 | if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { |
692088ae | 482 | |
814ad4bf | 483 | cout << "INFO: AliEMCALDigitizer::Digitize -> Adding SDigits " |
692088ae | 484 | |
814ad4bf | 485 | << GetName() << " from " << folder->GetName() << endl ; |
692088ae | 486 | |
814ad4bf | 487 | sdigArray->AddAt(sdigits, input) ; |
692088ae | 488 | |
814ad4bf | 489 | input++ ; |
692088ae | 490 | |
814ad4bf | 491 | } |
61e0abb5 | 492 | |
692088ae | 493 | |
494 | ||
d968cee0 | 495 | //Find the first tower with signal |
692088ae | 496 | |
814ad4bf | 497 | Int_t nextSig = 200000 ; |
692088ae | 498 | |
814ad4bf | 499 | Int_t i; |
692088ae | 500 | |
814ad4bf | 501 | for(i=0; i<input; i++){ |
692088ae | 502 | |
814ad4bf | 503 | sdigits = (TClonesArray *)sdigArray->At(i) ; |
692088ae | 504 | |
814ad4bf | 505 | if ( !sdigits->GetEntriesFast() ) |
692088ae | 506 | |
814ad4bf | 507 | continue ; |
692088ae | 508 | |
814ad4bf | 509 | Int_t curNext = ((AliEMCALDigit *)sdigits->At(0))->GetId() ; |
692088ae | 510 | |
814ad4bf | 511 | if(curNext < nextSig) |
692088ae | 512 | |
814ad4bf | 513 | nextSig = curNext ; |
692088ae | 514 | |
814ad4bf | 515 | } |
61e0abb5 | 516 | |
692088ae | 517 | |
518 | ||
814ad4bf | 519 | TArrayI index(input) ; |
692088ae | 520 | |
814ad4bf | 521 | index.Reset() ; //Set all indexes to zero |
61e0abb5 | 522 | |
692088ae | 523 | |
524 | ||
814ad4bf | 525 | AliEMCALDigit * digit = 0 ; |
692088ae | 526 | |
814ad4bf | 527 | AliEMCALDigit * curSDigit = 0 ; |
ffa6d63b | 528 | |
692088ae | 529 | |
530 | ||
814ad4bf | 531 | TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ; |
ffa6d63b | 532 | |
692088ae | 533 | |
534 | ||
814ad4bf | 535 | //Put Noise contribution |
692088ae | 536 | |
814ad4bf | 537 | for(absID = 1; absID <= nEMC; absID++){ |
692088ae | 538 | |
d968cee0 | 539 | Float_t noise = gRandom->Gaus(0., fPinNoise); |
692088ae | 540 | |
814ad4bf | 541 | new((*digits)[absID-1]) AliEMCALDigit( -1, -1, absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ; |
692088ae | 542 | |
814ad4bf | 543 | //look if we have to add signal? |
692088ae | 544 | |
814ad4bf | 545 | if(absID==nextSig){ |
692088ae | 546 | |
814ad4bf | 547 | //Add SDigits from all inputs |
692088ae | 548 | |
814ad4bf | 549 | digit = (AliEMCALDigit *) digits->At(absID-1) ; |
692088ae | 550 | |
814ad4bf | 551 | |
692088ae | 552 | |
814ad4bf | 553 | ticks->Clear() ; |
692088ae | 554 | |
814ad4bf | 555 | Int_t contrib = 0 ; |
692088ae | 556 | |
814ad4bf | 557 | Float_t a = digit->GetAmp() ; |
692088ae | 558 | |
814ad4bf | 559 | Float_t b = TMath::Abs( a /fTimeSignalLength) ; |
692088ae | 560 | |
814ad4bf | 561 | //Mark the beginnign of the signal |
692088ae | 562 | |
814ad4bf | 563 | new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b); |
692088ae | 564 | |
814ad4bf | 565 | //Mark the end of the ignal |
692088ae | 566 | |
814ad4bf | 567 | new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b); |
692088ae | 568 | |
814ad4bf | 569 | |
692088ae | 570 | |
814ad4bf | 571 | // loop over input |
692088ae | 572 | |
814ad4bf | 573 | |
692088ae | 574 | |
814ad4bf | 575 | for(i = 0; i< input ; i++){ //loop over (possible) merge sources |
692088ae | 576 | |
814ad4bf | 577 | if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] ) |
692088ae | 578 | |
814ad4bf | 579 | curSDigit = (AliEMCALDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ; |
692088ae | 580 | |
814ad4bf | 581 | else |
692088ae | 582 | |
814ad4bf | 583 | curSDigit = 0 ; |
692088ae | 584 | |
814ad4bf | 585 | //May be several digits will contribute from the same input |
692088ae | 586 | |
814ad4bf | 587 | while(curSDigit && curSDigit->GetId() == absID){ |
692088ae | 588 | |
814ad4bf | 589 | //Shift primary to separate primaries belonging different inputs |
692088ae | 590 | |
814ad4bf | 591 | Int_t primaryoffset ; |
692088ae | 592 | |
814ad4bf | 593 | if(fManager) |
692088ae | 594 | |
814ad4bf | 595 | primaryoffset = fManager->GetMask(i) ; |
692088ae | 596 | |
814ad4bf | 597 | else |
692088ae | 598 | |
814ad4bf | 599 | primaryoffset = i ; |
692088ae | 600 | |
814ad4bf | 601 | curSDigit->ShiftPrimary(primaryoffset) ; |
692088ae | 602 | |
814ad4bf | 603 | |
692088ae | 604 | |
814ad4bf | 605 | a = curSDigit->GetAmp() ; |
692088ae | 606 | |
814ad4bf | 607 | b = a /fTimeSignalLength ; |
692088ae | 608 | |
814ad4bf | 609 | new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b); |
692088ae | 610 | |
814ad4bf | 611 | new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); |
612 | ||
692088ae | 613 | |
614 | ||
814ad4bf | 615 | *digit = *digit + *curSDigit ; //add energies |
616 | ||
692088ae | 617 | |
618 | ||
814ad4bf | 619 | index[i]++ ; |
692088ae | 620 | |
814ad4bf | 621 | if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] ) |
692088ae | 622 | |
814ad4bf | 623 | curSDigit = (AliEMCALDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ; |
692088ae | 624 | |
814ad4bf | 625 | else |
692088ae | 626 | |
814ad4bf | 627 | curSDigit = 0 ; |
692088ae | 628 | |
814ad4bf | 629 | } |
692088ae | 630 | |
814ad4bf | 631 | } |
ffa6d63b | 632 | |
692088ae | 633 | |
634 | ||
814ad4bf | 635 | //calculate and set time |
692088ae | 636 | |
814ad4bf | 637 | Float_t time = FrontEdgeTime(ticks) ; |
692088ae | 638 | |
814ad4bf | 639 | digit->SetTime(time) ; |
640 | ||
692088ae | 641 | |
642 | ||
814ad4bf | 643 | //Find next signal module |
692088ae | 644 | |
814ad4bf | 645 | nextSig = 200000 ; |
692088ae | 646 | |
814ad4bf | 647 | for(i=0; i<input; i++){ |
692088ae | 648 | |
814ad4bf | 649 | sdigits = ((TClonesArray *)sdigArray->At(i)) ; |
692088ae | 650 | |
814ad4bf | 651 | Int_t curNext = nextSig ; |
692088ae | 652 | |
814ad4bf | 653 | if(sdigits->GetEntriesFast() > index[i] ){ |
692088ae | 654 | |
814ad4bf | 655 | curNext = ((AliEMCALDigit *) sdigits->At(index[i]))->GetId() ; |
692088ae | 656 | |
814ad4bf | 657 | |
692088ae | 658 | |
814ad4bf | 659 | } |
692088ae | 660 | |
814ad4bf | 661 | if(curNext < nextSig) nextSig = curNext ; |
692088ae | 662 | |
814ad4bf | 663 | } |
692088ae | 664 | |
814ad4bf | 665 | } |
692088ae | 666 | |
814ad4bf | 667 | } |
692088ae | 668 | |
814ad4bf | 669 | |
692088ae | 670 | |
814ad4bf | 671 | ticks->Delete() ; |
692088ae | 672 | |
814ad4bf | 673 | delete ticks ; |
61e0abb5 | 674 | |
61e0abb5 | 675 | |
61e0abb5 | 676 | |
61e0abb5 | 677 | |
692088ae | 678 | |
679 | ||
680 | ||
681 | ||
682 | ||
814ad4bf | 683 | //remove digits below thresholds |
692088ae | 684 | |
814ad4bf | 685 | for(absID = 0; absID < nEMC/2 ; absID++){ |
692088ae | 686 | |
d968cee0 | 687 | if(sDigitizer->Calibrate(((AliEMCALDigit*)digits->At(absID))->GetAmp()) < fTowerDigitThreshold) |
692088ae | 688 | |
814ad4bf | 689 | digits->RemoveAt(absID) ; |
692088ae | 690 | |
814ad4bf | 691 | else |
692088ae | 692 | |
814ad4bf | 693 | digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ; |
692088ae | 694 | |
814ad4bf | 695 | } |
692088ae | 696 | |
61e0abb5 | 697 | |
692088ae | 698 | |
814ad4bf | 699 | for(absID = nEMC/2; absID < nEMC ; absID++){ |
692088ae | 700 | |
814ad4bf | 701 | if(sDigitizer->Calibrate(((AliEMCALDigit*)digits->At(absID))->GetAmp()) < fPreShowerDigitThreshold) |
692088ae | 702 | |
814ad4bf | 703 | digits->RemoveAt(absID) ; |
692088ae | 704 | |
814ad4bf | 705 | else |
692088ae | 706 | |
814ad4bf | 707 | digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ; |
692088ae | 708 | |
61e0abb5 | 709 | } |
692088ae | 710 | |
61e0abb5 | 711 | |
692088ae | 712 | |
814ad4bf | 713 | digits->Compress() ; |
692088ae | 714 | |
61e0abb5 | 715 | |
692088ae | 716 | |
814ad4bf | 717 | Int_t ndigits = digits->GetEntriesFast() ; |
692088ae | 718 | |
61e0abb5 | 719 | |
692088ae | 720 | |
814ad4bf | 721 | digits->Expand(ndigits) ; |
692088ae | 722 | |
61e0abb5 | 723 | |
692088ae | 724 | |
61e0abb5 | 725 | |
692088ae | 726 | |
814ad4bf | 727 | //Set indexes in list of digits |
692088ae | 728 | |
814ad4bf | 729 | //Int_t i ; |
692088ae | 730 | |
ec803232 | 731 | cout << "fNADCTower = " << fNADCTower << " fNADCPreSho = " << fNADCPreSho << endl ; |
692088ae | 732 | |
ec803232 | 733 | for (i = 0 ; i < ndigits ; i++) { |
692088ae | 734 | |
814ad4bf | 735 | AliEMCALDigit * digit = (AliEMCALDigit *) digits->At(i) ; |
692088ae | 736 | |
814ad4bf | 737 | digit->SetIndexInList(i) ; |
692088ae | 738 | |
814ad4bf | 739 | Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ; |
692088ae | 740 | |
814ad4bf | 741 | digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ; |
692088ae | 742 | |
61e0abb5 | 743 | } |
692088ae | 744 | |
814ad4bf | 745 | } |
61e0abb5 | 746 | |
692088ae | 747 | |
748 | ||
814ad4bf | 749 | //____________________________________________________________________________ |
61e0abb5 | 750 | |
692088ae | 751 | |
752 | ||
814ad4bf | 753 | Int_t AliEMCALDigitizer::DigitizeEnergy(Float_t energy, Int_t absId) |
692088ae | 754 | |
814ad4bf | 755 | { |
692088ae | 756 | |
814ad4bf | 757 | Int_t channel = -999; |
692088ae | 758 | |
814ad4bf | 759 | Int_t nphi = AliEMCALGetter::GetInstance()->EMCALGeometry()->GetNPhi() ; |
692088ae | 760 | |
814ad4bf | 761 | Int_t nz = AliEMCALGetter::GetInstance()->EMCALGeometry()->GetNZ() ; |
692088ae | 762 | |
814ad4bf | 763 | |
692088ae | 764 | |
ec803232 | 765 | if(absId <= nphi*nz){ //digitize as tower |
692088ae | 766 | |
ec803232 | 767 | channel = static_cast<Int_t> (TMath::Ceil( (energy + fADCpedestalTower)/fADCchannelTower )) ; |
692088ae | 768 | |
ec803232 | 769 | if(channel > fNADCTower ) |
692088ae | 770 | |
ec803232 | 771 | channel = fNADCTower ; |
692088ae | 772 | |
ec803232 | 773 | } else { |
692088ae | 774 | |
ec803232 | 775 | channel = static_cast<Int_t>(TMath::Ceil( (energy + fADCpedestalPreSho)/fADCchannelPreSho )) ; |
692088ae | 776 | |
ec803232 | 777 | if(channel > fNADCPreSho ) |
692088ae | 778 | |
ec803232 | 779 | channel = fNADCPreSho ; |
692088ae | 780 | |
ec803232 | 781 | } |
692088ae | 782 | |
814ad4bf | 783 | |
692088ae | 784 | |
814ad4bf | 785 | return channel ; |
692088ae | 786 | |
61e0abb5 | 787 | } |
788 | ||
692088ae | 789 | |
790 | ||
61e0abb5 | 791 | //____________________________________________________________________________ |
692088ae | 792 | |
61e0abb5 | 793 | void AliEMCALDigitizer::Exec(Option_t *option) { |
692088ae | 794 | |
61e0abb5 | 795 | // Managing method |
692088ae | 796 | |
814ad4bf | 797 | if(strcmp(GetName(), "") == 0 ) |
692088ae | 798 | |
814ad4bf | 799 | Init() ; |
692088ae | 800 | |
814ad4bf | 801 | |
692088ae | 802 | |
814ad4bf | 803 | if (strstr(option,"print")) { |
692088ae | 804 | |
814ad4bf | 805 | Print(""); |
692088ae | 806 | |
814ad4bf | 807 | return ; |
692088ae | 808 | |
814ad4bf | 809 | } |
692088ae | 810 | |
814ad4bf | 811 | |
692088ae | 812 | |
61e0abb5 | 813 | if(strstr(option,"tim")) |
692088ae | 814 | |
61e0abb5 | 815 | gBenchmark->Start("EMCALDigitizer"); |
816 | ||
692088ae | 817 | |
818 | ||
814ad4bf | 819 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
692088ae | 820 | |
814ad4bf | 821 | |
692088ae | 822 | |
814ad4bf | 823 | Int_t nevents ; |
692088ae | 824 | |
814ad4bf | 825 | |
692088ae | 826 | |
814ad4bf | 827 | TTree * treeD ; |
692088ae | 828 | |
814ad4bf | 829 | |
692088ae | 830 | |
814ad4bf | 831 | if(fManager){ |
692088ae | 832 | |
814ad4bf | 833 | treeD = fManager->GetTreeD() ; |
692088ae | 834 | |
814ad4bf | 835 | nevents = 1 ; // Will process only one event |
692088ae | 836 | |
814ad4bf | 837 | } |
692088ae | 838 | |
814ad4bf | 839 | else { |
692088ae | 840 | |
814ad4bf | 841 | gAlice->GetEvent(0) ; |
692088ae | 842 | |
814ad4bf | 843 | nevents = (Int_t) gAlice->TreeE()->GetEntries() ; |
692088ae | 844 | |
814ad4bf | 845 | treeD=gAlice->TreeD() ; |
692088ae | 846 | |
814ad4bf | 847 | } |
692088ae | 848 | |
814ad4bf | 849 | if(treeD == 0 ){ |
692088ae | 850 | |
814ad4bf | 851 | cerr << " AliEMCALDigitizer :: Can not find TreeD " << endl ; |
692088ae | 852 | |
814ad4bf | 853 | return ; |
692088ae | 854 | |
814ad4bf | 855 | } |
856 | ||
692088ae | 857 | |
858 | ||
814ad4bf | 859 | //Check, if this branch already exits |
692088ae | 860 | |
814ad4bf | 861 | TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ; |
692088ae | 862 | |
814ad4bf | 863 | TIter next(lob) ; |
692088ae | 864 | |
814ad4bf | 865 | TBranch * branch = 0 ; |
692088ae | 866 | |
814ad4bf | 867 | Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ; |
692088ae | 868 | |
61e0abb5 | 869 | |
692088ae | 870 | |
814ad4bf | 871 | while ( (branch = (TBranch*)next()) && (!emcalfound || !digitizerfound) ) { |
692088ae | 872 | |
814ad4bf | 873 | if ( (strcmp(branch->GetName(), "EMCAL")==0) && |
692088ae | 874 | |
814ad4bf | 875 | (strcmp(branch->GetTitle(), GetName())==0) ) |
692088ae | 876 | |
814ad4bf | 877 | emcalfound = kTRUE ; |
692088ae | 878 | |
814ad4bf | 879 | |
692088ae | 880 | |
814ad4bf | 881 | else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && |
692088ae | 882 | |
814ad4bf | 883 | (strcmp(branch->GetTitle(), GetName())==0) ) |
692088ae | 884 | |
814ad4bf | 885 | digitizerfound = kTRUE ; |
692088ae | 886 | |
814ad4bf | 887 | } |
888 | ||
692088ae | 889 | |
890 | ||
814ad4bf | 891 | if ( emcalfound ) { |
692088ae | 892 | |
814ad4bf | 893 | cerr << "WARNING: AliEMCALDigitizer -> Digits branch with name " << GetName() |
692088ae | 894 | |
814ad4bf | 895 | << " already exits" << endl ; |
692088ae | 896 | |
814ad4bf | 897 | return ; |
692088ae | 898 | |
814ad4bf | 899 | } |
692088ae | 900 | |
814ad4bf | 901 | if ( digitizerfound ) { |
692088ae | 902 | |
814ad4bf | 903 | cerr << "WARNING: AliEMCALDigitizer -> Digitizer branch with name " << GetName() |
692088ae | 904 | |
814ad4bf | 905 | << " already exits" << endl ; |
692088ae | 906 | |
814ad4bf | 907 | return ; |
692088ae | 908 | |
814ad4bf | 909 | } |
910 | ||
692088ae | 911 | |
912 | ||
814ad4bf | 913 | Int_t ievent ; |
914 | ||
692088ae | 915 | |
916 | ||
814ad4bf | 917 | for(ievent = 0; ievent < nevents; ievent++){ |
692088ae | 918 | |
814ad4bf | 919 | |
692088ae | 920 | |
814ad4bf | 921 | if(fManager){ |
692088ae | 922 | |
814ad4bf | 923 | Int_t input ; |
692088ae | 924 | |
814ad4bf | 925 | for(input = 0 ; input < fManager->GetNinputs(); input ++){ |
692088ae | 926 | |
814ad4bf | 927 | TTree * treeS = fManager->GetInputTreeS(input) ; |
692088ae | 928 | |
814ad4bf | 929 | if(!treeS){ |
692088ae | 930 | |
814ad4bf | 931 | cerr << "AliEMCALDigitizer -> No Input " << endl ; |
692088ae | 932 | |
814ad4bf | 933 | return ; |
692088ae | 934 | |
814ad4bf | 935 | } |
692088ae | 936 | |
814ad4bf | 937 | gime->ReadTreeS(treeS,input) ; |
692088ae | 938 | |
814ad4bf | 939 | } |
692088ae | 940 | |
814ad4bf | 941 | } |
692088ae | 942 | |
814ad4bf | 943 | else |
692088ae | 944 | |
814ad4bf | 945 | gime->Event(ievent,"S") ; |
692088ae | 946 | |
61e0abb5 | 947 | |
692088ae | 948 | |
814ad4bf | 949 | Digitize(ievent) ; //Add prepared SDigits to digits and add the noise |
692088ae | 950 | |
61e0abb5 | 951 | |
692088ae | 952 | |
814ad4bf | 953 | WriteDigits(ievent) ; |
692088ae | 954 | |
61e0abb5 | 955 | |
692088ae | 956 | |
61e0abb5 | 957 | if(strstr(option,"deb")) |
692088ae | 958 | |
61e0abb5 | 959 | PrintDigits(option); |
692088ae | 960 | |
814ad4bf | 961 | |
692088ae | 962 | |
814ad4bf | 963 | //increment the total number of Digits per run |
692088ae | 964 | |
814ad4bf | 965 | fDigitsInRun += gime->Digits()->GetEntriesFast() ; |
692088ae | 966 | |
61e0abb5 | 967 | } |
692088ae | 968 | |
814ad4bf | 969 | |
692088ae | 970 | |
61e0abb5 | 971 | if(strstr(option,"tim")){ |
692088ae | 972 | |
61e0abb5 | 973 | gBenchmark->Stop("EMCALDigitizer"); |
692088ae | 974 | |
61e0abb5 | 975 | cout << "AliEMCALDigitizer:" << endl ; |
692088ae | 976 | |
814ad4bf | 977 | cout << " took " << gBenchmark->GetCpuTime("EMCALDigitizer") << " seconds for Digitizing " |
692088ae | 978 | |
814ad4bf | 979 | << gBenchmark->GetCpuTime("EMCALDigitizer")/nevents << " seconds per event " << endl ; |
692088ae | 980 | |
61e0abb5 | 981 | cout << endl ; |
692088ae | 982 | |
61e0abb5 | 983 | } |
692088ae | 984 | |
61e0abb5 | 985 | |
692088ae | 986 | |
61e0abb5 | 987 | } |
988 | ||
61e0abb5 | 989 | |
61e0abb5 | 990 | |
692088ae | 991 | |
992 | ||
993 | ||
994 | ||
61e0abb5 | 995 | //__________________________________________________________________ |
692088ae | 996 | |
814ad4bf | 997 | void AliEMCALDigitizer::MixWith(char* headerFile){ |
692088ae | 998 | |
61e0abb5 | 999 | // Alows produce digits by superimposing background and signal event. |
692088ae | 1000 | |
61e0abb5 | 1001 | // It is assumed, that headers file with SIGNAL events is opened in |
692088ae | 1002 | |
61e0abb5 | 1003 | // constructor, and now we set the BACKGROUND event, with which we |
692088ae | 1004 | |
61e0abb5 | 1005 | // will mix. Thus we avoid writing (changing) huge and expencive |
692088ae | 1006 | |
61e0abb5 | 1007 | // backgound files: all output will be writen into SIGNAL, i.e. |
692088ae | 1008 | |
61e0abb5 | 1009 | // opened in constructor file. |
692088ae | 1010 | |
61e0abb5 | 1011 | // |
692088ae | 1012 | |
61e0abb5 | 1013 | // One can open as many files to mix with as one wants. |
1014 | ||
692088ae | 1015 | |
1016 | ||
814ad4bf | 1017 | if( strcmp(GetName(), "") == 0 ) |
692088ae | 1018 | |
61e0abb5 | 1019 | Init() ; |
692088ae | 1020 | |
814ad4bf | 1021 | |
692088ae | 1022 | |
814ad4bf | 1023 | if(fManager){ |
692088ae | 1024 | |
814ad4bf | 1025 | cout << "Can not use this method under AliRunDigitizer " << endl ; |
692088ae | 1026 | |
61e0abb5 | 1027 | return ; |
692088ae | 1028 | |
814ad4bf | 1029 | } // check if the specified SDigits do not already exist on the White Board: |
692088ae | 1030 | |
814ad4bf | 1031 | // //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname |
1032 | ||
692088ae | 1033 | |
1034 | ||
814ad4bf | 1035 | TString path = "Folders/RunMC/Event/Data/EMCAL/SDigits" ; |
692088ae | 1036 | |
814ad4bf | 1037 | path += headerFile ; |
692088ae | 1038 | |
814ad4bf | 1039 | path += "/" ; |
692088ae | 1040 | |
814ad4bf | 1041 | path += GetName() ; |
692088ae | 1042 | |
814ad4bf | 1043 | if ( gROOT->FindObjectAny(path.Data()) ) { |
692088ae | 1044 | |
814ad4bf | 1045 | cerr << "WARNING: AliEMCALDigitizer::MixWith -> Entry already exists, do not add" << endl ; |
692088ae | 1046 | |
814ad4bf | 1047 | return; |
692088ae | 1048 | |
61e0abb5 | 1049 | } |
814ad4bf | 1050 | |
692088ae | 1051 | |
1052 | ||
814ad4bf | 1053 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
692088ae | 1054 | |
814ad4bf | 1055 | gime->PostSDigits(GetName(),headerFile) ; |
692088ae | 1056 | |
61e0abb5 | 1057 | |
692088ae | 1058 | |
814ad4bf | 1059 | // check if the requested file is already open or exist and if SDigits Branch exist |
692088ae | 1060 | |
814ad4bf | 1061 | TFile * file = (TFile*)gROOT->FindObject(headerFile); |
692088ae | 1062 | |
814ad4bf | 1063 | if ( !file ) { |
692088ae | 1064 | |
814ad4bf | 1065 | file = new TFile(headerFile, "READ") ; |
692088ae | 1066 | |
814ad4bf | 1067 | if (!file) { |
692088ae | 1068 | |
814ad4bf | 1069 | cerr << "ERROR: AliEMCALDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ; |
692088ae | 1070 | |
814ad4bf | 1071 | return ; |
692088ae | 1072 | |
814ad4bf | 1073 | } |
692088ae | 1074 | |
814ad4bf | 1075 | } |
692088ae | 1076 | |
61e0abb5 | 1077 | |
692088ae | 1078 | |
61e0abb5 | 1079 | } |
692088ae | 1080 | |
814ad4bf | 1081 | |
692088ae | 1082 | |
61e0abb5 | 1083 | //__________________________________________________________________ |
692088ae | 1084 | |
61e0abb5 | 1085 | void AliEMCALDigitizer::Print(Option_t* option)const { |
692088ae | 1086 | |
814ad4bf | 1087 | if( strcmp(GetName(), "") != 0) { |
692088ae | 1088 | |
61e0abb5 | 1089 | |
692088ae | 1090 | |
61e0abb5 | 1091 | cout << "------------------- "<< GetName() << " -------------" << endl ; |
692088ae | 1092 | |
61e0abb5 | 1093 | cout << "Digitizing sDigits from file(s): " <<endl ; |
692088ae | 1094 | |
61e0abb5 | 1095 | |
692088ae | 1096 | |
814ad4bf | 1097 | TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("Folders/RunMC/Event/Data/EMCAL/SDigits"))->GetListOfFolders() ; |
692088ae | 1098 | |
814ad4bf | 1099 | TIter next(folderslist) ; |
692088ae | 1100 | |
814ad4bf | 1101 | TFolder * folder = 0 ; |
692088ae | 1102 | |
814ad4bf | 1103 | while ( (folder = (TFolder*)next()) ) |
692088ae | 1104 | |
814ad4bf | 1105 | if ( folder->FindObject(GetName()) ) |
692088ae | 1106 | |
814ad4bf | 1107 | { |
692088ae | 1108 | |
814ad4bf | 1109 | cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; |
692088ae | 1110 | |
814ad4bf | 1111 | cout << endl ; |
692088ae | 1112 | |
814ad4bf | 1113 | cout << "Writing digits to " << GetTitle() << endl ; |
692088ae | 1114 | |
814ad4bf | 1115 | |
692088ae | 1116 | |
814ad4bf | 1117 | cout << endl ; |
692088ae | 1118 | |
814ad4bf | 1119 | cout << "With following parameters: " << endl ; |
692088ae | 1120 | |
814ad4bf | 1121 | cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ; |
692088ae | 1122 | |
d968cee0 | 1123 | cout << " Threshold in EMC (fTowerDigitThreshold) = " << fTowerDigitThreshold << endl; |
692088ae | 1124 | |
814ad4bf | 1125 | cout << " Threshold in PreShower (fPreShowerDigitThreshold) = " << fPreShowerDigitThreshold << endl ; ; |
692088ae | 1126 | |
814ad4bf | 1127 | cout << "---------------------------------------------------" << endl ; |
692088ae | 1128 | |
814ad4bf | 1129 | } |
692088ae | 1130 | |
814ad4bf | 1131 | else |
692088ae | 1132 | |
814ad4bf | 1133 | cout << "AliEMCALDigitizer not initialized " << endl ; |
692088ae | 1134 | |
814ad4bf | 1135 | } |
692088ae | 1136 | |
61e0abb5 | 1137 | } |
814ad4bf | 1138 | |
692088ae | 1139 | |
1140 | ||
61e0abb5 | 1141 | //__________________________________________________________________ |
692088ae | 1142 | |
61e0abb5 | 1143 | void AliEMCALDigitizer::PrintDigits(Option_t * option){ |
692088ae | 1144 | |
61e0abb5 | 1145 | |
692088ae | 1146 | |
814ad4bf | 1147 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
692088ae | 1148 | |
814ad4bf | 1149 | TClonesArray * fDigits = gime->Digits() ; |
1150 | ||
692088ae | 1151 | |
1152 | ||
61e0abb5 | 1153 | cout << "AliEMCALDigitiser:"<< endl ; |
692088ae | 1154 | |
61e0abb5 | 1155 | cout << " Number of entries in Digits list " << fDigits->GetEntriesFast() << endl ; |
692088ae | 1156 | |
61e0abb5 | 1157 | cout << endl ; |
692088ae | 1158 | |
61e0abb5 | 1159 | if(strstr(option,"all")){ |
692088ae | 1160 | |
61e0abb5 | 1161 | |
692088ae | 1162 | |
61e0abb5 | 1163 | //loop over digits |
692088ae | 1164 | |
61e0abb5 | 1165 | AliEMCALDigit * digit; |
692088ae | 1166 | |
61e0abb5 | 1167 | cout << "Digit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl; |
692088ae | 1168 | |
61e0abb5 | 1169 | Int_t index ; |
692088ae | 1170 | |
61e0abb5 | 1171 | for (index = 0 ; index < fDigits->GetEntries() ; index++) { |
692088ae | 1172 | |
61e0abb5 | 1173 | digit = (AliEMCALDigit * ) fDigits->At(index) ; |
692088ae | 1174 | |
61e0abb5 | 1175 | cout << setw(8) << digit->GetId() << " " << setw(3) << digit->GetAmp() << " " |
692088ae | 1176 | |
61e0abb5 | 1177 | << setw(6) << digit->GetIndexInList() << " " |
692088ae | 1178 | |
61e0abb5 | 1179 | << setw(5) << digit->GetNprimary() <<" "; |
692088ae | 1180 | |
61e0abb5 | 1181 | |
692088ae | 1182 | |
61e0abb5 | 1183 | Int_t iprimary; |
692088ae | 1184 | |
61e0abb5 | 1185 | for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) |
692088ae | 1186 | |
61e0abb5 | 1187 | cout << setw(5) << digit->GetPrimary(iprimary+1) << " "; |
692088ae | 1188 | |
61e0abb5 | 1189 | cout << endl; |
692088ae | 1190 | |
61e0abb5 | 1191 | } |
692088ae | 1192 | |
61e0abb5 | 1193 | |
692088ae | 1194 | |
61e0abb5 | 1195 | } |
692088ae | 1196 | |
61e0abb5 | 1197 | } |
692088ae | 1198 | |
814ad4bf | 1199 | //_________________________________________________________________________________________ |
692088ae | 1200 | |
814ad4bf | 1201 | void AliEMCALDigitizer::WriteDigits(Int_t event) |
692088ae | 1202 | |
814ad4bf | 1203 | { |
61e0abb5 | 1204 | |
692088ae | 1205 | |
1206 | ||
814ad4bf | 1207 | // Makes TreeD in the output file. |
692088ae | 1208 | |
814ad4bf | 1209 | // Check if branch already exists: |
692088ae | 1210 | |
814ad4bf | 1211 | // if yes, exit without writing: ROOT TTree does not support overwriting/updating of |
692088ae | 1212 | |
814ad4bf | 1213 | // already existing branches. |
692088ae | 1214 | |
814ad4bf | 1215 | // else creates branch with Digits, named "EMCAL", title "...", |
692088ae | 1216 | |
814ad4bf | 1217 | // and branch "AliEMCALDigitizer", with the same title to keep all the parameters |
692088ae | 1218 | |
814ad4bf | 1219 | // and names of files, from which digits are made. |
61e0abb5 | 1220 | |
692088ae | 1221 | |
1222 | ||
814ad4bf | 1223 | AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; |
692088ae | 1224 | |
814ad4bf | 1225 | const TClonesArray * digits = gime->Digits(GetName()) ; |
692088ae | 1226 | |
814ad4bf | 1227 | TTree * treeD ; |
1228 | ||
692088ae | 1229 | |
1230 | ||
814ad4bf | 1231 | if(fManager) |
692088ae | 1232 | |
814ad4bf | 1233 | treeD = fManager->GetTreeD() ; |
692088ae | 1234 | |
814ad4bf | 1235 | else |
692088ae | 1236 | |
814ad4bf | 1237 | treeD = gAlice->TreeD(); |
692088ae | 1238 | |
61e0abb5 | 1239 | |
692088ae | 1240 | |
814ad4bf | 1241 | // create new branches |
692088ae | 1242 | |
814ad4bf | 1243 | // -- generate file name if necessary |
692088ae | 1244 | |
814ad4bf | 1245 | char * file =0; |
692088ae | 1246 | |
814ad4bf | 1247 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name |
692088ae | 1248 | |
814ad4bf | 1249 | file = new char[strlen(gAlice->GetBaseFile())+20] ; |
692088ae | 1250 | |
814ad4bf | 1251 | sprintf(file,"%s/EMCAL.Digits.root",gAlice->GetBaseFile()) ; |
692088ae | 1252 | |
814ad4bf | 1253 | } |
1254 | ||
692088ae | 1255 | |
1256 | ||
814ad4bf | 1257 | TDirectory *cwd = gDirectory; |
692088ae | 1258 | |
814ad4bf | 1259 | // -- create Digits branch |
692088ae | 1260 | |
814ad4bf | 1261 | Int_t bufferSize = 32000 ; |
692088ae | 1262 | |
814ad4bf | 1263 | TBranch * digitsBranch = treeD->Branch("EMCAL",&digits,bufferSize); |
692088ae | 1264 | |
814ad4bf | 1265 | digitsBranch->SetTitle(GetName()); |
692088ae | 1266 | |
814ad4bf | 1267 | if (file) { |
692088ae | 1268 | |
814ad4bf | 1269 | digitsBranch->SetFile(file); |
692088ae | 1270 | |
814ad4bf | 1271 | TIter next( digitsBranch->GetListOfBranches()); |
692088ae | 1272 | |
814ad4bf | 1273 | TBranch * sbr ; |
692088ae | 1274 | |
814ad4bf | 1275 | while ((sbr=(TBranch*)next())) { |
692088ae | 1276 | |
814ad4bf | 1277 | sbr->SetFile(file); |
692088ae | 1278 | |
814ad4bf | 1279 | } |
692088ae | 1280 | |
814ad4bf | 1281 | cwd->cd(); |
692088ae | 1282 | |
814ad4bf | 1283 | } |
692088ae | 1284 | |
814ad4bf | 1285 | |
692088ae | 1286 | |
814ad4bf | 1287 | // -- Create Digitizer branch |
692088ae | 1288 | |
814ad4bf | 1289 | Int_t splitlevel = 0 ; |
692088ae | 1290 | |
814ad4bf | 1291 | AliEMCALDigitizer * d = gime->Digitizer(GetName()) ; |
692088ae | 1292 | |
814ad4bf | 1293 | TBranch * digitizerBranch = treeD->Branch("AliEMCALDigitizer", "AliEMCALDigitizer", &d,bufferSize,splitlevel); |
692088ae | 1294 | |
814ad4bf | 1295 | digitizerBranch->SetTitle(GetName()); |
692088ae | 1296 | |
814ad4bf | 1297 | if (file) { |
692088ae | 1298 | |
814ad4bf | 1299 | digitizerBranch->SetFile(file); |
692088ae | 1300 | |
814ad4bf | 1301 | TIter next( digitizerBranch->GetListOfBranches()); |
692088ae | 1302 | |
814ad4bf | 1303 | TBranch * sbr; |
692088ae | 1304 | |
814ad4bf | 1305 | while ((sbr=(TBranch*)next())) { |
692088ae | 1306 | |
814ad4bf | 1307 | sbr->SetFile(file); |
692088ae | 1308 | |
814ad4bf | 1309 | } |
692088ae | 1310 | |
814ad4bf | 1311 | cwd->cd(); |
692088ae | 1312 | |
814ad4bf | 1313 | } |
692088ae | 1314 | |
814ad4bf | 1315 | |
692088ae | 1316 | |
814ad4bf | 1317 | digitsBranch->Fill() ; |
692088ae | 1318 | |
814ad4bf | 1319 | digitizerBranch->Fill() ; |
1320 | ||
692088ae | 1321 | |
1322 | ||
814ad4bf | 1323 | treeD->Write(0,kOverwrite) ; |
692088ae | 1324 | |
814ad4bf | 1325 | |
692088ae | 1326 | |
814ad4bf | 1327 | } |
692088ae | 1328 | |
814ad4bf | 1329 | //____________________________________________________________________________ |
692088ae | 1330 | |
814ad4bf | 1331 | Float_t AliEMCALDigitizer::FrontEdgeTime(TClonesArray * ticks) |
692088ae | 1332 | |
814ad4bf | 1333 | { // |
692088ae | 1334 | |
814ad4bf | 1335 | ticks->Sort() ; //Sort in accordance with times of ticks |
692088ae | 1336 | |
814ad4bf | 1337 | TIter it(ticks) ; |
692088ae | 1338 | |
814ad4bf | 1339 | AliEMCALTick * ctick = (AliEMCALTick *) it.Next() ; |
692088ae | 1340 | |
814ad4bf | 1341 | Float_t time = ctick->CrossingTime(fTimeThreshold) ; |
692088ae | 1342 | |
814ad4bf | 1343 | |
692088ae | 1344 | |
814ad4bf | 1345 | AliEMCALTick * t ; |
692088ae | 1346 | |
814ad4bf | 1347 | while((t=(AliEMCALTick*) it.Next())){ |
692088ae | 1348 | |
814ad4bf | 1349 | if(t->GetTime() < time) //This tick starts before crossing |
692088ae | 1350 | |
814ad4bf | 1351 | *ctick+=*t ; |
692088ae | 1352 | |
814ad4bf | 1353 | else |
692088ae | 1354 | |
814ad4bf | 1355 | return time ; |
692088ae | 1356 | |
814ad4bf | 1357 | |
692088ae | 1358 | |
814ad4bf | 1359 | time = ctick->CrossingTime(fTimeThreshold) ; |
692088ae | 1360 | |
814ad4bf | 1361 | } |
692088ae | 1362 | |
814ad4bf | 1363 | return time ; |
692088ae | 1364 | |
814ad4bf | 1365 | } |
692088ae | 1366 | |
814ad4bf | 1367 | //____________________________________________________________________________ |
692088ae | 1368 | |
814ad4bf | 1369 | Float_t AliEMCALDigitizer::TimeOfNoise(void) |
692088ae | 1370 | |
814ad4bf | 1371 | { // Calculates the time signal generated by noise |
692088ae | 1372 | |
814ad4bf | 1373 | //to be rewritten, now returns just big number |
692088ae | 1374 | |
814ad4bf | 1375 | return 1. ; |
1376 | ||
692088ae | 1377 | |
1378 | ||
814ad4bf | 1379 | } |
692088ae | 1380 | |
814ad4bf | 1381 | //____________________________________________________________________________ |
692088ae | 1382 | |
814ad4bf | 1383 | void AliEMCALDigitizer::SetSDigitsBranch(const char* title) |
692088ae | 1384 | |
814ad4bf | 1385 | { |
692088ae | 1386 | |
814ad4bf | 1387 | // we set title (comment) of the SDigits branch in the first! header file |
692088ae | 1388 | |
814ad4bf | 1389 | if( strcmp(GetName(), "") == 0 ) |
692088ae | 1390 | |
814ad4bf | 1391 | Init() ; |
61e0abb5 | 1392 | |
692088ae | 1393 | |
1394 | ||
814ad4bf | 1395 | AliEMCALGetter::GetInstance()->SDigits()->SetName(title) ; |
692088ae | 1396 | |
61e0abb5 | 1397 | } |
692088ae | 1398 |