CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Types | Private Attributes

EcalSimHitsValidation Class Reference

#include <EcalSimHitsValidation.h>

Inheritance diagram for EcalSimHitsValidation:
edm::EDAnalyzer

List of all members.

Public Member Functions

 EcalSimHitsValidation (const edm::ParameterSet &ps)
 Constructor.
 ~EcalSimHitsValidation ()
 Destructor.

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze.
void beginJob ()
void endJob (void)

Private Types

typedef std::map< uint32_t,
float, std::less< uint32_t > > 
MapType

Private Attributes

DQMStoredbe_
std::string EBHitsCollection
std::string EEHitsCollection
std::string ESHitsCollection
std::string g4InfoLabel
std::string HepMCLabel
MonitorElementmeEBEnergyFraction_
MonitorElementmeEEEnergyFraction_
MonitorElementmeESEnergyFraction_
MonitorElementmeGunEnergy_
MonitorElementmeGunEta_
MonitorElementmeGunPhi_
std::string outputFile_
bool verbose_

Detailed Description

Definition at line 42 of file EcalSimHitsValidation.h.


Member Typedef Documentation

typedef std::map<uint32_t,float,std::less<uint32_t> > EcalSimHitsValidation::MapType [private]

Definition at line 44 of file EcalSimHitsValidation.h.


Constructor & Destructor Documentation

EcalSimHitsValidation::EcalSimHitsValidation ( const edm::ParameterSet ps)

Constructor.

Definition at line 19 of file EcalSimHitsValidation.cc.

References dbe_, edm::ParameterSet::getUntrackedParameter(), trackerHits::histo, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, cmsCodeRules::cppFunctionSkipper::operator, outputFile_, and verbose_.

                                                                     :
  HepMCLabel(ps.getParameter<std::string>("moduleLabelMC")),
  g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
  EBHitsCollection(ps.getParameter<std::string>("EBHitsCollection")),
  EEHitsCollection(ps.getParameter<std::string>("EEHitsCollection")),
  ESHitsCollection(ps.getParameter<std::string>("ESHitsCollection")){

  // DQM ROOT output
  outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
 
  if ( outputFile_.size() != 0 ) {
    edm::LogInfo("OutputInfo") << " Ecal SimHits Task histograms will be saved to " << outputFile_.c_str();
  } else {
    edm::LogInfo("OutputInfo") << " Ecal SimHits Task histograms will NOT be saved";
  }
 
  // verbosity switch
  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
 
  // DQMServices                                                        
  dbe_ = 0;

  // get hold of back-end interface
  dbe_ = edm::Service<DQMStore>().operator->();           
  if ( dbe_ ) {
    if ( verbose_ ) { dbe_->setVerbose(1); } 
    else            { dbe_->setVerbose(0); }
  }
                                                                                                            
  if ( dbe_ ) {
    if ( verbose_ ) dbe_->showDirStructure();
  }
 
  meGunEnergy_ = 0;
  meGunEta_    = 0;   
  meGunPhi_    = 0;   
  meEBEnergyFraction_  = 0;
  meEEEnergyFraction_  = 0;
  meESEnergyFraction_  = 0;

  Char_t histo[200];
 
  
  if ( dbe_ ) {
    dbe_->setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
  
    sprintf (histo, "EcalSimHitsValidation Gun Momentum" ) ;
    meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
  
    sprintf (histo, "EcalSimHitsValidation Gun Eta" ) ;
    meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
  
    sprintf (histo, "EcalSimHitsValidation Gun Phi" ) ;
    meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);

    sprintf (histo, "EcalSimHitsValidation Barrel fraction of energy" ) ;
    meEBEnergyFraction_ = dbe_->book1D(histo, histo, 100 , 0. , 1.1);
  
    sprintf (histo, "EcalSimHitsValidation Endcap fraction of energy" ) ;
    meEEEnergyFraction_ = dbe_->book1D(histo, histo, 100 , 0. , 1.1);
  
    sprintf (histo, "EcalSimHitsValidation Preshower fraction of energy" ) ;
    meESEnergyFraction_ = dbe_->book1D(histo, histo, 60 , 0. , 0.001);
  }
 
}
EcalSimHitsValidation::~EcalSimHitsValidation ( )

Destructor.

Definition at line 86 of file EcalSimHitsValidation.cc.

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

                                             {
 
  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);

}

Member Function Documentation

void EcalSimHitsValidation::analyze ( const edm::Event e,
const edm::EventSetup c 
) [protected, virtual]

Analyze.

Implements edm::EDAnalyzer.

Definition at line 100 of file EcalSimHitsValidation.cc.

References abs, EBHitsCollection, EEHitsCollection, ESHitsCollection, edm::EventID::event(), MonitorElement::Fill(), g4InfoLabel, edm::Event::getByLabel(), HepMCLabel, edm::EventBase::id(), edm::HandleBase::isValid(), funct::log(), LogDebug, M_PI, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, L1TEmulatorMonitor_cff::p, edm::EventID::run(), and funct::tan().

                                                                            {

  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
  
  std::vector<PCaloHit>  theEBCaloHits;
  std::vector<PCaloHit>  theEECaloHits;
  std::vector<PCaloHit>  theESCaloHits;

  edm::Handle<edm::HepMCProduct> MCEvt;
  edm::Handle<edm::PCaloHitContainer> EcalHitsEB;
  edm::Handle<edm::PCaloHitContainer> EcalHitsEE;
  edm::Handle<edm::PCaloHitContainer> EcalHitsES;

  e.getByLabel(HepMCLabel, MCEvt);
  e.getByLabel(g4InfoLabel,EBHitsCollection,EcalHitsEB);
  e.getByLabel(g4InfoLabel,EEHitsCollection,EcalHitsEE);
  e.getByLabel(g4InfoLabel,ESHitsCollection,EcalHitsES);

  for ( HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
        p != MCEvt->GetEvent()->particles_end(); ++p ) {

    double htheta = (*p)->momentum().theta();
    double heta = -99999.;
    if( tan(htheta * 0.5) > 0 ) {
      heta = -log(tan(htheta * 0.5));
    }
    double hphi = (*p)->momentum().phi();
    hphi = (hphi>=0) ? hphi : hphi+2*M_PI;
    hphi = hphi / M_PI * 180.;

    LogDebug("EventInfo") << "Particle gun type form MC = " << abs((*p)->pdg_id()) << "\n" << "Energy = "<< (*p)->momentum().e() << " Eta = " << heta << " Phi = " << hphi;

    if (meGunEnergy_) meGunEnergy_->Fill((*p)->momentum().e());
    if (meGunEta_)    meGunEta_   ->Fill(heta);
    if (meGunPhi_)    meGunPhi_   ->Fill(hphi);

  }
  
  double EBEnergy_ = 0.;
  if ( EcalHitsEB.isValid() ) {
    theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
    for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin();
         isim != theEBCaloHits.end(); ++isim){
      EBEnergy_ += isim->energy();
    }
  }

  double EEEnergy_ = 0.;
  if ( EcalHitsEE.isValid() ) {
    theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
    for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin();
         isim != theEECaloHits.end(); ++isim){
      EEEnergy_ += isim->energy();
    }
  }
  
  double ESEnergy_ = 0.;
  if ( EcalHitsES.isValid() ) {
    theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
    for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin();
         isim != theESCaloHits.end(); ++isim){
      ESEnergy_ += isim->energy();
    }
  }
  
  double etot = EBEnergy_ + EEEnergy_ + ESEnergy_ ;
  double fracEB = 0.0;
  double fracEE = 0.0;
  double fracES = 0.0;
  
  if (etot>0.0) { 
    fracEB  = EBEnergy_/etot; 
    fracEE  = EEEnergy_/etot; 
    fracES  = ESEnergy_/etot; 
  }
  
  if (meEBEnergyFraction_) meEBEnergyFraction_->Fill(fracEB);
  
  if (meEEEnergyFraction_) meEEEnergyFraction_->Fill(fracEE);
  
  if (meESEnergyFraction_) meESEnergyFraction_->Fill(fracES);
}
void EcalSimHitsValidation::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file EcalSimHitsValidation.cc.

                                    {

}
void EcalSimHitsValidation::endJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 96 of file EcalSimHitsValidation.cc.

                                  {

}

Member Data Documentation

Definition at line 75 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation(), and ~EcalSimHitsValidation().

Definition at line 69 of file EcalSimHitsValidation.h.

Referenced by analyze().

Definition at line 70 of file EcalSimHitsValidation.h.

Referenced by analyze().

Definition at line 71 of file EcalSimHitsValidation.h.

Referenced by analyze().

std::string EcalSimHitsValidation::g4InfoLabel [private]

Definition at line 68 of file EcalSimHitsValidation.h.

Referenced by analyze().

std::string EcalSimHitsValidation::HepMCLabel [private]

Definition at line 67 of file EcalSimHitsValidation.h.

Referenced by analyze().

Definition at line 83 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

Definition at line 84 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

Definition at line 85 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

Definition at line 79 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

Definition at line 80 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

Definition at line 81 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

std::string EcalSimHitsValidation::outputFile_ [private]

Definition at line 77 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation(), and ~EcalSimHitsValidation().

Definition at line 73 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().