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::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 TreeWriterForEcalCorrection (const edm::ParameterSet &)
 
 ~TreeWriterForEcalCorrection () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT< edm::PCaloHitContainertok_ebf_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_ebs_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_eef_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_ees_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_esf_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_ess_
 
const edm::EDGetTokenT< reco::GenParticleCollectio > tok_gen_
 
TTree * tree_
 
float tree_e_
 
float tree_eta_
 
float tree_response_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase 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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 23 of file TreeWriterForEcalCorrection.cc.

Constructor & Destructor Documentation

◆ TreeWriterForEcalCorrection()

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

Definition at line 44 of file TreeWriterForEcalCorrection.cc.

References geometryDiff::file, TFileService::kSharedResource, tree_, tree_e_, tree_eta_, and tree_response_.

45  : tok_gen_(consumes<reco::GenParticleCollectio>(edm::InputTag("genParticles", ""))),
46  tok_ebf_(consumes<edm::PCaloHitContainer>(edm::InputTag("fastSimProducer", "EcalHitsEB"))),
47  tok_eef_(consumes<edm::PCaloHitContainer>(edm::InputTag("fastSimProducer", "EcalHitsEE"))),
48  tok_esf_(consumes<edm::PCaloHitContainer>(edm::InputTag("fastSimProducer", "EcalHitsES"))),
49  tok_ebs_(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "EcalHitsEB"))),
50  tok_ees_(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "EcalHitsEE"))),
51  tok_ess_(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "EcalHitsES"))) {
52  usesResource(TFileService::kSharedResource);
54  tree_ = file->make<TTree>("responseTree", "same info as 3dhisto");
55  tree_->Branch("e", &tree_e_, "e/F");
56  tree_->Branch("eta", &tree_eta_, "eta/F");
57  tree_->Branch("r", &tree_response_, "r/F");
58 }
static const std::string kSharedResource
Definition: TFileService.h:76
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ebf_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_eef_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ess_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ebs_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ees_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_esf_
const edm::EDGetTokenT< reco::GenParticleCollectio > tok_gen_

◆ ~TreeWriterForEcalCorrection()

TreeWriterForEcalCorrection::~TreeWriterForEcalCorrection ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 60 of file TreeWriterForEcalCorrection.cc.

References Exception, heavyFlavorValidation_cfi::GenParticles, iEvent, edm::HandleBase::isValid(), edm::Handle< T >::product(), tok_ebf_, tok_ebs_, tok_eef_, tok_ees_, tok_esf_, tok_ess_, tok_gen_, tree_, tree_e_, tree_eta_, and tree_response_.

60  {
61  // get generated particles
63 
64  // As this module is intended for single particle guns, there should be
65  // exactly one generated particle.
66  if (GenParticles->size() != 1) {
67  throw cms::Exception("MismatchedInputFiles") << "Intended for particle guns only\n";
68  }
69 
70  // I assume here that the tracker simulation is disabled and no vertex
71  // smearing is done, so that the generated particles is exactly the same
72  // particle as the particle hitting the entrace of the ECAL.
74  float genE = gen.energy();
75  float genEta = gen.eta();
76  // genEta is positive for my photongun sample per definition.
77  // If not, you could take the absolute value here.
78 
79  // get sim hits
81  // Finds out automatically, if this is fullsim or fastsim
82  bool isFastSim = SimHitsEB.isValid();
83  if (!isFastSim)
84  SimHitsEB = iEvent.getHandle(tok_ebs_);
85  const edm::Handle<edm::PCaloHitContainer> SimHitsEE =
86  isFastSim ? iEvent.getHandle(tok_eef_) : iEvent.getHandle(tok_ees_);
87  const edm::Handle<edm::PCaloHitContainer> SimHitsES =
88  isFastSim ? iEvent.getHandle(tok_esf_) : iEvent.getHandle(tok_ess_);
89 
90  // merge them into one single vector
91  auto SimHits = *(SimHitsEB.product());
92  SimHits.insert(SimHits.end(), SimHitsEE->begin(), SimHitsEE->end());
93  SimHits.insert(SimHits.end(), SimHitsES->begin(), SimHitsES->end());
94 
95  // As we only had one generated particle (and hopefully no pileup),
96  // the total energy is due to the generated particle only
97  float energyTotal = 0;
98  for (auto const& Hit : SimHits) {
99  energyTotal += Hit.energy();
100  }
101 
102  tree_e_ = genE;
103  tree_eta_ = genEta;
104  tree_response_ = energyTotal / genE;
105  tree_->Fill();
106 }
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ebf_
T const * product() const
Definition: Handle.h:70
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_eef_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ess_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ebs_
int iEvent
Definition: GenABIO.cc:224
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_ees_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_esf_
const edm::EDGetTokenT< reco::GenParticleCollectio > tok_gen_

◆ fillDescriptions()

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

Definition at line 108 of file TreeWriterForEcalCorrection.cc.

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

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

Member Data Documentation

◆ tok_ebf_

const edm::EDGetTokenT<edm::PCaloHitContainer> TreeWriterForEcalCorrection::tok_ebf_
private

Definition at line 34 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tok_ebs_

const edm::EDGetTokenT<edm::PCaloHitContainer> TreeWriterForEcalCorrection::tok_ebs_
private

Definition at line 37 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tok_eef_

const edm::EDGetTokenT<edm::PCaloHitContainer> TreeWriterForEcalCorrection::tok_eef_
private

Definition at line 35 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tok_ees_

const edm::EDGetTokenT<edm::PCaloHitContainer> TreeWriterForEcalCorrection::tok_ees_
private

Definition at line 38 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tok_esf_

const edm::EDGetTokenT<edm::PCaloHitContainer> TreeWriterForEcalCorrection::tok_esf_
private

Definition at line 36 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tok_ess_

const edm::EDGetTokenT<edm::PCaloHitContainer> TreeWriterForEcalCorrection::tok_ess_
private

Definition at line 39 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tok_gen_

const edm::EDGetTokenT<reco::GenParticleCollectio> TreeWriterForEcalCorrection::tok_gen_
private

Definition at line 33 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze().

◆ tree_

TTree* TreeWriterForEcalCorrection::tree_
private

Definition at line 40 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

◆ tree_e_

float TreeWriterForEcalCorrection::tree_e_
private

Definition at line 41 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

◆ tree_eta_

float TreeWriterForEcalCorrection::tree_eta_
private

Definition at line 41 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().

◆ tree_response_

float TreeWriterForEcalCorrection::tree_response_
private

Definition at line 41 of file TreeWriterForEcalCorrection.cc.

Referenced by analyze(), and TreeWriterForEcalCorrection().