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

Constructor & Destructor Documentation

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

Definition at line 69 of file CTPPSBeamSmearingValidator.cc.

69  :
70  tokenBeforeSmearing_( consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagBeforeSmearing")) ),
71  tokenAfterSmearing_( consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagAfterSmearing")) ),
72  outputFile_(iConfig.getParameter<string>("outputFile")),
73  h_de_vtx_x_(new TH1D("h_de_vtx_x", ";#Delta vtx_{x} (mm)", 100, 0., 0.)),
74  h_de_vtx_y_(new TH1D("h_de_vtx_y", ";#Delta vtx_{y} (mm)", 100, 0., 0.)),
75  h_de_vtx_z_(new TH1D("h_de_vtx_z", ";#Delta vtx_{z} (mm)", 100, 0., 0.))
76 {}
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::HepMCProduct > tokenAfterSmearing_
edm::EDGetTokenT< edm::HepMCProduct > tokenBeforeSmearing_
CTPPSBeamSmearingValidator::~CTPPSBeamSmearingValidator ( )
inlineoverride

Definition at line 27 of file CTPPSBeamSmearingValidator.cc.

References analyze(), and endJob().

27 {}

Member Function Documentation

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

Definition at line 80 of file CTPPSBeamSmearingValidator.cc.

References edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), h_de_vtx_x_, h_de_vtx_y_, h_de_vtx_z_, training_settings::idx, M_PI, gen::n, connectstrParser::o, sectorPlots_, tokenAfterSmearing_, and tokenBeforeSmearing_.

Referenced by ~CTPPSBeamSmearingValidator().

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 146 of file CTPPSBeamSmearingValidator.cc.

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

Referenced by ~CTPPSBeamSmearingValidator().

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

Member Data Documentation

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

Definition at line 39 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

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

Definition at line 39 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

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

Definition at line 39 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

std::string CTPPSBeamSmearingValidator::outputFile_
private

Definition at line 37 of file CTPPSBeamSmearingValidator.cc.

Referenced by endJob().

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

Definition at line 58 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze(), and endJob().

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

Definition at line 35 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze().

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

Definition at line 34 of file CTPPSBeamSmearingValidator.cc.

Referenced by analyze().