10 #include <TDirectory.h>
12 #include <adst/RecEventFile.h>
13 #include <adst/DetectorGeometry.h>
14 #include <adst/FileInfo.h>
15 #include <adst/RecEvent.h>
16 #include <adst/FDEvent.h>
17 #include <adst/GenShower.h>
33 const unsigned int nRef = refFile.GetNEvents();
34 const unsigned int nTest = testFile.GetNEvents();
35 isDiag(nTest, nRef,
"Same no. of events");
37 RecEvent* refRE =
new RecEvent();
38 RecEvent* testRE =
new RecEvent();
42 for (
unsigned int iEvent = 0; iEvent < nRef && iEvent < nTest; ++iEvent)
44 ostringstream eventNoStr;
46 string eventNo = string(
" (event ") + eventNoStr.str() + string(
")");
48 diag(
string(
"Testing event ") + eventNoStr.str());
53 diag(
string(
"This event has auger id ") + refRE->GetAugerId());
64 cmpFileInfo(
const RecEventFile& refFile,
const RecEventFile& testFile)
68 if (!refInfo || !testInfo)
72 isDiag(testInfo->HasMC(), refInfo->HasMC(),
"FileInfo->HasMC");
73 isDiag(testInfo->HasVEMTraces(), refInfo->HasVEMTraces(),
"FileInfo->HasVEMTraces");
74 isDiag(testInfo->HasSdAllTraces(), refInfo->HasSdAllTraces(),
"FileInfo->HasSdAllTraces");
75 isDiag(testInfo->HasFdTraces(), refInfo->HasFdTraces(),
"FileInfo->HasFdTraces");
76 isDiag(testInfo->HasFdSpotRecTraces(), refInfo->HasFdSpotRecTraces(),
"FileInfo->HasFdSpotRecTraces");
77 ok(testInfo->GetHost() != string(
""),
"FileInfo->GetHost");
78 ok(testInfo->GetUser() != string(
""),
"FileInfo->GetUser");
79 ok(testInfo->GetOfflineConfiguration() != string(
""),
"FileInfo->GetOfflineConfiguration");
80 ok(testInfo->GetRecEventVersion() != string(
""),
"FileInfo->GetRecEventVersion");
81 isDiag(testInfo->GetLDFType(), refInfo->GetLDFType(),
"FileInfo->GetLDFType");
82 isDiag(testInfo->GetLDFType(), refInfo->GetLDFType(),
"FileInfo->GetLDFType");
95 isDiag(test.GetDetector().GetTemperature(),
96 ref.GetDetector().GetTemperature(),
97 "detector.GetTemperature");
98 isDiag(test.GetDetector().GetPressure(),
99 ref.GetDetector().GetPressure(),
100 "detector.GetPressure");
101 isDiag(test.GetDetector().GetTemperaturePressureGPSSeconds(),
102 ref.GetDetector().GetTemperaturePressureGPSSeconds(),
103 "detector.GetTemperaturePressureGPSSeconds");
104 isDiag(test.GetDetector().HasWeatherStationData(),
105 ref.GetDetector().HasWeatherStationData(),
106 "detector.HasWeatherStationData");
107 isDiag(test.GetDetector().HasMieDatabase(),
108 ref.GetDetector().HasMieDatabase(),
109 "detector.HasMieDatabase");
110 isDiag(test.GetDetector().HasVAODs(),
111 ref.GetDetector().HasVAODs(),
112 "detector.HasVAODs");
113 isDiag(test.GetDetector().HasOverallQualityDatabase(),
114 ref.GetDetector().HasOverallQualityDatabase(),
115 "detector.HasOverallQualityDatabase");
116 isDiag(test.GetDetector().GetQDBHorizonalUniformity(),
117 ref.GetDetector().GetQDBHorizonalUniformity(),
118 "detector.GetQDBHorizonalUniformity");
119 isDiag(test.GetDetector().GetQDBCloudCoverage(),
120 ref.GetDetector().GetQDBCloudCoverage(),
121 "detector.GetQDBCloudCoverage");
122 isDiag(test.GetDetector().GetQDBMinCloudBaseHeight(),
123 ref.GetDetector().GetQDBMinCloudBaseHeight(),
124 "detector.GetQDBMinCloudBaseHeight");
125 isDiag(test.GetDetector().GetQDBMinCloudBaseDepth(),
126 ref.GetDetector().GetQDBMinCloudBaseDepth(),
127 "detector.GetQDBMinCloudBaseDepth");
128 isDiag(test.GetDetector().HasAerosolData(),
129 ref.GetDetector().HasAerosolData(),
130 "detector.HasAerosolData");
131 isDiag(test.GetDetector().HasLidarData(),
132 ref.GetDetector().HasLidarData(),
133 "detector.HasLidarData");
134 isEpsDiag(test.GetDetector().GetVAODsAtReferenceHeight().size(),
135 ref.GetDetector().GetVAODsAtReferenceHeight().size(),
137 "detector.GetVAODsAtReferenceHeight().size");
139 const TBits refEyes = ref.GetDetector().GetActiveEyes();
140 const TBits testEyes = test.GetDetector().GetActiveEyes();
141 isDiag(testEyes.GetNbits(), refEyes.GetNbits(),
"# of telescopes");
142 for (
unsigned int eye = 0; eye < refEyes.GetNbits(); ++eye) {
143 ostringstream eyeNoS;
145 diag(
"Testing eye " + eyeNoS.str());
146 if (refEyes.TestBitNumber(eye)) {
147 isDiag(test.GetDetector().GetSDFDTimeOffset(eye),
148 ref.GetDetector().GetSDFDTimeOffset(eye),
149 "GetSDFDTimeOffset");
150 isDiag(test.GetDetector().HasAerosolData(eye),
151 ref.GetDetector().HasAerosolData(eye),
152 "detector.HasAerosolData(eye)");
153 isEpsDiag(test.GetDetector().GetVAODAtReferenceHeight(eye),
154 ref.GetDetector().GetVAODAtReferenceHeight(eye),
156 "detector.GetVAODAtReferenceHeight(eye)");
157 isDiag(test.GetDetector().HasVAOD(eye),
158 ref.GetDetector().HasVAOD(eye),
159 "detector.HasVAOD(eye)");
160 isDiag(test.GetDetector().GetPointingIdsForEye(eye).size(),
161 ref.GetDetector().GetPointingIdsForEye(eye).size(),
162 "detector.GetPointingIdsForEye(eye)");
163 isDiag(test.GetDetector().HasLidarData(eye),
164 ref.GetDetector().HasLidarData(eye),
165 "detector.HasLidarData(eye)");
174 if (test.GetDetector().HasLidarData(eye) &&
175 ref.GetDetector().HasLidarData(eye)) {
176 isDiag(test.GetDetector().GetAerosolData(eye).GetMieAttenuationLength(),
177 ref.GetDetector().GetAerosolData(eye).GetMieAttenuationLength(),
178 "aerosols.att_length");
179 isDiag(test.GetDetector().GetAerosolData(eye).GetMieAttenuationHeight(),
180 ref.GetDetector().GetAerosolData(eye).GetMieAttenuationHeight(),
181 "aerosols.att_height");
184 if (test.GetDetector().HasLidarData(eye) &&
185 ref.GetDetector().HasLidarData(eye)) {
186 isDiag(test.GetDetector().GetLidarData(eye).GetCloudCoverage(),
187 ref.GetDetector().GetLidarData(eye).GetCloudCoverage(),
188 "lidarData.GetCloudCoverage");
189 isDiag(test.GetDetector().GetLidarData(eye).GetCloudHeight(),
190 ref.GetDetector().GetLidarData(eye).GetCloudHeight(),
191 "lidarData.GetCloudHeight");
192 isDiag(test.GetDetector().GetLidarData(eye).GetCloudThickness(),
193 ref.GetDetector().GetLidarData(eye).GetCloudThickness(),
194 "lidarData.GetCloudThickness");
195 isDiag(test.GetDetector().GetLidarData(eye).GetCloudDepth(),
196 ref.GetDetector().GetLidarData(eye).GetCloudDepth(),
197 "lidarData.GetCloudDepth");
198 isDiag(test.GetDetector().GetLidarData(eye).GetCloudSlantThickness(),
199 ref.GetDetector().GetLidarData(eye).GetCloudSlantThickness(),
200 "lidarData.GetCloudSlantThickness");
201 isDiag(test.GetDetector().GetLidarData(eye).GetCloudVAOD(),
202 ref.GetDetector().GetLidarData(eye).GetCloudVAOD(),
203 "lidarData.GetCloudVAOD");
204 isDiag(test.GetDetector().GetLidarData(eye).GetLidarRange(),
205 ref.GetDetector().GetLidarData(eye).GetLidarRange(),
206 "lidarData.GetLidarRange");
210 isDiag(test.GetDetector().GetBadPixelSet().size(),
211 ref.GetDetector().GetBadPixelSet().size(),
215 const TBits refStations = ref.GetDetector().GetActiveStations();
216 const TBits testStations = test.GetDetector().GetActiveStations();
218 const std::vector<SdRecStation>& stations = ref.GetSDEvent().GetStationVector();
219 for (
unsigned int i = 0; i != stations.size(); ++i) {
220 if (stations[i].IsDense()) {
221 TVector3 ref_pos = ref.GetDetector().GetStationPosition(stations[i].GetId());
222 TVector3 test_pos = test.GetDetector().GetStationPosition(stations[i].GetId());
224 name <<
"station " << stations[i].GetId() <<
" pos ";
225 isDiag(ref_pos.x(),test_pos .x(), name.str());
226 isDiag(ref_pos.y(),test_pos .y(), name.str());
230 for (
unsigned int id = 0;
id < refStations.GetNbits(); ++id) {
232 isDiag(testStations.TestBitNumber(
id), refStations.TestBitNumber(
id), name.str());
241 if (!refGeo || !testGeo)
248 isDiag(testGeo->GetNEyes(), refGeo->GetNEyes(),
"Same no of eyes in DetectorGeometry");
250 for (DetectorGeometry::ConstEyeIterator ieye = refGeo->EyesBegin(),
251 end = refGeo->EyesEnd(); ieye != end; ++ieye)
253 ok(testGeo->HasEye( ieye->first ),
"Has correct eye in detgeo");
254 if (!testGeo->HasEye(ieye->first))
257 isDiag(testGeo->GetEye(ieye->first).GetNumberOfMirrors(),
258 refGeo->GetEye(ieye->first).GetNumberOfMirrors(),
259 "eyeGeom.GetNumberOfMirrors");
260 isEpsDiag(testGeo->GetEye(ieye->first).GetEyePos(),
261 refGeo->GetEye(ieye->first).GetEyePos(), 1.e-6,
262 "eyeGeom.GetEyePos");
263 isDiag(testGeo->GetEye(ieye->first).GetEyeName(),
264 refGeo->GetEye(ieye->first).GetEyeName(),
265 "eyeGeom.GetEyeName");
266 isDiag(testGeo->GetEye(ieye->first).GetEyeNameAbbr(),
267 refGeo->GetEye(ieye->first).GetEyeNameAbbr(),
268 "eyeGeom.GetEyeNameAbbr");
269 isDiag(testGeo->GetEye(ieye->first).GetBackWallAngle(),
270 refGeo->GetEye(ieye->first).GetBackWallAngle(),
271 "eyeGeom.GetBackWallAngle");
272 isDiag(testGeo->GetEye(ieye->first).GetEyePhiZ(),
273 refGeo->GetEye(ieye->first).GetEyePhiZ(),
274 "eyeGeom.GetEyePhiZ");
275 isDiag(testGeo->GetEye(ieye->first).GetEyeThetaZ(),
276 refGeo->GetEye(ieye->first).GetEyeThetaZ(),
277 "eyeGeom.GetEyeThetaZ");
278 isDiag(testGeo->GetEye(ieye->first).GetTelescopeIDs(),
279 refGeo->GetEye(ieye->first).GetTelescopeIDs(),
280 "eyeGeom.GetTelescopeIDs");
282 for (EyeGeometry::TelescopeIterator telescope = refGeo->GetEye(ieye->first).TelescopesBegin(),
283 end = refGeo->GetEye(ieye->first).TelescopesEnd();
284 telescope != end; ++telescope) {
285 ok(testGeo->GetEye(ieye->first).HasTelescope(telescope->first),
286 "Has correct telescope in detgeo");
287 if (!testGeo->GetEye(ieye->first).HasTelescope(telescope->first))
290 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetNumberOfPixels(),
291 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetNumberOfPixels(),
292 "telescopeGeom.GetNumberOfPixels");
293 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetFADCSize(),
294 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetFADCSize(),
295 "telescopeGeom.GetFADCSize");
296 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetFADCBinning(),
297 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetFADCBinning(),
298 "telescopeGeom.GetFADCBinning");
299 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPointingIds(),
300 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPointingIds(),
301 "telescopeGeom.GetPointingIds");
303 vector<TString> pointing =
304 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPointingIds();
306 for (vector<TString>::iterator it = pointing.begin(); it != pointing.end(); ++it) {
307 isEpsDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetElevation(*it),
308 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetElevation(*it),
310 "telescopeGeom.GetElevation");
311 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMinPhi(*it),
312 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMinPhi(*it),
313 "telescopeGeom.GetPixelMinPhi");
314 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMaxPhi(*it),
315 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMaxPhi(*it),
316 "telescopeGeom.GetPixelMaxPhi");
317 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMinOmega(*it),
318 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMinOmega(*it),
319 "telescopeGeom.GetPixelMinOmega");
320 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMaxOmega(*it),
321 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelMaxOmega(*it),
322 "telescopeGeom.GetPixelMaxOmega");
323 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelsPhi(*it),
324 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelsPhi(*it),
325 "telescopeGeom.GetPixelsPhi");
326 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelsOmega(*it),
327 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelsOmega(*it),
328 "telescopeGeom.GetPixelsOmega");
330 const TelescopeGeometry::PixelList_t& pixels_phi = telescope->second.GetPixelsPhi(*it);
331 for (
unsigned int i = 0; i != pixels_phi.size(); ++i) {
332 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).HasPixel(pixels_phi[i]),
333 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).HasPixel(pixels_phi[i]),
334 "telescopeGeom.HasPixel");
335 if (!testGeo->GetEye(ieye->first).GetTelescope(telescope->first).HasPixel(pixels_phi[i]))
338 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelPhi(pixels_phi[i], *it),
339 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelPhi(pixels_phi[i], *it),
340 "telescopeGeom.GetPixelPhi");
341 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelOmega(pixels_phi[i], *it),
342 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelOmega(pixels_phi[i], *it),
343 "telescopeGeom.GetPixelOmega");
346 const TelescopeGeometry::PixelList_t& pixels_omega = telescope->second.GetPixelsOmega(*it);
347 for (
unsigned int i = 0; i != pixels_omega.size(); ++i) {
348 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).HasPixel(pixels_omega[i]),
349 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).HasPixel(pixels_omega[i]),
350 "telescopeGeom.HasPixel");
351 if (!testGeo->GetEye(ieye->first).GetTelescope(telescope->first).HasPixel(pixels_omega[i]))
354 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelPhi(pixels_omega[i], *it),
355 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelPhi(pixels_omega[i], *it),
356 "telescopeGeom.GetPixelPhi");
357 isDiag(testGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelOmega(pixels_omega[i], *it),
358 refGeo->GetEye(ieye->first).GetTelescope(telescope->first).GetPixelOmega(pixels_omega[i], *it),
359 "telescopeGeom.GetPixelOmega");
365 isDiag(testGeo->GetNStations(), refGeo->GetNStations(),
"Same no of stations in DetectorGeometry");
367 DetectorGeometry::ConstStationPosMap pos = testGeo->GetStations();
368 for (DetectorGeometry::StationPosMapConstIterator
is = refGeo->GetStationsBegin(),
369 end = refGeo->GetStationsEnd();
is != end; ++
is)
371 const unsigned int id =
is->first;
372 if (!
ok(pos.find(
id) != pos.end(),
"station exists in test geo")) {
374 msg <<
"Station " <<
id <<
" is missing from test DetectorGeometry";
378 isDiag(testGeo->GetStationName(
id), refGeo->GetStationName(
id),
"Station name identical");
379 isEpsDiag(testGeo->GetStationPosition(
id), refGeo->GetStationPosition(
id), 0.001,
"Station position identical");
380 isDiag(testGeo->GetHexagon(
id), refGeo->GetHexagon(
id),
"Station hexagon");
381 isDiag(testGeo->GetFdTriggerReadoutSection(
id), refGeo->GetFdTriggerReadoutSection(
id),
"Station's FD readout section");
392 cmpEvent(
const RecEvent& ref,
const RecEvent& test)
396 isDiag(test.GetNEyes(), ref.GetNEyes(),
"Same no. of eyes");
399 for (RecEvent::ConstEyeIterator iEye = ref.EyesBegin();
400 iEye != ref.EyesEnd(); ++iEye)
402 if (
ok(test.HasEye(iEye->GetEyeId()),
"Eye exists")) {
403 cmpFDEvent(*iEye, test.GetEye(iEye->GetEyeId()));
407 m <<
"Missing eye from test event: " << iEye->GetEyeId();
413 cmpSDEvent(ref.GetSDEvent(), test.GetSDEvent());
426 isDiag(test.GetEventId(), ref.GetEventId(),
"RecEvent.GetEventId");
427 isDiag(test.GetYYMMDD(), ref.GetYYMMDD(),
"RecEvent.GetYYMMDD");
428 isDiag(test.GetHHMMSS(), ref.GetHHMMSS(),
"RecEvent.GetHHMMSS");
429 isDiag(test.GetMJD(), ref.GetMJD(),
"RecEvent.GetMJD");
431 isDiag(test.GetDetector().HasMieDatabase(), ref.GetDetector().HasMieDatabase(),
"Detector.HasMieDatabase");
442 isDiag(test.GetPrimary(), ref.GetPrimary(),
"genShower.GetPrimary");
443 isDiag(test.GetPrimaryName(), ref.GetPrimaryName(),
"genShower.GetPrimaryName");
444 isDiag(test.GetShortPrimaryName(), ref.GetShortPrimaryName(),
"genShower.GetShortPrimaryName");
445 isDiag(test.GetElecEnergy(), ref.GetElecEnergy(),
"genShower.GetElecEnergy");
446 isDiag(test.GetX1(), ref.GetX1(),
"genShower.GetX1");
447 isDiag(test.GetXmax(), ref.GetXmax(),
"genShower.GetXmax");
448 isDiag(test.GetdEdXmax(), ref.GetdEdXmax(),
"genShower.GetdEdXmax");
449 isDiag(test.GetElectrons(), ref.GetElectrons(),
"genShower.GetElectrons");
450 isDiag(test.GetEnergyDeposit(), ref.GetEnergyDeposit(),
"genShower.GetEnergyDeposit");
451 isDiag(test.GetDepth(), ref.GetDepth(),
"genShower.GetDepth");
452 isDiag(test.GetShowerAge(), ref.GetShowerAge(),
"genShower.GetShowerAge");
void cmpSDEvent(const SDEvent &ref, const SDEvent &test)
void cmpDetectorGeometry(const RecEventFile &refFile, const RecEventFile &testFile)
bool is(const double a, const double b)
void diag(const std::string &msg)
FileInfo * readFileInfo(const RecEventFile &file, const std::string &title)
void cmpGenShower(const GenShower &ref, const GenShower &test)
void cmpFDEvent(const FDEvent &ref, const FDEvent &test)
bool isEpsDiag(const double a, const double b, const double thisEps, const std::string &name)
void cmpEventGlobalInfo(const RecEvent &ref, const RecEvent &test)
void cmpDetector(const RecEvent &ref, const RecEvent &test)
void cmpRecEventFile(RecEventFile &refFile, RecEventFile &testFile)
bool isDiag(const double a, const double b, const std::string &name)
DetectorGeometry * readDetectorGeometry(const RecEventFile &file, const std::string &title)
void cmpFileInfo(const RecEventFile &refFile, const RecEventFile &testFile)
void cmpEvent(const RecEvent &ref, const RecEvent &test)