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

158  :
159  tokenHepMCBeforeSmearing_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMCBeforeSmearing"))),
160  tokenHepMCAfterSmearing_ (consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMCAfterSmearing"))),
161  tokenRecoProtonsSingleRP_(consumes<reco::ForwardProtonCollection>(iConfig.getParameter<InputTag>("tagRecoProtonsSingleRP"))),
162  tokenRecoProtonsMultiRP_ (consumes<reco::ForwardProtonCollection>(iConfig.getParameter<InputTag>("tagRecoProtonsMultiRP"))),
163  lhcInfoLabel_(iConfig.getParameter<std::string>("lhcInfoLabel")),
164  outputFile_(iConfig.getParameter<string>("outputFile"))
165 {}
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 169 of file CTPPSProtonReconstructionSimulationValidator.cc.

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

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

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

331 {
332  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
333 
334  for (const auto& mit : plots_) {
335  const char* method = (mit.first == 0) ? "single rp" : "multi rp";
336  TDirectory *d_method = f_out->mkdir(method);
337 
338  for (const auto& eit : mit.second) {
339  gDirectory = d_method->mkdir(Form("%i", eit.first));
340  eit.second.write();
341  }
342  }
343 }
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 291 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().

293 {
294  const double p_nom = lhcInfo.energy();
295  const double xi_simu = (p_nom - mom.rho()) / p_nom;
296  const double th_x_simu = mom.x() / mom.rho();
297  const double th_y_simu = mom.y() / mom.rho();
298  const double vtx_y_simu = vtx.y();
299  const double th_simu = sqrt(th_x_simu*th_x_simu + th_y_simu*th_y_simu);
300  const double t_simu = - reco::ForwardProton::calculateT(p_nom, mom.rho(), th_simu);
301 
302  const double xi_reco = rec_pr.xi();
303  const double th_x_reco = rec_pr.thetaX();
304  const double th_y_reco = rec_pr.thetaY();
305  const double vtx_y_reco = rec_pr.vertex().y() * 10.; // conversion: cm --> mm
306  const double t_reco = - rec_pr.t();
307 
308  auto& plt = plots_[meth_idx][idx];
309 
310  plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco);
311  plt.h_de_xi->Fill(xi_reco - xi_simu);
312  plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu);
313 
314  plt.h_de_th_x->Fill(th_x_reco - th_x_simu);
315  plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu);
316 
317  plt.h_de_th_y->Fill(th_y_reco - th_y_simu);
318  plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu);
319 
320  plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu);
321  plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu);
322 
323  plt.h_de_t->Fill(t_reco - t_simu);
324  plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu);
325  plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu);
326 }
const Point & vertex() const
fitted vertex position
Definition: ForwardProton.h:46
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:78
T sqrt(T t)
Definition: SSEVec.h:18
float xi() const
longitudinal fractional momentum loss
Definition: ForwardProton.h:76
float const energy() const
Definition: LHCInfo.cc:192
float thetaY() const
horizontal scattering angle, in rad
Definition: ForwardProton.h:80
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_

Member Data Documentation

std::string CTPPSProtonReconstructionSimulationValidator::lhcInfoLabel_
private

Definition at line 53 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

std::string CTPPSProtonReconstructionSimulationValidator::outputFile_
private

Definition at line 55 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob().

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

Definition at line 147 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob(), and fillPlots().

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

Definition at line 48 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

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

Definition at line 47 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

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

Definition at line 51 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

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

Definition at line 50 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().