ATLAS Offline Software
Loading...
Searching...
No Matches
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;
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
31std::istream& operator >> (std::istream& is,CosmicEventParser& ev) {
32 return ev.read(is);
33}
34
35std::ostream& operator << (std::ostream& os,const CosmicEventParser& ev) {
36 return ev.write(os);
37}
38
39inline
40std::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
76inline
77std::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
std::ostream & operator<<(std::ostream &os, const CosmicEventParser &ev)
std::istream & operator>>(std::istream &is, CosmicEventParser &ev)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
constexpr int pow(int base, int exp) noexcept
std::ostream & write(std::ostream &os) const
CLHEP::HepLorentzVector m_vertex
const CLHEP::HepLorentzVector & Vertex(void)
const CLHEP::HepLorentzVector & Momentum(void)
friend std::ostream & operator<<(std::ostream &os, const CosmicEventParser &ev)
friend std::istream & operator>>(std::istream &is, CosmicEventParser &ev)
CLHEP::HepLorentzVector m_momentum
std::istream & read(std::istream &is)
int ev
Definition globals.cxx:25
constexpr double muonMassInMeV
the mass of the muon (in MeV)