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 24 of file TreeWriterForEcalCorrection.cc.

Constructor & Destructor Documentation

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

Definition at line 40 of file TreeWriterForEcalCorrection.cc.

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

41 {
42  tree = file->make<TTree>("responseTree", "same info as 3dhisto");
43  tree->Branch( "e", &tree_e, "e/F");
44  tree->Branch( "eta", &tree_eta, "eta/F");
45  tree->Branch( "r", &tree_response, "r/F");
46 }
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 27 of file TreeWriterForEcalCorrection.cc.

References analyze(), and fillDescriptions().

27 {};

Member Function Documentation

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

Definition at line 49 of file TreeWriterForEcalCorrection.cc.

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

Referenced by ~TreeWriterForEcalCorrection().

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

Definition at line 107 of file TreeWriterForEcalCorrection.cc.

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

Referenced by ~TreeWriterForEcalCorrection().

107  {
109  descriptions.add( "ecalScaleFactorCalculator", desc );
110 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

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

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by TreeWriterForEcalCorrection().

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

Definition at line 37 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

float TreeWriterForEcalCorrection::tree_eta
private

Definition at line 37 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

float TreeWriterForEcalCorrection::tree_response
private

Definition at line 37 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().