CMS 3D CMS Logo

Public Member Functions | Protected Attributes

HCovarianceVSParts Class Reference

#include <Histograms.h>

Inheritance diagram for HCovarianceVSParts:
Histograms

List of all members.

Public Member Functions

virtual void Clear ()
virtual void Fill (const reco::Particle::LorentzVector &recoP1, const reco::Particle::LorentzVector &genP1, const reco::Particle::LorentzVector &recoP2, const reco::Particle::LorentzVector &genP2)
virtual double Get (const reco::Particle::LorentzVector &recoP1, const TString &covarianceName)
 HCovarianceVSParts (TFile *outputFile, const TString &name, const double &ptMax)
 HCovarianceVSParts (const TString &inputFileName, const TString &name)
 Constructor reading the histograms from file.
virtual void Write ()
 ~HCovarianceVSParts ()

Protected Attributes

std::map< TString,
HCovarianceVSxy * > 
mapHisto_
bool readMode_

Detailed Description

This class uses the HCovariance histograms to compute the covariances between the two input muons kinematic quantities. The covariances are computed against pt and eta.

Definition at line 1702 of file Histograms.h.


Constructor & Destructor Documentation

HCovarianceVSParts::HCovarianceVSParts ( TFile *  outputFile,
const TString &  name,
const double &  ptMax 
) [inline]

Definition at line 1705 of file Histograms.h.

References jptDQMConfig_cff::etaMax, jptDQMConfig_cff::etaMin, Histograms::histoDir_, mapHisto_, PtMinSelector_cfg::ptMin, and readMode_.

                                                                                      : Histograms( outputFile, name ) {
    int totBinsX = 40;
    int totBinsY = 40;
    double etaMin = -3.;
    double etaMax = 3.;
    double ptMin = 0.;

    readMode_ = false;

    // Variances
    mapHisto_[name+"Pt"]                    = new HCovarianceVSxy(name+"Pt_", "Pt", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
    mapHisto_[name+"CotgTheta"]             = new HCovarianceVSxy(name+"CotgTheta_", "CotgTheta", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
    mapHisto_[name+"Phi"]                   = new HCovarianceVSxy(name+"Phi_", "Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_, true);
    // Covariances
    mapHisto_[name+"Pt-CotgTheta"]          = new HCovarianceVSxy(name+"Pt_CotgTheta_", "Pt-CotgTheta", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"Pt-Phi"]                = new HCovarianceVSxy(name+"Pt_Phi_", "Pt-Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"CotgTheta-Phi"]         = new HCovarianceVSxy(name+"CotgTheta_Phi_", "CotgTheta-Phi", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"Pt1-Pt2"]               = new HCovarianceVSxy(name+"Pt1_Pt2_", "Pt1-Pt2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"CotgTheta1-CotgTheta2"] = new HCovarianceVSxy(name+"CotgTheta1_CotgTheta2_", "CotgTheta1-CotgTheta2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"Phi1-Phi2"]             = new HCovarianceVSxy(name+"Phi1_Phi2_", "Phi1-Phi2", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"Pt12-CotgTheta21"]      = new HCovarianceVSxy(name+"Pt12_CotgTheta21_", "Pt12-CotgTheta21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"Pt12-Phi21"]            = new HCovarianceVSxy(name+"Pt12_Phi21_", "Pt12-Phi21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
    mapHisto_[name+"CotgTheta12-Phi21"]     = new HCovarianceVSxy(name+"CotgTheta12_Phi21_", "CotgTheta12-Phi21", totBinsX, ptMin, ptMax, totBinsY, etaMin, etaMax, histoDir_);
  }
HCovarianceVSParts::HCovarianceVSParts ( const TString &  inputFileName,
const TString &  name 
) [inline]

Constructor reading the histograms from file.

Definition at line 1731 of file Histograms.h.

References analyzePatCleaning_cfg::inputFile, mapHisto_, mergeVDriftHistosByStation::name, Histograms::name_, and readMode_.

  {
    name_ = name;
    TFile * inputFile = new TFile(inputFileName, "READ");
    readMode_ = true;

    // Variances
    mapHisto_[name_+"Pt"]                    = new HCovarianceVSxy(inputFile, name_+"Pt_"+name_, name_);
    mapHisto_[name_+"CotgTheta"]             = new HCovarianceVSxy(inputFile, name_+"CotgTheta_"+name_, name_);
    mapHisto_[name_+"Phi"]                   = new HCovarianceVSxy(inputFile, name_+"Phi_"+name_, name_);
    // Covariances
    mapHisto_[name_+"Pt-CotgTheta"]          = new HCovarianceVSxy(inputFile, name_+"Pt_CotgTheta_"+name_, name_);
    mapHisto_[name_+"Pt-Phi"]                = new HCovarianceVSxy(inputFile, name_+"Pt_Phi_"+name_, name_);
    mapHisto_[name_+"CotgTheta-Phi"]         = new HCovarianceVSxy(inputFile, name_+"CotgTheta_Phi_"+name_, name_);
    mapHisto_[name_+"Pt1-Pt2"]               = new HCovarianceVSxy(inputFile, name_+"Pt1_Pt2_"+name_, name_);
    mapHisto_[name_+"CotgTheta1-CotgTheta2"] = new HCovarianceVSxy(inputFile, name_+"CotgTheta1_CotgTheta2_"+name_, name_);
    mapHisto_[name_+"Phi1-Phi2"]             = new HCovarianceVSxy(inputFile, name_+"Phi1_Phi2_"+name_, name_);
    mapHisto_[name_+"Pt12-CotgTheta21"]      = new HCovarianceVSxy(inputFile, name_+"Pt12_CotgTheta21_"+name_, name_);
    mapHisto_[name_+"Pt12-Phi21"]            = new HCovarianceVSxy(inputFile, name_+"Pt12_Phi21_"+name_, name_);
    mapHisto_[name_+"CotgTheta12-Phi21"]     = new HCovarianceVSxy(inputFile, name_+"CotgTheta12_Phi21_"+name_, name_);
  }
HCovarianceVSParts::~HCovarianceVSParts ( ) [inline]

Definition at line 1753 of file Histograms.h.

References timingPdfMaker::histo, and mapHisto_.

                        {
    for (std::map<TString, HCovarianceVSxy*>::const_iterator histo=mapHisto_.begin(); 
         histo!=mapHisto_.end(); histo++) {
      delete (*histo).second;
    }
  }

Member Function Documentation

virtual void HCovarianceVSParts::Clear ( ) [inline, virtual]

Implements Histograms.

Definition at line 1842 of file Histograms.h.

References timingPdfMaker::histo, and mapHisto_.

                       {
    for (std::map<TString, HCovarianceVSxy*>::const_iterator histo=mapHisto_.begin(); 
         histo!=mapHisto_.end(); histo++) {
      (*histo).second->Clear();
    }
  }
virtual void HCovarianceVSParts::Fill ( const reco::Particle::LorentzVector recoP1,
const reco::Particle::LorentzVector genP1,
const reco::Particle::LorentzVector recoP2,
const reco::Particle::LorentzVector genP2 
) [inline, virtual]

Reimplemented from Histograms.

Definition at line 1764 of file Histograms.h.

References MuScleFitUtils::deltaPhiNoFabs(), mapHisto_, and Histograms::name_.

                                                               {

    double pt1 = recoP1.pt();
    double eta1 = recoP1.eta();
    double pt2 = recoP2.pt();
    double eta2 = recoP2.eta();

    double diffPt1 = (pt1 - genP1.pt())/genP1.pt();
    double diffPt2 = (pt2 - genP2.pt())/genP2.pt();

    double genTheta1 = genP1.theta();
    double genTheta2 = genP2.theta();
    double recoTheta1 = recoP1.theta();
    double recoTheta2 = recoP2.theta();

    double genCotgTheta1 = TMath::Cos(genTheta1)/(TMath::Sin(genTheta1));
    double genCotgTheta2 = TMath::Cos(genTheta2)/(TMath::Sin(genTheta2));
    double recoCotgTheta1 = TMath::Cos(recoTheta1)/(TMath::Sin(recoTheta1));
    double recoCotgTheta2 = TMath::Cos(recoTheta2)/(TMath::Sin(recoTheta2));

    // double diffCotgTheta1 = (recoCotgTheta1 - genCotgTheta1)/genCotgTheta1;
    // double diffCotgTheta2 = (recoCotgTheta2 - genCotgTheta2)/genCotgTheta2;
    double diffCotgTheta1 = recoCotgTheta1 - genCotgTheta1;
    double diffCotgTheta2 = recoCotgTheta2 - genCotgTheta2;

    // double diffPhi1 = (recoP1.phi() - genP1.phi())/genP1.phi();
    // double diffPhi2 = (recoP2.phi() - genP2.phi())/genP2.phi();
    double diffPhi1 = MuScleFitUtils::deltaPhiNoFabs(recoP1.phi(), genP1.phi());
    double diffPhi2 = MuScleFitUtils::deltaPhiNoFabs(recoP2.phi(), genP2.phi());

    // Fill the variances
    mapHisto_[name_+"Pt"]->Fill(pt1, eta1, diffPt1, diffPt1);
    mapHisto_[name_+"Pt"]->Fill(pt2, eta2, diffPt2, diffPt2);
    mapHisto_[name_+"CotgTheta"]->Fill(pt1, eta1, diffCotgTheta1, diffCotgTheta1);
    mapHisto_[name_+"CotgTheta"]->Fill(pt2, eta2, diffCotgTheta2, diffCotgTheta2);
    mapHisto_[name_+"Phi"]->Fill(pt1, eta1, diffPhi1, diffPhi1);
    mapHisto_[name_+"Phi"]->Fill(pt2, eta2, diffPhi2, diffPhi2);

    // Fill these histograms with both muons
    mapHisto_[name_+"Pt-CotgTheta"]->Fill(pt1, eta1, diffPt1, diffCotgTheta1 );
    mapHisto_[name_+"Pt-CotgTheta"]->Fill(pt2, eta2, diffPt2, diffCotgTheta2 );
    mapHisto_[name_+"Pt-Phi"]->Fill(pt1, eta1, diffPt1, diffPhi1);
    mapHisto_[name_+"Pt-Phi"]->Fill(pt2, eta2, diffPt2, diffPhi2);
    mapHisto_[name_+"CotgTheta-Phi"]->Fill(pt1, eta1, diffCotgTheta1, diffPhi1);
    mapHisto_[name_+"CotgTheta-Phi"]->Fill(pt2, eta2, diffCotgTheta2, diffPhi2);

    // We fill two (pt, eta) bins for each pair of values. The bin of the
    // first and of the second muon. This should take account for the
    // assumed symmetry between the exchange of the first with the second muon.
    mapHisto_[name_+"Pt1-Pt2"]->Fill(pt1, eta1, diffPt1, diffPt2);
    mapHisto_[name_+"Pt1-Pt2"]->Fill(pt2, eta2, diffPt1, diffPt2);
    mapHisto_[name_+"CotgTheta1-CotgTheta2"]->Fill(pt1, eta1, diffCotgTheta1, diffCotgTheta2);
    mapHisto_[name_+"CotgTheta1-CotgTheta2"]->Fill(pt2, eta2, diffCotgTheta1, diffCotgTheta2);
    mapHisto_[name_+"Phi1-Phi2"]->Fill(pt1, eta1, diffPhi1, diffPhi2);
    mapHisto_[name_+"Phi1-Phi2"]->Fill(pt2, eta2, diffPhi1, diffPhi2);

    // Fill the following histograms again for each muon (pt, eta) bin. Same
    // reason as in the previous case. If the symmetry is true, it does not
    // make any difference the order by which we fill the pt and cotgTheta combinations.
    mapHisto_[name_+"Pt12-CotgTheta21"]->Fill(pt1, eta1, diffPt1, diffCotgTheta2);
    mapHisto_[name_+"Pt12-CotgTheta21"]->Fill(pt2, eta2, diffPt2, diffCotgTheta1);
    mapHisto_[name_+"Pt12-Phi21"]->Fill(pt1, eta1, diffPt1, diffPhi2);
    mapHisto_[name_+"Pt12-Phi21"]->Fill(pt2, eta2, diffPt2, diffPhi1);
    mapHisto_[name_+"CotgTheta12-Phi21"]->Fill(pt1, eta1, diffCotgTheta1, diffPhi2);
    mapHisto_[name_+"CotgTheta12-Phi21"]->Fill(pt2, eta2, diffCotgTheta2, diffPhi1);
  }
virtual double HCovarianceVSParts::Get ( const reco::Particle::LorentzVector recoP1,
const TString &  covarianceName 
) [inline, virtual]

Reimplemented from Histograms.

Definition at line 1760 of file Histograms.h.

References mapHisto_, and Histograms::name_.

                                                                                                 {
    return mapHisto_[name_+covarianceName]->Get(recoP1.pt(), recoP1.eta());
  }
virtual void HCovarianceVSParts::Write ( ) [inline, virtual]

Implements Histograms.

Definition at line 1833 of file Histograms.h.

References timingPdfMaker::histo, Histograms::histoDir_, mapHisto_, and readMode_.

                       {
    if( !readMode_ ) {
      histoDir_->cd();
      for (std::map<TString, HCovarianceVSxy*>::const_iterator histo=mapHisto_.begin(); 
           histo!=mapHisto_.end(); histo++) {
        (*histo).second->Write();
      }
    }
  }

Member Data Documentation

std::map<TString, HCovarianceVSxy*> HCovarianceVSParts::mapHisto_ [protected]

Definition at line 1849 of file Histograms.h.

Referenced by Clear(), Fill(), Get(), HCovarianceVSParts(), Write(), and ~HCovarianceVSParts().

Definition at line 1850 of file Histograms.h.

Referenced by HCovarianceVSParts(), and Write().