CMS 3D CMS Logo

PhysicsHistograms.cc

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 // -*- C++ -*-
00003 //
00008 //
00009 // Original Author:  Petar Maksimovic
00010 //         Created:  Christmas 2007
00011 // $Id: PhysicsHistograms.cc,v 1.5 2008/07/07 20:06:56 srappocc Exp $
00012 //
00013 // Revision History:
00014 //------------------------------------------------------------------------
00015 
00016 
00017 #include "PhysicsTools/StarterKit/interface/PhysicsHistograms.h"
00018 
00019 #include <string>
00020 #include <sstream>
00021 
00022 //------------------------------------------------------------------------
00024 //------------------------------------------------------------------------
00025 PhysicsHistograms::PhysicsHistograms( KinAxisLimits const & muonAxis, 
00026                                       KinAxisLimits const & electronAxis, 
00027                                       KinAxisLimits const & tauAxis, 
00028                                       KinAxisLimits const & jetAxis, 
00029                                       KinAxisLimits const & METAxis, 
00030                                       KinAxisLimits const & photonAxis, 
00031                                       KinAxisLimits const & trackAxis
00032                                       )
00033 {
00034   //--- Initialize histogram objects
00035   std::cout << "PhysicsHistograms: Creating muon histograms" << std::endl;
00036   muonHistograms_     = 
00037     new pat::HistoMuon    ( "muon", "Muon", "mu", muonAxis.pt1, muonAxis.pt2, muonAxis.m1, muonAxis.m2 );
00038   std::cout << "PhysicsHistograms: Creating electron histograms" << std::endl;
00039   electronHistograms_ = 
00040     new pat::HistoElectron( "electron", "Electron", "e", electronAxis.pt1, electronAxis.pt2, electronAxis.m1, electronAxis.m2 );
00041   std::cout << "PhysicsHistograms: Creating tau histograms" << std::endl;
00042   tauHistograms_      = 
00043     new pat::HistoTau     ( "tau", "Tau", "tau", tauAxis.pt1, tauAxis.pt2, tauAxis.m1, tauAxis.m2 );
00044   std::cout << "PhysicsHistograms: Creating jet histograms" << std::endl;
00045   jetHistograms_      =
00046     new pat::HistoJet     ( "jet", "Jet", "jet", jetAxis.pt1, jetAxis.pt2, jetAxis.m1, jetAxis.m2 );
00047   std::cout << "PhysicsHistograms: Creating met histograms" << std::endl;
00048   metHistograms_      = 
00049     new pat::HistoMET     ( "met", "MET", "met", METAxis.pt1, METAxis.pt2, METAxis.m1, METAxis.m2 );
00050   std::cout << "PhysicsHistograms: Creating photon histograms" << std::endl;
00051   photonHistograms_   = 
00052     new pat::HistoPhoton  ( "photon", "Photon", "photon", photonAxis.pt1, photonAxis.pt2, photonAxis.m1, photonAxis.m2 );
00053   std::cout << "PhysicsHistograms: Creating track histograms" << std::endl;
00054   trackHistograms_    = 
00055     new pat::HistoTrack   ( "track", "Track", "track", trackAxis.pt1, trackAxis.pt2, trackAxis.m1, trackAxis.m2 );
00056 }
00057 
00058 
00059 //------------------------------------------------------------------------
00065 //------------------------------------------------------------------------
00066 PhysicsHistograms::~PhysicsHistograms()
00067 {
00068   delete muonHistograms_     ;
00069   delete electronHistograms_ ;
00070   delete tauHistograms_      ;
00071   delete jetHistograms_      ;
00072   delete metHistograms_      ;
00073   delete photonHistograms_   ;
00074   delete trackHistograms_    ;
00075 
00076   for ( unsigned int i = 0; i < allVarHistos_.size(); ++i ) {
00077     if ( allVarHistos_[i] ) delete allVarHistos_[i];
00078   }
00079 
00080   outputFile_.close();
00081 }
00082 
00083 
00084 
00085 //------------------------------------------------------------------------
00088 //------------------------------------------------------------------------
00089 void
00090 PhysicsHistograms::configure( std::string & histos_to_disable,   // comma separated list of names
00091                               std::string & histos_to_enable )   // comma separated list of names
00092 {
00093   std::cout << "PhysicsHistograms:: configuring..."
00094             << "\n   First disabling: " << histos_to_disable
00095             << "\n   Then  enabling : " << histos_to_enable
00096             << std::endl;
00097 
00098 
00099   //--- Pass this information to histogramGroups
00100   muonHistograms_    ->configure( histos_to_disable, histos_to_enable ) ;
00101   electronHistograms_->configure( histos_to_disable, histos_to_enable ) ;
00102   tauHistograms_     ->configure( histos_to_disable, histos_to_enable ) ;
00103   metHistograms_     ->configure( histos_to_disable, histos_to_enable ) ;
00104   jetHistograms_     ->configure( histos_to_disable, histos_to_enable ) ;
00105   photonHistograms_  ->configure( histos_to_disable, histos_to_enable ) ;
00106   trackHistograms_   ->configure( histos_to_disable, histos_to_enable ) ;
00107 
00108 }
00109 
00110 
00111 //------------------------------------------------------------------------
00113 //------------------------------------------------------------------------
00114 void
00115 PhysicsHistograms::select( std::string  vars_to_select,   // comma separated list of names
00116                            std::vector< pat::PhysVarHisto * > & selectedVars )
00117 {
00118   std::cout << "PhysicsHistograms:: selecting the following variables:\n\t"
00119             << vars_to_select
00120             << std::endl;
00121 
00122 
00123   //--- Pass this information to histogramGroups
00124   muonHistograms_    ->select( vars_to_select, selectedVars ) ;
00125   electronHistograms_->select( vars_to_select, selectedVars ) ;
00126   tauHistograms_     ->select( vars_to_select, selectedVars ) ;
00127   metHistograms_     ->select( vars_to_select, selectedVars ) ;
00128   jetHistograms_     ->select( vars_to_select, selectedVars ) ;
00129   photonHistograms_  ->select( vars_to_select, selectedVars ) ;
00130   trackHistograms_   ->select( vars_to_select, selectedVars ) ;
00131   
00132   std::vector<pat::PhysVarHisto*>::iterator i = allVarHistos_.begin();
00133   std::vector<pat::PhysVarHisto*>::iterator end = allVarHistos_.end();
00134   std::string temp = "," + vars_to_select + ",";
00135   for ( ; i != end; ++i  ) {
00136     std::string test = "," + (*i)->name() + ",";
00137     std::cout << "testing " << test << std::endl;
00138     if ( temp.find( test ) != std::string::npos || temp == ",all," ) {
00139       std::cout << "FOUND!" << std::endl;
00140       selectedVars.push_back ( *i );
00141     }
00142   }
00143 
00144   std::cout << "PhysicsHistograms:: selected " << selectedVars.size()
00145             << " variables." << std::endl;
00146 }
00147 
00148 void PhysicsHistograms::clearVec()
00149 {
00150   muonHistograms_    ->clearVec() ;
00151   electronHistograms_->clearVec() ;
00152   tauHistograms_     ->clearVec() ;
00153   metHistograms_     ->clearVec() ;
00154   jetHistograms_     ->clearVec() ;
00155   photonHistograms_  ->clearVec() ;
00156   trackHistograms_   ->clearVec() ;
00157   for ( uint i = 0; i < allVarHistos_.size(); i++ ) {
00158     allVarHistos_[i]->clearVec();
00159   }
00160 }
00161 
00162 //------------------------------------------------------------------------
00165 //------------------------------------------------------------------------
00166 void
00167 PhysicsHistograms::beginJob()
00168 {
00169   // Dummy for now
00170 }
00171 
00172 
00173 //------------------------------------------------------------------------
00176 //------------------------------------------------------------------------
00177 void
00178 PhysicsHistograms::endJob()
00179 {
00180   // Dummy for now
00181 }
00182 
00183 
00184 
00185 //------------------------------------------------------------------------
00187 // &&& Design suggestion: this should go into HistoGroup<> instead.
00188 //------------------------------------------------------------------------
00189 std::ostream & operator<<( std::ostream & out, const reco::Candidate & cand )
00190 {
00191   char buff[1000];
00192   sprintf( buff, "Pt, Eta, Phi, M = (%6.2f, %6.2f, %6.2f, %6.2f)",
00193            cand.pt(), cand.eta(), cand.phi(), cand.mass() );
00194   out << buff;
00195   return out;
00196 }
00197 
00198 
00199 
00200 //--- Code graveyard:
00201 //
00202 //   // Muons
00203 //   typedef std::vector<Muon>::const_iterator muonIter ;
00204 //   outputFile_ << "Muons: " << muons.size() << endl;
00205 //   int imuon = 0;
00206 //   for (muonIter muon = muons.begin(); muon != muons.end();++muon, ++imuon) {
00207 //     outputFile_ << setw(6) << imuon << " : " << *muon << endl;
00208 //     histoMuon_->fill( *muon, imuon+1 );
00209 //   }
00210 
00211 

Generated on Tue Jun 9 17:41:56 2009 for CMSSW by  doxygen 1.5.4