Fork me on GitHub

Changeset d77b51d in git for modules/Calorimeter.cc


Ignore:
Timestamp:
Sep 29, 2015, 2:08:10 PM (9 years ago)
Author:
Michele Selvaggi <michele.selvaggi@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
a98c7ef
Parents:
d870fc5 (diff), 06ec139 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'upstream/master'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/Calorimeter.cc

    rd870fc5 rd77b51d  
    142142  }
    143143
    144 /*
    145   TFractionMap::iterator itFractionMap;
    146   for(itFractionMap = fFractionMap.begin(); itFractionMap != fFractionMap.end(); ++itFractionMap)
    147   {
    148     cout << itFractionMap->first << "   " << itFractionMap->second.first  << "   " << itFractionMap->second.second << endl;
    149   }
    150 */
     144  // read min E value for timing measurement in ECAL
     145  fTimingEnergyMin = GetDouble("TimingEnergyMin",4.);
     146  // For timing
     147  // So far this flag needs to be false
     148  // Curved extrapolation not supported
     149  fElectronsFromTrack = false;
    151150
    152151  // read min E value for towers to be saved
     
    158157
    159158  // switch on or off the dithering of the center of calorimeter towers
    160   fDitherTowerCenter = GetBool("DitherTowerCenter", true);
     159  fSmearTowerCenter = GetBool("SmearTowerCenter", true);
    161160
    162161  // read resolution formulas
     
    356355      fTrackHCalEnergy = 0.0;
    357356
    358       fTowerECalTime = 0.0;
    359       fTowerHCalTime = 0.0;
    360 
    361       fTrackECalTime = 0.0;
    362       fTrackHCalTime = 0.0;
    363 
    364       fTowerECalTimeWeight = 0.0;
    365       fTowerHCalTimeWeight = 0.0;
    366 
    367357      fTowerTrackHits = 0;
    368358      fTowerPhotonHits = 0;
     
    380370      position = track->Position;
    381371
    382 
    383372      ecalEnergy = momentum.E() * fTrackECalFractions[number];
    384373      hcalEnergy = momentum.E() * fTrackHCalFractions[number];
     
    387376      fTrackHCalEnergy += hcalEnergy;
    388377
    389       fTrackECalTime += TMath::Sqrt(ecalEnergy)*position.T();
    390       fTrackHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
    391 
    392       fTrackECalTimeWeight += TMath::Sqrt(ecalEnergy);
    393       fTrackHCalTimeWeight += TMath::Sqrt(hcalEnergy);
     378      if(ecalEnergy > fTimingEnergyMin && fTower)
     379      {
     380        if(fElectronsFromTrack)
     381        {
     382          fTower->ECalEnergyTimePairs.push_back(make_pair<Float_t, Float_t>(ecalEnergy, track->Position.T()));
     383        }
     384      }
    394385
    395386      fTowerTrackArray->Add(track);
     
    412403    fTowerHCalEnergy += hcalEnergy;
    413404
    414     fTowerECalTime += TMath::Sqrt(ecalEnergy)*position.T();
    415     fTowerHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
    416 
    417     fTowerECalTimeWeight += TMath::Sqrt(ecalEnergy);
    418     fTowerHCalTimeWeight += TMath::Sqrt(hcalEnergy);
    419 
     405    if(ecalEnergy > fTimingEnergyMin && fTower)
     406    {
     407      if (abs(particle->PID) != 11 || !fElectronsFromTrack)
     408      {
     409        fTower->ECalEnergyTimePairs.push_back(make_pair<Float_t, Float_t>(ecalEnergy, particle->Position.T()));
     410      }
     411    }
    420412
    421413    fTower->AddCandidate(particle);
     
    434426  Double_t ecalEnergy, hcalEnergy;
    435427  Double_t ecalSigma, hcalSigma;
    436   Double_t ecalTime, hcalTime, time;
     428  Float_t weight, sumWeightedTime, sumWeight;
    437429
    438430  if(!fTower) return;
     
    444436  hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma);
    445437
    446   ecalTime = (fTowerECalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerECalTime/fTowerECalTimeWeight;
    447   hcalTime = (fTowerHCalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerHCalTime/fTowerHCalTimeWeight;
    448 
    449438  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
    450439  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
     
    454443
    455444  energy = ecalEnergy + hcalEnergy;
    456   time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy));
    457 
    458   if(fDitherTowerCenter)
     445
     446  if(fSmearTowerCenter)
    459447  {
    460448    eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
     
    469457  pt = energy / TMath::CosH(eta);
    470458
    471   fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time);
     459  // Time calculation for tower
     460  fTower->NTimeHits = 0;
     461  sumWeightedTime = 0.0;
     462  sumWeight = 0.0;
     463
     464  for(size_t i = 0; i < fTower->ECalEnergyTimePairs.size(); ++i)
     465  {
     466    weight = TMath::Sqrt(fTower->ECalEnergyTimePairs[i].first);
     467    sumWeightedTime += weight * fTower->ECalEnergyTimePairs[i].second;
     468    sumWeight += weight;
     469    fTower->NTimeHits++;
     470  }
     471
     472  if(sumWeight > 0.0)
     473  {
     474    fTower->Position.SetPtEtaPhiE(1.0, eta, phi, sumWeightedTime/sumWeight);
     475  }
     476  else
     477  {
     478    fTower->Position.SetPtEtaPhiE(1.0, eta, phi, 999999.9);
     479  }
     480
     481
    472482  fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
    473483  fTower->Eem = ecalEnergy;
Note: See TracChangeset for help on using the changeset viewer.