Changes in modules/Calorimeter.cc [3db5282:e33e6db] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/Calorimeter.cc
r3db5282 re33e6db 150 150 */ 151 151 152 // read min E value for timing measurement in ECAL153 fTimingEMin = GetDouble("TimingEMin",4.);154 // For timing155 // So far this flag needs to be false156 // Curved extrapolation not supported157 fElectronsFromTrack = false;158 159 160 152 // read min E value for towers to be saved 161 153 fECalEnergyMin = GetDouble("ECalEnergyMin", 0.0); … … 364 356 fTrackHCalEnergy = 0.0; 365 357 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 366 367 fTowerTrackHits = 0; 367 368 fTowerPhotonHits = 0; … … 379 380 position = track->Position; 380 381 382 381 383 ecalEnergy = momentum.E() * fTrackECalFractions[number]; 382 384 hcalEnergy = momentum.E() * fTrackHCalFractions[number]; … … 385 387 fTrackHCalEnergy += hcalEnergy; 386 388 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 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); 409 394 410 395 fTowerTrackArray->Add(track); … … 412 397 continue; 413 398 } 414 399 415 400 // check for photon and electron hits in current tower 416 401 if(flags & 2) ++fTowerPhotonHits; … … 427 412 fTowerHCalEnergy += hcalEnergy; 428 413 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 } 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 442 420 443 421 fTower->AddCandidate(particle); … … 456 434 Double_t ecalEnergy, hcalEnergy; 457 435 Double_t ecalSigma, hcalSigma; 458 436 Double_t ecalTime, hcalTime, time; 437 459 438 if(!fTower) return; 460 439 … … 465 444 hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma); 466 445 446 ecalTime = (fTowerECalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerECalTime/fTowerECalTimeWeight; 447 hcalTime = (fTowerHCalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerHCalTime/fTowerHCalTimeWeight; 448 467 449 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy); 468 450 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy); … … 472 454 473 455 energy = ecalEnergy + hcalEnergy; 474 456 time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy)); 457 475 458 if(fSmearTowerCenter) 476 459 { … … 486 469 pt = energy / TMath::CosH(eta); 487 470 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 471 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time); 508 472 fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy); 509 473 fTower->Eem = ecalEnergy; … … 517 481 if(energy > 0.0) 518 482 { 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); 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 } 572 552 } 573 553 }
Note:
See TracChangeset
for help on using the changeset viewer.