Changes in modules/SimpleCalorimeter.cc [341014c:7da1826] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/SimpleCalorimeter.cc
r341014c r7da1826 17 17 */ 18 18 19 19 20 /** \class SimpleCalorimeter 20 21 * … … 32 33 #include "classes/DelphesFormula.h" 33 34 35 #include "ExRootAnalysis/ExRootResult.h" 36 #include "ExRootAnalysis/ExRootFilter.h" 34 37 #include "ExRootAnalysis/ExRootClassifier.h" 35 #include "ExRootAnalysis/ExRootFilter.h" 36 #include "ExRootAnalysis/ExRootResult.h" 37 38 39 #include "TMath.h" 40 #include "TString.h" 41 #include "TFormula.h" 42 #include "TRandom3.h" 43 #include "TObjArray.h" 38 44 #include "TDatabasePDG.h" 39 #include "TFormula.h"40 45 #include "TLorentzVector.h" 41 #include "TMath.h"42 #include "TObjArray.h"43 #include "TRandom3.h"44 #include "TString.h"45 46 46 47 #include <algorithm> 48 #include <stdexcept> 47 49 #include <iostream> 48 50 #include <sstream> 49 #include <stdexcept>50 51 51 52 using namespace std; … … 57 58 fItParticleInputArray(0), fItTrackInputArray(0) 58 59 { 59 60 60 61 fResolutionFormula = new DelphesFormula; 61 62 fTowerTrackArray = new TObjArray; 62 63 fItTowerTrackArray = fTowerTrackArray->MakeIterator(); 64 63 65 } 64 66 … … 67 69 SimpleCalorimeter::~SimpleCalorimeter() 68 70 { 69 71 70 72 if(fResolutionFormula) delete fResolutionFormula; 71 73 if(fTowerTrackArray) delete fTowerTrackArray; 72 74 if(fItTowerTrackArray) delete fItTowerTrackArray; 75 73 76 } 74 77 … … 81 84 Double_t fraction; 82 85 TBinMap::iterator itEtaBin; 83 set< Double_t>::iterator itPhiBin;84 vector< Double_t> *phiBins;86 set< Double_t >::iterator itPhiBin; 87 vector< Double_t > *phiBins; 85 88 86 89 // read eta and phi bins … … 90 93 fEtaBins.clear(); 91 94 fPhiBins.clear(); 92 for(i = 0; i < size /2; ++i)93 { 94 paramEtaBins = param[i *2];95 for(i = 0; i < size/2; ++i) 96 { 97 paramEtaBins = param[i*2]; 95 98 sizeEtaBins = paramEtaBins.GetSize(); 96 paramPhiBins = param[i *2 + 1];99 paramPhiBins = param[i*2 + 1]; 97 100 sizePhiBins = paramPhiBins.GetSize(); 98 101 … … 111 114 { 112 115 fEtaBins.push_back(itEtaBin->first); 113 phiBins = new vector< double>(itEtaBin->second.size());116 phiBins = new vector< double >(itEtaBin->second.size()); 114 117 fPhiBins.push_back(phiBins); 115 118 phiBins->clear(); … … 128 131 fFractionMap[0] = 1.0; 129 132 130 for(i = 0; i < size /2; ++i)131 { 132 paramFractions = param[i *2 + 1];133 for(i = 0; i < size/2; ++i) 134 { 135 paramFractions = param[i*2 + 1]; 133 136 fraction = paramFractions[0].GetDouble(); 134 fFractionMap[param[i *2].GetInt()] = fraction;137 fFractionMap[param[i*2].GetInt()] = fraction; 135 138 } 136 139 … … 167 170 void SimpleCalorimeter::Finish() 168 171 { 169 vector< vector<Double_t> *>::iterator itPhiBin;172 vector< vector< Double_t >* >::iterator itPhiBin; 170 173 if(fItParticleInputArray) delete fItParticleInputArray; 171 174 if(fItTrackInputArray) delete fItTrackInputArray; … … 194 197 TFractionMap::iterator itFractionMap; 195 198 196 vector< Double_t>::iterator itEtaBin;197 vector< Double_t>::iterator itPhiBin;198 vector< Double_t> *phiBins;199 200 vector< Long64_t>::iterator itTowerHits;199 vector< Double_t >::iterator itEtaBin; 200 vector< Double_t >::iterator itPhiBin; 201 vector< Double_t > *phiBins; 202 203 vector< Long64_t >::iterator itTowerHits; 201 204 202 205 DelphesFactory *factory = GetFactory(); … … 208 211 fItParticleInputArray->Reset(); 209 212 number = -1; 210 while((particle = static_cast<Candidate 213 while((particle = static_cast<Candidate*>(fItParticleInputArray->Next()))) 211 214 { 212 215 const TLorentzVector &particlePosition = particle->Position; … … 251 254 fItTrackInputArray->Reset(); 252 255 number = -1; 253 while((track = static_cast<Candidate 256 while((track = static_cast<Candidate*>(fItTrackInputArray->Next()))) 254 257 { 255 258 const TLorentzVector &trackPosition = track->Position; … … 300 303 towerHit = (*itTowerHits); 301 304 flags = (towerHit >> 24) & 0x00000000000000FFLL; 302 number = (towerHit) &0x0000000000FFFFFFLL;305 number = (towerHit) & 0x0000000000FFFFFFLL; 303 306 hitEtaPhi = towerHit >> 32; 304 307 … … 321 324 322 325 // calculate eta and phi of the tower's center 323 fTowerEta = 0.5 *(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);324 fTowerPhi = 0.5 *((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);326 fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]); 327 fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]); 325 328 326 329 fTowerEdges[0] = fEtaBins[etaBin - 1]; … … 343 346 344 347 fTowerTrackArray->Clear(); 345 }348 } 346 349 347 350 // check for track hits … … 350 353 ++fTowerTrackHits; 351 354 352 track = static_cast<Candidate 355 track = static_cast<Candidate*>(fTrackInputArray->At(number)); 353 356 momentum = track->Momentum; 354 357 position = track->Position; … … 356 359 energy = momentum.E() * fTrackFractions[number]; 357 360 358 fTrackTime += TMath::Sqrt(energy) *position.T();361 fTrackTime += TMath::Sqrt(energy)*position.T(); 359 362 fTrackTimeWeight += TMath::Sqrt(energy); 360 363 361 364 if(fTrackFractions[number] > 1.0E-9) 362 365 { 363 364 // compute total charged energy 365 fTrackEnergy += energy; 366 sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 367 if(sigma / momentum.E() < track->TrackResolution) 368 energyGuess = energy; 369 else 370 energyGuess = momentum.E(); 371 372 fTrackSigma += ((track->TrackResolution) * energyGuess) * ((track->TrackResolution) * energyGuess); 373 fTowerTrackArray->Add(track); 366 367 // compute total charged energy 368 fTrackEnergy += energy; 369 sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E()); 370 if(sigma/momentum.E() < track->TrackResolution) energyGuess = energy; 371 else energyGuess = momentum.E(); 372 373 fTrackSigma += ((track->TrackResolution)*energyGuess)*((track->TrackResolution)*energyGuess); 374 fTowerTrackArray->Add(track); 374 375 } 375 376 376 377 else 377 378 { … … 385 386 if(flags & 2) ++fTowerPhotonHits; 386 387 387 particle = static_cast<Candidate 388 particle = static_cast<Candidate*>(fParticleInputArray->At(number)); 388 389 momentum = particle->Momentum; 389 390 position = particle->Position; … … 394 395 fTowerEnergy += energy; 395 396 396 fTowerTime += energy *position.T();397 fTowerTime += energy*position.T(); 397 398 fTowerTimeWeight += energy; 398 399 … … 409 410 { 410 411 Candidate *tower, *track, *mother; 411 Double_t energy, 412 Double_t energy,neutralEnergy, pt, eta, phi; 412 413 Double_t sigma, neutralSigma; 413 414 Double_t time; 414 415 415 416 Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor; 416 417 … … 424 425 energy = LogNormal(fTowerEnergy, sigma); 425 426 426 time = (fTowerTimeWeight < 1.0E-09 ) ? 0.0 : fTowerTime /fTowerTimeWeight;427 time = (fTowerTimeWeight < 1.0E-09 ) ? 0.0 : fTowerTime/fTowerTimeWeight; 427 428 428 429 sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy); 429 430 430 if(energy < fEnergyMin || energy < fEnergySignificanceMin * sigma) energy = 0.0; 431 if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0; 432 431 433 432 434 if(fSmearTowerCenter) … … 457 459 if(energy > 0.0) fTowerOutputArray->Add(fTower); 458 460 461 459 462 // e-flow candidates 460 463 461 464 //compute neutral excess 462 465 463 466 fTrackSigma = TMath::Sqrt(fTrackSigma); 464 neutralEnergy = max( (energy - fTrackEnergy), 0.0);465 467 neutralEnergy = max( (energy - fTrackEnergy) , 0.0); 468 466 469 //compute sigma_trk total 467 neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma * fTrackSigma + sigma *sigma);468 470 neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma*fTrackSigma+ sigma*sigma); 471 469 472 // if neutral excess is significant, simply create neutral Eflow tower and clone each track into eflowtrack 470 473 if(neutralEnergy > fEnergyMin && neutralSigma > fEnergySignificanceMin) 471 474 { 472 475 // create new photon tower 473 tower = static_cast<Candidate 476 tower = static_cast<Candidate*>(fTower->Clone()); 474 477 pt = neutralEnergy / TMath::CosH(eta); 475 478 … … 477 480 tower->Ehad = (fIsEcal) ? 0 : neutralEnergy; 478 481 tower->PID = (fIsEcal) ? 22 : 0; 479 482 480 483 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, neutralEnergy); 481 484 fEFlowTowerOutputArray->Add(tower); 482 485 483 486 fItTowerTrackArray->Reset(); 484 while((track = static_cast<Candidate 487 while((track = static_cast<Candidate*>(fItTowerTrackArray->Next()))) 485 488 { 486 489 mother = track; 487 track = static_cast<Candidate 490 track = static_cast<Candidate*>(track->Clone()); 488 491 track->AddCandidate(mother); 489 492 … … 491 494 } 492 495 } 493 496 494 497 // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking 495 else if (fTrackEnergy > 0.0)496 { 497 weightTrack = (fTrackSigma > 0.0) ? 1 / (fTrackSigma *fTrackSigma) : 0.0;498 weightCalo = (sigma > 0.0) ? 1 / (sigma *sigma) : 0.0;499 500 bestEnergyEstimate = (weightTrack * fTrackEnergy + weightCalo * energy) / (weightTrack + weightCalo);501 rescaleFactor = bestEnergyEstimate /fTrackEnergy;502 498 else if (fTrackEnergy > 0.0) 499 { 500 weightTrack = (fTrackSigma > 0.0) ? 1 / (fTrackSigma*fTrackSigma) : 0.0; 501 weightCalo = (sigma > 0.0) ? 1 / (sigma*sigma) : 0.0; 502 503 bestEnergyEstimate = (weightTrack*fTrackEnergy + weightCalo*energy) / (weightTrack + weightCalo); 504 rescaleFactor = bestEnergyEstimate/fTrackEnergy; 505 503 506 fItTowerTrackArray->Reset(); 504 while((track = static_cast<Candidate 507 while((track = static_cast<Candidate*>(fItTowerTrackArray->Next()))) 505 508 { 506 509 mother = track; 507 track = static_cast<Candidate 510 track = static_cast<Candidate*>(track->Clone()); 508 511 track->AddCandidate(mother); 509 512 … … 513 516 } 514 517 } 518 519 } 520 521 //------------------------------------------------------------------------------ 522 523 Double_t SimpleCalorimeter::LogNormal(Double_t mean, Double_t sigma) 524 { 525 Double_t a, b; 526 527 if(mean > 0.0) 528 { 529 b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean)))); 530 a = TMath::Log(mean) - 0.5*b*b; 531 532 return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0)); 533 } 534 else 535 { 536 return 0.0; 537 } 515 538 } 516 517 //------------------------------------------------------------------------------518 519 Double_t SimpleCalorimeter::LogNormal(Double_t mean, Double_t sigma)520 {521 Double_t a, b;522 523 if(mean > 0.0)524 {525 b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));526 a = TMath::Log(mean) - 0.5 * b * b;527 528 return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0));529 }530 else531 {532 return 0.0;533 }534 }
Note:
See TracChangeset
for help on using the changeset viewer.