Fork me on GitHub

Changeset 00e8dca in git


Ignore:
Timestamp:
Oct 8, 2015, 1:05:51 PM (9 years ago)
Author:
Pavel Demin <pavel.demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
cdeea24
Parents:
e2dd4c5
Message:

fix ecalEnergy and hcalEnergy in Calorimeter

Location:
modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/Calorimeter.cc

    re2dd4c5 r00e8dca  
    5656Calorimeter::Calorimeter() :
    5757  fECalResolutionFormula(0), fHCalResolutionFormula(0),
    58   fItParticleInputArray(0), fItTrackInputArray(0),
    59   fTowerTrackArray(0), fItTowerTrackArray(0)
     58  fItParticleInputArray(0), fItTrackInputArray(0)
    6059{
     60  Int_t i;
     61
    6162  fECalResolutionFormula = new DelphesFormula;
    6263  fHCalResolutionFormula = new DelphesFormula;
    6364
    64   fTowerTrackArray = new TObjArray;
    65   fItTowerTrackArray = fTowerTrackArray->MakeIterator();
     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  }
    6673}
    6774
     
    7077Calorimeter::~Calorimeter()
    7178{
     79  Int_t i;
     80
    7281  if(fECalResolutionFormula) delete fECalResolutionFormula;
    7382  if(fHCalResolutionFormula) delete fHCalResolutionFormula;
    7483
    75   if(fTowerTrackArray) delete fTowerTrackArray;
    76   if(fItTowerTrackArray) delete fItTowerTrackArray;
     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  }
    7792}
    7893
     
    203218  Double_t ecalFraction, hcalFraction;
    204219  Double_t ecalEnergy, hcalEnergy;
     220  Double_t ecalSigma, hcalSigma;
    205221  Int_t pdgCode;
    206222
     
    215231  DelphesFactory *factory = GetFactory();
    216232  fTowerHits.clear();
    217   fTowerECalFractions.clear();
    218   fTowerHCalFractions.clear();
    219   fTrackECalFractions.clear();
    220   fTrackHCalFractions.clear();
     233  fECalTowerFractions.clear();
     234  fHCalTowerFractions.clear();
     235  fECalTrackFractions.clear();
     236  fHCalTrackFractions.clear();
    221237
    222238  // loop over all particles
     
    239255    hcalFraction = itFractionMap->second.second;
    240256
    241     fTowerECalFractions.push_back(ecalFraction);
    242     fTowerHCalFractions.push_back(hcalFraction);
     257    fECalTowerFractions.push_back(ecalFraction);
     258    fHCalTowerFractions.push_back(hcalFraction);
    243259
    244260    if(ecalFraction < 1.0E-9 && hcalFraction < 1.0E-9) continue;
     
    285301    hcalFraction = itFractionMap->second.second;
    286302
    287     fTrackECalFractions.push_back(ecalFraction);
    288     fTrackHCalFractions.push_back(hcalFraction);
     303    fECalTrackFractions.push_back(ecalFraction);
     304    fHCalTrackFractions.push_back(hcalFraction);
    289305
    290306    // find eta bin [1, fEtaBins.size - 1]
     
    349365      fTowerEdges[3] = (*phiBins)[phiBin];
    350366
    351       fTowerECalEnergy = 0.0;
    352       fTowerHCalEnergy = 0.0;
    353 
    354       fTrackECalEnergy = 0.0;
    355       fTrackHCalEnergy = 0.0;
     367      fECalTowerEnergy = 0.0;
     368      fHCalTowerEnergy = 0.0;
     369
     370      fECalTrackEnergy[0] = 0.0;
     371      fECalTrackEnergy[1] = 0.0;
     372
     373      fHCalTrackEnergy[0] = 0.0;
     374      fHCalTrackEnergy[1] = 0.0;
    356375
    357376      fTowerTrackHits = 0;
    358377      fTowerPhotonHits = 0;
    359378
    360       fTowerTrackArray->Clear();
     379      fECalTowerTrackArray[0]->Clear();
     380      fECalTowerTrackArray[1]->Clear();
     381
     382      fHCalTowerTrackArray[0]->Clear();
     383      fHCalTowerTrackArray[1]->Clear();
    361384    }
    362385
     
    370393      position = track->Position;
    371394
    372       ecalEnergy = momentum.E() * fTrackECalFractions[number];
    373       hcalEnergy = momentum.E() * fTrackHCalFractions[number];
    374 
    375       fTrackECalEnergy += ecalEnergy;
    376       fTrackHCalEnergy += hcalEnergy;
     395      ecalEnergy = momentum.E() * fECalTrackFractions[number];
     396      hcalEnergy = momentum.E() * fHCalTrackFractions[number];
    377397
    378398      if(ecalEnergy > fTimingEnergyMin && fTower)
     
    384404      }
    385405
    386       fTowerTrackArray->Add(track);
     406      if(fECalTrackFractions[number] > 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9 )
     407      {
     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        }
     419      }
     420      else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9 )
     421      {
     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        }
     433      }
    387434
    388435      continue;
     
    397444
    398445    // fill current tower
    399     ecalEnergy = momentum.E() * fTowerECalFractions[number];
    400     hcalEnergy = momentum.E() * fTowerHCalFractions[number];
    401 
    402     fTowerECalEnergy += ecalEnergy;
    403     fTowerHCalEnergy += hcalEnergy;
     446    ecalEnergy = momentum.E() * fECalTowerFractions[number];
     447    hcalEnergy = momentum.E() * fHCalTowerFractions[number];
     448
     449    fECalTowerEnergy += ecalEnergy;
     450    fHCalTowerEnergy += hcalEnergy;
    404451
    405452    if(ecalEnergy > fTimingEnergyMin && fTower)
     
    426473  Double_t ecalEnergy, hcalEnergy;
    427474  Double_t ecalSigma, hcalSigma;
    428   Double_t ecalTrkSigma, hcalTrkSigma;
    429   Double_t ecalFraction, hcalFraction;
    430 
    431   Int_t pdgCode;
     475
    432476  TLorentzVector momentum;
    433477  TFractionMap::iterator itFractionMap;
     
    438482
    439483
    440   ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy);
    441   hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy);
    442 
    443   ecalEnergy = LogNormal(fTowerECalEnergy, ecalSigma);
    444   hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma);
     484  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fECalTowerEnergy);
     485  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fHCalTowerEnergy);
     486
     487  ecalEnergy = LogNormal(fECalTowerEnergy, ecalSigma);
     488  hcalEnergy = LogNormal(fHCalTowerEnergy, hcalSigma);
    445489
    446490  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
     
    509553  // fill energy flow candidates
    510554
    511   // save as eflowtracks only tracks that have better resolution than calo
    512 
    513   fItTowerTrackArray->Reset();
    514   while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
    515   {
    516     pdgCode = TMath::Abs(track->PID);
    517 
    518     itFractionMap = fFractionMap.find(pdgCode);
    519     if(itFractionMap == fFractionMap.end())
    520     {
    521       itFractionMap = fFractionMap.find(0);
    522     }
    523 
    524     ecalFraction = itFractionMap->second.first;
    525     hcalFraction = itFractionMap->second.second;
    526 
     555  ecalEnergy -= fECalTrackEnergy[1];
     556  hcalEnergy -= fHCalTrackEnergy[1];
     557
     558  fItECalTowerTrackArray[0]->Reset();
     559  while((track = static_cast<Candidate*>(fItECalTowerTrackArray[0]->Next())))
     560  {
    527561    mother = track;
    528562    track = static_cast<Candidate*>(track->Clone());
    529563    track->AddCandidate(mother);
    530     momentum = track->Momentum;
    531 
    532     if(ecalFraction > 1.0E-9 && hcalFraction < 1.0E-9 )
    533     {
    534       ecalTrkSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
    535       if(ecalTrkSigma/momentum.E() < track->TrackResolution)
    536       {
    537         momentum *= ecalEnergy/fTrackECalEnergy;
    538       }
    539     }
    540     else if(ecalFraction < 1.0E-9 && hcalFraction > 1.0E-9 )
    541     {
    542       hcalTrkSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
    543       if(hcalTrkSigma/momentum.E() < track->TrackResolution)
    544       {
    545         momentum *= hcalEnergy/fTrackHCalEnergy;
    546       }
    547     }
     564
     565    track->Momentum *= ecalEnergy/fECalTrackEnergy[0];
    548566
    549567    fEFlowTrackOutputArray->Add(track);
    550568  }
    551569
    552   ecalEnergy -= fTrackECalEnergy;
    553   hcalEnergy -= fTrackHCalEnergy;
     570  fItECalTowerTrackArray[1]->Reset();
     571  while((track = static_cast<Candidate*>(fItECalTowerTrackArray[1]->Next())))
     572  {
     573    mother = track;
     574    track = static_cast<Candidate*>(track->Clone());
     575    track->AddCandidate(mother);
     576
     577    fEFlowTrackOutputArray->Add(track);
     578  }
     579
     580  fItHCalTowerTrackArray[0]->Reset();
     581  while((track = static_cast<Candidate*>(fItHCalTowerTrackArray[0]->Next())))
     582  {
     583    mother = track;
     584    track = static_cast<Candidate*>(track->Clone());
     585    track->AddCandidate(mother);
     586
     587    track->Momentum *= ecalEnergy/fECalTrackEnergy[0];
     588
     589    fEFlowTrackOutputArray->Add(track);
     590  }
     591
     592  fItHCalTowerTrackArray[1]->Reset();
     593  while((track = static_cast<Candidate*>(fItHCalTowerTrackArray[1]->Next())))
     594  {
     595    mother = track;
     596    track = static_cast<Candidate*>(track->Clone());
     597    track->AddCandidate(mother);
     598
     599    fEFlowTrackOutputArray->Add(track);
     600  }
    554601
    555602  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
  • modules/Calorimeter.h

    re2dd4c5 r00e8dca  
    5757  Candidate *fTower;
    5858  Double_t fTowerEta, fTowerPhi, fTowerEdges[4];
    59   Double_t fTowerECalEnergy, fTowerHCalEnergy;
    60   Double_t fTrackECalEnergy, fTrackHCalEnergy;
     59  Double_t fECalTowerEnergy, fHCalTowerEnergy;
     60  Double_t fECalTrackEnergy[2], fHCalTrackEnergy[2];
    6161
    6262  Double_t fTimingEnergyMin;
     
    8181  std::vector < Long64_t > fTowerHits;
    8282
    83   std::vector < Double_t > fTowerECalFractions;
    84   std::vector < Double_t > fTowerHCalFractions;
     83  std::vector < Double_t > fECalTowerFractions;
     84  std::vector < Double_t > fHCalTowerFractions;
    8585
    86   std::vector < Double_t > fTrackECalFractions;
    87   std::vector < Double_t > fTrackHCalFractions;
     86  std::vector < Double_t > fECalTrackFractions;
     87  std::vector < Double_t > fHCalTrackFractions;
    8888
    8989  DelphesFormula *fECalResolutionFormula; //!
     
    103103  TObjArray *fEFlowNeutralHadronOutputArray; //!
    104104
    105   TObjArray *fTowerTrackArray; //!
    106   TIterator *fItTowerTrackArray; //!
     105  TObjArray *fECalTowerTrackArray[2]; //!
     106  TIterator *fItECalTowerTrackArray[2]; //!
     107
     108  TObjArray *fHCalTowerTrackArray[2]; //!
     109  TIterator *fItHCalTowerTrackArray[2]; //!
    107110
    108111  void FinalizeTower();
Note: See TracChangeset for help on using the changeset viewer.