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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 23 of file TreeWriterForEcalCorrection.cc.

Constructor & Destructor Documentation

◆ TreeWriterForEcalCorrection()

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

Definition at line 38 of file TreeWriterForEcalCorrection.cc.

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 }

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

◆ ~TreeWriterForEcalCorrection()

TreeWriterForEcalCorrection::~TreeWriterForEcalCorrection ( )
inlineoverride

Definition at line 26 of file TreeWriterForEcalCorrection.cc.

26 {};

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 45 of file TreeWriterForEcalCorrection.cc.

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.
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 }

References Exception, heavyFlavorValidation_cfi::GenParticles, iEvent, tree_e, tree_eta, and tree_response.

◆ fillDescriptions()

void TreeWriterForEcalCorrection::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 99 of file TreeWriterForEcalCorrection.cc.

99  {
101  descriptions.add("ecalScaleFactorCalculator", desc);
102 }

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

Member Data Documentation

◆ file

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

◆ tree

TTree* TreeWriterForEcalCorrection::tree
private

◆ tree_e

float TreeWriterForEcalCorrection::tree_e
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

◆ tree_eta

float TreeWriterForEcalCorrection::tree_eta
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

◆ tree_response

float TreeWriterForEcalCorrection::tree_response
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

Hit
Definition: HitCollection.h:12
reco::GenParticle
Definition: GenParticle.h:21
tree
Definition: tree.py:1
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TreeWriterForEcalCorrection::tree_e
float tree_e
Definition: TreeWriterForEcalCorrection.cc:35
heavyFlavorValidation_cfi.GenParticles
GenParticles
Definition: heavyFlavorValidation_cfi.py:12
edm::Handle< reco::GenParticleCollection >
TreeWriterForEcalCorrection::tree_eta
float tree_eta
Definition: TreeWriterForEcalCorrection.cc:35
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
gen
Definition: PythiaDecays.h:13
iEvent
int iEvent
Definition: GenABIO.cc:224
TreeWriterForEcalCorrection::file
edm::Service< TFileService > file
Definition: TreeWriterForEcalCorrection.cc:33
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
TreeWriterForEcalCorrection::tree_response
float tree_response
Definition: TreeWriterForEcalCorrection.cc:35
Exception
Definition: hltDiff.cc:245
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64