Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:07

0001 #ifndef RecoLocalMuon_DTRecHitHistograms_H
0002 #define RecoLocalMuon_DTRecHitHistograms_H
0003 
0004 /** \class DTRecHitHistograms
0005  *  Collection of histograms for 1D DT RecHit test.
0006  *
0007  *  \author G. Cerminara - INFN Torino
0008  */
0009 
0010 #include "TH1F.h"
0011 #include "TH2F.h"
0012 #include "TFile.h"
0013 #include "TString.h"
0014 #include <string>
0015 
0016 class H1DRecHit {
0017 public:
0018   /// Constructor from collection name
0019   H1DRecHit(std::string name_) {
0020     TString N = name_.c_str();
0021     name = N;
0022 
0023     hRecDist = new TH1F(N + "_hRecDist", "1D DTRecHit distance from wire (cm)", 100, 0, 2.5);
0024     hSimDist = new TH1F(N + "_hSimDist", "Mu SimHit distance from wire (cm)", 100, 0, 2.5);
0025     hResDist = new TH1F(N + "_hResDist", "1D DTRecHit residual on the distance from wire (cm)", 100, -0.5, 0.5);
0026     hResDistVsDist = new TH2F(N + "_hResDistVsDist",
0027                               "1D DTRecHit residual on the distance from wire vs distance (cm)",
0028                               100,
0029                               0,
0030                               2.5,
0031                               100,
0032                               -0.5,
0033                               0.5);
0034   }
0035 
0036   /// Constructor from collection name and TFile.
0037   /// It retrieves all the histos of the set from the file.
0038   H1DRecHit(TString name_, TFile *file) {
0039     name = name_;
0040     hRecDist = (TH1F *)file->Get(name + "_hRecDist");
0041     hSimDist = (TH1F *)file->Get(name + "_hSimDist");
0042     hResDist = (TH1F *)file->Get(name + "_hResDist");
0043     hResDistVsDist = (TH2F *)file->Get(name + "_hResDistVsDist");
0044   }
0045 
0046   /// Destructor
0047   virtual ~H1DRecHit() {
0048     delete hRecDist;
0049     delete hSimDist;
0050     delete hResDist;
0051     delete hResDistVsDist;
0052   }
0053 
0054   // Operations
0055   /// Fill all the histos
0056   void Fill(float recDist, float simDist) {
0057     hRecDist->Fill(recDist);
0058     hSimDist->Fill(simDist);
0059     hResDist->Fill(recDist - simDist);
0060     hResDistVsDist->Fill(simDist, recDist - simDist);
0061   }
0062 
0063   /// Write all the histos to currently opened file
0064   void Write() {
0065     hRecDist->Write();
0066     hSimDist->Write();
0067     hResDist->Write();
0068     hResDistVsDist->Write();
0069   }
0070 
0071   TH1F *hRecDist;
0072   TH1F *hSimDist;
0073   TH1F *hResDist;
0074   TH2F *hResDistVsDist;
0075   TString name;
0076 };
0077 #endif