Changes in modules/Calorimeter.cc [e33e6db:3db5282] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/Calorimeter.cc
re33e6db r3db5282 150 150 */ 151 151 152 // read min E value for timing measurement in ECAL 153 fTimingEMin = GetDouble("TimingEMin",4.); 154 // For timing 155 // So far this flag needs to be false 156 // Curved extrapolation not supported 157 fElectronsFromTrack = false; 158 159 152 160 // read min E value for towers to be saved 153 161 fECalEnergyMin = GetDouble("ECalEnergyMin", 0.0); … … 356 364 fTrackHCalEnergy = 0.0; 357 365 358 fTowerECalTime = 0.0;359 fTowerHCalTime = 0.0;360 361 fTrackECalTime = 0.0;362 fTrackHCalTime = 0.0;363 364 fTowerECalTimeWeight = 0.0;365 fTowerHCalTimeWeight = 0.0;366 367 366 fTowerTrackHits = 0; 368 367 fTowerPhotonHits = 0; … … 380 379 position = track->Position; 381 380 382 383 381 ecalEnergy = momentum.E() * fTrackECalFractions[number]; 384 382 hcalEnergy = momentum.E() * fTrackHCalFractions[number]; … … 387 385 fTrackHCalEnergy += hcalEnergy; 388 386 389 fTrackECalTime += TMath::Sqrt(ecalEnergy)*position.T(); 390 fTrackHCalTime += TMath::Sqrt(hcalEnergy)*position.T(); 391 392 fTrackECalTimeWeight += TMath::Sqrt(ecalEnergy); 393 fTrackHCalTimeWeight += TMath::Sqrt(hcalEnergy); 387 bool dbg_scz = false; 388 if (dbg_scz) { 389 cout << " Calorimeter input track has x y z t " << track->Position.X() << " " << track->Position.Y() << " " << track->Position.Z() << " " << track->Position.T() 390 << endl; 391 Candidate *prt = static_cast<Candidate*>(track->GetCandidates()->Last()); 392 const TLorentzVector &ini = prt->Position; 393 394 cout << " and parent has x y z t " << ini.X() << " " << ini.Y() << " " << ini.Z() << " " << ini.T(); 395 396 } 397 398 if (ecalEnergy > fTimingEMin && fTower) { 399 if (fElectronsFromTrack) { 400 // cout << " SCZ Debug pushing back track hit E=" << ecalEnergy << " T=" << track->Position.T() << " isPU=" << track->IsPU << " isRecoPU=" << track->IsRecoPU 401 // << " PID=" << track->PID << endl; 402 fTower->Ecal_E_t.push_back(std::make_pair<float,float>(ecalEnergy,track->Position.T())); 403 } else { 404 // cout << " Skipping track hit E=" << ecalEnergy << " T=" << track->Position.T() << " isPU=" << track->IsPU << " isRecoPU=" << track->IsRecoPU 405 // << " PID=" << track->PID << endl; 406 } 407 } 408 394 409 395 410 fTowerTrackArray->Add(track); … … 397 412 continue; 398 413 } 399 414 400 415 // check for photon and electron hits in current tower 401 416 if(flags & 2) ++fTowerPhotonHits; … … 412 427 fTowerHCalEnergy += hcalEnergy; 413 428 414 fTowerECalTime += TMath::Sqrt(ecalEnergy)*position.T(); 415 fTowerHCalTime += TMath::Sqrt(hcalEnergy)*position.T(); 416 417 fTowerECalTimeWeight += TMath::Sqrt(ecalEnergy); 418 fTowerHCalTimeWeight += TMath::Sqrt(hcalEnergy); 419 429 if (ecalEnergy > fTimingEMin && fTower) { 430 if (abs(particle->PID) != 11 || !fElectronsFromTrack) { 431 // cout << " SCZ Debug About to push back particle hit E=" << ecalEnergy << " T=" << particle->Position.T() << " isPU=" << particle->IsPU 432 // << " PID=" << particle->PID << endl; 433 fTower->Ecal_E_t.push_back(std::make_pair<Float_t,Float_t>(ecalEnergy,particle->Position.T())); 434 } else { 435 436 // N.B. Only charged particle set to leave ecal energy is the electrons 437 // cout << " SCZ Debug To avoid double-counting, skipping particle hit E=" << ecalEnergy << " T=" << particle->Position.T() << " isPU=" << particle->IsPU 438 // << " PID=" << particle->PID << endl; 439 440 } 441 } 420 442 421 443 fTower->AddCandidate(particle); … … 434 456 Double_t ecalEnergy, hcalEnergy; 435 457 Double_t ecalSigma, hcalSigma; 436 Double_t ecalTime, hcalTime, time; 437 458 438 459 if(!fTower) return; 439 460 … … 444 465 hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma); 445 466 446 ecalTime = (fTowerECalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerECalTime/fTowerECalTimeWeight;447 hcalTime = (fTowerHCalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerHCalTime/fTowerHCalTimeWeight;448 449 467 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy); 450 468 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy); … … 454 472 455 473 energy = ecalEnergy + hcalEnergy; 456 time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy)); 457 474 458 475 if(fSmearTowerCenter) 459 476 { … … 469 486 pt = energy / TMath::CosH(eta); 470 487 471 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time); 488 // Time calculation for tower 489 fTower->Ntimes = 0; 490 Float_t tow_sumT = 0; 491 Float_t tow_sumW = 0; 492 493 for (Int_t i = 0 ; i < fTower->Ecal_E_t.size() ; i++) 494 { 495 Float_t w = TMath::Sqrt(fTower->Ecal_E_t[i].first); 496 tow_sumT += w*fTower->Ecal_E_t[i].second; 497 tow_sumW += w; 498 fTower->Ntimes++; 499 } 500 501 if (tow_sumW > 0.) { 502 fTower->Position.SetPtEtaPhiE(1.0, eta, phi,tow_sumT/tow_sumW); 503 } else { 504 fTower->Position.SetPtEtaPhiE(1.0,eta,phi,999999.); 505 } 506 507 472 508 fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy); 473 509 fTower->Eem = ecalEnergy; … … 481 517 if(energy > 0.0) 482 518 { 483 bool isCalPhoton = false; 484 485 if(fTowerTrackHits == 0) 486 { 487 // We have a CalPhoton when there are NOT tracks and there ARE photon hits 488 isCalPhoton = (fTowerPhotonHits > 0); 489 } 490 else 491 { 492 // save all the tracks as energy flow tracks 493 fItTowerTrackArray->Reset(); 494 while((track = static_cast<Candidate*>(fItTowerTrackArray->Next()))) 495 { 496 fEFlowTrackOutputArray->Add(track); 497 } 498 499 ecalEnergy -= fTrackECalEnergy; 500 hcalEnergy -= fTrackHCalEnergy; 501 502 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy); 503 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy); 504 505 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0; 506 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0; 507 508 energy = ecalEnergy + hcalEnergy; 509 } 510 511 // If it's NOT a CalPhoton; add the tower as a whole entity. 512 // Otherwise, the tower will be split into its ECAL and HCAL components, 513 // then added to fPhotonArray and fTowerArray (respectively). 514 // By construction (no track hits), no track subtraction will occur 515 // for CalPhotons 516 if(!isCalPhoton) 517 fTowerOutputArray->Add(fTower); 518 519 // fill energy flow candidates 520 521 if(ecalEnergy > 0.0) 522 { 523 // create new photon tower 524 tower = static_cast<Candidate*>(fTower->Clone()); 525 526 pt = ecalEnergy / TMath::CosH(eta); 527 528 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy); 529 tower->Eem = ecalEnergy; 530 tower->Ehad = 0.0; 531 532 fEFlowPhotonOutputArray->Add(tower); 533 if(isCalPhoton) 534 fPhotonOutputArray->Add(tower); 535 } 536 537 if(hcalEnergy > 0.0) 538 { 539 // create new neutral hadron tower 540 tower = static_cast<Candidate*>(fTower->Clone()); 541 542 pt = hcalEnergy / TMath::CosH(eta); 543 544 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy); 545 tower->Eem = 0.0; 546 tower->Ehad = hcalEnergy; 547 548 fEFlowNeutralHadronOutputArray->Add(tower); 549 if(isCalPhoton) 550 fTowerOutputArray->Add(tower); 551 } 519 if(fTowerPhotonHits > 0 && fTowerTrackHits == 0) 520 { 521 fPhotonOutputArray->Add(fTower); 522 } 523 524 fTowerOutputArray->Add(fTower); 525 } 526 527 // fill energy flow candidates 528 529 // save all the tracks as energy flow tracks 530 fItTowerTrackArray->Reset(); 531 while((track = static_cast<Candidate*>(fItTowerTrackArray->Next()))) 532 { 533 fEFlowTrackOutputArray->Add(track); 534 } 535 536 ecalEnergy -= fTrackECalEnergy; 537 hcalEnergy -= fTrackHCalEnergy; 538 539 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy); 540 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy); 541 542 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0; 543 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0; 544 545 energy = ecalEnergy + hcalEnergy; 546 547 if(ecalEnergy > 0.0) 548 { 549 // create new photon tower 550 tower = static_cast<Candidate*>(fTower->Clone()); 551 552 pt = ecalEnergy / TMath::CosH(eta); 553 554 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy); 555 tower->Eem = ecalEnergy; 556 tower->Ehad = 0.0; 557 558 fEFlowPhotonOutputArray->Add(tower); 559 } 560 if(hcalEnergy > 0.0) 561 { 562 // create new neutral hadron tower 563 tower = static_cast<Candidate*>(fTower->Clone()); 564 565 pt = hcalEnergy / TMath::CosH(eta); 566 567 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy); 568 tower->Eem = 0.0; 569 tower->Ehad = hcalEnergy; 570 571 fEFlowNeutralHadronOutputArray->Add(tower); 552 572 } 553 573 }
Note:
See TracChangeset
for help on using the changeset viewer.