Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/Calorimeter.cc

    r01f457a r38bf1ae  
    22 *  Delphes: a framework for fast simulation of a generic collider experiment
    33 *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
    4  * 
     4 *
    55 *  This program is free software: you can redistribute it and/or modify
    66 *  it under the terms of the GNU General Public License as published by
    77 *  the Free Software Foundation, either version 3 of the License, or
    88 *  (at your option) any later version.
    9  * 
     9 *
    1010 *  This program is distributed in the hope that it will be useful,
    1111 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1212 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1313 *  GNU General Public License for more details.
    14  * 
     14 *
    1515 *  You should have received a copy of the GNU General Public License
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2222 *  Fills calorimeter towers, performs calorimeter resolution smearing,
    2323 *  and creates energy flow objects (tracks, photons, and neutral hadrons).
    24  *
    25  *  $Date$
    26  *  $Revision$
    27  *
    2824 *
    2925 *  \author P. Demin - UCL, Louvain-la-Neuve
     
    8682{
    8783  ExRootConfParam param, paramEtaBins, paramPhiBins, paramFractions;
    88   Long_t i, j, k, size, sizeEtaBins, sizePhiBins, sizeFractions;
     84  Long_t i, j, k, size, sizeEtaBins, sizePhiBins;
    8985  Double_t ecalFraction, hcalFraction;
    9086  TBinMap::iterator itEtaBin;
     
    139135  {
    140136    paramFractions = param[i*2 + 1];
    141     sizeFractions = paramFractions.GetSize();
    142137
    143138    ecalFraction = paramFractions[0].GetDouble();
     
    146141    fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
    147142  }
     143
    148144/*
    149145  TFractionMap::iterator itFractionMap;
     
    155151
    156152  // read min E value for towers to be saved
    157   fEcalEnergyMin = GetDouble("EcalTowerMinEnergy", 0.0);
    158   fHcalEnergyMin = GetDouble("HcalTowerMinEnergy", 0.0);
    159  
    160   fEcalSigmaMin  = GetDouble("EcalTowerMinSignificance", 0.0);
    161   fHcalSigmaMin  = GetDouble("HcalTowerMinSignificance", 0.0);
    162 
    163  
     153  fECalEnergyMin = GetDouble("ECalEnergyMin", 0.0);
     154  fHCalEnergyMin = GetDouble("HCalEnergyMin", 0.0);
     155
     156  fECalEnergySignificanceMin = GetDouble("ECalEnergySignificanceMin", 0.0);
     157  fHCalEnergySignificanceMin = GetDouble("HCalEnergySignificanceMin", 0.0);
     158
     159  // switch on or off the dithering of the center of calorimeter towers
     160  fDitherTowerCenter = GetBool("DitherTowerCenter", true);
     161
    164162  // read resolution formulas
    165163  fECalResolutionFormula->Compile(GetString("ECalResolutionFormula", "0"));
     
    176174  fTowerOutputArray = ExportArray(GetString("TowerOutputArray", "towers"));
    177175  fPhotonOutputArray = ExportArray(GetString("PhotonOutputArray", "photons"));
    178  
     176
    179177  fEFlowTrackOutputArray = ExportArray(GetString("EFlowTrackOutputArray", "eflowTracks"));
    180178  fEFlowPhotonOutputArray = ExportArray(GetString("EFlowPhotonOutputArray", "eflowPhotons"));
    181179  fEFlowNeutralHadronOutputArray = ExportArray(GetString("EFlowNeutralHadronOutputArray", "eflowNeutralHadrons"));
    182 
    183 
    184180}
    185181
     
    366362      fTrackHCalTime = 0.0;
    367363
    368       fTowerECalWeightTime = 0.0;
    369       fTowerHCalWeightTime = 0.0;
    370      
     364      fTowerECalTimeWeight = 0.0;
     365      fTowerHCalTimeWeight = 0.0;
     366
    371367      fTowerTrackHits = 0;
    372368      fTowerPhotonHits = 0;
    373      
     369
    374370      fTowerTrackArray->Clear();
    375371    }
     
    384380      position = track->Position;
    385381
    386      
     382
    387383      ecalEnergy = momentum.E() * fTrackECalFractions[number];
    388384      hcalEnergy = momentum.E() * fTrackHCalFractions[number];
     
    390386      fTrackECalEnergy += ecalEnergy;
    391387      fTrackHCalEnergy += hcalEnergy;
    392      
     388
    393389      fTrackECalTime += TMath::Sqrt(ecalEnergy)*position.T();
    394390      fTrackHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
    395        
    396       fTrackECalWeightTime += TMath::Sqrt(ecalEnergy);
    397       fTrackHCalWeightTime += TMath::Sqrt(hcalEnergy);
     391
     392      fTrackECalTimeWeight += TMath::Sqrt(ecalEnergy);
     393      fTrackHCalTimeWeight += TMath::Sqrt(hcalEnergy);
    398394
    399395      fTowerTrackArray->Add(track);
     
    401397      continue;
    402398    }
    403    
     399
    404400    // check for photon and electron hits in current tower
    405401    if(flags & 2) ++fTowerPhotonHits;
    406    
     402
    407403    particle = static_cast<Candidate*>(fParticleInputArray->At(number));
    408404    momentum = particle->Momentum;
     
    419415    fTowerHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
    420416
    421     fTowerECalWeightTime += TMath::Sqrt(ecalEnergy);
    422     fTowerHCalWeightTime += TMath::Sqrt(hcalEnergy);
    423    
     417    fTowerECalTimeWeight += TMath::Sqrt(ecalEnergy);
     418    fTowerHCalTimeWeight += TMath::Sqrt(hcalEnergy);
     419
    424420
    425421    fTower->AddCandidate(particle);
     
    441437
    442438  if(!fTower) return;
    443 //  cout<<"----------------------"<<endl;
    444 //  cout<<"Finalize Tower"<<endl;
    445 //  cout<<""<<endl;
    446 
    447439
    448440  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy);
    449 
    450 //  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, ecalSigma);
    451 //  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
     441  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy);
    452442
    453443  ecalEnergy = LogNormal(fTowerECalEnergy, ecalSigma);
    454   ecalTime = (fTowerECalWeightTime < 1.0E-09 ) ? 0 : fTowerECalTime/fTowerECalWeightTime;
    455 
    456   hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy);
    457 
    458 //  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, hcalSigma);
    459 //  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
    460 
    461444  hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma);
    462   hcalTime = (fTowerHCalWeightTime < 1.0E-09 ) ? 0 : fTowerHCalTime/fTowerHCalWeightTime;
    463 
    464  
     445
     446  ecalTime = (fTowerECalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerECalTime/fTowerECalTimeWeight;
     447  hcalTime = (fTowerHCalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerHCalTime/fTowerHCalTimeWeight;
     448
    465449  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
    466450  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
    467451
    468   ecalEnergy = (ecalEnergy < fEcalEnergyMin || ecalEnergy < fEcalSigmaMin*ecalSigma) ? 0 : ecalEnergy;
    469   hcalEnergy = (hcalEnergy < fHcalEnergyMin || hcalEnergy < fHcalSigmaMin*hcalSigma) ? 0 : hcalEnergy;
     452  if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
     453  if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
    470454
    471455  energy = ecalEnergy + hcalEnergy;
    472   time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy));
    473 
    474 //  eta = fTowerEta;
    475 //  phi = fTowerPhi;
    476 
    477   eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
    478   phi = gRandom->Uniform(fTowerEdges[2], fTowerEdges[3]);
     456  time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy));
     457
     458  if(fDitherTowerCenter)
     459  {
     460    eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
     461    phi = gRandom->Uniform(fTowerEdges[2], fTowerEdges[3]);
     462  }
     463  else
     464  {
     465    eta = fTowerEta;
     466    phi = fTowerPhi;
     467  }
    479468
    480469  pt = energy / TMath::CosH(eta);
    481470
    482  // fTower->Position.SetXYZT(-time, 0.0, 0.0, time);
    483471  fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time);
    484472  fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
     
    491479  fTower->Edges[3] = fTowerEdges[3];
    492480
    493   if( energy > 0.0 )
     481  if(energy > 0.0)
    494482  {
    495483    if(fTowerPhotonHits > 0 && fTowerTrackHits == 0)
     
    497485      fPhotonOutputArray->Add(fTower);
    498486    }
    499    
     487
    500488    fTowerOutputArray->Add(fTower);
    501489  }
     
    511499
    512500  ecalEnergy -= fTrackECalEnergy;
    513   if(ecalEnergy < fEcalEnergyMin || ecalEnergy < fEcalSigmaMin*fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy)) ecalEnergy = 0.0;
    514 
    515501  hcalEnergy -= fTrackHCalEnergy;
    516   if(hcalEnergy < fHcalEnergyMin || hcalEnergy < fHcalSigmaMin*fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy)) hcalEnergy = 0.0;
     502
     503  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
     504  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
     505
     506  if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
     507  if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
    517508
    518509  energy = ecalEnergy + hcalEnergy;
     
    527518    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy);
    528519    tower->Eem = ecalEnergy;
    529     tower->Ehad = 0;
     520    tower->Ehad = 0.0;
    530521
    531522    fEFlowPhotonOutputArray->Add(tower);
     
    539530
    540531    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);
    541     tower->Eem = 0;
     532    tower->Eem = 0.0;
    542533    tower->Ehad = hcalEnergy;
    543534
    544535    fEFlowNeutralHadronOutputArray->Add(tower);
    545536  }
    546 
    547 
    548 
    549 
    550537}
    551538
     
    561548    a = TMath::Log(mean) - 0.5*b*b;
    562549
    563     return TMath::Exp(a + b*gRandom->Gaus(0, 1));
     550    return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
    564551  }
    565552  else
Note: See TracChangeset for help on using the changeset viewer.