Fork me on GitHub

Changeset 4600a41 in git


Ignore:
Timestamp:
Jun 25, 2013, 4:24:34 PM (11 years ago)
Author:
pavel <pavel@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
e3ab175
Parents:
6e338f1
Message:

optimize LogNormal

Location:
modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/Calorimeter.cc

    r6e338f1 r4600a41  
    155155  fEFlowTrackOutputArray = ExportArray(GetString("EFlowTrackOutputArray", "eflowTracks"));
    156156  fEFlowTowerOutputArray = ExportArray(GetString("EFlowTowerOutputArray", "eflowTowers"));
    157 
    158  
    159 
    160157}
    161158
     
    376373  Double_t energy, pt, eta, phi;
    377374  Double_t ecalEnergy, hcalEnergy;
    378   Double_t sE,mE,sH,mH,SE=0,ME=0,SH=0,MH=0;
    379  
     375
    380376  if(!fTower) return;
    381377
    382  // cout<<"new tower -----------------------"<<endl;
    383 
    384  
    385   sE = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy);
    386   mE = fTowerECalEnergy;
    387  
    388   sH = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy);
    389   mH = fTowerHCalEnergy;
    390  
    391  // cout<<sE<<","<<mE<<endl;
    392  // cout<<sH<<","<<mH<<endl;
    393  // cout<<"---"<<endl;
    394  
    395   if(mE>0)SE = TMath::Sqrt(TMath::Log((1+(sE*sE)/(mE*mE))));
    396   if(mE>0)ME = TMath::Log(mE)-0.5*SE*SE;
    397  
    398   if(mH>0)SH = TMath::Sqrt(TMath::Log((1+(sH*sH)/(mH*mH))));
    399   if(mH>0)MH = TMath::Log(mH)-0.5*SH*SH;
    400  
    401  // cout<<SE<<","<<ME<<endl;
    402  // cout<<SH<<","<<MH<<endl;
    403  // cout<<"---"<<endl;
    404  
    405378//  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
    406   ecalEnergy = (ME != 0.0 ? Draw_lognormal(ME,SE) : 0.0);
    407  // cout<<ecalEnergy<<endl;
    408  
    409   if(ecalEnergy < 0.0) ecalEnergy = 0.0;
    410 
    411   hcalEnergy = (MH != 0.0 ? Draw_lognormal(MH,SH) : 0.0);
    412   //hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
    413   if(hcalEnergy < 0.0) hcalEnergy = 0.0;
    414 
    415 //  cout<<hcalEnergy<<endl;
    416    
     379//  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
     380
     381  ecalEnergy = LogNormal(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
     382
     383//  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
     384//  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
     385
     386  hcalEnergy = LogNormal(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
     387
    417388  energy = ecalEnergy + hcalEnergy;
    418389
    419  // eta = fTowerEta;
    420  // phi = fTowerPhi;
     390// eta = fTowerEta;
     391// phi = fTowerPhi;
    421392
    422393  eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
     
    502473//------------------------------------------------------------------------------
    503474
    504 Double_t Calorimeter::Draw_lognormal(Double_t mu, Double_t sigma)
    505   {
    506      Double_t g = gRandom->Gaus(0, 1);
    507      return TMath::Exp(mu + sigma * g);
    508   }
     475Double_t Calorimeter::LogNormal(Double_t mean, Double_t sigma)
     476{
     477  Double_t a, b;
     478
     479  if(mean > 0.0)
     480  {
     481    b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
     482    a = TMath::Log(mean) - 0.5*b*b;
     483
     484    return TMath::Exp(a + b*gRandom->Gaus(0, 1));
     485  }
     486  else
     487  {
     488    return 0.0;
     489  }
     490}
  • modules/Calorimeter.h

    r6e338f1 r4600a41  
    3535  void Process();
    3636  void Finish();
    37   Double_t Draw_lognormal(Double_t mu, Double_t sigma);
     37
    3838private:
    3939
     
    8080
    8181  void FinalizeTower();
    82  
     82  Double_t LogNormal(Double_t mean, Double_t sigma);
     83
    8384  ClassDef(Calorimeter, 1)
    8485};
Note: See TracChangeset for help on using the changeset viewer.