CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- 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
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 &)
 

Private Member Functions

virtual 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 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, 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
TreeWriterForEcalCorrection::~TreeWriterForEcalCorrection ( )
inline

Definition at line 27 of file TreeWriterForEcalCorrection.cc.

27 {};

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 49 of file TreeWriterForEcalCorrection.cc.

References reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), Exception, relval_steps::gen(), edm::Event::getByLabel(), tree, tree_e, tree_eta, and tree_response.

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( "famosSimHits", "EcalHitsEB", SimHitsEB );
78  if( isFastSim ) {
79  iEvent.getByLabel( "famosSimHits", "EcalHitsEE", SimHitsEE );
80  iEvent.getByLabel( "famosSimHits", "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 }
virtual double eta() const
momentum pseudorapidity
virtual double energy() const
energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
void TreeWriterForEcalCorrection::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 107 of file TreeWriterForEcalCorrection.cc.

References edm::ConfigurationDescriptions::add().

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