CMS 3D CMS Logo

List of all members | Public Member Functions | Static 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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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
 
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_
 
const edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcdlhcInfoPerFillToken_
 
const edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcdlhcInfoPerLSToken_
 
const edm::ESGetToken< LHCInfo, LHCInfoRcdlhcInfoToken_
 
const std::string outputFile_
 
const edm::EDGetTokenT< edm::HepMCProducttokenHepMC_
 
const bool useNewLHCInfo_
 

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 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 27 of file CTPPSHepMCDistributionPlotter.cc.

Constructor & Destructor Documentation

◆ CTPPSHepMCDistributionPlotter()

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

Definition at line 58 of file CTPPSHepMCDistributionPlotter.cc.

59  : tokenHepMC_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMC"))),
60 
61  lhcInfoToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
62  lhcInfoPerLSToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerLSLabel")))),
63  lhcInfoPerFillToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerFillLabel")))),
64  useNewLHCInfo_(iConfig.getParameter<bool>("useNewLHCInfo")),
65 
66  outputFile_(iConfig.getParameter<string>("outputFile")),
67 
68  h_vtx_x_(new TH1D("h_vtx_x", ";vtx_x (mm)", 100, 0., 0.)),
69  h_vtx_y_(new TH1D("h_vtx_y", ";vtx_y (mm)", 100, 0., 0.)),
70  h_vtx_z_(new TH1D("h_vtx_z", ";vtx_z (mm)", 100, 0., 0.)),
71  h_vtx_t_(new TH1D("h_vtx_t", ";vtx_t (mm)", 100, 0., 0.)),
72 
73  h_xi_(new TH1D("h_xi", ";#xi", 100, 0., 0.30)),
74  h_th_x_(new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6)),
75  h_th_y_(new TH1D("h_th_y", ";#theta^{*}_{y}", 100, -300E-6, +300E-6)) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
const edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcd > lhcInfoPerFillToken_
const edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
const edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcd > lhcInfoPerLSToken_

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 92 of file CTPPSHepMCDistributionPlotter.cc.

References LHCInfoCombined::energy, edm::HepMCProduct::GetEvent(), h_th_x_, h_th_y_, h_vtx_t_, h_vtx_x_, h_vtx_y_, h_vtx_z_, h_xi_, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, lhcInfoPerFillToken_, lhcInfoPerLSToken_, lhcInfoToken_, tokenHepMC_, and useNewLHCInfo_.

92  {
93  // get conditions
95 
96  // get input
98  iEvent.getByToken(tokenHepMC_, hHepMC);
99  HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *)hHepMC->GetEvent();
100 
101  // plot vertices
102  for (HepMC::GenEvent::vertex_iterator vit = hepMCEvent->vertices_begin(); vit != hepMCEvent->vertices_end(); ++vit) {
103  const auto pos = (*vit)->position();
104  h_vtx_x_->Fill(pos.x());
105  h_vtx_y_->Fill(pos.y());
106  h_vtx_z_->Fill(pos.z());
107  h_vtx_t_->Fill(pos.t());
108  }
109 
110  // extract protons
111  for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) {
112  const auto &part = *it;
113 
114  // accept only stable non-beam protons
115  if (part->pdg_id() != 2212)
116  continue;
117 
118  if (part->status() != 1)
119  continue;
120 
121  if (part->is_beam())
122  continue;
123 
124  const auto &mom = part->momentum();
125  const double p_nom = lhcInfoCombined.energy;
126 
127  if (mom.rho() / p_nom < 0.7)
128  continue;
129 
130  const double xi_simu = (p_nom - mom.e()) / p_nom;
131  const double th_x_simu = mom.x() / mom.rho();
132  const double th_y_simu = mom.y() / mom.rho();
133 
134  h_xi_->Fill(xi_simu);
135  h_th_x_->Fill(th_x_simu);
136  h_th_y_->Fill(th_y_simu);
137  }
138 }
const edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
const edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcd > lhcInfoPerFillToken_
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
const edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcd > lhcInfoPerLSToken_
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
part
Definition: HCALResponse.h:20
VertexRefVector::iterator vertex_iterator
iterator over a vector of references to Vertex objects in the same collection
Definition: VertexFwd.h:19

◆ endJob()

void CTPPSHepMCDistributionPlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 142 of file CTPPSHepMCDistributionPlotter.cc.

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

142  {
143  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
144 
145  h_vtx_x_->Write();
146  h_vtx_y_->Write();
147  h_vtx_z_->Write();
148  h_vtx_t_->Write();
149 
150  h_xi_->Write();
151  h_th_x_->Write();
152  h_th_y_->Write();
153 }

◆ fillDescriptions()

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

Definition at line 79 of file CTPPSHepMCDistributionPlotter.cc.

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

79  {
81 
82  desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");
83  desc.add<std::string>("lhcInfoPerLSLabel", "")->setComment("label of the LHCInfoPerLS record");
84  desc.add<std::string>("lhcInfoPerFillLabel", "")->setComment("label of the LHCInfoPerFill record");
85  desc.add<bool>("useNewLHCInfo", false)->setComment("flag whether to use new LHCInfoPer* records or old LHCInfo");
86 
87  desc.add<std::string>("outputFile", "")->setComment("output file");
88 
89  descriptions.add("ctppsHepMCDistributionPlotterDefault", desc);
90 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ h_th_x_

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

Definition at line 47 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_th_y_

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

Definition at line 47 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_t_

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

Definition at line 46 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_x_

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

Definition at line 46 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_y_

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

Definition at line 46 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_vtx_z_

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

Definition at line 46 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ h_xi_

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

Definition at line 47 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ lhcInfoPerFillToken_

const edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> CTPPSHepMCDistributionPlotter::lhcInfoPerFillToken_
private

Definition at line 41 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

◆ lhcInfoPerLSToken_

const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> CTPPSHepMCDistributionPlotter::lhcInfoPerLSToken_
private

Definition at line 40 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

◆ lhcInfoToken_

const edm::ESGetToken<LHCInfo, LHCInfoRcd> CTPPSHepMCDistributionPlotter::lhcInfoToken_
private

Definition at line 39 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

◆ outputFile_

const std::string CTPPSHepMCDistributionPlotter::outputFile_
private

Definition at line 44 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by endJob().

◆ tokenHepMC_

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

Definition at line 37 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().

◆ useNewLHCInfo_

const bool CTPPSHepMCDistributionPlotter::useNewLHCInfo_
private

Definition at line 42 of file CTPPSHepMCDistributionPlotter.cc.

Referenced by analyze().