9 #ifndef ACCLAIM_CLUSTERING_H 10 #define ACCLAIM_CLUSTERING_H 12 #include "UsefulAdu5Pat.h" 13 #include "AnitaConventions.h" 15 #include "AnitaEventSummary.h" 18 #include "TEntryList.h" 19 #include "Math/Minimizer.h" 20 #include "Math/Functor.h" 21 #include "AcclaimOpenMP.h" 35 namespace Clustering {
37 const Double_t default_sigma_theta = 0.25;
38 const Double_t default_sigma_phi = 0.5;
39 const Double_t default_range_easting_northing = 750e3;
40 const Double_t default_horizon_distance = 750e3;
43 void getAngularResolution(
double snr,
double& sigma_theta,
double& sigma_phi);
44 TCanvas* drawAngularResolutionModel(
double maxSnr);
47 Bool_t isVaguelyNearMcMurdo(
const T& t){
48 return t.longitude >= 150 && t.longitude < 180 && t.latitude >= -85 && t.latitude < -75;
51 Bool_t inSandbox(
const T& t){
52 return t.longitude >= -90 && t.longitude < 90;
90 Double_t* dThetaCluster;
91 Double_t* dPhiCluster;
93 Bool_t eventEventClustering;
112 Event(
int pol,
int peakInd,
double peak_phi,
double peak_theta,
int nT, UInt_t eventNumber, Int_t
run,
113 double anita_longitude,
double anita_latitude,
double anita_altitude,
double anita_heading,
double coherent_filtered_snr);
118 void resetClusteringNumbers();
122 double logLikelihoodFromPoint(
double sourceLon,
double sourceLat,
double sourceAlt,
bool addOverHorizonPenalty=
false)
const;
124 double logLikelihoodFromPoint(
const T& point,
bool addOverHorizonPenalty=
false)
const {
125 return logLikelihoodFromPoint(point.longitude, point.latitude, point.altitude, addOverHorizonPenalty);
128 inline double cartesianSeparation(
const T& event2){
129 double d0 =
centre[0] - event2.centre[0];
130 double d1 =
centre[1] - event2.centre[1];
131 double d2 =
centre[2] - event2.centre[2];
132 return TMath::Sqrt(d0*d0 + d1*d1 + d2*d2);
142 return (eventNumber < other.eventNumber);
162 McEvent(
double weight,
double energy,
int pol,
int peakInd,
double peak_phi,
double peak_theta,
int nT, UInt_t eventNumber, Int_t
run,
163 double anita_longitude,
double anita_latitude,
double anita_altitude,
double anita_heading,
double coherent_filtered_snr);
217 static const Int_t SmallClusterSizeThreshold = 100;
222 void doClustering(
const char* dataGlob,
const char* mcGlob,
const char* outFileName,
bool useAcclaimFiles=
true);
223 void testSmallClusters(
const char* dataGlob,
const char* outFileName,
int clusterSizeMin=5,
int clusterSizeMax=16,
int nAttempts=100);
225 bool getUseBaseList(){
return fUseBaseList;}
226 void setUseBaseList(
bool useBaseList){
227 fUseBaseList = useBaseList;
230 void setCut(TCut cut){ fCut = cut; }
231 void setCutHical(
bool hc){ fCutHical = hc; }
232 void setSelfLLMax(
double llmax){ fSelfLLMax = llmax; }
233 void setSurfaceDistThresholdKm(Double_t dist){ surfaceDistThresholdKm = dist; }
234 void setPercentOfMC(Int_t percent){ fPercentOfMC = percent; }
236 bool getDebug(){
return fDebug;}
237 void setDebug(
bool db){fDebug = db;}
245 fThermalChainCuts.push_back(c);
246 return fThermalChainCuts.size();
249 bool fStoreUnclusteredHistograms;
252 Double_t getDistSqEventCluster(
const Event& event,
const Cluster& cluster);
253 Double_t getAngDistSqEventCluster(
const Event& event,
const Cluster& cluster);
254 void getDeltaThetaDegDeltaPhiDegEventCluster(
const Event& event,
const Cluster& cluster, Double_t& deltaThetaDeg, Double_t& deltaPhiDeg);
257 Long64_t readInSummaries(
const char* summaryGlob);
258 Long64_t readInTMVATreeSummaries(
const char* summaryGlob,
bool isMC);
259 void readInSummariesForTesting(
const char* summaryGlob);
260 void pickEventsFromList(
int n_in_cluster);
263 void assignSingleEventToCloserCluster(Int_t eventInd, Int_t isMC,
Cluster& cluster, Int_t z,
double llEventCut = -1);
264 void readInBaseList();
268 void assignMcEventsToClusters();
269 void setInitialBaseClusters();
270 void makeSummaryTrees();
271 void addToHistograms(TH2D* h, TH2D* h2);
272 void resetClusters();
273 Double_t getSumOfMcWeights();
277 Double_t dMin(
const Event* event1,
const Event* event2);
278 Double_t dSum(
const Event* event1,
const Event* event2);
279 Double_t dAsym(
const Event* event1,
const Event* event2);
280 Double_t dFit(
const Event* event1,
const Event* event2);
282 void testTriangleInequality();
283 void testSmallClustersFromPointSource();
284 Int_t removeLargeBasesNearMcMurdo();
286 void doBaseEventClustering();
287 void doEventEventClustering();
289 void doMcEventClustering();
290 void doMcBaseClustering();
291 bool considerBin(
const Event& event, Int_t bx, Int_t by,
double& easting,
double& northing);
292 void nearbyEvents2(UInt_t eventInd, std::vector<UInt_t>& nearbyEvents);
294 void makeAndWriteNSquaredEventEventHistograms();
295 Double_t evalPairLogLikelihoodAtLonLat(
const Double_t* params);
300 std::vector<const Acclaim::Clustering::Event*> fFitEvent1s;
301 std::vector<const Acclaim::Clustering::Event*> fFitEvent2s;
302 Int_t fMaxFitterAttempts;
306 TEntryList* fEntryList;
310 std::vector<Double_t> fFitEastings;
311 std::vector<Double_t> fFitNorthings;
312 const Int_t numMcDivisions;
315 std::vector<Double_t> llEventCuts;
316 Double_t surfaceDistThresholdKm;
317 Bool_t fEventsAlreadyClustered;
319 std::vector<std::vector<Acclaim::Clustering::Cluster> >clusters;
321 std::vector<Acclaim::Clustering::Event> events;
322 std::vector<Acclaim::Clustering::McEvent> mcEvents;
323 std::vector<std::vector<std::vector<UInt_t> > > fLookupEN;
328 std::vector<Double_t> fEventEastings;
329 std::vector<Double_t> fEventNorthings;
331 std::vector<TH2DAntarctica*> hUnclusteredEvents;
337 TGraph* grTestMinimizerWalk;
338 TGraph* grTestMinimizerValue;
339 TGraph* grTestMinimumPosition;
340 std::vector<ROOT::Math::Minimizer*> fMinimizers;
341 std::vector<ROOT::Math::Functor> fFunctors;
342 Int_t fROOTgErrorIgnoreLevel;
343 bool fDrawNewNearbyEventsHistograms;
344 bool fReadInBaseList;
346 std::vector<TCut> fThermalChainCuts;
Double_t longitude
cluster center latitude
Double_t sigmaTheta
the adjustment from traceBackToContinent
Int_t llEventCutInd
Where am I in the cluster array?
Double_t nearestKnownBaseLogLikelihood
Remove huge clusters near MCM before doing event-to-event clustering.
Int_t nThresholds
resolution associated with this snr?
Double_t thetaAdjustmentRequired
reconstructed phi
Int_t nearestKnownBaseCluster
How far to the nearest known base?
Double_t latitude
Does not persist /// Center in cartesian.
void resetClusteringNumbers()
/// Which event seeded the cluster?
TArrowAntarctica * makeArrowFromAnitaToEvent()
Double_t centre[3]
Which peak in the map does this represent?
Int_t antarcticaHistBin
What's the event number of the nearest surface neighbour by LL?
Double_t nearestEventSurfaceDistanceKm
If the event is above the continent surface, this may be non-zero.
Double_t llEventCut
which entry in the llEventCut array does this correspond to?
Double_t sigmaPhi
resolution associated with this snr?
Double_t nearestEventSurfaceLogLikelihood
What's the event number of the nearest surface neighbour?
Int_t knownBase
How many MC events does this cluster contain?
size_t addCut(const TCut c)
Int_t nearestKnownBaseClusterSurface
How far to the nearest known base?
UsefulAdu5Pat usefulPat
Which global bin in the TH2DAntarctica?
Double_t nearestKnownBaseSurfaceSeparationKm
How far to the nearest known base?
void setupUsefulPat(bool calculateNow=true)
Namespace which wraps everything in the library.
Bool_t fDebug
/// Only construct this once
McEvent(Int_t nT=0)
MC information.
Int_t numDataEvents
cluster center altitude
Double_t theta
Anita's position.
Double_t longitude
latitude
UInt_t nearestEventSurfaceEventNumber
How far away to the nearest event, in kilometers?
Double_t latitude
/// Cartesian coordinates, does not persist in ROOT
Int_t antarcticaHistBin
and what's the value of that cut?
UInt_t nearestEventSurfaceLLEventNumber
What's the fitted log likelihood to the nearest surface neighbour?
Double_t selfLogLikelihood
How far to the nearest known base?
Double_t altitude
longitude
As UsefulAnitaEvent is to RawAnitaEvent, UsefulAdu5Pat is to Adu5Pat. Well not quite as useful but yo...
Same as event, but with an energy and a weight.
Workhorse class: groups events into clusters around bases and other events using the log likelihood m...
Int_t seedEvent
/// Which global bin in the TH2DAntarctica?
Double_t altitude
cluster center longitude
AnitaEventSummary::PayloadLocation anita
northing
A position on the continent, with which a bunch of events are associated.
Common analysis format between UCorrelator and Acclaim.
AnitaPol::AnitaPol_t pol
Run.
bool operator<(const Event &other) const
Minimum required information about an ANITA event to be clustered.
Double_t energy
MC information.
Int_t index
Known base == 0, Pseudo-base == 1.
Draw an arrow between two lon/lat points.
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.
Double_t sumMcWeights
How many data events does this cluster contain?
void setNThresholds(int n)
Double_t phi
reconstructed theta
Double_t easting
longitude
Int_t peakIndex
Polarization.