CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CTPPSHepMCDistributionPlotter Class Reference
Inheritance diagram for CTPPSHepMCDistributionPlotter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 CTPPSHepMCDistributionPlotter (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 

Private Member Functions

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

Private Attributes

std::unique_ptr< TH1D > h_th_x_
 
std::unique_ptr< TH1D > h_th_y_
 
std::unique_ptr< TH1D > h_xi_
 
std::string lhcInfoLabel_
 
std::string outputFile_
 
edm::EDGetTokenT< edm::HepMCProducttokenHepMC_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 28 of file CTPPSHepMCDistributionPlotter.cc.

Constructor & Destructor Documentation

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

Definition at line 51 of file CTPPSHepMCDistributionPlotter.cc.

52  : tokenHepMC_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMC"))),
53  lhcInfoLabel_(iConfig.getParameter<std::string>("lhcInfoLabel")),
54  outputFile_(iConfig.getParameter<string>("outputFile")),
55  h_xi_(new TH1D("h_xi", ";#xi", 100, 0., 0.30)),
56  h_th_x_(new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6)),
57  h_th_y_(new TH1D("h_th_y", ";#theta^{*}_{y}", 100, -300E-6, +300E-6)) {}
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_

Member Function Documentation

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

Definition at line 61 of file CTPPSHepMCDistributionPlotter.cc.

References LHCInfo::energy(), edm::EventSetup::get(), edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), h_th_x_, h_th_y_, h_xi_, lhcInfoLabel_, and tokenHepMC_.

61  {
62  // get conditions
63  edm::ESHandle<LHCInfo> hLHCInfo;
64  iSetup.get<LHCInfoRcd>().get(lhcInfoLabel_, hLHCInfo);
65 
66  // get input
68  iEvent.getByToken(tokenHepMC_, hHepMC);
69  HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *)hHepMC->GetEvent();
70 
71  // extract protons
72  for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) {
73  const auto &part = *it;
74 
75  // accept only stable non-beam protons
76  if (part->pdg_id() != 2212)
77  continue;
78 
79  if (part->status() != 1)
80  continue;
81 
82  if (part->is_beam())
83  continue;
84 
85  const auto &mom = part->momentum();
86  const double p_nom = hLHCInfo->energy();
87 
88  if (mom.rho() / p_nom < 0.7)
89  continue;
90 
91  const double xi_simu = (p_nom - mom.e()) / p_nom;
92  const double th_x_simu = mom.x() / mom.rho();
93  const double th_y_simu = mom.y() / mom.rho();
94 
95  h_xi_->Fill(xi_simu);
96  h_th_x_->Fill(th_x_simu);
97  h_th_y_->Fill(th_y_simu);
98  }
99 }
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
part
Definition: HCALResponse.h:20
T get() const
Definition: EventSetup.h:73
float const energy() const
Definition: LHCInfo.cc:190
void CTPPSHepMCDistributionPlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 103 of file CTPPSHepMCDistributionPlotter.cc.

References DEFINE_FWK_MODULE, h_th_x_, h_th_y_, h_xi_, and outputFile_.

103  {
104  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
105 
106  h_xi_->Write();
107  h_th_x_->Write();
108  h_th_y_->Write();
109 }

Member Data Documentation

std::unique_ptr<TH1D> CTPPSHepMCDistributionPlotter::h_th_x_
private

Definition at line 40 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

std::unique_ptr<TH1D> CTPPSHepMCDistributionPlotter::h_th_y_
private

Definition at line 40 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

std::unique_ptr<TH1D> CTPPSHepMCDistributionPlotter::h_xi_
private

Definition at line 40 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

std::string CTPPSHepMCDistributionPlotter::lhcInfoLabel_
private

Definition at line 37 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

std::string CTPPSHepMCDistributionPlotter::outputFile_
private

Definition at line 38 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by endJob().

edm::EDGetTokenT<edm::HepMCProduct> CTPPSHepMCDistributionPlotter::tokenHepMC_
private

Definition at line 36 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().