CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TreeWriterForEcalCorrection Class Reference
Inheritance diagram for TreeWriterForEcalCorrection:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 TreeWriterForEcalCorrection (const edm::ParameterSet &)
 
 ~TreeWriterForEcalCorrection () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::Service< TFileServicefile
 
TTree * tree
 
float tree_e
 
float tree_eta
 
float tree_response
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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)
 

Detailed Description

Definition at line 23 of file TreeWriterForEcalCorrection.cc.

Constructor & Destructor Documentation

TreeWriterForEcalCorrection::TreeWriterForEcalCorrection ( const edm::ParameterSet iConfig)
explicit

Definition at line 38 of file TreeWriterForEcalCorrection.cc.

References file, TFileService::make(), tree_e, tree_eta, and tree_response.

38  {
39  tree = file->make<TTree>("responseTree", "same info as 3dhisto");
40  tree->Branch("e", &tree_e, "e/F");
41  tree->Branch("eta", &tree_eta, "eta/F");
42  tree->Branch("r", &tree_response, "r/F");
43 }
edm::Service< TFileService > file
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
Definition: tree.py:1
TreeWriterForEcalCorrection::~TreeWriterForEcalCorrection ( )
inlineoverride

Definition at line 26 of file TreeWriterForEcalCorrection.cc.

References analyze(), and fillDescriptions().

26 {};

Member Function Documentation

void TreeWriterForEcalCorrection::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 45 of file TreeWriterForEcalCorrection.cc.

References reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), Exception, heavyFlavorValidation_cfi::GenParticles, edm::Event::getByLabel(), tree_e, tree_eta, and tree_response.

Referenced by ~TreeWriterForEcalCorrection().

45  {
46  // get generated particles
48  iEvent.getByLabel("genParticles", "", GenParticles);
49 
50  // As this module is intended for single particle guns, there should be
51  // exactly one generated particle.
52  if (GenParticles->size() != 1) {
53  throw cms::Exception("MismatchedInputFiles") << "Intended for particle guns only\n";
54  }
55 
56  // I assume here that the tracker simulation is disabled and no vertex
57  // smearing is done, so that the generated particles is exactly the same
58  // particle as the particle hitting the entrace of the ECAL.
59  reco::GenParticle gen = GenParticles->at(0);
60  float genE = gen.energy();
61  float genEta = gen.eta();
62  // genEta is positive for my photongun sample per definition.
63  // If not, you could take the absolute value here.
64 
65  // get sim hits
69 
70  // Finds out automatically, if this is fullsim or fastsim
71  bool isFastSim = iEvent.getByLabel("fastSimProducer", "EcalHitsEB", SimHitsEB);
72  if (isFastSim) {
73  iEvent.getByLabel("fastSimProducer", "EcalHitsEE", SimHitsEE);
74  iEvent.getByLabel("fastSimProducer", "EcalHitsES", SimHitsES);
75  } else {
76  iEvent.getByLabel("g4SimHits", "EcalHitsEB", SimHitsEB);
77  iEvent.getByLabel("g4SimHits", "EcalHitsEE", SimHitsEE);
78  iEvent.getByLabel("g4SimHits", "EcalHitsES", SimHitsES);
79  }
80 
81  // merge them into one single vector
82  auto SimHits = *SimHitsEB;
83  SimHits.insert(SimHits.end(), SimHitsEE->begin(), SimHitsEE->end());
84  SimHits.insert(SimHits.end(), SimHitsES->begin(), SimHitsES->end());
85 
86  // As we only had one generated particle (and hopefully no pileup),
87  // the total energy is due to the generated particle only
88  float energyTotal = 0;
89  for (auto const& Hit : SimHits) {
90  energyTotal += Hit.energy();
91  }
92 
93  tree_e = genE;
94  tree_eta = genEta;
95  tree_response = energyTotal / genE;
96  tree->Fill();
97 }
double eta() const final
momentum pseudorapidity
double energy() const final
energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
Definition: tree.py:1
void TreeWriterForEcalCorrection::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 99 of file TreeWriterForEcalCorrection.cc.

References edm::ConfigurationDescriptions::add(), and DEFINE_FWK_MODULE.

Referenced by ~TreeWriterForEcalCorrection().

99  {
101  descriptions.add("ecalScaleFactorCalculator", desc);
102 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

edm::Service<TFileService> TreeWriterForEcalCorrection::file
private

Definition at line 33 of file TreeWriterForEcalCorrection.cc.

Referenced by TreeWriterForEcalCorrection().

TTree* TreeWriterForEcalCorrection::tree
private
float TreeWriterForEcalCorrection::tree_e
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

float TreeWriterForEcalCorrection::tree_eta
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

float TreeWriterForEcalCorrection::tree_response
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().