ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/STAOfflineAnalyzer.cc
(Generate patch)

Comparing UserCode/DTDPGAnalysis/src/STAOfflineAnalyzer.cc (file contents):
Revision 1.1 by giorgia, Fri Oct 10 11:00:31 2008 UTC vs.
Revision 1.2 by battilan, Sun Nov 2 20:43:11 2008 UTC

# Line 23 | Line 23
23   #include "FWCore/ParameterSet/interface/ParameterSet.h"
24   #include "FWCore/Framework/interface/ESHandle.h"
25   #include "FWCore/Utilities/interface/Exception.h"
26 + #include "DQMServices/Core/interface/DQMStore.h"
27 + #include "DQMServices/Core/interface/MonitorElement.h"
28 + #include "FWCore/ServiceRegistry/interface/Service.h"
29  
30   using namespace edm;
31  
# Line 94 | Line 97 | STAOfflineAnalyzer::STAOfflineAnalyzer(c
97  
98    doSA = pset.getParameter<bool>("doSA");
99  
100 +  theDQMStore = edm::Service<DQMStore>().operator->();
101 +
102    init=false;
103    // Create the root file
104 <  theFile = new TFile(theRootFileName.c_str(), "RECREATE");
104 >  // theFile = new TFile(theRootFileName.c_str(), "RECREATE");
105  
106    // CosmicMuon
107    createTH1F("hNSA","Num SA tracks in events","", 6, -0.5, 5.5);
# Line 156 | Line 161 | STAOfflineAnalyzer::STAOfflineAnalyzer(c
161  
162   /* Destructor */
163   STAOfflineAnalyzer::~STAOfflineAnalyzer() {
164 <  theFile->cd();
165 <  theFile->Write();
166 <  theFile->Close();
164 >  theDQMStore->rmdir("DT/STAOfflineAnalyzer");
165 >  // theFile->cd();
166 >  // theFile->Write();
167 >  // theFile->Close();
168   }
169  
170   /* Operations */
# Line 597 | Line 603 | void STAOfflineAnalyzer::pippo(const DTR
603   }
604  
605   TH1F* STAOfflineAnalyzer::histo(const string& name) const{
606 <  if (TH1F* h =  dynamic_cast<TH1F*>(theFile->Get(name.c_str())) ) return h;
607 <  else throw cms::Exception("STAOfflineAnalyzer") << " Not a TH1F " << name;
606 >  MonitorElement* me = theDQMStore->get(("DT/STAOfflineAnalyzer/"+name).c_str());
607 >  if (!me) throw cms::Exception("STAOfflineAnalyzer") << " ME not existing " << name;
608 >  TH1F* histo = me->getTH1F();
609 >  if (!histo)cms::Exception("STAOfflineAnalyzer") << " Not a TH1F " << name;
610 >  return histo;
611   }
612  
613   TH2F* STAOfflineAnalyzer::histo2d(const string& name) const{
614 <  if (TH2F* h =  dynamic_cast<TH2F*>(theFile->Get(name.c_str())) ) return h;
615 <  else throw  cms::Exception("STAOfflineAnalyzer") << " Not a TH2F " << name;
614 >  MonitorElement* me = theDQMStore->get(("DT/STAOfflineAnalyzer/"+name).c_str());
615 >  if (!me) throw cms::Exception("STAOfflineAnalyzer") << " ME not existing " << name;
616 >  TH2F* histo = me->getTH2F();
617 >  if (!histo)cms::Exception("STAOfflineAnalyzer") << " Not a TH2F " << name;
618 >  return histo;
619   }
620  
621   bool STAOfflineAnalyzer::getLCT(LCTType t) const {
# Line 654 | Line 666 | void STAOfflineAnalyzer::createTH1F(cons
666    stringstream hTitle;
667    hName << name << suffix;
668    hTitle << title << suffix;
669 <  TH1F * _h = new TH1F(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
670 <  _h->SetDirectory(theFile); // Needed when the input is a root file
669 >  theDQMStore->setCurrentFolder("DT/STAOfflineAnalyzer");
670 >  theDQMStore->book1D(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
671 > //   TH1F * _h = new TH1F(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
672 > //   _h->SetDirectory(theFile); // Needed when the input is a root file
673   }
674  
675   void STAOfflineAnalyzer::createTH2F(const std::string& name,
# Line 671 | Line 685 | void STAOfflineAnalyzer::createTH2F(cons
685    stringstream hTitle;
686    hName << name << suffix;
687    hTitle << title << suffix;
688 <  TH2F * _h = new TH2F(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
689 <  _h->SetDirectory(theFile); // Needed when the input is a root file
688 >  theDQMStore->setCurrentFolder("DT/STAOfflineAnalyzer");
689 >  theDQMStore->book2D(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
690 > //   TH2F * _h = new TH2F(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
691 > //   _h->SetDirectory(theFile); // Needed when the input is a root file
692  
693   }
694  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines