ATLAS Offline Software
FlukaParticle.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <iostream>
7 #include <sstream>
8 
9 //---------------------------------------------------------------------------
10 
12  m_eventId(0),
13  m_flukaId(0),
14  m_partGenNum(0),
15  m_kineticEnergy(0.),
16  m_positionAtScoringPlane(),
17  m_directionalCosines(),
18  m_weight(1.),
19  m_totalEnergy(0.),
20  m_positionAtPrimary() {
21 }
22 
23 //---------------------------------------------------------------------------
24 
26  m_eventId = 0;
27  m_flukaId = 0;
28  m_partGenNum = 0;
29  m_kineticEnergy = 0.;
30  m_positionAtScoringPlane.setX(0.);
31  m_positionAtScoringPlane.setY(0.);
32  m_positionAtScoringPlane.setZ(0.);
33  m_positionAtScoringPlane.setT(0.);
34  m_directionalCosines.setX(0.);
35  m_directionalCosines.setY(0.);
36  m_directionalCosines.setZ(0.);
37  m_weight = 1.;
38  m_totalEnergy = 0.;
39  m_positionAtPrimary.setX(0.);
40  m_positionAtPrimary.setY(0.);
41  m_positionAtPrimary.setZ(0.);
42  m_positionAtPrimary.setT(0.);
43 }
44 
45 //---------------------------------------------------------------------------
46 
47 int FlukaParticle::read(std::vector<std::string> *eventAsStringVector) {
48  clear();
49 
50  if(!eventAsStringVector) {
51  std::cerr << "ERROR: string vector passed to FlukaParticle::read is null." << std::endl;
52  return 1;
53  }
54 
55  if(m_type == BRUCE) {
56  if(eventAsStringVector->size() != 15) {
57  std::cerr << "ERROR: there are " << eventAsStringVector->size() << " data words, which is out of range. This particle will be null." << std::endl;
58  return 2;
59  }
60  }
61  else if(m_type == TALANOV) {
62  if(eventAsStringVector->size() < 10 || eventAsStringVector->size() > 11 ) {
63  std::cerr << "ERROR: there are " << eventAsStringVector->size() << " data words, which is out of range. This particle will be null." << std::endl;
64  return 3;
65  }
66  }
67  else {
68  std::cerr << "ERROR: unknown input Fluka record type. This particle will be null." << std::endl;
69  return 4;
70  }
71 
72  double doubleValue;
73  std::vector<std::string>::iterator itr = eventAsStringVector->begin();
74  std::vector<std::string>::iterator itr_end = eventAsStringVector->end();
75  int wordNumber = 0;
76  if(m_type == BRUCE) {
77  for(;itr!=itr_end;++itr,++wordNumber) {
78  if((*itr).length() == 0) {
79  std::cerr << "ERROR: string word has zero length." << std::endl;
80  return 5;
81  }
82  std::istringstream inStr((*itr));
83  switch (wordNumber) {
84  case 0 : inStr >> m_eventId; break; // FLUKA run number (between 1 and 3000)
85  case 1 : inStr >> m_partGenNum; break; // ID of primary particle (between 1 and 100 in each run)
86  case 2 : inStr >> m_flukaId; break; // Standard FLUKA particle id
87  case 3 : inStr >> m_kineticEnergy; break; // GeV
88  case 4 : inStr >> m_weight; break;
89  case 5 : inStr >> doubleValue; m_positionAtScoringPlane.setX(doubleValue); break; // (cm)
90  case 6 : inStr >> doubleValue; m_positionAtScoringPlane.setY(doubleValue); break; // (cm)
91  case 7 : inStr >> doubleValue; m_directionalCosines.setX(doubleValue); break; // w.r.t x-axis
92  case 8 : inStr >> doubleValue; m_directionalCosines.setY(doubleValue); break; // w.r.t y-axis
93  //case 9 : inStr >> doubleValue; m_positionAtScoringPlane.setT(doubleValue); break; // time (s) since start of primary particle (use t=0 for ATLAS Geant)
94  case 10 : inStr >> m_totalEnergy; break; // total energy (GeV)
95  case 11 : inStr >> doubleValue; m_positionAtPrimary.setX(doubleValue); break; // (cm)
96  case 12 : inStr >> doubleValue; m_positionAtPrimary.setY(doubleValue); break; // (cm)
97  case 13 : inStr >> doubleValue; m_positionAtPrimary.setZ(doubleValue); break; // (cm)
98  case 14 : inStr >> doubleValue; m_positionAtPrimary.setT(doubleValue); break; // (cm)
99  default : break;
100  }
101  }
102  }
103  else if(m_type == TALANOV) {
104  for(;itr!=itr_end;++itr,++wordNumber) {
105  std::istringstream inStr((*itr));
106  switch (wordNumber) {
107  case 0 : inStr >> m_eventId; break;
108  case 1 : inStr >> m_flukaId; break;
109  case 2 : inStr >> m_partGenNum; break;
110  case 3 : inStr >> m_kineticEnergy; break;
111  case 4 : inStr >> doubleValue; m_positionAtScoringPlane.setX(doubleValue); break;
112  case 5 : inStr >> doubleValue; m_positionAtScoringPlane.setY(doubleValue); break;
113  case 6 : inStr >> doubleValue; m_positionAtScoringPlane.setZ(doubleValue); break;
114  case 7 : inStr >> doubleValue; m_directionalCosines.setX(doubleValue); break;
115  case 8 : inStr >> doubleValue; m_directionalCosines.setY(doubleValue); break;
116  case 9 : inStr >> doubleValue; m_directionalCosines.setZ(doubleValue); break;
117  case 10 : inStr >> doubleValue; m_positionAtScoringPlane.setT(doubleValue); break;
118  default : break;
119  }
120  }
121  }
122 
123  return 0;
124 }
125 
126 //---------------------------------------------------------------------------
127 
129  int pdgID = 0;
130 
131  // There does not appear to be a clever way to do this. The case
132  // statement mapping is taken from the FLUKA manual:
133  // http://www.fluka.org/fluka.php?id=man_onl&sub=7
134 
135  switch (m_flukaId) {
136  case -6 : pdgID = 1000020040; break;
137  case -5 : pdgID = 1000020030; break;
138  case -4 : pdgID = 1000010030; break;
139  case -3 : pdgID = 1000010020; break;
140  case 1 : pdgID = 2212; break;
141  case 2 : pdgID = -2212; break;
142  case 3 : pdgID = 11; break;
143  case 4 : pdgID = -11; break;
144  case 5 : pdgID = 12; break;
145  case 6 : pdgID = -12; break;
146  case 7 : pdgID = 22; break;
147  case 8 : pdgID = 2112; break;
148  case 9 : pdgID = -2112; break;
149  case 10 : pdgID = -13; break;
150  case 11 : pdgID = 13; break;
151  case 12 : pdgID = 130; break;
152  case 13 : pdgID = 211; break;
153  case 14 : pdgID = -211; break;
154  case 15 : pdgID = 321; break;
155  case 16 : pdgID = -321; break;
156  case 17 : pdgID = 3122; break;
157  case 18 : pdgID = -3122; break;
158  case 19 : pdgID = 310; break;
159  case 20 : pdgID = 3112; break;
160  case 21 : pdgID = 3222; break;
161  case 22 : pdgID = 3212; break;
162  case 23 : pdgID = 111; break;
163  case 24 : pdgID = 311; break;
164  case 25 : pdgID = -311; break;
165  case 27 : pdgID = 14; break;
166  case 28 : pdgID = -14; break;
167  case 31 : pdgID = -3222; break;
168  case 32 : pdgID = -3212; break;
169  case 33 : pdgID = -3112; break;
170  case 34 : pdgID = 3322; break;
171  case 35 : pdgID = -3322; break;
172  case 36 : pdgID = 3312; break;
173  case 37 : pdgID = -3312; break;
174  case 38 : pdgID = 3334; break;
175  case 39 : pdgID = -3334; break;
176  case 41 : pdgID = -15; break;
177  case 42 : pdgID = 15; break;
178  case 43 : pdgID = 16; break;
179  case 44 : pdgID = -16; break;
180  case 45 : pdgID = 411; break;
181  case 46 : pdgID = -411; break;
182  case 47 : pdgID = 421; break;
183  case 48 : pdgID = -421; break;
184  case 49 : pdgID = 431; break;
185  case 50 : pdgID = -431; break;
186  case 51 : pdgID = 4122; break;
187  case 52 : pdgID = 4232; break;
188  case 53 : pdgID = 4112; break;
189  case 54 : pdgID = 4322; break;
190  case 55 : pdgID = 4312; break;
191  case 56 : pdgID = 4332; break;
192  case 57 : pdgID = -4122; break;
193  case 58 : pdgID = -4232; break;
194  case 59 : pdgID = -4132; break;
195  case 60 : pdgID = -4322; break;
196  case 61 : pdgID = -4312; break;
197  case 62 : pdgID = -4332; break;
198  default : pdgID = 0;
199  }
200 
201  return pdgID;
202 }
203 
204 //---------------------------------------------------------------------------
205 
207  if(m_type == BRUCE) {
208  std::cout.fill(' ');
209  std::cout.width(6); std::cout << m_eventId << " ";
210  std::cout.width(6); std::cout << m_partGenNum << " ";
211  std::cout.width(6); std::cout << m_flukaId << " ";
212  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_kineticEnergy << " ";
213  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_weight << " ";
214  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtScoringPlane.x() << " ";
215  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtScoringPlane.y() << " ";
216  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_directionalCosines.x() << " ";
217  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_directionalCosines.y() << " ";
218  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtScoringPlane.t() << " ";
219  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_totalEnergy << " ";
220  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtPrimary.x() << " ";
221  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtPrimary.y() << " ";
222  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtPrimary.z() << " ";
223  std::cout.width(13); std::cout.precision(6); std::cout << std::scientific << m_positionAtPrimary.t() << " ";
224  std::cout.precision(6);
225  std::cout << std::endl;
226  }
227  else if(m_type == TALANOV) {
228  std::cout.fill(' ');
229  std::cout.width(7); std::cout << m_eventId << " ";
230  std::cout.width(2); std::cout << m_flukaId << " ";
231  std::cout.width(4); std::cout << m_partGenNum << " ";
232  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_kineticEnergy << " ";
233  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_positionAtScoringPlane.x() << " ";
234  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_positionAtScoringPlane.y() << " ";
235  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_positionAtScoringPlane.z() << " ";
236  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_directionalCosines.x() << " ";
237  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_directionalCosines.y() << " ";
238  std::cout.width(19); std::cout.precision(12); std::cout << std::scientific << m_directionalCosines.z() << " ";
239  std::cout.width(19); std::cout.precision(6); std::cout << std::scientific << m_positionAtScoringPlane.t();
240  std::cout.precision(6);
241  std::cout << std::endl;
242  }
243 }
244 
245 //---------------------------------------------------------------------------
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
FlukaParticle::read
int read(std::vector< std::string > *eventAsStringVector)
A function to read the values from a single row definition and fill the data members.
Definition: FlukaParticle.cxx:47
FlukaParticle::m_eventId
long m_eventId
Definition: FlukaParticle.h:79
FlukaParticle::print
void print(void)
A function to print the contents of this particle.
Definition: FlukaParticle.cxx:206
FlukaParticle::m_kineticEnergy
double m_kineticEnergy
Definition: FlukaParticle.h:82
FlukaParticle::m_positionAtPrimary
HepMC::FourVector m_positionAtPrimary
Definition: FlukaParticle.h:87
FlukaParticle::pdgId
int pdgId()
A function to return the PDG id of this particle.
Definition: FlukaParticle.cxx:128
FlukaParticle::m_totalEnergy
double m_totalEnergy
Definition: FlukaParticle.h:86
FlukaParticle::m_partGenNum
int m_partGenNum
Definition: FlukaParticle.h:81
FlukaParticle::clear
void clear(void)
A function to clear the values of this particle.
Definition: FlukaParticle.cxx:25
FlukaParticle::m_weight
double m_weight
Definition: FlukaParticle.h:85
FlukaParticle.h
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
FlukaParticle::m_flukaId
int m_flukaId
Definition: FlukaParticle.h:80
FlukaParticle::m_directionalCosines
HepMC::FourVector m_directionalCosines
Definition: FlukaParticle.h:84
FlukaParticle::m_type
int m_type
Definition: FlukaParticle.h:77
FlukaParticle::BRUCE
@ BRUCE
Definition: FlukaParticle.h:73
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
FlukaParticle::m_positionAtScoringPlane
HepMC::FourVector m_positionAtScoringPlane
Definition: FlukaParticle.h:83
FlukaParticle::FlukaParticle
FlukaParticle(int type=0)
Definition: FlukaParticle.cxx:11
FlukaParticle::TALANOV
@ TALANOV
Definition: FlukaParticle.h:74
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79