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

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_vtx_t_
 
std::unique_ptr< TH1D > h_vtx_x_
 
std::unique_ptr< TH1D > h_vtx_y_
 
std::unique_ptr< TH1D > h_vtx_z_
 
std::unique_ptr< TH1D > h_xi_
 
edm::ESGetToken< LHCInfo, LHCInfoRcdlhcInfoESToken_
 
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
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 27 of file CTPPSHepMCDistributionPlotter.cc.

Constructor & Destructor Documentation

◆ CTPPSHepMCDistributionPlotter()

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

Definition at line 51 of file CTPPSHepMCDistributionPlotter.cc.

53  : tokenHepMC_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMC"))),
54  lhcInfoESToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
55  outputFile_(iConfig.getParameter<string>("outputFile")),
56 
57  h_vtx_x_(new TH1D("h_vtx_x", ";vtx_x (mm)", 100, 0., 0.)),
58  h_vtx_y_(new TH1D("h_vtx_y", ";vtx_y (mm)", 100, 0., 0.)),
59  h_vtx_z_(new TH1D("h_vtx_z", ";vtx_z (mm)", 100, 0., 0.)),
60  h_vtx_t_(new TH1D("h_vtx_t", ";vtx_t (mm)", 100, 0., 0.)),
61 
62  h_xi_(new TH1D("h_xi", ";#xi", 100, 0., 0.30)),
63  h_th_x_(new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6)),

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 67 of file CTPPSHepMCDistributionPlotter.cc.

68  {
69  // get conditions
70  const auto &lhcInfo = iSetup.getData(lhcInfoESToken_);
71 
72  // get input
74  iEvent.getByToken(tokenHepMC_, hHepMC);
75  HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *)hHepMC->GetEvent();
76 
77  // plot vertices
78  for (HepMC::GenEvent::vertex_iterator vit = hepMCEvent->vertices_begin(); vit != hepMCEvent->vertices_end(); ++vit) {
79  const auto pos = (*vit)->position();
80  h_vtx_x_->Fill(pos.x());
81  h_vtx_y_->Fill(pos.y());
82  h_vtx_z_->Fill(pos.z());
83  h_vtx_t_->Fill(pos.t());
84  }
85 
86  // extract protons
87  for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) {
88  const auto &part = *it;
89 
90  // accept only stable non-beam protons
91  if (part->pdg_id() != 2212)
92  continue;
93 
94  if (part->status() != 1)
95  continue;
96 
97  if (part->is_beam())
98  continue;
99 
100  const auto &mom = part->momentum();
101  const double p_nom = lhcInfo.energy();
102 
103  if (mom.rho() / p_nom < 0.7)
104  continue;
105 
106  const double xi_simu = (p_nom - mom.e()) / p_nom;
107  const double th_x_simu = mom.x() / mom.rho();
108  const double th_y_simu = mom.y() / mom.rho();
109 
110  h_xi_->Fill(xi_simu);
111  h_th_x_->Fill(th_x_simu);
112  h_th_y_->Fill(th_y_simu);
113  }

References edm::EventSetup::getData(), edm::HepMCProduct::GetEvent(), h_th_x_, h_th_y_, h_vtx_t_, h_vtx_x_, h_vtx_y_, h_vtx_z_, h_xi_, iEvent, lhcInfoESToken_, and tokenHepMC_.

◆ endJob()

void CTPPSHepMCDistributionPlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 117 of file CTPPSHepMCDistributionPlotter.cc.

118  {
119  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
120 
121  h_vtx_x_->Write();
122  h_vtx_y_->Write();
123  h_vtx_z_->Write();
124  h_vtx_t_->Write();
125 
126  h_xi_->Write();
127  h_th_x_->Write();
128  h_th_y_->Write();

References h_th_x_, h_th_y_, h_vtx_t_, h_vtx_x_, h_vtx_y_, h_vtx_z_, h_xi_, and outputFile_.

Member Data Documentation

◆ h_th_x_

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

Definition at line 42 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_th_y_

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

Definition at line 42 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_t_

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

Definition at line 41 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_x_

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

Definition at line 41 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_y_

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

Definition at line 41 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_z_

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

Definition at line 41 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_xi_

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

Definition at line 42 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ lhcInfoESToken_

edm::ESGetToken<LHCInfo, LHCInfoRcd> CTPPSHepMCDistributionPlotter::lhcInfoESToken_
private

Definition at line 38 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

◆ outputFile_

std::string CTPPSHepMCDistributionPlotter::outputFile_
private

Definition at line 39 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by endJob().

◆ tokenHepMC_

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

Definition at line 37 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

edm::ESInputTag
Definition: ESInputTag.h:87
pos
Definition: PixelAliasList.h:18
edm::Handle< edm::HepMCProduct >
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
CTPPSHepMCDistributionPlotter::h_th_x_
std::unique_ptr< TH1D > h_th_x_
Definition: CTPPSHepMCDistributionPlotter.cc:42
part
part
Definition: HCALResponse.h:20
CTPPSHepMCDistributionPlotter::h_vtx_x_
std::unique_ptr< TH1D > h_vtx_x_
Definition: CTPPSHepMCDistributionPlotter.cc:41
CTPPSHepMCDistributionPlotter::lhcInfoESToken_
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoESToken_
Definition: CTPPSHepMCDistributionPlotter.cc:38
CTPPSHepMCDistributionPlotter::h_vtx_y_
std::unique_ptr< TH1D > h_vtx_y_
Definition: CTPPSHepMCDistributionPlotter.cc:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSHepMCDistributionPlotter::h_th_y_
std::unique_ptr< TH1D > h_th_y_
Definition: CTPPSHepMCDistributionPlotter.cc:42
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
CTPPSHepMCDistributionPlotter::h_vtx_z_
std::unique_ptr< TH1D > h_vtx_z_
Definition: CTPPSHepMCDistributionPlotter.cc:41
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
CTPPSHepMCDistributionPlotter::outputFile_
std::string outputFile_
Definition: CTPPSHepMCDistributionPlotter.cc:39
CTPPSHepMCDistributionPlotter::h_xi_
std::unique_ptr< TH1D > h_xi_
Definition: CTPPSHepMCDistributionPlotter.cc:42
CTPPSHepMCDistributionPlotter::h_vtx_t_
std::unique_ptr< TH1D > h_vtx_t_
Definition: CTPPSHepMCDistributionPlotter.cc:41
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDConsumerBase::esConsumes
auto esConsumes()
Definition: EDConsumerBase.h:202
CTPPSHepMCDistributionPlotter::tokenHepMC_
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
Definition: CTPPSHepMCDistributionPlotter.cc:37
edm::InputTag
Definition: InputTag.h:15
reco::vertex_iterator
VertexRefVector::iterator vertex_iterator
iterator over a vector of references to Vertex objects in the same collection
Definition: VertexFwd.h:19