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  DoubleArmPlotGroup
 
struct  PlotGroup
 

Public Member Functions

 CTPPSProtonReconstructionSimulationValidator (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 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
 
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)
 

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

DoubleArmPlotGroup double_arm_plots_
 
edm::ESGetToken< LHCInfo, LHCInfoRcdlhcInfoESToken_
 
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)
 
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 37 of file CTPPSProtonReconstructionSimulationValidator.cc.

Constructor & Destructor Documentation

◆ CTPPSProtonReconstructionSimulationValidator()

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

Definition at line 194 of file CTPPSProtonReconstructionSimulationValidator.cc.

197  consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMCBeforeSmearing"))),
199  consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMCAfterSmearing"))),
201  consumes<reco::ForwardProtonCollection>(iConfig.getParameter<InputTag>("tagRecoProtonsSingleRP"))),
203  consumes<reco::ForwardProtonCollection>(iConfig.getParameter<InputTag>("tagRecoProtonsMultiRP"))),
204  lhcInfoESToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
205  outputFile_(iConfig.getParameter<string>("outputFile")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 209 of file CTPPSProtonReconstructionSimulationValidator.cc.

References double_arm_plots_, CTPPSProtonReconstructionSimulationValidator::DoubleArmPlotGroup::fill(), fillPlots(), edm::EventSetup::getData(), edm::HepMCProduct::GetEvent(), patZpeak::handle, heavyIonCSV_trainingSettings::idx, iEvent, lhcInfoESToken_, reco::ForwardProton::multiRP, reco::ForwardProton::sector45, reco::ForwardProton::sector56, reco::ForwardProton::singleRP, tokenHepMCAfterSmearing_, tokenHepMCBeforeSmearing_, tokenRecoProtonsMultiRP_, tokenRecoProtonsSingleRP_, and L1BJetProducer_cff::vtx.

209  {
210  // get conditions
211  const auto &lhcInfo = iSetup.getData(lhcInfoESToken_);
212 
213  // get input
214  edm::Handle<edm::HepMCProduct> hHepMCBeforeSmearing;
215  iEvent.getByToken(tokenHepMCBeforeSmearing_, hHepMCBeforeSmearing);
216  HepMC::GenEvent *hepMCEventBeforeSmearing = (HepMC::GenEvent *)hHepMCBeforeSmearing->GetEvent();
217 
218  edm::Handle<edm::HepMCProduct> hHepMCAfterSmearing;
219  iEvent.getByToken(tokenHepMCAfterSmearing_, hHepMCAfterSmearing);
220  HepMC::GenEvent *hepMCEventAfterSmearing = (HepMC::GenEvent *)hHepMCAfterSmearing->GetEvent();
221 
222  Handle<reco::ForwardProtonCollection> hRecoProtonsSingleRP;
223  iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP);
224 
225  Handle<reco::ForwardProtonCollection> hRecoProtonsMultiRP;
226  iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP);
227 
228  // extract vertex position
229  bool vertex_set = false;
230  FourVector vtx;
231  for (auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) {
232  if (vertex_set) {
233  LogError("CTPPSProtonReconstructionSimulationValidator") << "Multiple vertices found.";
234  return;
235  }
236 
237  vertex_set = true;
238  vtx = (*it)->position();
239  }
240 
241  // extract forward protons
242  bool proton_45_set = false;
243  bool proton_56_set = false;
244  FourVector mom_45, mom_56;
245 
246  for (auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) {
247  const auto &part = *it;
248 
249  // accept only stable non-beam protons
250  if (part->pdg_id() != 2212)
251  continue;
252 
253  if (part->status() != 1)
254  continue;
255 
256  if (part->is_beam())
257  continue;
258 
259  const auto &mom = part->momentum();
260 
261  if (mom.e() < 4500.)
262  continue;
263 
264  if (mom.z() > 0) {
265  // 45
266  if (proton_45_set) {
267  LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 45.";
268  return;
269  }
270 
271  proton_45_set = true;
272  mom_45 = mom;
273  } else {
274  // 56
275  if (proton_56_set) {
276  LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 56.";
277  return;
278  }
279 
280  proton_56_set = true;
281  mom_56 = mom;
282  }
283  }
284 
285  // single-arm comparison
286  for (const auto &handle : {hRecoProtonsSingleRP, hRecoProtonsMultiRP}) {
287  for (const auto &rec_pr : *handle) {
288  if (!rec_pr.validFit())
289  continue;
290 
291  unsigned int idx = 12345;
292 
293  bool mom_set = false;
294  FourVector mom;
295 
296  if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector45) {
297  idx = 0;
298  mom_set = proton_45_set;
299  mom = mom_45;
300  }
301  if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector56) {
302  idx = 1;
303  mom_set = proton_56_set;
304  mom = mom_56;
305  }
306 
307  if (!mom_set)
308  continue;
309 
310  unsigned int meth_idx = 1234;
311 
313  meth_idx = 0;
314 
315  CTPPSDetId rpId((*rec_pr.contributingLocalTracks().begin())->rpId());
316  idx = 100 * rpId.arm() + 10 * rpId.station() + rpId.rp();
317  }
318 
320  meth_idx = 1;
321 
322  fillPlots(meth_idx, idx, rec_pr, vtx, mom, lhcInfo);
323  }
324  }
325 
326  // double-arm comparison
327  bool time_set_45 = false, time_set_56 = false;
328  double time_45 = 0., time_56 = 0.;
329  for (const auto &rec_pr : *hRecoProtonsMultiRP) {
330  if (!rec_pr.validFit())
331  continue;
332 
333  // skip protons with no timing information
334  if (rec_pr.timeError() < 1E-3)
335  continue;
336 
337  if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector45) {
338  time_set_45 = true;
339  time_45 = rec_pr.time();
340  }
341  if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector56) {
342  time_set_56 = true;
343  time_56 = rec_pr.time();
344  }
345  }
346 
347  if (time_set_45 && time_set_56)
348  double_arm_plots_.fill(time_45, time_56, vtx.z(), vtx.t());
349 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
Log< level::Error, false > LogError
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
part
Definition: HCALResponse.h:20
void fill(double time_45, double time_56, double vtx_z, double vtx_t)
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
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)

◆ endJob()

void CTPPSProtonReconstructionSimulationValidator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 396 of file CTPPSProtonReconstructionSimulationValidator.cc.

References double_arm_plots_, AlcaSiPixelAliHarvester0T_cff::method, outputFile_, plots_, and CTPPSProtonReconstructionSimulationValidator::DoubleArmPlotGroup::write().

396  {
397  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
398 
399  for (const auto &mit : plots_) {
400  const char *method = (mit.first == 0) ? "single rp" : "multi rp";
401  TDirectory *d_method = f_out->mkdir(method);
402 
403  for (const auto &eit : mit.second) {
404  gDirectory = d_method->mkdir(Form("%i", eit.first));
405  eit.second.write();
406  }
407  }
408 
409  gDirectory = f_out->mkdir("double arm");
411 }
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_

◆ fillPlots()

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

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

Referenced by analyze().

358  {
359  const double p_nom = lhcInfo.energy();
360  const double xi_simu = (p_nom - mom.rho()) / p_nom;
361  const double th_x_simu = mom.x() / mom.rho();
362  const double th_y_simu = mom.y() / mom.rho();
363  const double vtx_y_simu = vtx.y();
364  const double th_simu = sqrt(th_x_simu * th_x_simu + th_y_simu * th_y_simu);
365  const double t_simu = -reco::ForwardProton::calculateT(p_nom, mom.rho(), th_simu);
366 
367  const double xi_reco = rec_pr.xi();
368  const double th_x_reco = rec_pr.thetaX();
369  const double th_y_reco = rec_pr.thetaY();
370  const double vtx_y_reco = rec_pr.vertex().y() * 10.; // conversion: cm --> mm
371  const double t_reco = -rec_pr.t();
372 
373  auto &plt = plots_[meth_idx][idx];
374 
375  plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco);
376  plt.h_de_xi->Fill(xi_reco - xi_simu);
377  plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu);
378 
379  plt.h_de_th_x->Fill(th_x_reco - th_x_simu);
380  plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu);
381 
382  plt.h_de_th_y->Fill(th_y_reco - th_y_simu);
383  plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu);
384 
385  plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu);
386  plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu);
387 
388  plt.h_de_t->Fill(t_reco - t_simu);
389  plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu);
390  plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu);
391  plt.h2_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu);
392 }
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 thetaY() const
horizontal scattering angle, in rad
Definition: ForwardProton.h:83
float const energy() const
Definition: LHCInfo.cc:190
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
const Point & vertex() const
fitted vertex position
Definition: ForwardProton.h:51
float t() const
four-momentum transfer squared, in GeV^2
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_

Member Data Documentation

◆ double_arm_plots_

DoubleArmPlotGroup CTPPSProtonReconstructionSimulationValidator::double_arm_plots_
private

Definition at line 183 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze(), and endJob().

◆ lhcInfoESToken_

edm::ESGetToken<LHCInfo, LHCInfoRcd> CTPPSProtonReconstructionSimulationValidator::lhcInfoESToken_
private

Definition at line 58 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ outputFile_

std::string CTPPSProtonReconstructionSimulationValidator::outputFile_
private

Definition at line 60 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob().

◆ plots_

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

Definition at line 151 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob(), and fillPlots().

◆ tokenHepMCAfterSmearing_

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

Definition at line 53 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ tokenHepMCBeforeSmearing_

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

Definition at line 52 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ tokenRecoProtonsMultiRP_

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

Definition at line 56 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ tokenRecoProtonsSingleRP_

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

Definition at line 55 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().