From c11aeec8d95e8fa3ef76e31f7d0d20ca0f4fff26 Mon Sep 17 00:00:00 2001 From: mfloris Date: Fri, 14 Mar 2014 17:30:01 +0100 Subject: [PATCH] Mapping instance copied of when reading from file + Track Clear This avoids problems when switching file (the mapping would be deleted). The AliNanoAODTrack track class now has a Clear method. --- PWG/DevNanoAOD/AliNanoAODTrack.cxx | 6 ++++++ PWG/DevNanoAOD/AliNanoAODTrack.h | 4 ++-- PWG/DevNanoAOD/AliNanoAODTrackMapping.cxx | 2 +- PWG/DevNanoAOD/AliNanoAODTrackMapping.h | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/PWG/DevNanoAOD/AliNanoAODTrack.cxx b/PWG/DevNanoAOD/AliNanoAODTrack.cxx index 1b206494bad..11cd8627e59 100644 --- a/PWG/DevNanoAOD/AliNanoAODTrack.cxx +++ b/PWG/DevNanoAOD/AliNanoAODTrack.cxx @@ -528,3 +528,9 @@ Bool_t AliNanoAODTrack::GetXYZAt(Double_t x, Double_t b, Double_t *r) const //_______________________________________________________ + +void AliNanoAODTrack::Clear(Option_t * /*opt*/) { + // empty storage + fVars.clear(); + fNVars = 0; +} diff --git a/PWG/DevNanoAOD/AliNanoAODTrack.h b/PWG/DevNanoAOD/AliNanoAODTrack.h index 7241cac3347..66f70879b0e 100644 --- a/PWG/DevNanoAOD/AliNanoAODTrack.h +++ b/PWG/DevNanoAOD/AliNanoAODTrack.h @@ -81,7 +81,8 @@ public: AliNanoAODTrack(const AliNanoAODTrack& trk); AliNanoAODTrack& operator=(const AliNanoAODTrack& trk); - // Storage helper methods + + virtual void Clear(Option_t * opt) ; // kinematics virtual Double_t OneOverPt() const { return (Pt() != 0.) ? 1./Pt() : -999.; } @@ -361,7 +362,6 @@ void SetChi2perNDF(Double_t chi2perNDF) { fVars[AliNanoAODTrackMapping::GetInsta private : - // Remove everything from here on? // Momentum & position // FIXME: the following was replaced by posx, posy, posz. Check if the names make sense diff --git a/PWG/DevNanoAOD/AliNanoAODTrackMapping.cxx b/PWG/DevNanoAOD/AliNanoAODTrackMapping.cxx index 81bba1a6ef5..d882b9ceac5 100644 --- a/PWG/DevNanoAOD/AliNanoAODTrackMapping.cxx +++ b/PWG/DevNanoAOD/AliNanoAODTrackMapping.cxx @@ -297,7 +297,7 @@ void AliNanoAODTrackMapping::LoadInstance() { if(tree) { tree->GetUserInfo()->Print(); - fInstance = (AliNanoAODTrackMapping*) tree->GetUserInfo()->FindObject("AliNanoAODTrackMapping"); + fInstance = new AliNanoAODTrackMapping(*((AliNanoAODTrackMapping*) tree->GetUserInfo()->FindObject("AliNanoAODTrackMapping"))); // Otherwise try to get it from the current directory std::cout << " from tree: " << fInstance << std::endl; diff --git a/PWG/DevNanoAOD/AliNanoAODTrackMapping.h b/PWG/DevNanoAOD/AliNanoAODTrackMapping.h index 44fc6411d81..256498594f3 100644 --- a/PWG/DevNanoAOD/AliNanoAODTrackMapping.h +++ b/PWG/DevNanoAOD/AliNanoAODTrackMapping.h @@ -153,7 +153,7 @@ private: static AliNanoAODTrackMapping * fInstance; //instance, needed for the singleton implementation static TString fMappingString; // the string which this class was initialized with - std::map fMapCstVar;// Map of indexes of custom variables: CASH THIS TO CONST INTs IN YOUR TASK TO AVOID CONTINUOUS STRING COMPARISONS + std::map fMapCstVar;// Map of indexes of custom variables: CACHE THIS TO CONST INTs IN YOUR TASK TO AVOID CONTINUOUS STRING COMPARISONS ClassDef(AliNanoAODTrackMapping, 1) }; -- 2.43.0