CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
EcalSimHitsValidation Class Reference

#include <EcalSimHitsValidation.h>

Inheritance diagram for EcalSimHitsValidation:
edm::EDAnalyzer

Public Member Functions

 EcalSimHitsValidation (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~EcalSimHitsValidation ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginJob ()
 
void endJob (void)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

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(), interpolateCardsSimple::histo, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, cppFunctionSkipper::operator, outputFile_, and verbose_.

19  :
20  HepMCLabel(ps.getParameter<std::string>("moduleLabelMC")),
21  g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
22  EBHitsCollection(ps.getParameter<std::string>("EBHitsCollection")),
23  EEHitsCollection(ps.getParameter<std::string>("EEHitsCollection")),
24  ESHitsCollection(ps.getParameter<std::string>("ESHitsCollection")){
25 
26  // DQM ROOT output
27  outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
28 
29  if ( outputFile_.size() != 0 ) {
30  edm::LogInfo("OutputInfo") << " Ecal SimHits Task histograms will be saved to " << outputFile_.c_str();
31  } else {
32  edm::LogInfo("OutputInfo") << " Ecal SimHits Task histograms will NOT be saved";
33  }
34 
35  // verbosity switch
36  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
37 
38  // DQMServices
39  dbe_ = 0;
40 
41  // get hold of back-end interface
42  dbe_ = edm::Service<DQMStore>().operator->();
43  if ( dbe_ ) {
44  if ( verbose_ ) { dbe_->setVerbose(1); }
45  else { dbe_->setVerbose(0); }
46  }
47 
48  if ( dbe_ ) {
49  if ( verbose_ ) dbe_->showDirStructure();
50  }
51 
52  meGunEnergy_ = 0;
53  meGunEta_ = 0;
54  meGunPhi_ = 0;
58 
59  Char_t histo[200];
60 
61 
62  if ( dbe_ ) {
63  dbe_->setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
64 
65  sprintf (histo, "EcalSimHitsValidation Gun Momentum" ) ;
66  meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
67 
68  sprintf (histo, "EcalSimHitsValidation Gun Eta" ) ;
69  meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
70 
71  sprintf (histo, "EcalSimHitsValidation Gun Phi" ) ;
72  meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
73 
74  sprintf (histo, "EcalSimHitsValidation Barrel fraction of energy" ) ;
75  meEBEnergyFraction_ = dbe_->book1D(histo, histo, 100 , 0. , 1.1);
76 
77  sprintf (histo, "EcalSimHitsValidation Endcap fraction of energy" ) ;
78  meEEEnergyFraction_ = dbe_->book1D(histo, histo, 100 , 0. , 1.1);
79 
80  sprintf (histo, "EcalSimHitsValidation Preshower fraction of energy" ) ;
81  meESEnergyFraction_ = dbe_->book1D(histo, histo, 60 , 0. , 0.001);
82  }
83 
84 }
MonitorElement * meEBEnergyFraction_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * meGunEnergy_
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
MonitorElement * meEEEnergyFraction_
void showDirStructure(void) const
Definition: DQMStore.cc:2761
MonitorElement * meESEnergyFraction_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
EcalSimHitsValidation::~EcalSimHitsValidation ( )

Destructor.

Definition at line 86 of file EcalSimHitsValidation.cc.

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

86  {
87 
88  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
89 
90 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113

Member Function Documentation

void EcalSimHitsValidation::analyze ( const edm::Event e,
const edm::EventSetup c 
)
protectedvirtual

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(), create_public_lumi_plots::log, LogDebug, M_PI, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, AlCaHLTBitMon_ParallelJobs::p, edm::EventID::run(), and funct::tan().

100  {
101 
102  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
103 
104  std::vector<PCaloHit> theEBCaloHits;
105  std::vector<PCaloHit> theEECaloHits;
106  std::vector<PCaloHit> theESCaloHits;
107 
112 
113  e.getByLabel(HepMCLabel, MCEvt);
117 
118  for ( HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
119  p != MCEvt->GetEvent()->particles_end(); ++p ) {
120 
121  double htheta = (*p)->momentum().theta();
122  double heta = -99999.;
123  if( tan(htheta * 0.5) > 0 ) {
124  heta = -log(tan(htheta * 0.5));
125  }
126  double hphi = (*p)->momentum().phi();
127  hphi = (hphi>=0) ? hphi : hphi+2*M_PI;
128  hphi = hphi / M_PI * 180.;
129 
130  LogDebug("EventInfo") << "Particle gun type form MC = " << abs((*p)->pdg_id()) << "\n" << "Energy = "<< (*p)->momentum().e() << " Eta = " << heta << " Phi = " << hphi;
131 
132  if (meGunEnergy_) meGunEnergy_->Fill((*p)->momentum().e());
133  if (meGunEta_) meGunEta_ ->Fill(heta);
134  if (meGunPhi_) meGunPhi_ ->Fill(hphi);
135 
136  }
137 
138  double EBEnergy_ = 0.;
139  if ( EcalHitsEB.isValid() ) {
140  theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
141  for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin();
142  isim != theEBCaloHits.end(); ++isim){
143  EBEnergy_ += isim->energy();
144  }
145  }
146 
147  double EEEnergy_ = 0.;
148  if ( EcalHitsEE.isValid() ) {
149  theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
150  for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin();
151  isim != theEECaloHits.end(); ++isim){
152  EEEnergy_ += isim->energy();
153  }
154  }
155 
156  double ESEnergy_ = 0.;
157  if ( EcalHitsES.isValid() ) {
158  theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
159  for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin();
160  isim != theESCaloHits.end(); ++isim){
161  ESEnergy_ += isim->energy();
162  }
163  }
164 
165  double etot = EBEnergy_ + EEEnergy_ + ESEnergy_ ;
166  double fracEB = 0.0;
167  double fracEE = 0.0;
168  double fracES = 0.0;
169 
170  if (etot>0.0) {
171  fracEB = EBEnergy_/etot;
172  fracEE = EEEnergy_/etot;
173  fracES = ESEnergy_/etot;
174  }
175 
177 
179 
181 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
MonitorElement * meEBEnergyFraction_
EventNumber_t event() const
Definition: EventID.h:44
#define abs(x)
Definition: mlp_lapack.h:159
void Fill(long long x)
MonitorElement * meGunEnergy_
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define M_PI
Definition: BFit3D.cc:3
MonitorElement * meEEEnergyFraction_
edm::EventID id() const
Definition: EventBase.h:56
MonitorElement * meESEnergyFraction_
void EcalSimHitsValidation::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file EcalSimHitsValidation.cc.

92  {
93 
94 }
void EcalSimHitsValidation::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 96 of file EcalSimHitsValidation.cc.

96  {
97 
98 }

Member Data Documentation

DQMStore* EcalSimHitsValidation::dbe_
private

Definition at line 75 of file EcalSimHitsValidation.h.

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

std::string EcalSimHitsValidation::EBHitsCollection
private

Definition at line 69 of file EcalSimHitsValidation.h.

Referenced by analyze().

std::string EcalSimHitsValidation::EEHitsCollection
private

Definition at line 70 of file EcalSimHitsValidation.h.

Referenced by analyze().

std::string EcalSimHitsValidation::ESHitsCollection
private

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().

MonitorElement* EcalSimHitsValidation::meEBEnergyFraction_
private

Definition at line 83 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meEEEnergyFraction_
private

Definition at line 84 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meESEnergyFraction_
private

Definition at line 85 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meGunEnergy_
private

Definition at line 79 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meGunEta_
private

Definition at line 80 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

MonitorElement* EcalSimHitsValidation::meGunPhi_
private

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().

bool EcalSimHitsValidation::verbose_
private

Definition at line 73 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().