Changes in modules/Calorimeter.cc [298734e:341014c] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/Calorimeter.cc
r298734e r341014c 17 17 */ 18 18 19 20 19 /** \class Calorimeter 21 20 * … … 33 32 #include "classes/DelphesFormula.h" 34 33 34 #include "ExRootAnalysis/ExRootClassifier.h" 35 #include "ExRootAnalysis/ExRootFilter.h" 35 36 #include "ExRootAnalysis/ExRootResult.h" 36 #include "ExRootAnalysis/ExRootFilter.h" 37 #include "ExRootAnalysis/ExRootClassifier.h" 38 37 38 #include "TDatabasePDG.h" 39 #include "TFormula.h" 40 #include "TLorentzVector.h" 39 41 #include "TMath.h" 42 #include "TObjArray.h" 43 #include "TRandom3.h" 40 44 #include "TString.h" 41 #include "TFormula.h"42 #include "TRandom3.h"43 #include "TObjArray.h"44 #include "TDatabasePDG.h"45 #include "TLorentzVector.h"46 45 47 46 #include <algorithm> 48 #include <stdexcept>49 47 #include <iostream> 50 48 #include <sstream> 49 #include <stdexcept> 51 50 52 51 using namespace std; … … 58 57 fItParticleInputArray(0), fItTrackInputArray(0) 59 58 { 60 59 61 60 fECalResolutionFormula = new DelphesFormula; 62 61 fHCalResolutionFormula = new DelphesFormula; … … 67 66 fHCalTowerTrackArray = new TObjArray; 68 67 fItHCalTowerTrackArray = fHCalTowerTrackArray->MakeIterator(); 69 70 68 } 71 69 … … 74 72 Calorimeter::~Calorimeter() 75 73 { 76 74 77 75 if(fECalResolutionFormula) delete fECalResolutionFormula; 78 76 if(fHCalResolutionFormula) delete fHCalResolutionFormula; … … 83 81 if(fHCalTowerTrackArray) delete fHCalTowerTrackArray; 84 82 if(fItHCalTowerTrackArray) delete fItHCalTowerTrackArray; 85 86 83 } 87 84 … … 94 91 Double_t ecalFraction, hcalFraction; 95 92 TBinMap::iterator itEtaBin; 96 set< Double_t>::iterator itPhiBin;97 vector< Double_t> *phiBins;93 set<Double_t>::iterator itPhiBin; 94 vector<Double_t> *phiBins; 98 95 99 96 // read eta and phi bins … … 103 100 fEtaBins.clear(); 104 101 fPhiBins.clear(); 105 for(i = 0; i < size /2; ++i)106 { 107 paramEtaBins = param[i *2];102 for(i = 0; i < size / 2; ++i) 103 { 104 paramEtaBins = param[i * 2]; 108 105 sizeEtaBins = paramEtaBins.GetSize(); 109 paramPhiBins = param[i *2 + 1];106 paramPhiBins = param[i * 2 + 1]; 110 107 sizePhiBins = paramPhiBins.GetSize(); 111 108 … … 124 121 { 125 122 fEtaBins.push_back(itEtaBin->first); 126 phiBins = new vector< double>(itEtaBin->second.size());123 phiBins = new vector<double>(itEtaBin->second.size()); 127 124 fPhiBins.push_back(phiBins); 128 125 phiBins->clear(); … … 141 138 fFractionMap[0] = make_pair(0.0, 1.0); 142 139 143 for(i = 0; i < size /2; ++i)144 { 145 paramFractions = param[i *2 + 1];140 for(i = 0; i < size / 2; ++i) 141 { 142 paramFractions = param[i * 2 + 1]; 146 143 147 144 ecalFraction = paramFractions[0].GetDouble(); 148 145 hcalFraction = paramFractions[1].GetDouble(); 149 146 150 fFractionMap[param[i *2].GetInt()] = make_pair(ecalFraction, hcalFraction);147 fFractionMap[param[i * 2].GetInt()] = make_pair(ecalFraction, hcalFraction); 151 148 } 152 149 153 150 // read min E value for timing measurement in ECAL 154 fTimingEnergyMin = GetDouble("TimingEnergyMin", 4.);151 fTimingEnergyMin = GetDouble("TimingEnergyMin", 4.); 155 152 // For timing 156 153 // So far this flag needs to be false … … 192 189 void Calorimeter::Finish() 193 190 { 194 vector< vector< Double_t >*>::iterator itPhiBin;191 vector<vector<Double_t> *>::iterator itPhiBin; 195 192 if(fItParticleInputArray) delete fItParticleInputArray; 196 193 if(fItTrackInputArray) delete fItTrackInputArray; … … 218 215 TFractionMap::iterator itFractionMap; 219 216 220 vector< Double_t>::iterator itEtaBin;221 vector< Double_t>::iterator itPhiBin;222 vector< Double_t> *phiBins;223 224 vector< Long64_t>::iterator itTowerHits;217 vector<Double_t>::iterator itEtaBin; 218 vector<Double_t>::iterator itPhiBin; 219 vector<Double_t> *phiBins; 220 221 vector<Long64_t>::iterator itTowerHits; 225 222 226 223 DelphesFactory *factory = GetFactory(); … … 234 231 fItParticleInputArray->Reset(); 235 232 number = -1; 236 while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))233 while((particle = static_cast<Candidate *>(fItParticleInputArray->Next()))) 237 234 { 238 235 const TLorentzVector &particlePosition = particle->Position; … … 280 277 fItTrackInputArray->Reset(); 281 278 number = -1; 282 while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))279 while((track = static_cast<Candidate *>(fItTrackInputArray->Next()))) 283 280 { 284 281 const TLorentzVector &trackPosition = track->Position; … … 331 328 towerHit = (*itTowerHits); 332 329 flags = (towerHit >> 24) & 0x00000000000000FFLL; 333 number = (towerHit) &0x0000000000FFFFFFLL;330 number = (towerHit)&0x0000000000FFFFFFLL; 334 331 hitEtaPhi = towerHit >> 32; 335 332 … … 352 349 353 350 // calculate eta and phi of the tower's center 354 fTowerEta = 0.5 *(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);355 fTowerPhi = 0.5 *((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);351 fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]); 352 fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]); 356 353 357 354 fTowerEdges[0] = fEtaBins[etaBin - 1]; … … 365 362 fECalTrackEnergy = 0.0; 366 363 fHCalTrackEnergy = 0.0; 367 364 368 365 fECalTrackSigma = 0.0; 369 366 fHCalTrackSigma = 0.0; 370 367 371 368 fTowerTrackHits = 0; 372 369 fTowerPhotonHits = 0; … … 374 371 fECalTowerTrackArray->Clear(); 375 372 fHCalTowerTrackArray->Clear(); 376 377 373 } 378 374 … … 382 378 ++fTowerTrackHits; 383 379 384 track = static_cast<Candidate *>(fTrackInputArray->At(number));380 track = static_cast<Candidate *>(fTrackInputArray->At(number)); 385 381 momentum = track->Momentum; 386 382 position = track->Position; … … 400 396 { 401 397 fECalTrackEnergy += ecalEnergy; 402 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 403 if(ecalSigma/momentum.E() < track->TrackResolution) energyGuess = ecalEnergy; 404 else energyGuess = momentum.E(); 405 406 fECalTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess; 398 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 399 if(ecalSigma / momentum.E() < track->TrackResolution) 400 energyGuess = ecalEnergy; 401 else 402 energyGuess = momentum.E(); 403 404 fECalTrackSigma += (track->TrackResolution) * energyGuess * (track->TrackResolution) * energyGuess; 407 405 fECalTowerTrackArray->Add(track); 408 406 } 409 407 410 408 else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9) 411 409 { 412 410 fHCalTrackEnergy += hcalEnergy; 413 411 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 414 if(hcalSigma/momentum.E() < track->TrackResolution) energyGuess = hcalEnergy; 415 else energyGuess = momentum.E(); 416 417 fHCalTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess; 412 if(hcalSigma / momentum.E() < track->TrackResolution) 413 energyGuess = hcalEnergy; 414 else 415 energyGuess = momentum.E(); 416 417 fHCalTrackSigma += (track->TrackResolution) * energyGuess * (track->TrackResolution) * energyGuess; 418 418 fHCalTowerTrackArray->Add(track); 419 419 } 420 420 421 421 else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9) 422 422 { … … 430 430 if(flags & 2) ++fTowerPhotonHits; 431 431 432 particle = static_cast<Candidate *>(fParticleInputArray->At(number));432 particle = static_cast<Candidate *>(fParticleInputArray->At(number)); 433 433 momentum = particle->Momentum; 434 434 position = particle->Position; … … 443 443 if(ecalEnergy > fTimingEnergyMin && fTower) 444 444 { 445 if 445 if(abs(particle->PID) != 11 || !fElectronsFromTrack) 446 446 { 447 447 fTower->ECalEnergyTimePairs.push_back(make_pair<Float_t, Float_t>(ecalEnergy, particle->Position.T())); … … 464 464 Double_t ecalEnergy, hcalEnergy; 465 465 Double_t ecalNeutralEnergy, hcalNeutralEnergy; 466 466 467 467 Double_t ecalSigma, hcalSigma; 468 468 Double_t ecalNeutralSigma, hcalNeutralSigma; 469 469 470 470 Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor; 471 471 472 472 TLorentzVector momentum; 473 473 TFractionMap::iterator itFractionMap; … … 486 486 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy); 487 487 488 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin *ecalSigma) ecalEnergy = 0.0;489 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin *hcalSigma) hcalEnergy = 0.0;488 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin * ecalSigma) ecalEnergy = 0.0; 489 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin * hcalSigma) hcalEnergy = 0.0; 490 490 491 491 energy = ecalEnergy + hcalEnergy; … … 519 519 if(sumWeight > 0.0) 520 520 { 521 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, sumWeightedTime /sumWeight);521 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, sumWeightedTime / sumWeight); 522 522 } 523 523 else … … 525 525 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, 999999.9); 526 526 } 527 528 527 529 528 fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy); … … 545 544 fTowerOutputArray->Add(fTower); 546 545 } 547 546 548 547 // fill energy flow candidates 549 548 fECalTrackSigma = TMath::Sqrt(fECalTrackSigma); … … 551 550 552 551 //compute neutral excesses 553 ecalNeutralEnergy = max( (ecalEnergy - fECalTrackEnergy), 0.0);554 hcalNeutralEnergy = max( (hcalEnergy - fHCalTrackEnergy), 0.0);555 556 ecalNeutralSigma = ecalNeutralEnergy / TMath::Sqrt(fECalTrackSigma *fECalTrackSigma + ecalSigma*ecalSigma);557 hcalNeutralSigma = hcalNeutralEnergy / TMath::Sqrt(fHCalTrackSigma *fHCalTrackSigma + hcalSigma*hcalSigma);558 559 552 ecalNeutralEnergy = max((ecalEnergy - fECalTrackEnergy), 0.0); 553 hcalNeutralEnergy = max((hcalEnergy - fHCalTrackEnergy), 0.0); 554 555 ecalNeutralSigma = ecalNeutralEnergy / TMath::Sqrt(fECalTrackSigma * fECalTrackSigma + ecalSigma * ecalSigma); 556 hcalNeutralSigma = hcalNeutralEnergy / TMath::Sqrt(fHCalTrackSigma * fHCalTrackSigma + hcalSigma * hcalSigma); 557 558 // if ecal neutral excess is significant, simply create neutral EflowPhoton tower and clone each track into eflowtrack 560 559 if(ecalNeutralEnergy > fECalEnergyMin && ecalNeutralSigma > fECalEnergySignificanceMin) 561 560 { 562 561 // create new photon tower 563 tower = static_cast<Candidate *>(fTower->Clone());564 pt = 565 562 tower = static_cast<Candidate *>(fTower->Clone()); 563 pt = ecalNeutralEnergy / TMath::CosH(eta); 564 566 565 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalNeutralEnergy); 567 566 tower->Eem = ecalNeutralEnergy; 568 567 tower->Ehad = 0.0; 569 568 tower->PID = 22; 570 569 571 570 fEFlowPhotonOutputArray->Add(tower); 572 571 573 572 //clone tracks 574 573 fItECalTowerTrackArray->Reset(); 575 while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next())))574 while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next()))) 576 575 { 577 576 mother = track; 578 track = static_cast<Candidate *>(track->Clone());577 track = static_cast<Candidate *>(track->Clone()); 579 578 track->AddCandidate(mother); 580 579 581 580 fEFlowTrackOutputArray->Add(track); 582 581 } 583 584 } 585 582 } 583 586 584 // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking 587 585 else if(fECalTrackEnergy > 0.0) 588 586 { 589 weightTrack = (fECalTrackSigma > 0.0) ? 1 / (fECalTrackSigma *fECalTrackSigma) : 0.0;590 weightCalo = (ecalSigma > 0.0) ? 1 / (ecalSigma*ecalSigma) : 0.0;591 592 bestEnergyEstimate = (weightTrack *fECalTrackEnergy + weightCalo*ecalEnergy) / (weightTrack + weightCalo);593 rescaleFactor = bestEnergyEstimate /fECalTrackEnergy;587 weightTrack = (fECalTrackSigma > 0.0) ? 1 / (fECalTrackSigma * fECalTrackSigma) : 0.0; 588 weightCalo = (ecalSigma > 0.0) ? 1 / (ecalSigma * ecalSigma) : 0.0; 589 590 bestEnergyEstimate = (weightTrack * fECalTrackEnergy + weightCalo * ecalEnergy) / (weightTrack + weightCalo); 591 rescaleFactor = bestEnergyEstimate / fECalTrackEnergy; 594 592 595 593 //rescale tracks 596 594 fItECalTowerTrackArray->Reset(); 597 while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next())))598 { 595 while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next()))) 596 { 599 597 mother = track; 600 track = static_cast<Candidate *>(track->Clone());598 track = static_cast<Candidate *>(track->Clone()); 601 599 track->AddCandidate(mother); 602 600 … … 606 604 } 607 605 } 608 609 606 610 607 // if hcal neutral excess is significant, simply create neutral EflowNeutralHadron tower and clone each track into eflowtrack … … 612 609 { 613 610 // create new photon tower 614 tower = static_cast<Candidate *>(fTower->Clone());615 pt = 616 611 tower = static_cast<Candidate *>(fTower->Clone()); 612 pt = hcalNeutralEnergy / TMath::CosH(eta); 613 617 614 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalNeutralEnergy); 618 615 tower->Ehad = hcalNeutralEnergy; 619 616 tower->Eem = 0.0; 620 617 621 618 fEFlowNeutralHadronOutputArray->Add(tower); 622 619 623 620 //clone tracks 624 621 fItHCalTowerTrackArray->Reset(); 625 while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next())))622 while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next()))) 626 623 { 627 624 mother = track; 628 track = static_cast<Candidate *>(track->Clone());625 track = static_cast<Candidate *>(track->Clone()); 629 626 track->AddCandidate(mother); 630 627 631 628 fEFlowTrackOutputArray->Add(track); 632 629 } 633 634 } 635 630 } 631 636 632 // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking 637 633 else if(fHCalTrackEnergy > 0.0) 638 634 { 639 weightTrack = (fHCalTrackSigma > 0.0) ? 1 / (fHCalTrackSigma *fHCalTrackSigma) : 0.0;640 weightCalo = (hcalSigma > 0.0) ? 1 / (hcalSigma*hcalSigma) : 0.0;641 642 bestEnergyEstimate = (weightTrack *fHCalTrackEnergy + weightCalo*hcalEnergy) / (weightTrack + weightCalo);635 weightTrack = (fHCalTrackSigma > 0.0) ? 1 / (fHCalTrackSigma * fHCalTrackSigma) : 0.0; 636 weightCalo = (hcalSigma > 0.0) ? 1 / (hcalSigma * hcalSigma) : 0.0; 637 638 bestEnergyEstimate = (weightTrack * fHCalTrackEnergy + weightCalo * hcalEnergy) / (weightTrack + weightCalo); 643 639 rescaleFactor = bestEnergyEstimate / fHCalTrackEnergy; 644 640 645 641 //rescale tracks 646 642 fItHCalTowerTrackArray->Reset(); 647 while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next())))648 { 643 while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next()))) 644 { 649 645 mother = track; 650 track = static_cast<Candidate *>(track->Clone());646 track = static_cast<Candidate *>(track->Clone()); 651 647 track->AddCandidate(mother); 652 648 … … 656 652 } 657 653 } 658 659 660 654 } 661 655 … … 668 662 if(mean > 0.0) 669 663 { 670 b = TMath::Sqrt(TMath::Log((1.0 + (sigma *sigma)/(mean*mean))));671 a = TMath::Log(mean) - 0.5 *b*b;672 673 return TMath::Exp(a + b *gRandom->Gaus(0.0, 1.0));664 b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean)))); 665 a = TMath::Log(mean) - 0.5 * b * b; 666 667 return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0)); 674 668 } 675 669 else
Note:
See TracChangeset
for help on using the changeset viewer.