CMS 3D CMS Logo

Public Member Functions | Private Attributes

CaloTowersClient Class Reference

#include <CaloTowersClient.h>

Inheritance diagram for CaloTowersClient:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (void)
virtual void beginRun (const edm::Run &run, const edm::EventSetup &c)
 CaloTowersClient (const edm::ParameterSet &)
int CaloTowersEndjob (const std::vector< MonitorElement * > &hcalMEs)
virtual void endJob ()
virtual void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
virtual void endRun (const edm::Run &run, const edm::EventSetup &c)
virtual void runClient_ ()
virtual ~CaloTowersClient ()

Private Attributes

edm::ParameterSet conf_
DQMStoredbe_
bool debug_
std::string dirName_
std::string dirNameJet_
std::string dirNameMET_
std::string outputFile_
bool verbose_

Detailed Description

Definition at line 36 of file CaloTowersClient.h.


Constructor & Destructor Documentation

CaloTowersClient::CaloTowersClient ( const edm::ParameterSet iConfig) [explicit]

Definition at line 12 of file CaloTowersClient.cc.

References dbe_, debug_, dirName_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), cmsCodeRules::cppFunctionSkipper::operator, outputFile_, and verbose_.

                                                                :conf_(iConfig)
{

  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");

  dbe_ = edm::Service<DQMStore>().operator->();
  if (!dbe_) {
    edm::LogError("CaloTowersClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
  }
  if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
    if(dbe_) dbe_->setVerbose(0);
  }
 
  debug_ = false;
  verbose_ = false;

  dirName_=iConfig.getParameter<std::string>("DQMDirName");
  if(dbe_) dbe_->setCurrentFolder(dirName_);
 
}
CaloTowersClient::~CaloTowersClient ( ) [virtual]

Definition at line 34 of file CaloTowersClient.cc.

{ 
  
}

Member Function Documentation

void CaloTowersClient::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 62 of file CaloTowersClient.cc.

{
  
}
void CaloTowersClient::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file CaloTowersClient.cc.

{
 

}
void CaloTowersClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file CaloTowersClient.cc.

{
 
}
int CaloTowersClient::CaloTowersEndjob ( const std::vector< MonitorElement * > &  hcalMEs)

Definition at line 108 of file CaloTowersClient.cc.

References cont, gather_cfg::cout, MonitorElement::getEntries(), edm::getName(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), i, j, nevent, and verbose_.

Referenced by runClient_().

                                                                               {

   int useAllHistos = 0;
   MonitorElement* Ntowers_vs_ieta =0;
   MonitorElement* mapEnergy_N =0, *mapEnergy_E =0, *mapEnergy_H =0, *mapEnergy_EH =0;
   MonitorElement* occupancy_map =0, *occupancy_vs_ieta =0;
   for(unsigned int ih=0; ih<hcalMEs.size(); ih++){
      if( strcmp(hcalMEs[ih]->getName().c_str(), "Ntowers_per_event_vs_ieta") ==0  ){
         Ntowers_vs_ieta = hcalMEs[ih];
      } 
      if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_Nentries") ==0  ){
         mapEnergy_N = hcalMEs[ih];
      }
      if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_H") ==0  ){
         useAllHistos++; mapEnergy_H = hcalMEs[ih];
      }
      if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_E") ==0  ){
         useAllHistos++; mapEnergy_E = hcalMEs[ih];
      }
      if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_EH") ==0  ){
         useAllHistos++; mapEnergy_EH = hcalMEs[ih];
      }
      if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_occupancy") ==0  ){
         occupancy_map = hcalMEs[ih];
      }
      if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_occupancy_vs_ieta") ==0  ){
         occupancy_vs_ieta = hcalMEs[ih];
      }
  
   } 
   if( useAllHistos !=0 && useAllHistos !=3 ) return 0;

   double nevent = mapEnergy_N->getEntries();
   if(verbose_) std::cout<<"nevent : "<<nevent<<std::endl;

   // mean number of towers per ieta
   int nx = Ntowers_vs_ieta->getNbinsX();
   float cont;
   float fev = float(nevent);

   for (int i = 1; i <= nx; i++) {
      cont = Ntowers_vs_ieta -> getBinContent(i) / fev ;
      Ntowers_vs_ieta -> setBinContent(i,cont);
   }

   // mean energies & occupancies evaluation

   nx = mapEnergy_N->getNbinsX();
   int ny = mapEnergy_N->getNbinsY();
   float cnorm;
   float phi_factor;

   for (int i = 1; i <= nx; i++) {
      float sumphi = 0.;

      for (int j = 1; j <= ny; j++) {

         // Emean
         cnorm   = mapEnergy_N -> getBinContent(i,j);
         //Phi histos are not used in the macros
         if(cnorm > 0.000001 && useAllHistos) {

            cont = mapEnergy_E -> getBinContent(i,j) / cnorm ;
            mapEnergy_E -> setBinContent(i,j,cont);

            cont = mapEnergy_H -> getBinContent(i,j) / cnorm ;
            mapEnergy_H -> setBinContent(i,j,cont);

            cont = mapEnergy_EH -> getBinContent(i,j) / cnorm ;
            mapEnergy_EH -> setBinContent(i,j,cont);
         }

         // Occupancy (needed for occupancy vs ieta)
         cnorm   = occupancy_map -> getBinContent(i,j) / fev;
         if(cnorm > 1.e-30) occupancy_map -> setBinContent(i,j,cnorm);

         sumphi += cnorm;

      } // end of iphy cycle (j)

      //Occupancy vs ieta histo is drawn
      // phi-factor evaluation for occupancy_vs_ieta calculation
      int ieta = i - 42;        // -41 -1, 0 40 
      if(ieta >=0 ) ieta +=1;   // -41 -1, 1 41  - to make it detector-like

      if(ieta >= -20 && ieta <= 20 )
         {phi_factor = 72.;}
         else {
            if(ieta >= 40 || ieta <= -40 ) {phi_factor = 18.;}
         else
            phi_factor = 36.;
       }
       if(ieta >= 0) ieta -= 1; // -41 -1, 0 40  - to bring back to histo num

       cnorm = sumphi / phi_factor;
       occupancy_vs_ieta->Fill(double(ieta), cnorm);

   } // end of ieta cycle (i)
   
   return 1;

}
void CaloTowersClient::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 45 of file CaloTowersClient.cc.

References dbe_, outputFile_, and DQMStore::save().

{
   if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
}
void CaloTowersClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file CaloTowersClient.cc.

{ 
//  runClient_();
}
void CaloTowersClient::endRun ( const edm::Run run,
const edm::EventSetup c 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file CaloTowersClient.cc.

References runClient_().

{
  runClient_();
}
void CaloTowersClient::runClient_ ( ) [virtual]

Definition at line 72 of file CaloTowersClient.cc.

References CaloTowersEndjob(), gather_cfg::cout, dbe_, dirName_, DQMStore::getContents(), DQMStore::getSubdirs(), i, j, DQMStore::setCurrentFolder(), and verbose_.

Referenced by endRun().

{
  if(!dbe_) return; //we dont have the DQMStore so we cant do anything
  dbe_->setCurrentFolder(dirName_);

  if (verbose_) std::cout << "\nrunClient" << std::endl; 

  std::vector<MonitorElement*> hcalMEs;

  // Since out folders are fixed to three, we can just go over these three folders
  // i.e., CaloTowersV/CaloTowersTask, HcalRecHitsV/HcalRecHitTask, NoiseRatesV/NoiseRatesTask.
  std::vector<std::string> fullPathHLTFolders = dbe_->getSubdirs();
  for(unsigned int i=0;i<fullPathHLTFolders.size();i++) {

    if (verbose_) std::cout <<"\nfullPath: "<< fullPathHLTFolders[i] << std::endl;
    dbe_->setCurrentFolder(fullPathHLTFolders[i]);

    std::vector<std::string> fullSubPathHLTFolders = dbe_->getSubdirs();
    for(unsigned int j=0;j<fullSubPathHLTFolders.size();j++) {

      if (verbose_) std::cout <<"fullSub: "<<fullSubPathHLTFolders[j] << std::endl;

      if( strcmp(fullSubPathHLTFolders[j].c_str(), "CaloTowersV/CaloTowersTask") ==0  ){
         hcalMEs = dbe_->getContents(fullSubPathHLTFolders[j]);
         if (verbose_) std::cout <<"hltMES size : "<<hcalMEs.size()<<std::endl;
         if( !CaloTowersEndjob(hcalMEs) ) std::cout<<"\nError in CaloTowersEndjob!"<<std::endl<<std::endl;
      }

    }    

  }

}

Member Data Documentation

Definition at line 42 of file CaloTowersClient.h.

Definition at line 39 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), endJob(), and runClient_().

bool CaloTowersClient::debug_ [private]

Definition at line 45 of file CaloTowersClient.h.

Referenced by CaloTowersClient().

std::string CaloTowersClient::dirName_ [private]

Definition at line 47 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), and runClient_().

std::string CaloTowersClient::dirNameJet_ [private]

Definition at line 48 of file CaloTowersClient.h.

std::string CaloTowersClient::dirNameMET_ [private]

Definition at line 49 of file CaloTowersClient.h.

std::string CaloTowersClient::outputFile_ [private]

Definition at line 40 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), and endJob().

Definition at line 44 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), CaloTowersEndjob(), and runClient_().