CMS 3D CMS Logo

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 edm::EDConsumerBase

Public Member Functions

 EcalSimHitsValidation (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~EcalSimHitsValidation ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Types

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

Private Attributes

DQMStoredbe_
 
edm::EDGetTokenT< edm::PCaloHitContainerEBHitsCollectionToken
 
edm::EDGetTokenT< edm::PCaloHitContainerEEHitsCollectionToken
 
edm::EDGetTokenT< edm::PCaloHitContainerESHitsCollectionToken
 
std::string g4InfoLabel
 
edm::EDGetTokenT< edm::HepMCProductHepMCToken
 
MonitorElementmeEBEnergyFraction_
 
MonitorElementmeEEEnergyFraction_
 
MonitorElementmeESEnergyFraction_
 
MonitorElementmeGunEnergy_
 
MonitorElementmeGunEta_
 
MonitorElementmeGunPhi_
 
std::string outputFile_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 20 of file EcalSimHitsValidation.cc.

References dbe_, EBHitsCollectionToken, EEHitsCollectionToken, ESHitsCollectionToken, g4InfoLabel, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), trackerHits::histo, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, Utilities::operator, outputFile_, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

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

Destructor.

Definition at line 88 of file EcalSimHitsValidation.cc.

References dbe_, and outputFile_.

88  {
89 
90  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
91 
92 }

Member Function Documentation

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

Analyze.

Definition at line 102 of file EcalSimHitsValidation.cc.

References funct::abs(), EBHitsCollectionToken, EEHitsCollectionToken, ESHitsCollectionToken, edm::EventID::event(), MonitorElement::Fill(), edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), HepMCToken, edm::EventBase::id(), edm::HandleBase::isValid(), cmsBatch::log, LogDebug, M_PI, meEBEnergyFraction_, meEEEnergyFraction_, meESEnergyFraction_, meGunEnergy_, meGunEta_, meGunPhi_, AlCaHLTBitMon_ParallelJobs::p, edm::EventID::run(), and funct::tan().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 94 of file EcalSimHitsValidation.cc.

94  {
95 
96 }
void EcalSimHitsValidation::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 98 of file EcalSimHitsValidation.cc.

98  {
99 
100 }

Member Data Documentation

DQMStore* EcalSimHitsValidation::dbe_
private

Definition at line 75 of file EcalSimHitsValidation.h.

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

edm::EDGetTokenT<edm::PCaloHitContainer> EcalSimHitsValidation::EBHitsCollectionToken
private

Definition at line 69 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

edm::EDGetTokenT<edm::PCaloHitContainer> EcalSimHitsValidation::EEHitsCollectionToken
private

Definition at line 70 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

edm::EDGetTokenT<edm::PCaloHitContainer> EcalSimHitsValidation::ESHitsCollectionToken
private

Definition at line 71 of file EcalSimHitsValidation.h.

Referenced by analyze(), and EcalSimHitsValidation().

std::string EcalSimHitsValidation::g4InfoLabel
private

Definition at line 67 of file EcalSimHitsValidation.h.

Referenced by EcalSimHitsValidation().

edm::EDGetTokenT<edm::HepMCProduct> EcalSimHitsValidation::HepMCToken
private

Definition at line 68 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().