CMS 3D CMS Logo

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

Classes

struct  PlotGroup
 

Public Member Functions

 CTPPSProtonReconstructionSimulationValidator (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
 
- 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
 
void fillPlots (unsigned int meth_idx, unsigned int idx, const reco::ForwardProton &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo)
 

Private Attributes

std::string lhcInfoLabel_
 
std::string outputFile_
 
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_
 
edm::EDGetTokenT< edm::HepMCProducttokenHepMCAfterSmearing_
 
edm::EDGetTokenT< edm::HepMCProducttokenHepMCBeforeSmearing_
 
edm::EDGetTokenT< reco::ForwardProtonCollectiontokenRecoProtonsMultiRP_
 
edm::EDGetTokenT< reco::ForwardProtonCollectiontokenRecoProtonsSingleRP_
 

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 35 of file CTPPSProtonReconstructionSimulationValidator.cc.

Constructor & Destructor Documentation

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

Definition at line 157 of file CTPPSProtonReconstructionSimulationValidator.cc.

160  consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMCBeforeSmearing"))),
162  consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMCAfterSmearing"))),
164  consumes<reco::ForwardProtonCollection>(iConfig.getParameter<InputTag>("tagRecoProtonsSingleRP"))),
166  consumes<reco::ForwardProtonCollection>(iConfig.getParameter<InputTag>("tagRecoProtonsMultiRP"))),
167  lhcInfoLabel_(iConfig.getParameter<std::string>("lhcInfoLabel")),
168  outputFile_(iConfig.getParameter<string>("outputFile")) {}
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_

Member Function Documentation

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

Definition at line 172 of file CTPPSProtonReconstructionSimulationValidator.cc.

References CTPPSDetId::arm(), fillPlots(), edm::EventSetup::get(), edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), patZpeak::handle, training_settings::idx, lhcInfoLabel_, reco::ForwardProton::multiRP, reco::ForwardProton::sector45, reco::ForwardProton::singleRP, tokenHepMCAfterSmearing_, tokenHepMCBeforeSmearing_, tokenRecoProtonsMultiRP_, tokenRecoProtonsSingleRP_, and badGlobalMuonTaggersAOD_cff::vtx.

172  {
173  // get conditions
174  edm::ESHandle<LHCInfo> hLHCInfo;
175  iSetup.get<LHCInfoRcd>().get(lhcInfoLabel_, hLHCInfo);
176 
177  // get input
178  edm::Handle<edm::HepMCProduct> hHepMCBeforeSmearing;
179  iEvent.getByToken(tokenHepMCBeforeSmearing_, hHepMCBeforeSmearing);
180  HepMC::GenEvent *hepMCEventBeforeSmearing = (HepMC::GenEvent *)hHepMCBeforeSmearing->GetEvent();
181 
182  edm::Handle<edm::HepMCProduct> hHepMCAfterSmearing;
183  iEvent.getByToken(tokenHepMCAfterSmearing_, hHepMCAfterSmearing);
184  HepMC::GenEvent *hepMCEventAfterSmearing = (HepMC::GenEvent *)hHepMCAfterSmearing->GetEvent();
185 
186  Handle<reco::ForwardProtonCollection> hRecoProtonsSingleRP;
187  iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP);
188 
189  Handle<reco::ForwardProtonCollection> hRecoProtonsMultiRP;
190  iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP);
191 
192  // extract vertex position
193  bool vertex_set = false;
194  FourVector vtx;
195  for (auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) {
196  if (vertex_set) {
197  LogError("CTPPSProtonReconstructionSimulationValidator") << "Multiple vertices found.";
198  return;
199  }
200 
201  vertex_set = true;
202  vtx = (*it)->position();
203  }
204 
205  // extract forward protons
206  bool proton_45_set = false;
207  bool proton_56_set = false;
208  FourVector mom_45, mom_56;
209 
210  for (auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) {
211  const auto &part = *it;
212 
213  // accept only stable non-beam protons
214  if (part->pdg_id() != 2212)
215  continue;
216 
217  if (part->status() != 1)
218  continue;
219 
220  if (part->is_beam())
221  continue;
222 
223  const auto &mom = part->momentum();
224 
225  if (mom.e() < 4500.)
226  continue;
227 
228  if (mom.z() > 0) {
229  // 45
230  if (proton_45_set) {
231  LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 45.";
232  return;
233  }
234 
235  proton_45_set = true;
236  mom_45 = mom;
237  } else {
238  // 56
239  if (proton_56_set) {
240  LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 56.";
241  return;
242  }
243 
244  proton_56_set = true;
245  mom_56 = mom;
246  }
247  }
248 
249  // do comparison
250  for (const auto &handle : {hRecoProtonsSingleRP, hRecoProtonsMultiRP}) {
251  for (const auto &rec_pr : *handle) {
252  if (!rec_pr.validFit())
253  continue;
254 
255  unsigned int idx;
256 
257  bool mom_set = false;
258  FourVector mom;
259 
260  if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector45) {
261  idx = 0;
262  mom_set = proton_45_set;
263  mom = mom_45;
264  } else {
265  idx = 1;
266  mom_set = proton_56_set;
267  mom = mom_56;
268  }
269 
270  if (!mom_set)
271  continue;
272 
273  unsigned int meth_idx = 1234;
274 
276  meth_idx = 0;
277 
278  CTPPSDetId rpId((*rec_pr.contributingLocalTracks().begin())->rpId());
279  idx = 100 * rpId.arm() + 10 * rpId.station() + rpId.rp();
280  }
281 
283  meth_idx = 1;
284 
285  fillPlots(meth_idx, idx, rec_pr, vtx, mom, *hLHCInfo);
286  }
287  }
288 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
uint32_t arm() const
Definition: CTPPSDetId.h:51
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
part
Definition: HCALResponse.h:20
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
T get() const
Definition: EventSetup.h:73
void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ForwardProton &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo)
void CTPPSProtonReconstructionSimulationValidator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 334 of file CTPPSProtonReconstructionSimulationValidator.cc.

References DEFINE_FWK_MODULE, AlcaSiPixelAliHarvester0T_cff::method, outputFile_, and plots_.

334  {
335  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
336 
337  for (const auto &mit : plots_) {
338  const char *method = (mit.first == 0) ? "single rp" : "multi rp";
339  TDirectory *d_method = f_out->mkdir(method);
340 
341  for (const auto &eit : mit.second) {
342  gDirectory = d_method->mkdir(Form("%i", eit.first));
343  eit.second.write();
344  }
345  }
346 }
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_
void CTPPSProtonReconstructionSimulationValidator::fillPlots ( unsigned int  meth_idx,
unsigned int  idx,
const reco::ForwardProton rec_pr,
const HepMC::FourVector &  vtx,
const HepMC::FourVector &  mom,
const LHCInfo lhcInfo 
)
private

Definition at line 292 of file CTPPSProtonReconstructionSimulationValidator.cc.

References reco::ForwardProton::calculateT(), LHCInfo::energy(), training_settings::idx, plots_, mathSSE::sqrt(), reco::ForwardProton::t(), reco::ForwardProton::thetaX(), reco::ForwardProton::thetaY(), reco::ForwardProton::vertex(), and reco::ForwardProton::xi().

Referenced by analyze().

297  {
298  const double p_nom = lhcInfo.energy();
299  const double xi_simu = (p_nom - mom.rho()) / p_nom;
300  const double th_x_simu = mom.x() / mom.rho();
301  const double th_y_simu = mom.y() / mom.rho();
302  const double vtx_y_simu = vtx.y();
303  const double th_simu = sqrt(th_x_simu * th_x_simu + th_y_simu * th_y_simu);
304  const double t_simu = -reco::ForwardProton::calculateT(p_nom, mom.rho(), th_simu);
305 
306  const double xi_reco = rec_pr.xi();
307  const double th_x_reco = rec_pr.thetaX();
308  const double th_y_reco = rec_pr.thetaY();
309  const double vtx_y_reco = rec_pr.vertex().y() * 10.; // conversion: cm --> mm
310  const double t_reco = -rec_pr.t();
311 
312  auto &plt = plots_[meth_idx][idx];
313 
314  plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco);
315  plt.h_de_xi->Fill(xi_reco - xi_simu);
316  plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu);
317 
318  plt.h_de_th_x->Fill(th_x_reco - th_x_simu);
319  plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu);
320 
321  plt.h_de_th_y->Fill(th_y_reco - th_y_simu);
322  plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu);
323 
324  plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu);
325  plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu);
326 
327  plt.h_de_t->Fill(t_reco - t_simu);
328  plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu);
329  plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu);
330 }
const Point & vertex() const
fitted vertex position
Definition: ForwardProton.h:51
static float calculateT(double beam_mom, double proton_mom, double theta)
compute the squared four-momentum transfer from incident and scattered momenta, and angular informati...
float t() const
four-momentum transfer squared, in GeV^2
float thetaX() const
vertical scattering angle, in rad
Definition: ForwardProton.h:81
T sqrt(T t)
Definition: SSEVec.h:19
float xi() const
longitudinal fractional momentum loss
Definition: ForwardProton.h:79
float const energy() const
Definition: LHCInfo.cc:190
float thetaY() const
horizontal scattering angle, in rad
Definition: ForwardProton.h:83
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_

Member Data Documentation

std::string CTPPSProtonReconstructionSimulationValidator::lhcInfoLabel_
private

Definition at line 56 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

std::string CTPPSProtonReconstructionSimulationValidator::outputFile_
private

Definition at line 58 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob().

std::map<unsigned int, std::map<unsigned int, PlotGroup> > CTPPSProtonReconstructionSimulationValidator::plots_
private

Definition at line 146 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob(), and fillPlots().

edm::EDGetTokenT<edm::HepMCProduct> CTPPSProtonReconstructionSimulationValidator::tokenHepMCAfterSmearing_
private

Definition at line 51 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

edm::EDGetTokenT<edm::HepMCProduct> CTPPSProtonReconstructionSimulationValidator::tokenHepMCBeforeSmearing_
private

Definition at line 50 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

edm::EDGetTokenT<reco::ForwardProtonCollection> CTPPSProtonReconstructionSimulationValidator::tokenRecoProtonsMultiRP_
private

Definition at line 54 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

edm::EDGetTokenT<reco::ForwardProtonCollection> CTPPSProtonReconstructionSimulationValidator::tokenRecoProtonsSingleRP_
private

Definition at line 53 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().