]>
Commit | Line | Data |
---|---|---|
da32329d AM |
1 | /////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // Copyright 2010 | |
4 | // | |
5 | // This file is part of starlight. | |
6 | // | |
7 | // starlight is free software: you can redistribute it and/or modify | |
8 | // it under the terms of the GNU General Public License as published by | |
9 | // the Free Software Foundation, either version 3 of the License, or | |
10 | // (at your option) any later version. | |
11 | // | |
12 | // starlight is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | // | |
17 | // You should have received a copy of the GNU General Public License | |
18 | // along with starlight. If not, see <http://www.gnu.org/licenses/>. | |
19 | // | |
20 | /////////////////////////////////////////////////////////////////////////// | |
21 | // | |
22 | // File and Version Information: | |
23 | // $Rev:: $: revision of last commit | |
24 | // $Author:: $: author of last commit | |
25 | // $Date:: $: date of last commit | |
26 | // | |
27 | // Description: | |
28 | // | |
29 | // | |
30 | // | |
31 | /////////////////////////////////////////////////////////////////////////// | |
32 | ||
33 | ||
34 | #include "eventfilewriter.h" | |
35 | #include "starlightparticlecodes.h" | |
36 | ||
37 | ||
38 | //______________________________________________________________________________ | |
39 | eventFileWriter::eventFileWriter() | |
40 | : fileWriter() | |
41 | ,_writeFullPythia(false) | |
42 | { } | |
43 | ||
44 | ||
45 | //______________________________________________________________________________ | |
46 | eventFileWriter::eventFileWriter(std::string filename) | |
47 | : fileWriter(filename) | |
48 | { } | |
49 | ||
50 | ||
51 | //______________________________________________________________________________ | |
52 | int eventFileWriter::writeEvent(upcEvent &event, int eventnumber) | |
53 | { | |
54 | ||
55 | int numberoftracks = 0; | |
56 | if(_writeFullPythia) | |
57 | { | |
58 | numberoftracks = event.getParticles()->size(); | |
59 | } | |
60 | else | |
61 | { | |
62 | for(unsigned int i = 0; i<event.getParticles()->size(); ++i) | |
63 | { | |
64 | if(event.getParticles()->at(i).getStatus() >= 0) numberoftracks++; | |
65 | } | |
66 | } | |
67 | ||
68 | // int _numberOfVertices = event.getVertices()->size(); | |
69 | ||
70 | // sometimes we don't have tracks due to wrongly picked W , check it | |
71 | if(numberoftracks){ | |
72 | eventnumber++; | |
73 | ||
74 | _fileStream << "EVENT: " << eventnumber << " " << numberoftracks << " " << 1 << std::endl; | |
75 | if(event.getGammaEnergies()->size()) _fileStream << "GAMMAENERGIES:"; | |
76 | for(unsigned int n = 0; n < event.getGammaEnergies()->size(); n++) | |
77 | { | |
78 | _fileStream << " " << event.getGammaEnergies()->at(n); | |
79 | } | |
80 | if(event.getGammaEnergies()->size()) _fileStream<< std::endl; | |
81 | _fileStream <<"VERTEX: "<<0.<<" "<<0.<<" "<<0.<<" "<<0.<<" "<<1<<" "<<0<<" "<<0<<" "<<numberoftracks<<std::endl; | |
82 | ||
83 | int ipart = 0; | |
84 | std::vector<starlightParticle>::const_iterator part = (event.getParticles())->begin(); | |
85 | ||
86 | for (part = event.getParticles()->begin(); part != event.getParticles()->end(); part++, ipart++) | |
87 | { | |
88 | if(!_writeFullPythia) | |
89 | { | |
90 | if((*part).getStatus() < 0) continue; | |
91 | } | |
92 | _fileStream << "TRACK: " << " " << starlightParticleCodes::jetsetToGeant((*part).getPdgCode()) <<" "<< (*part).GetPx() << " " << (*part).GetPy() | |
93 | << " "<< (*part).GetPz() << " " << eventnumber << " " << ipart << " " << 0 << " " | |
94 | << (*part).getPdgCode(); | |
95 | ||
96 | if(_writeFullPythia) | |
97 | { | |
98 | // std::cout << (*part).getFirstDaughter() << std::endl; | |
99 | lorentzVector vtx = (*part).getVertex(); | |
100 | _fileStream << " " << vtx.GetPx() << " " << vtx.GetPy() << " " << vtx.GetPz() << " " << vtx.GetE(); | |
101 | _fileStream << " " << (*part).getFirstParent() << " " << (*part).getLastParent() << " " << (*part).getFirstDaughter() << " " << (*part).getLastDaughter() << " " << (*part).getStatus(); | |
102 | } | |
103 | ||
104 | _fileStream <<std::endl; | |
105 | } | |
106 | } | |
107 | ||
108 | return 0; | |
109 | } | |
110 | ||
111 | ||
112 | //______________________________________________________________________________ | |
113 | // Output from the pythia based generation... | |
114 | // if (PythiaOutput==true) { | |
115 | // | |
116 | // for (int t=0;t<(*VD)._numberOfVertices;t++) { | |
117 | // outputfile <<"VERTEX: "<<(*VD)._vertx[t]/10.<<" "<<(*VD)._verty[t]/10.<<" "<<(*VD)._vertz[t]/10.<<" "<<0.<<" "<<1<<" "<<0<<" "<<0<<" "<<_numberOfTracks<<endl; //convert from mm to cm for Geant | |
118 | // } | |
119 | // | |
120 | // for (int i=0;i<_numberOfTracks;i++) { | |
121 | // outputfile << "TRACK: " <<" "<<jtog((*VD)._charge[i]*(*VD)._fsParticle[i])<<" "<<(*VD).px[i]<<" "<<(*VD).py[i]<<" "<<(*VD).pz[i]<<" "<<eventnumber<<" "<<i<<" "<<(*VD)._mother1[i]<<" "<<(*VD)._mother2[i]<<" "<<(*VD)._daughter1[i]<<" "<<(*VD)._daughter2[i]<<" "<<(*VD)._charge[i]*(*VD)._fsParticle[i]<<endl; | |
122 | // }//end of track for loop | |
123 | // }//if pythiatrue loop |