Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/Calorimeter.cc

    r3db5282 re33e6db  
    150150*/
    151151
    152   // read min E value for timing measurement in ECAL
    153   fTimingEMin = GetDouble("TimingEMin",4.);
    154   // For timing
    155   // So far this flag needs to be false
    156   // Curved extrapolation not supported
    157   fElectronsFromTrack = false;
    158 
    159  
    160152  // read min E value for towers to be saved
    161153  fECalEnergyMin = GetDouble("ECalEnergyMin", 0.0);
     
    364356      fTrackHCalEnergy = 0.0;
    365357
     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
    366367      fTowerTrackHits = 0;
    367368      fTowerPhotonHits = 0;
     
    379380      position = track->Position;
    380381
     382
    381383      ecalEnergy = momentum.E() * fTrackECalFractions[number];
    382384      hcalEnergy = momentum.E() * fTrackHCalFractions[number];
     
    385387      fTrackHCalEnergy += hcalEnergy;
    386388
    387       bool dbg_scz = false;
    388       if (dbg_scz) {
    389         cout << "   Calorimeter input track has x y z t " << track->Position.X() << " " << track->Position.Y() << " " << track->Position.Z() << " " << track->Position.T()
    390              << endl;
    391         Candidate *prt = static_cast<Candidate*>(track->GetCandidates()->Last());
    392         const TLorentzVector &ini = prt->Position;
    393 
    394         cout << "                and parent has x y z t " << ini.X() << " " << ini.Y() << " " << ini.Z() << " " << ini.T();
    395 
    396       }
    397      
    398       if (ecalEnergy > fTimingEMin && fTower) {
    399         if (fElectronsFromTrack) {
    400           //      cout << " SCZ Debug pushing back track hit E=" << ecalEnergy << " T=" << track->Position.T() << " isPU=" << track->IsPU << " isRecoPU=" << track->IsRecoPU
    401           //           << " PID=" << track->PID << endl;
    402           fTower->Ecal_E_t.push_back(std::make_pair<float,float>(ecalEnergy,track->Position.T()));
    403         } else {
    404           //      cout << " Skipping track hit E=" << ecalEnergy << " T=" << track->Position.T() << " isPU=" << track->IsPU << " isRecoPU=" << track->IsRecoPU
    405           //           << " PID=" << track->PID << endl;
    406         }
    407       }
    408 
     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);
    409394
    410395      fTowerTrackArray->Add(track);
     
    412397      continue;
    413398    }
    414  
     399
    415400    // check for photon and electron hits in current tower
    416401    if(flags & 2) ++fTowerPhotonHits;
     
    427412    fTowerHCalEnergy += hcalEnergy;
    428413
    429     if (ecalEnergy > fTimingEMin && fTower) {
    430       if (abs(particle->PID) != 11 || !fElectronsFromTrack) {
    431         //      cout << " SCZ Debug About to push back particle hit E=" << ecalEnergy << " T=" << particle->Position.T() << " isPU=" << particle->IsPU
    432         //   << " PID=" << particle->PID << endl;
    433         fTower->Ecal_E_t.push_back(std::make_pair<Float_t,Float_t>(ecalEnergy,particle->Position.T()));
    434       } else {
    435        
    436         // N.B. Only charged particle set to leave ecal energy is the electrons
    437         //      cout << " SCZ Debug To avoid double-counting, skipping particle hit E=" << ecalEnergy << " T=" << particle->Position.T() << " isPU=" << particle->IsPU
    438         //           << " PID=" << particle->PID << endl;
    439        
    440       }
    441     }
     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
    442420
    443421    fTower->AddCandidate(particle);
     
    456434  Double_t ecalEnergy, hcalEnergy;
    457435  Double_t ecalSigma, hcalSigma;
    458  
     436  Double_t ecalTime, hcalTime, time;
     437
    459438  if(!fTower) return;
    460439
     
    465444  hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma);
    466445
     446  ecalTime = (fTowerECalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerECalTime/fTowerECalTimeWeight;
     447  hcalTime = (fTowerHCalTimeWeight < 1.0E-09 ) ? 0.0 : fTowerHCalTime/fTowerHCalTimeWeight;
     448
    467449  ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
    468450  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
     
    472454
    473455  energy = ecalEnergy + hcalEnergy;
    474    
     456  time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy));
     457
    475458  if(fSmearTowerCenter)
    476459  {
     
    486469  pt = energy / TMath::CosH(eta);
    487470
    488   // Time calculation for tower
    489   fTower->Ntimes = 0;
    490   Float_t tow_sumT = 0;
    491   Float_t tow_sumW = 0;
    492  
    493   for (Int_t i = 0 ; i < fTower->Ecal_E_t.size() ; i++)
    494   {
    495     Float_t w = TMath::Sqrt(fTower->Ecal_E_t[i].first);
    496     tow_sumT += w*fTower->Ecal_E_t[i].second;
    497     tow_sumW += w;
    498     fTower->Ntimes++;
    499   }
    500  
    501   if (tow_sumW > 0.) {
    502     fTower->Position.SetPtEtaPhiE(1.0, eta, phi,tow_sumT/tow_sumW);
    503   } else {
    504     fTower->Position.SetPtEtaPhiE(1.0,eta,phi,999999.);
    505   }
    506 
    507 
     471  fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time);
    508472  fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
    509473  fTower->Eem = ecalEnergy;
     
    517481  if(energy > 0.0)
    518482  {
    519     if(fTowerPhotonHits > 0 && fTowerTrackHits == 0)
    520     {
    521       fPhotonOutputArray->Add(fTower);
    522     }
    523 
    524     fTowerOutputArray->Add(fTower);
    525   }
    526 
    527   // fill energy flow candidates
    528 
    529   // save all the tracks as energy flow tracks
    530   fItTowerTrackArray->Reset();
    531   while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
    532   {
    533     fEFlowTrackOutputArray->Add(track);
    534   }
    535 
    536   ecalEnergy -= fTrackECalEnergy;
    537   hcalEnergy -= fTrackHCalEnergy;
    538 
    539   ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
    540   hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
    541 
    542   if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
    543   if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
    544 
    545   energy = ecalEnergy + hcalEnergy;
    546 
    547   if(ecalEnergy > 0.0)
    548   {
    549     // create new photon tower
    550     tower = static_cast<Candidate*>(fTower->Clone());
    551 
    552     pt = ecalEnergy / TMath::CosH(eta);
    553 
    554     tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy);
    555     tower->Eem = ecalEnergy;
    556     tower->Ehad = 0.0;
    557 
    558     fEFlowPhotonOutputArray->Add(tower);
    559   }
    560   if(hcalEnergy > 0.0)
    561   {
    562     // create new neutral hadron tower
    563     tower = static_cast<Candidate*>(fTower->Clone());
    564 
    565     pt = hcalEnergy / TMath::CosH(eta);
    566 
    567     tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);
    568     tower->Eem = 0.0;
    569     tower->Ehad = hcalEnergy;
    570 
    571     fEFlowNeutralHadronOutputArray->Add(tower);
     483     bool isCalPhoton = false;
     484
     485     if(fTowerTrackHits == 0)
     486     {
     487        // We have a CalPhoton when there are NOT tracks and there ARE photon hits
     488        isCalPhoton = (fTowerPhotonHits > 0);
     489     }
     490     else
     491     {
     492         // save all the tracks as energy flow tracks
     493         fItTowerTrackArray->Reset();
     494         while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
     495         {
     496            fEFlowTrackOutputArray->Add(track);
     497         }
     498
     499         ecalEnergy -= fTrackECalEnergy;
     500         hcalEnergy -= fTrackHCalEnergy;
     501
     502         ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
     503         hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
     504
     505         if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
     506         if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
     507
     508         energy = ecalEnergy + hcalEnergy;
     509     }
     510
     511     // If it's NOT a CalPhoton; add the tower as a whole entity.
     512     // Otherwise, the tower will be split into its ECAL and HCAL components,
     513     // then added to fPhotonArray and fTowerArray (respectively).
     514     // By construction (no track hits), no track subtraction will occur
     515     // for CalPhotons
     516     if(!isCalPhoton)
     517        fTowerOutputArray->Add(fTower);
     518
     519     // fill energy flow candidates
     520
     521     if(ecalEnergy > 0.0)
     522     {
     523         // create new photon tower
     524         tower = static_cast<Candidate*>(fTower->Clone());
     525
     526         pt = ecalEnergy / TMath::CosH(eta);
     527
     528         tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy);
     529         tower->Eem = ecalEnergy;
     530         tower->Ehad = 0.0;
     531
     532         fEFlowPhotonOutputArray->Add(tower);
     533         if(isCalPhoton)
     534                      fPhotonOutputArray->Add(tower);
     535     }
     536
     537     if(hcalEnergy > 0.0)
     538     {
     539        // create new neutral hadron tower
     540        tower = static_cast<Candidate*>(fTower->Clone());
     541
     542        pt = hcalEnergy / TMath::CosH(eta);
     543
     544        tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);
     545        tower->Eem = 0.0;
     546        tower->Ehad = hcalEnergy;
     547
     548        fEFlowNeutralHadronOutputArray->Add(tower);
     549        if(isCalPhoton)
     550           fTowerOutputArray->Add(tower);
     551     }
    572552  }
    573553}
Note: See TracChangeset for help on using the changeset viewer.