CMS 3D CMS Logo

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

Classes

struct  SectorPlots
 

Public Member Functions

 CTPPSBeamSmearingValidator (const edm::ParameterSet &)
 
 ~CTPPSBeamSmearingValidator () override
 
- 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 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)
 

Private Member Functions

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

Private Attributes

std::unique_ptr< TH1D > h_de_vtx_t_
 
std::unique_ptr< TH1D > h_de_vtx_x_
 
std::unique_ptr< TH1D > h_de_vtx_y_
 
std::unique_ptr< TH1D > h_de_vtx_z_
 
std::string outputFile_
 
std::map< unsigned int, SectorPlotssectorPlots_
 
edm::EDGetTokenT< edm::HepMCProducttokenAfterSmearing_
 
edm::EDGetTokenT< edm::HepMCProducttokenBeforeSmearing_
 

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)
 
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 21 of file CTPPSBeamSmearingValidator.cc.

Constructor & Destructor Documentation

◆ CTPPSBeamSmearingValidator()

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

Definition at line 65 of file CTPPSBeamSmearingValidator.cc.

66  : tokenBeforeSmearing_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagBeforeSmearing"))),
67  tokenAfterSmearing_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagAfterSmearing"))),
68  outputFile_(iConfig.getParameter<string>("outputFile")),
69  h_de_vtx_x_(new TH1D("h_de_vtx_x", ";#Delta vtx_{x} (mm)", 100, 0., 0.)),
70  h_de_vtx_y_(new TH1D("h_de_vtx_y", ";#Delta vtx_{y} (mm)", 100, 0., 0.)),
71  h_de_vtx_z_(new TH1D("h_de_vtx_z", ";#Delta vtx_{z} (mm)", 100, 0., 0.)),
72  h_de_vtx_t_(new TH1D("h_de_vtx_t", ";#Delta vtx_{t} (mm)", 100, 0., 0.)) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::HepMCProduct > tokenAfterSmearing_
edm::EDGetTokenT< edm::HepMCProduct > tokenBeforeSmearing_

◆ ~CTPPSBeamSmearingValidator()

CTPPSBeamSmearingValidator::~CTPPSBeamSmearingValidator ( )
inlineoverride

Definition at line 25 of file CTPPSBeamSmearingValidator.cc.

25 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 76 of file CTPPSBeamSmearingValidator.cc.

References edm::HepMCProduct::GetEvent(), h_de_vtx_t_, h_de_vtx_x_, h_de_vtx_y_, h_de_vtx_z_, heavyIonCSV_trainingSettings::idx, iEvent, M_PI, dqmiodumpmetadata::n, EcalTangentSkim_cfg::o, sectorPlots_, tokenAfterSmearing_, and tokenBeforeSmearing_.

76  {
77  // get input
78  edm::Handle<edm::HepMCProduct> hBeforeSmearing;
79  iEvent.getByToken(tokenBeforeSmearing_, hBeforeSmearing);
80  HepMC::GenEvent *orig = (HepMC::GenEvent *)hBeforeSmearing->GetEvent();
81 
82  edm::Handle<edm::HepMCProduct> hAfterSmearing;
83  iEvent.getByToken(tokenAfterSmearing_, hAfterSmearing);
84  HepMC::GenEvent *smear = (HepMC::GenEvent *)hAfterSmearing->GetEvent();
85 
86  // vertices
87  GenEvent::vertex_const_iterator vold, vnew;
88  for (vold = orig->vertices_begin(), vnew = smear->vertices_begin();
89  vold != orig->vertices_end() && vnew != smear->vertices_end();
90  ++vold, ++vnew) {
91  const FourVector &vo = (*vold)->position();
92  const FourVector &vn = (*vnew)->position();
93 
94  // HepMC gives vertex in mm
95  h_de_vtx_x_->Fill(vn.x() - vo.x());
96  h_de_vtx_y_->Fill(vn.y() - vo.y());
97  h_de_vtx_z_->Fill(vn.z() - vo.z());
98  h_de_vtx_t_->Fill(vn.t() - vo.t());
99  }
100 
101  // particles
102  GenEvent::particle_const_iterator pold, pnew;
103  for (pold = orig->particles_begin(), pnew = smear->particles_begin();
104  pold != orig->particles_end() && pnew != smear->particles_end();
105  ++pold, ++pnew) {
106  FourVector o = (*pold)->momentum(), n = (*pnew)->momentum();
107 
108  // determine direction region
109  signed int idx = -1;
110  const double thetaLim = 0.01; // rad
111  double th = o.theta();
112 
113  if (th < thetaLim)
114  idx = 0;
115  if (th > (M_PI - thetaLim))
116  idx = 1;
117 
118  if (idx < 0)
119  continue;
120 
121  /*
122  cout << "particle\n\told: [" << o.x() << ", " << o.y() << ", " << o.z() << ", " << o.t()
123  << "]\n\tnew: [" << n.x() << ", " << n.y() << ", " << n.z() << ", " << n.t()
124  << "]\n\tregion: " << idx << endl;
125  */
126 
127  // fill histograms
128  auto &sp = sectorPlots_[idx];
129 
130  double othx = o.x() / o.rho(), othy = o.y() / o.rho();
131  double nthx = n.x() / n.rho(), nthy = n.y() / n.rho();
132 
133  sp.h_de_p->Fill(n.rho() - o.rho());
134 
135  sp.h_de_th_x->Fill(nthx - othx);
136  sp.h_de_th_y->Fill(nthy - othy);
137  }
138 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::HepMCProduct > tokenAfterSmearing_
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
#define M_PI
edm::EDGetTokenT< edm::HepMCProduct > tokenBeforeSmearing_
std::map< unsigned int, SectorPlots > sectorPlots_

◆ endJob()

void CTPPSBeamSmearingValidator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 142 of file CTPPSBeamSmearingValidator.cc.

References h_de_vtx_t_, h_de_vtx_x_, h_de_vtx_y_, h_de_vtx_z_, outputFile_, and sectorPlots_.

142  {
143  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
144 
145  h_de_vtx_x_->Write();
146  h_de_vtx_y_->Write();
147  h_de_vtx_z_->Write();
148  h_de_vtx_t_->Write();
149 
150  gDirectory = f_out->mkdir("sector 45");
151  sectorPlots_[0].write();
152 
153  gDirectory = f_out->mkdir("sector 56");
154  sectorPlots_[1].write();
155 }
std::map< unsigned int, SectorPlots > sectorPlots_

Member Data Documentation

◆ h_de_vtx_t_

std::unique_ptr<TH1D> CTPPSBeamSmearingValidator::h_de_vtx_t_
private

Definition at line 37 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ h_de_vtx_x_

std::unique_ptr<TH1D> CTPPSBeamSmearingValidator::h_de_vtx_x_
private

Definition at line 37 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ h_de_vtx_y_

std::unique_ptr<TH1D> CTPPSBeamSmearingValidator::h_de_vtx_y_
private

Definition at line 37 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ h_de_vtx_z_

std::unique_ptr<TH1D> CTPPSBeamSmearingValidator::h_de_vtx_z_
private

Definition at line 37 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ outputFile_

std::string CTPPSBeamSmearingValidator::outputFile_
private

Definition at line 35 of file CTPPSBeamSmearingValidator.cc.

Referenced by endJob().

◆ sectorPlots_

std::map<unsigned int, SectorPlots> CTPPSBeamSmearingValidator::sectorPlots_
private

Definition at line 54 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ tokenAfterSmearing_

edm::EDGetTokenT<edm::HepMCProduct> CTPPSBeamSmearingValidator::tokenAfterSmearing_
private

Definition at line 33 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze().

◆ tokenBeforeSmearing_

edm::EDGetTokenT<edm::HepMCProduct> CTPPSBeamSmearingValidator::tokenBeforeSmearing_
private

Definition at line 32 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze().