11 #include <fwk/LocalCoordinateSystem.h>
12 #include <fwk/CentralConfig.h>
14 #include <sdet/SDetector.h>
15 #include <sdet/Station.h>
17 #include <evt/ShowerRecData.h>
18 #include <evt/ShowerSRecData.h>
20 #include <sevt/SdFootprintData.h>
23 #include <utl/ErrorLogger.h>
24 #include <utl/AugerUnits.h>
31 using namespace SdFootprintAnalyzerNS;
44 static const sdet::SDetector& sdetector = det::Detector::GetInstance().GetSDetector();
64 fMinProjDistForSpeed(1000),
65 fRecomputeBarycenter(false)
80 INFO(
"SdFootprintAnalyzer::Init()");
83 CentralConfig::GetInstance()->
GetTopBranch(
"SdFootprintAnalyzerOG");
97 cout <<
" Config parameters: " << endl
98 <<
"\t Verbose: " <<
fVerbose << endl
111 INFO(
"SdFootprintAnalyzer::Run()");
114 INFO(
"No sd event. Skipping.");
117 SEvent & theSEvent =
event.GetSEvent();
123 event.GetRecShower().MakeSRecShower();
125 if(
fVerbose) cout <<
" Barycenter info not available. Will be recomputed." << endl;
128 ShowerSRecData & theSRecShower =
event.GetRecShower().GetSRecShower();
143 if(
fVerbose) cout <<
" Footprint Variables: " << endl
144 <<
" Length : " << theFootprint.
GetLength() << endl
145 <<
" Width : " << theFootprint.
GetWidth() << endl
146 <<
" Ground Speed : " << theFootprint.
GetSpeed() << endl
148 <<
" Alignment : " << theFootprint.
GetAlignment() << endl;
172 det::Detector::GetInstance().GetSDetector();
174 det::Detector::GetInstance().GetSiteCoordinateSystem();
183 if (!sIt->IsCandidate() || !detStation.
IsInGrid())
185 barycenter += sIt->GetRecData().GetTotalSignal()*(detStation.
GetPosition()-origin);
186 wSum += sIt->GetRecData().GetTotalSignal();
189 if(
fVerbose) cout <<
" Computed Barycenter (X, Y, Z): ("
190 << (origin + barycenter/wSum).GetX(siteCs) <<
" , "
191 << (origin + barycenter/wSum).GetY(siteCs) <<
" , "
192 << (origin + barycenter/wSum).GetZ(siteCs) <<
")"
195 return origin + barycenter/wSum;
205 event.GetSEvent().SortStations(criterion);
213 det::Detector::GetInstance().GetSDetector();
217 if(
fVerbose) cout <<
" Selected Station Id (Id, GPSNs, Signal, AoP, TOT) " << endl;
224 if(!sIt->HasRecData()){
225 if(
fVerbose) cerr <<
" Warning! Candidate Station without Rec Data. Skiping..." << endl;
230 if(!sIt->GetRecData().GetAreaOverPeak()){
235 unsigned int Start = sIt->GetRecData().GetSignalStartSlot();
236 unsigned int Stop = sIt->GetRecData().GetSignalEndSlot();
237 for(
unsigned int slot=Start; slot<Stop; slot++){
238 AoP += vemChargeTrace[slot];
239 Peak = Peak > vemPeakTrace[slot] ? Peak : vemPeakTrace[slot];
241 AoP = Peak != 0 ? AoP/Peak : 0;
242 sIt->GetRecData().SetAreaOverPeak(AoP);
245 if(!sIt->HasTriggerData()){
246 if(
fVerbose) cerr <<
" Warning! Candidate Station without Trigger Data. Skiping..." << endl;
252 sIt->GetRecData().GetSignalStartTime(),
254 sIt->GetRecData().GetTotalSignal(),
255 sIt->GetRecData().GetAreaOverPeak(),
256 sIt->GetTriggerData().IsTimeOverThreshold(),
267 <<
" , " << thisSt.fTime.GetGPSNanoSecond()
268 <<
" , " << thisSt.fSignal
269 <<
" , " << thisSt.fAoP
270 <<
" , " << thisSt.fTOT
273 AllStations.push_back(thisSt);
295 int NStations=station.size();
297 if(
fVerbose>3) cout <<
" Computing Length and Width for " << NStations << endl;
299 for (
int i = 0; i<NStations; i++) {
301 double wi = station[i].fSignal;
304 Point StPos = station[i].fPos;
305 double xDiff = StPos.
GetX(fBaryCS);
306 Ixx += wi*xDiff*xDiff;
307 double yDiff = StPos.
GetY(fBaryCS);
308 Iyy += wi*yDiff*yDiff;
310 Ixy += wi*xDiff*yDiff;
312 ToTFrac+=station[i].fTOT/(double)NStations;
315 if(
fVerbose>4) cout <<
" Computed TOT Fraction " << ToTFrac << endl;
323 double lambda1 = (Ixx + Iyy +
sqrt(
pow(Ixx-Iyy,2.)+4.*Ixy*Ixy)) /2.;
324 double lambda2 = (Ixx + Iyy -
sqrt(
pow(Ixx-Iyy,2.)+4.*Ixy*Ixy)) /2.;
325 double l =
sqrt(lambda1/wSum);
326 double w =
sqrt(lambda2/wSum);
329 double q = (lambda1-Ixx)/Ixy;
332 double v1 = 1./
sqrt(1.+ q2);
333 double v2 = q/
sqrt(1.+ q2);
342 if(
fVerbose>3) cout <<
" Momentum matrix of footprint Stations: " << endl
343 <<
" wSum : " << wSum << endl
344 <<
" Ixx : " << Ixx << endl
345 <<
" Iyy : " << Iyy << endl
346 <<
" Ixy : " << Ixy << endl
347 <<
" lambda1 : " << lambda1 << endl
348 <<
" lambda2 : " << lambda2 << endl
349 <<
" q : " << q << endl
350 <<
" q2 : " << q2 << endl
351 <<
" v1 : " << v1 << endl
352 <<
" v2 : " << v2 << endl
353 <<
" Length : " << l << endl
354 <<
" Width : " << w << endl
365 for (
int i = 0; i<NStations; i++) {
366 Point StPosi = station[i].fPos;
367 station[i].fLp=v1*StPosi.
GetX(fBaryCS) + v2*StPosi.
GetY(fBaryCS);
375 for (
int i=0;i<NStations;i++){
377 for (
int j=0;j<i;j++) {
378 double dLPij = station[i].fLp-station[j].fLp;
383 double dTij = (tj - ti).GetInterval();
384 double speedij=dLPij/dTij;
385 double w=station[i].fSignal*station[j].fSignal;
387 spe2Sum+=speedij*speedij*w;
393 double speMean=speSum/wSum;
394 double spe2Mean=spe2Sum/wSum;
395 double Sspe=spe2Mean-speMean*speMean;
397 if(
fVerbose>3) cout <<
" Variables for speed computing: " << endl
398 <<
" Weight : " << wSum << endl
399 <<
" Speed Sum : " << speSum << endl
400 <<
" Square Speed Sum : " << spe2Sum << endl
401 <<
" Sspe : " << Sspe << endl
411 double phiDeg=acos(v1)/
deg;
413 theFootprint.
SetAlignment(SdFootprintEnumerations::eAligned);
415 for (
int i=0;i<NStations;i++){
416 double xi = station[i].fPos.GetX(fBaryCS);
417 double yi = station[i].fPos.GetY(fBaryCS);
420 for (
int j=0;j<NStations;j++){
422 double xj = station[j].fPos.GetX(fBaryCS);
423 double yj = station[j].fPos.GetY(fBaryCS);
426 double dXij = xj - xi;
427 double dYij = yj - yi;
428 double dTij = (tj - ti).GetInterval();
430 double vXij = dXij/dTij;
431 double vYij = dYij/dTij;
433 double Phi = 180. + atan2(vYij,vXij)/
deg;
434 if(Phi>180) Phi = Phi-360;
436 double alfa = fabs(phiDeg - Phi);
439 if(
fVerbose>3) cout <<
" Station " << station[i].fId <<
" and " << station[j].fId <<
" disaligned with angle " << alfa << endl;
440 if (theFootprint.
GetAlignment() == SdFootprintEnumerations::eIll) {
441 theFootprint.
SetAlignment(SdFootprintEnumerations::eNotAligned);
445 theFootprint.
SetAlignment(SdFootprintEnumerations::eIll);
464 int NStations = stations.size();
465 if(NStations==4 || NStations==5)
467 else if(NStations==6 || NStations==7)
472 for(
unsigned int i=0; i<st; i++){
473 AoPEarly+=stations[i].fAoP;
474 AoPLate+=stations[NStations-1-st].fAoP;
477 AoPAsym=AoPEarly-AoPLate;
487 vector<const PMT*> validPMTs;
490 det::Detector::GetInstance().GetSDetector().GetStation(station);
495 const int traceLength = vemTrace.
GetSize();
496 for (
int i = 0; i < traceLength; ++i)
500 pmtIt != station.
PMTsEnd(); ++pmtIt)
501 if (pmtIt->HasCalibData() && pmtIt->GetCalibData().IsTubeOk() &&
502 pmtIt->HasRecData() && pmtIt->GetRecData().HasVEMTrace() )
503 validPMTs.push_back(&(*pmtIt));
506 if (!validPMTs.empty()) {
507 const int nPMTs = validPMTs.size();
508 for (vector<const PMT*>::const_iterator pmtIt = validPMTs.begin();
509 pmtIt != validPMTs.end(); ++pmtIt) {
510 const PMTRecData & pmtRec=(*pmtIt)->GetRecData();
513 for (
int i = 0; i < traceLength; ++i)
514 vemTrace[i] += (pmtTrace[i] * PeakChargeFactor) / nPMTs;
double GetVEMCharge() const
Branch GetTopBranch() const
utl::TraceD & GetVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
Traces calibrated in VEM Peak.
void SetBarycenter(const utl::Point &bary)
Detector description interface for Station-related data.
Report success to RunController.
sevt::SdFootprintData & GetFootprintData()
Interface class to access to the SD Reconstruction of a Shower.
bool HasRecShower() const
Interface class to access to the SD part of an event.
PMTIterator PMTsBegin(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
begin PMT iterator for read/write
ShowerRecData & GetRecShower()
#define INFO(message)
Macro for logging informational messages.
bool IsInGrid(const SDetectorConstants::GridIndex index=SDetectorConstants::eStandard) const
Tells whether the station is in the regular triangular grid.
boost::filter_iterator< CandidateStationFilter, StationIterator > CandidateStationIterator
Iterator over candidate stations.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
ShowerSRecData & GetSRecShower()
A TimeStamp holds GPS second and nanosecond for some event.
utl::Point GetPosition() const
Tank position.
CandidateStationIterator CandidateStationsBegin()
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
class to hold data at Station level
class to hold reconstructed data at PMT level
double GetX(const CoordinateSystemPtr &coordinateSystem) const
double abs(const SVector< n, T > &v)
const utl::Point & GetBarycenter() const
PMTIterator PMTsEnd(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
end PMT iterator for read/write
void GetData(bool &b) const
Overloads of the GetData member template function.
double GetRho(const CoordinateSystemPtr &coordinateSystem) const
radius r in cylindrical coordinates (distance to z axis)
double GetY(const CoordinateSystemPtr &coordinateSystem) const
bool HasFootprintData() const
ResultFlag
Flag returned by module methods to the RunController.
double GetFADCBinSize() const
bool HasRecData() const
Check whether station reconstructed data exists.
boost::filter_iterator< PMTFilter, InternalConstPMTIterator > ConstPMTIterator
Iterator over station for read.
Detector description interface for SDetector-related data.
unsigned int GetFADCTraceLength() const
CandidateStationIterator CandidateStationsEnd()
const Station & GetStation(const int stationId) const
Get station by Station Id.
double GetVEMPeak() const
bool HasSRecShower() const
boost::filter_iterator< CandidateStationFilter, ConstStationIterator > ConstCandidateStationIterator