Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:38

0001 #include <TFile.h>
0002 #include <TTree.h>
0003 #include <TPad.h>
0004 #include <TH1F.h>
0005 #include <iostream>
0006 
0007 bool isValidFile(const TString& fileName) {
0008   TFile* file = TFile::Open(fileName, "read");
0009   if (!file || file->IsZombie()) {
0010     std::cout << "Error: Invalid file or file is a zombie.\n";
0011     return false;
0012   }
0013   return true;
0014 }
0015 
0016 void printParameters(const TString& fileName) {
0017   if (!isValidFile(fileName)) {
0018     exit(EXIT_FAILURE);
0019   }
0020 
0021   TFile* file = TFile::Open(fileName, "read");
0022   TTree* tree = static_cast<TTree*>(file->Get("zMuMuMassConstraintParameterFinder/di_muon_from_Z"));
0023   tree->Draw("di_muon_mass>>htemp", "in_mass_window");
0024   TH1F* htemp = static_cast<TH1F*>(gPad->GetPrimitive("htemp"));
0025 
0026   std::cout << "\n========================================\n";
0027   std::cout << "'Z -> mu mu' mass constraint parameters:\n";
0028   std::cout << "----------------------------------------\n";
0029   std::cout << "  PrimaryMass  = " << htemp->GetMean() << "\n";
0030   std::cout << "  PrimaryWidth = " << htemp->GetRMS() << "\n";
0031   std::cout << "========================================\n";
0032 
0033   exit(EXIT_SUCCESS);
0034 }