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