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 &&)=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
 
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
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 34 of file CTPPSProtonReconstructionSimulationValidator.cc.

Constructor & Destructor Documentation

◆ CTPPSProtonReconstructionSimulationValidator()

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

Definition at line 156 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")),

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 171 of file CTPPSProtonReconstructionSimulationValidator.cc.

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  }

References edm::RefVector< C, T, F >::begin(), reco::ForwardProton::contributingLocalTracks(), fillPlots(), edm::EventSetup::get(), get, edm::HepMCProduct::GetEvent(), patZpeak::handle, charmTagsComputerCvsB_cfi::idx, iEvent, lhcInfoLabel_, reco::ForwardProton::lhcSector(), reco::ForwardProton::method(), reco::ForwardProton::multiRP, year_2016_postTS2_cff::rpId, reco::ForwardProton::sector45, reco::ForwardProton::singleRP, tokenHepMCAfterSmearing_, tokenHepMCBeforeSmearing_, tokenRecoProtonsMultiRP_, tokenRecoProtonsSingleRP_, reco::ForwardProton::validFit(), and badGlobalMuonTaggersAOD_cff::vtx.

◆ endJob()

void CTPPSProtonReconstructionSimulationValidator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 333 of file CTPPSProtonReconstructionSimulationValidator.cc.

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  }

References AlcaSiPixelAliHarvester0T_cff::method, outputFile_, and 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 291 of file CTPPSProtonReconstructionSimulationValidator.cc.

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);

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

Referenced by analyze().

Member Data Documentation

◆ lhcInfoLabel_

std::string CTPPSProtonReconstructionSimulationValidator::lhcInfoLabel_
private

Definition at line 57 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ outputFile_

std::string CTPPSProtonReconstructionSimulationValidator::outputFile_
private

Definition at line 59 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by endJob().

◆ plots_

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

◆ tokenHepMCAfterSmearing_

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

Definition at line 52 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ tokenHepMCBeforeSmearing_

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

Definition at line 51 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ tokenRecoProtonsMultiRP_

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

Definition at line 55 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

◆ tokenRecoProtonsSingleRP_

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

Definition at line 54 of file CTPPSProtonReconstructionSimulationValidator.cc.

Referenced by analyze().

LHCInfo::energy
const float energy() const
Definition: LHCInfo.cc:190
CTPPSProtonReconstructionSimulationValidator::lhcInfoLabel_
std::string lhcInfoLabel_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:57
CTPPSProtonReconstructionSimulationValidator::tokenHepMCAfterSmearing_
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMCAfterSmearing_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:52
reco::ForwardProton::ReconstructionMethod::singleRP
patZpeak.handle
handle
Definition: patZpeak.py:23
reco::ForwardProton::thetaY
float thetaY() const
horizontal scattering angle, in rad
Definition: ForwardProton.h:89
AlcaSiPixelAliHarvester0T_cff.method
method
Definition: AlcaSiPixelAliHarvester0T_cff.py:41
CTPPSProtonReconstructionSimulationValidator::fillPlots
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)
Definition: CTPPSProtonReconstructionSimulationValidator.cc:291
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
reco::ForwardProton::vertex
const Point & vertex() const
fitted vertex position
Definition: ForwardProton.h:57
year_2016_postTS2_cff.rpId
rpId
Definition: year_2016_postTS2_cff.py:23
edm::Handle< edm::HepMCProduct >
CTPPSProtonReconstructionSimulationValidator::plots_
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:147
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
part
part
Definition: HCALResponse.h:20
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
CTPPSProtonReconstructionSimulationValidator::tokenRecoProtonsMultiRP_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:55
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< LHCInfo >
LHCInfoRcd
Definition: LHCInfoRcd.h:24
CTPPSProtonReconstructionSimulationValidator::tokenHepMCBeforeSmearing_
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMCBeforeSmearing_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:51
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogError
Definition: MessageLogger.h:183
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
reco::ForwardProton::xi
float xi() const
longitudinal fractional momentum loss
Definition: ForwardProton.h:85
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::ForwardProton::calculateT
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...
Definition: ForwardProton.cc:44
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
reco::ForwardProton::thetaX
float thetaX() const
vertical scattering angle, in rad
Definition: ForwardProton.h:87
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
reco::ForwardProton::ReconstructionMethod::multiRP
reco::ForwardProton::LHCSector::sector45
CTPPSProtonReconstructionSimulationValidator::outputFile_
std::string outputFile_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:59
reco::ForwardProton::t
float t() const
four-momentum transfer squared, in GeV^2
Definition: ForwardProton.cc:51
edm::InputTag
Definition: InputTag.h:15
CTPPSProtonReconstructionSimulationValidator::tokenRecoProtonsSingleRP_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
Definition: CTPPSProtonReconstructionSimulationValidator.cc:54