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
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
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_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
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>
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)
 
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 20 of file CTPPSBeamSmearingValidator.cc.

Constructor & Destructor Documentation

◆ CTPPSBeamSmearingValidator()

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

Definition at line 64 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.)),

◆ ~CTPPSBeamSmearingValidator()

CTPPSBeamSmearingValidator::~CTPPSBeamSmearingValidator ( )
inlineoverride

Definition at line 26 of file CTPPSBeamSmearingValidator.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 74 of file CTPPSBeamSmearingValidator.cc.

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

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

◆ endJob()

void CTPPSBeamSmearingValidator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 139 of file CTPPSBeamSmearingValidator.cc.

140  {
141  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
142 
143  h_de_vtx_x_->Write();
144  h_de_vtx_y_->Write();
145  h_de_vtx_z_->Write();
146 
147  gDirectory = f_out->mkdir("sector 45");
148  sectorPlots_[0].write();
149 
150  gDirectory = f_out->mkdir("sector 56");
151  sectorPlots_[1].write();

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

Member Data Documentation

◆ h_de_vtx_x_

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

Definition at line 38 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 38 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 38 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ outputFile_

std::string CTPPSBeamSmearingValidator::outputFile_
private

Definition at line 36 of file CTPPSBeamSmearingValidator.cc.

Referenced by endJob().

◆ sectorPlots_

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

Definition at line 55 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

◆ tokenAfterSmearing_

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

Definition at line 34 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze().

◆ tokenBeforeSmearing_

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

Definition at line 33 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze().

CTPPSBeamSmearingValidator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CTPPSBeamSmearingValidator.cc:74
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
CTPPSBeamSmearingValidator::h_de_vtx_z_
std::unique_ptr< TH1D > h_de_vtx_z_
Definition: CTPPSBeamSmearingValidator.cc:38
edm::Handle< edm::HepMCProduct >
CTPPSBeamSmearingValidator::h_de_vtx_x_
std::unique_ptr< TH1D > h_de_vtx_x_
Definition: CTPPSBeamSmearingValidator.cc:38
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
CTPPSBeamSmearingValidator::tokenAfterSmearing_
edm::EDGetTokenT< edm::HepMCProduct > tokenAfterSmearing_
Definition: CTPPSBeamSmearingValidator.cc:34
CTPPSBeamSmearingValidator::outputFile_
std::string outputFile_
Definition: CTPPSBeamSmearingValidator.cc:36
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
edm::EventSetup
Definition: EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
CTPPSBeamSmearingValidator::h_de_vtx_y_
std::unique_ptr< TH1D > h_de_vtx_y_
Definition: CTPPSBeamSmearingValidator.cc:38
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CTPPSBeamSmearingValidator::sectorPlots_
std::map< unsigned int, SectorPlots > sectorPlots_
Definition: CTPPSBeamSmearingValidator.cc:55
edm::Event
Definition: Event.h:73
CTPPSBeamSmearingValidator::tokenBeforeSmearing_
edm::EDGetTokenT< edm::HepMCProduct > tokenBeforeSmearing_
Definition: CTPPSBeamSmearingValidator.cc:33
edm::InputTag
Definition: InputTag.h:15