Changeset 70b9632 in git for modules/Calorimeter.cc
- Timestamp:
- Aug 25, 2016, 2:04:58 PM (8 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 629e819
- Parents:
- 7bb13cd (diff), 1408174 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/Calorimeter.cc
r7bb13cd r70b9632 58 58 fItParticleInputArray(0), fItTrackInputArray(0) 59 59 { 60 Int_t i; 61 60 62 61 fECalResolutionFormula = new DelphesFormula; 63 62 fHCalResolutionFormula = new DelphesFormula; 64 63 65 for(i = 0; i < 2; ++i) 66 { 67 fECalTowerTrackArray[i] = new TObjArray; 68 fItECalTowerTrackArray[i] = fECalTowerTrackArray[i]->MakeIterator(); 69 70 fHCalTowerTrackArray[i] = new TObjArray; 71 fItHCalTowerTrackArray[i] = fHCalTowerTrackArray[i]->MakeIterator(); 72 } 64 fECalTowerTrackArray = new TObjArray; 65 fItECalTowerTrackArray = fECalTowerTrackArray->MakeIterator(); 66 67 fHCalTowerTrackArray = new TObjArray; 68 fItHCalTowerTrackArray = fHCalTowerTrackArray->MakeIterator(); 69 73 70 } 74 71 … … 77 74 Calorimeter::~Calorimeter() 78 75 { 79 Int_t i; 80 76 81 77 if(fECalResolutionFormula) delete fECalResolutionFormula; 82 78 if(fHCalResolutionFormula) delete fHCalResolutionFormula; 83 79 84 for(i = 0; i < 2; ++i) 85 { 86 if(fECalTowerTrackArray[i]) delete fECalTowerTrackArray[i]; 87 if(fItECalTowerTrackArray[i]) delete fItECalTowerTrackArray[i]; 88 89 if(fHCalTowerTrackArray[i]) delete fHCalTowerTrackArray[i]; 90 if(fItHCalTowerTrackArray[i]) delete fItHCalTowerTrackArray[i]; 91 } 80 if(fECalTowerTrackArray) delete fECalTowerTrackArray; 81 if(fItECalTowerTrackArray) delete fItECalTowerTrackArray; 82 83 if(fHCalTowerTrackArray) delete fHCalTowerTrackArray; 84 if(fItHCalTowerTrackArray) delete fItHCalTowerTrackArray; 85 92 86 } 93 87 … … 218 212 Double_t ecalFraction, hcalFraction; 219 213 Double_t ecalEnergy, hcalEnergy; 220 Double_t ecalSigma, hcalSigma;221 214 Int_t pdgCode; 222 215 … … 368 361 fHCalTowerEnergy = 0.0; 369 362 370 fECalTrackEnergy [0]= 0.0;371 f ECalTrackEnergy[1]= 0.0;372 373 f HCalTrackEnergy[0]= 0.0;374 fHCalTrack Energy[1]= 0.0;375 363 fECalTrackEnergy = 0.0; 364 fHCalTrackEnergy = 0.0; 365 366 fECalTrackSigma = 0.0; 367 fHCalTrackSigma = 0.0; 368 376 369 fTowerTrackHits = 0; 377 370 fTowerPhotonHits = 0; 378 371 379 fECalTowerTrackArray[0]->Clear(); 380 fECalTowerTrackArray[1]->Clear(); 381 382 fHCalTowerTrackArray[0]->Clear(); 383 fHCalTowerTrackArray[1]->Clear(); 372 fECalTowerTrackArray->Clear(); 373 fHCalTowerTrackArray->Clear(); 374 384 375 } 385 376 … … 406 397 if(fECalTrackFractions[number] > 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9) 407 398 { 408 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 409 if(ecalSigma/momentum.E() < track->TrackResolution) 410 { 411 fECalTrackEnergy[0] += ecalEnergy; 412 fECalTowerTrackArray[0]->Add(track); 413 } 414 else 415 { 416 fECalTrackEnergy[1] += ecalEnergy; 417 fECalTowerTrackArray[1]->Add(track); 418 } 399 fECalTrackEnergy += ecalEnergy; 400 fECalTrackSigma += (track->TrackResolution)*momentum.E()*(track->TrackResolution)*momentum.E(); 401 fECalTowerTrackArray->Add(track); 419 402 } 403 420 404 else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9) 421 405 { 422 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 423 if(hcalSigma/momentum.E() < track->TrackResolution) 424 { 425 fHCalTrackEnergy[0] += hcalEnergy; 426 fHCalTowerTrackArray[0]->Add(track); 427 } 428 else 429 { 430 fHCalTrackEnergy[1] += hcalEnergy; 431 fHCalTowerTrackArray[1]->Add(track); 432 } 406 fHCalTrackEnergy += hcalEnergy; 407 fHCalTrackSigma += (track->TrackResolution)*momentum.E()*(track->TrackResolution)*momentum.E(); 408 fHCalTowerTrackArray->Add(track); 433 409 } 410 434 411 else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9) 435 412 { … … 476 453 Double_t energy, pt, eta, phi; 477 454 Double_t ecalEnergy, hcalEnergy; 455 Double_t ecalNeutralEnergy, hcalNeutralEnergy; 456 478 457 Double_t ecalSigma, hcalSigma; 479 458 Double_t ecalNeutralSigma, hcalNeutralSigma; 459 460 Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor; 461 480 462 TLorentzVector momentum; 481 463 TFractionMap::iterator itFractionMap; … … 484 466 485 467 if(!fTower) return; 486 487 468 488 469 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fECalTowerEnergy); … … 554 535 fTowerOutputArray->Add(fTower); 555 536 } 556 537 557 538 // fill energy flow candidates 558 559 ecalEnergy -= fECalTrackEnergy[1]; 560 hcalEnergy -= fHCalTrackEnergy[1]; 561 562 fItECalTowerTrackArray[0]->Reset(); 563 while((track = static_cast<Candidate*>(fItECalTowerTrackArray[0]->Next()))) 564 { 565 mother = track; 566 track = static_cast<Candidate*>(track->Clone()); 567 track->AddCandidate(mother); 568 569 track->Momentum *= ecalEnergy/fECalTrackEnergy[0]; 570 571 fEFlowTrackOutputArray->Add(track); 572 } 573 574 fItECalTowerTrackArray[1]->Reset(); 575 while((track = static_cast<Candidate*>(fItECalTowerTrackArray[1]->Next()))) 576 { 577 mother = track; 578 track = static_cast<Candidate*>(track->Clone()); 579 track->AddCandidate(mother); 580 581 fEFlowTrackOutputArray->Add(track); 582 } 583 584 fItHCalTowerTrackArray[0]->Reset(); 585 while((track = static_cast<Candidate*>(fItHCalTowerTrackArray[0]->Next()))) 586 { 587 mother = track; 588 track = static_cast<Candidate*>(track->Clone()); 589 track->AddCandidate(mother); 590 591 track->Momentum *= hcalEnergy/fHCalTrackEnergy[0]; 592 593 fEFlowTrackOutputArray->Add(track); 594 } 595 596 fItHCalTowerTrackArray[1]->Reset(); 597 while((track = static_cast<Candidate*>(fItHCalTowerTrackArray[1]->Next()))) 598 { 599 mother = track; 600 track = static_cast<Candidate*>(track->Clone()); 601 track->AddCandidate(mother); 602 603 fEFlowTrackOutputArray->Add(track); 604 } 605 606 if(fECalTowerTrackArray[0]->GetEntriesFast() > 0) ecalEnergy = 0.0; 607 if(fHCalTowerTrackArray[0]->GetEntriesFast() > 0) hcalEnergy = 0.0; 608 609 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy); 610 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy); 611 612 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0; 613 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0; 614 615 energy = ecalEnergy + hcalEnergy; 616 617 if(ecalEnergy > 0.0) 539 fECalTrackSigma = TMath::Sqrt(fECalTrackSigma); 540 fHCalTrackSigma = TMath::Sqrt(fHCalTrackSigma); 541 542 //compute neutral excesses 543 ecalNeutralEnergy = max( (ecalEnergy - fECalTrackEnergy) , 0.0); 544 hcalNeutralEnergy = max( (hcalEnergy - fHCalTrackEnergy) , 0.0); 545 546 ecalNeutralSigma = ecalNeutralEnergy / TMath::Sqrt(fECalTrackSigma*fECalTrackSigma + ecalSigma*ecalSigma); 547 hcalNeutralSigma = hcalNeutralEnergy / TMath::Sqrt(fHCalTrackSigma*fHCalTrackSigma + hcalSigma*hcalSigma); 548 549 // if ecal neutral excess is significant, simply create neutral EflowPhoton tower and clone each track into eflowtrack 550 if(ecalNeutralEnergy > fECalEnergyMin && ecalNeutralSigma > fECalEnergySignificanceMin) 618 551 { 619 552 // create new photon tower 620 553 tower = static_cast<Candidate*>(fTower->Clone()); 621 622 pt = ecalEnergy / TMath::CosH(eta); 623 624 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy); 625 tower->Eem = ecalEnergy; 554 pt = ecalNeutralEnergy / TMath::CosH(eta); 555 556 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalNeutralEnergy); 557 tower->Eem = ecalNeutralEnergy; 626 558 tower->Ehad = 0.0; 627 559 tower->PID = 22; 628 560 629 561 fEFlowPhotonOutputArray->Add(tower); 630 } 631 if(hcalEnergy > 0.0) 632 { 633 // create new neutral hadron tower 562 563 //clone tracks 564 fItECalTowerTrackArray->Reset(); 565 while((track = static_cast<Candidate*>(fItECalTowerTrackArray->Next()))) 566 { 567 mother = track; 568 track = static_cast<Candidate*>(track->Clone()); 569 track->AddCandidate(mother); 570 571 fEFlowTrackOutputArray->Add(track); 572 } 573 574 } 575 576 // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking 577 else if(fECalTrackEnergy > 0.0) 578 { 579 weightTrack = (fECalTrackSigma > 0.0) ? 1 / (fECalTrackSigma*fECalTrackSigma) : 0.0; 580 weightCalo = (ecalSigma > 0.0) ? 1 / (ecalSigma*ecalSigma) : 0.0; 581 582 bestEnergyEstimate = (weightTrack*fECalTrackEnergy + weightCalo*ecalEnergy) / (weightTrack + weightCalo); 583 rescaleFactor = bestEnergyEstimate/fECalTrackEnergy; 584 585 //rescale tracks 586 fItECalTowerTrackArray->Reset(); 587 while((track = static_cast<Candidate*>(fItECalTowerTrackArray->Next()))) 588 { 589 mother = track; 590 track = static_cast<Candidate*>(track->Clone()); 591 track->AddCandidate(mother); 592 593 track->Momentum *= rescaleFactor; 594 595 fEFlowTrackOutputArray->Add(track); 596 } 597 } 598 599 600 // if hcal neutral excess is significant, simply create neutral EflowNeutralHadron tower and clone each track into eflowtrack 601 if(hcalNeutralEnergy > fHCalEnergyMin && hcalNeutralSigma > fHCalEnergySignificanceMin) 602 { 603 // create new photon tower 634 604 tower = static_cast<Candidate*>(fTower->Clone()); 635 636 pt = hcalEnergy / TMath::CosH(eta);637 638 tower-> Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);605 pt = hcalNeutralEnergy / TMath::CosH(eta); 606 607 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalNeutralEnergy); 608 tower->Ehad = hcalNeutralEnergy; 639 609 tower->Eem = 0.0; 640 tower->Ehad = hcalEnergy; 641 610 642 611 fEFlowNeutralHadronOutputArray->Add(tower); 643 } 612 613 //clone tracks 614 fItHCalTowerTrackArray->Reset(); 615 while((track = static_cast<Candidate*>(fItHCalTowerTrackArray->Next()))) 616 { 617 mother = track; 618 track = static_cast<Candidate*>(track->Clone()); 619 track->AddCandidate(mother); 620 621 fEFlowTrackOutputArray->Add(track); 622 } 623 624 } 625 626 // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking 627 else if(fHCalTrackEnergy > 0.0) 628 { 629 weightTrack = (fHCalTrackSigma > 0.0) ? 1 / (fHCalTrackSigma*fHCalTrackSigma) : 0.0; 630 weightCalo = (hcalSigma > 0.0) ? 1 / (hcalSigma*hcalSigma) : 0.0; 631 632 bestEnergyEstimate = (weightTrack*fHCalTrackEnergy + weightCalo*hcalEnergy) / (weightTrack + weightCalo); 633 rescaleFactor = bestEnergyEstimate / fHCalTrackEnergy; 634 635 //rescale tracks 636 fItHCalTowerTrackArray->Reset(); 637 while((track = static_cast<Candidate*>(fItHCalTowerTrackArray->Next()))) 638 { 639 mother = track; 640 track = static_cast<Candidate*>(track->Clone()); 641 track->AddCandidate(mother); 642 643 track->Momentum *= rescaleFactor; 644 645 fEFlowTrackOutputArray->Add(track); 646 } 647 } 648 649 644 650 } 645 651
Note:
See TracChangeset
for help on using the changeset viewer.