7 #include <det/Detector.h>
8 #include <sdet/SDetector.h>
9 #include <sdet/Station.h>
11 #include <evt/Event.h>
13 #include <fwk/RunController.h>
15 #include <sevt/SEvent.h>
16 #include <sevt/Station.h>
18 #include <sevt/PMTRecData.h>
19 #include <sevt/PMTSimData.h>
20 #include <sevt/PMTCalibData.h>
21 #include <sevt/StationSimData.h>
22 #include <sevt/StationRecData.h>
24 #include <utl/Trace.h>
25 #include <utl/AugerUnits.h>
26 #include <utl/MathConstants.h>
27 #include <utl/PhysicalConstants.h>
28 #include <utl/TimeStamp.h>
29 #include <utl/TabulatedFunction.h>
30 #include <utl/ErrorLogger.h>
31 #include <utl/Particle.h>
32 #include <utl/AugerCoordinateSystem.h>
33 #include <utl/MultiTimeDistribution.h>
35 #include <TObjArray.h>
38 #include <TGraphErrors.h>
39 #include <TMultiGraph.h>
57 using namespace G4TankSimulatorASCII;
68 std::string FileName=
"DataWriter.dat";
70 fTextFile =
new ofstream(FileName.c_str());
72 FileName=
"DataWriter.pulses";
73 fPulsesFile =
new ofstream(FileName.c_str());
85 INFO(
"DataWriter::No SEvent!!!!!!!!");
105 INFO(
"DataWriter::WriteInfo()");
108 sIt !=
event.StationsEnd(); ++sIt) {
111 if (!sIt->HasSimData())
116 const unsigned long numParticles =
120 unsigned int fPESum[2]={0,0};
121 unsigned int fADCSum_HG[2]={0,0};
122 unsigned int fADCSum_LG[2]={0,0};
128 if (!pmtIt->HasSimData())
continue;
136 if ( npe<=100 )
continue;
152 cout <<
"[ERROR]: Unrecognized PMT type. Terminating." << endl;
158 if (!pmtIt->HasSimData())
continue;
159 if (!pmtIt->GetSimData().HasPETimeDistribution(component))
continue;
169 unsigned int npe=peIt->get<1>();
170 fPESum[idetector]+= npe;
174 if ( pmtIt->GetSimData().HasFADCTrace(component) )
176 for (
int igain=0;igain<2;igain++)
183 if ( igain==0 ) fADCSum_HG[idetector]+=trace[i];
184 else fADCSum_LG[idetector]+=trace[i];
190 if ( !PrintPulses )
continue;
194 if ( idetector == 0 ) *fPulsesFile <<
" PE_trace_ASCII " << sIt->GetId() <<
" " << entries <<
" " << endl;
195 if ( idetector == 1 && pmtIt->GetId()==1 ) *fPulsesFile <<
" PE_trace_WCD1 " << sIt->GetId() <<
" " << entries <<
" " << endl;
196 if ( idetector == 1 && pmtIt->GetId()==2 ) *fPulsesFile <<
" PE_trace_WCD2 " << sIt->GetId() <<
" " << entries <<
" " << endl;
197 if ( idetector == 1 && pmtIt->GetId()==3 ) *fPulsesFile <<
" PE_trace_WCD3 " << sIt->GetId() <<
" " << entries <<
" " << endl;
203 double time=timeSlot*(peIt->get<0>());
204 unsigned int npe=peIt->get<1>();
205 *fPulsesFile<< time <<
" " << npe <<
" " ;
207 *fPulsesFile << endl;
211 if ( pmtIt->GetSimData().HasFADCTrace(component) )
213 for (
int igain=0;igain<2;igain++)
220 if ( trace[i]>0 ) entries++;
222 if ( idetector == 0 && igain==0 ) *fPulsesFile <<
" FADC_HG_ASCII " << sIt->GetId() <<
" " << entries <<
" " << endl;
223 if ( idetector == 0 && igain==1 ) *fPulsesFile <<
" FADC_LG_ASCII " << sIt->GetId() <<
" " << entries <<
" " << endl;
224 if ( idetector == 1 && igain==0 && pmtIt->GetId()==1 ) *fPulsesFile <<
" FADC_HG_WCD1 " << sIt->GetId() <<
" " << entries <<
" " << endl;
225 if ( idetector == 1 && igain==1 && pmtIt->GetId()==1 ) *fPulsesFile <<
" FADC_LG_WCD1 " << sIt->GetId() <<
" " << entries <<
" " << endl;
226 if ( idetector == 1 && igain==0 && pmtIt->GetId()==2 ) *fPulsesFile <<
" FADC_HG_WCD2 " << sIt->GetId() <<
" " << entries <<
" " << endl;
227 if ( idetector == 1 && igain==1 && pmtIt->GetId()==2 ) *fPulsesFile <<
" FADC_LG_WCD2 " << sIt->GetId() <<
" " << entries <<
" " << endl;
228 if ( idetector == 1 && igain==0 && pmtIt->GetId()==3 ) *fPulsesFile <<
" FADC_HG_WCD3 " << sIt->GetId() <<
" " << entries <<
" " << endl;
229 if ( idetector == 1 && igain==1 && pmtIt->GetId()==3 ) *fPulsesFile <<
" FADC_LG_WCD3 " << sIt->GetId() <<
" " << entries <<
" " << endl;
234 if ( trace[i]>0 ) *fPulsesFile << i <<
" " << trace[i] <<
" " ;
235 *fPulsesFile << endl;
239 *fPulsesFile << endl;
246 *fTextFile << sIt->GetId() <<
" " << fPESum[0] <<
" " << fPESum[1]
247 <<
" " << fADCSum_LG[0] <<
" " << fADCSum_HG[0] <<
" " << fADCSum_LG[1] <<
" " << fADCSum_HG[1]
251 msg <<
"StatId= " << sIt->GetId()<<
" " << fPESum[0] <<
" " << fPESum[1]
252 <<
" " << fADCSum_LG[0] <<
" " << fADCSum_HG[0] <<
" " << fADCSum_LG[1] <<
" " << fADCSum_HG[1]
254 msg <<
"------------------------------------------------------" <<endl<< endl;
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
int GetStart() const
First slot with data.
Station Level Simulated Data
total (shower and background)
Interface class to access to the SD part of an event.
Histogram class for time distributions with suppressed empty bins.
#define INFO(message)
Macro for logging informational messages.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
boost::filter_iterator< PMTFilter, InternalPMTIterator > PMTIterator
Iterator over station for read/write.
fwk::VModule::ResultFlag Run(evt::Event &theEvent)
Run: invoked once per event.
void WriteInfo(sevt::SEvent &theSEvent)
double GetBinning() const
Size of one slot.
int GetStop() const
Last slot with data (1 less than First slot if no data)
SparseIterator SparseEnd() const
ParticleIterator ParticlesBegin()
Beginning of simulated particles entering the station.
ResultFlag
Flag returned by module methods to the RunController.
StationIterator StationsBegin()
Beginning of all stations.
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
SparseIterator SparseBegin() const
Iterator over time slots with data in them (skips empty slots).
ParticleIterator ParticlesEnd()
End of simulated particles entering the station.
sevt::SEvent & GetSEvent()
boost::transform_iterator< InternalMapFunctor, InternalConstIterator, Tuple > SparseIterator