ATLAS Offline Software
CosmicEventParser.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef COSMICGENERATOR_COSMICEVENTPARSER_H
6 #define COSMICGENERATOR_COSMICEVENTPARSER_H
7 
8 #include <iostream>
9 #include "CLHEP/Vector/ThreeVector.h"
11 
12 
14  public:
16  const CLHEP::HepLorentzVector& Vertex(void){return m_vertex;}
17  const CLHEP::HepLorentzVector& Momentum(void){return m_momentum;}
18  int pdgID(void){return m_pdgId;}
19  private:
20  CLHEP::HepLorentzVector m_vertex;
21  CLHEP::HepLorentzVector m_momentum;
23  int m_pdgId;
24  std::istream& read(std::istream& is);
25  std::ostream& write(std::ostream& os) const;
26 
27  friend std::istream& operator >> (std::istream& is,CosmicEventParser& ev);
28  friend std::ostream& operator << (std::ostream& os,const CosmicEventParser& ev);
29 };
30 
31 std::istream& operator >> (std::istream& is,CosmicEventParser& ev) {
32  return ev.read(is);
33 }
34 
35 std::ostream& operator << (std::ostream& os,const CosmicEventParser& ev) {
36  return ev.write(os);
37 }
38 
39 inline
40 std::istream& CosmicEventParser::read(std::istream& is)
41 {
42  int dummy;
43  int id;
44  CLHEP::Hep3Vector vert,mom;
45  double v_x,v_y,v_z;
46  is >> m_eventNumber >> dummy >> id >> v_x >> v_y >> v_z >> mom;
47 
48  //
49  // rotate over pi in x-z plane
50  //
51  vert.setX(-v_x);
52  vert.setY( v_y);
53  vert.setZ(-v_z);
54 
55  //
56  // convert to MeV's and mm units
57  //
58  mom = 1000*mom;
59  vert = 10*vert;
60 
61 
62  m_vertex.setVect(vert);
63  m_vertex.setE(0.);
64 
65 
66  m_momentum.setVect(mom);
67  double energy = sqrt(pow(ParticleConstants::muonMassInMeV,2)+mom.mag2());
68  m_momentum.setE(energy);
69 
70  if(id == 5) m_pdgId = 13;
71  else m_pdgId = -13;
72 
73  return is;
74 }
75 
76 inline
77 std::ostream& CosmicEventParser::write(std::ostream& os) const
78 {
79  int dummy(1);
80  int id(5);
81  if(m_pdgId == -13) id = 6;
82  os << m_eventNumber << " " << dummy << " " << id << " "
83  << m_vertex.x() << " " << m_vertex.y() << " " << m_vertex.z() << " "
84  << m_momentum.x() << " " << m_momentum.y() << " " << m_momentum.z();
85 
86  return os;
87 }
88 
89 
90 #endif
CosmicEventParser::read
std::istream & read(std::istream &is)
Definition: CosmicEventParser.h:40
ParticleConstants::PDG2011::muonMassInMeV
constexpr double muonMassInMeV
the mass of the muon (in MeV)
Definition: ParticleConstants.h:29
CosmicEventParser::Vertex
const CLHEP::HepLorentzVector & Vertex(void)
Definition: CosmicEventParser.h:16
CosmicEventParser::Momentum
const CLHEP::HepLorentzVector & Momentum(void)
Definition: CosmicEventParser.h:17
CosmicEventParser::m_vertex
CLHEP::HepLorentzVector m_vertex
Definition: CosmicEventParser.h:20
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
ev
int ev
Definition: globals.cxx:25
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
ParticleConstants.h
CosmicEventParser::m_eventNumber
int m_eventNumber
Definition: CosmicEventParser.h:22
CosmicEventParser::operator<<
friend std::ostream & operator<<(std::ostream &os, const CosmicEventParser &ev)
Definition: CosmicEventParser.h:35
CalibDbCompareRT.dummy
dummy
Definition: CalibDbCompareRT.py:59
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
CosmicEventParser::operator>>
friend std::istream & operator>>(std::istream &is, CosmicEventParser &ev)
Definition: CosmicEventParser.h:31
CosmicEventParser::pdgID
int pdgID(void)
Definition: CosmicEventParser.h:18
operator>>
std::istream & operator>>(std::istream &is, CosmicEventParser &ev)
Definition: CosmicEventParser.h:31
CosmicEventParser::m_momentum
CLHEP::HepLorentzVector m_momentum
Definition: CosmicEventParser.h:21
CosmicEventParser::m_pdgId
int m_pdgId
Definition: CosmicEventParser.h:23
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
CosmicEventParser::CosmicEventParser
CosmicEventParser()
Definition: CosmicEventParser.h:15
operator<<
std::ostream & operator<<(std::ostream &os, const CosmicEventParser &ev)
Definition: CosmicEventParser.h:35
CosmicEventParser::write
std::ostream & write(std::ostream &os) const
Definition: CosmicEventParser.h:77
CosmicEventParser
Definition: CosmicEventParser.h:13