Fixing bugs.
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Mar 2010 13:57:52 +0000 (13:57 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Mar 2010 13:57:52 +0000 (13:57 +0000)
A crash was being caused by incorrect checking of pointers in AliHLTMUONDecision.
AliHLTMUONRootifierComponent was incorrectly making duplicate track objects if they were not found.
The deep copy of AliHLTMUONEvent was not maintaining the cross reference pointers correctly.
Fixing documentation for AliHLTMUONMansoTrack.
Improving checking for MUON module in AliHLTMUONAgent.

HLT/MUON/AliHLTMUONDecision.cxx
HLT/MUON/AliHLTMUONEvent.cxx
HLT/MUON/AliHLTMUONEvent.h
HLT/MUON/AliHLTMUONMansoTrack.h
HLT/MUON/OfflineInterface/AliHLTMUONAgent.cxx
HLT/MUON/OfflineInterface/AliHLTMUONRootifierComponent.cxx

index 387866e417eeb4efaebf9370570a4c3175f32a15..ed7fa70c0d725af4bd85e2aec7df57cf67736834 100644 (file)
@@ -255,11 +255,11 @@ void AliHLTMUONDecision::Print(Option_t* option) const
                                cout << setw(10) << "-";
                        }
                        
-                       if (decision->MansoTrackB() == NULL)
+                       if (decision->MansoTrackB() != NULL)
                        {
                                cout << setw(10) << decision->MansoTrackB()->Id();
                        }
-                       else if (decision->FullTrackB() == NULL)
+                       else if (decision->FullTrackB() != NULL)
                        {
                                cout << setw(10) << decision->FullTrackB()->Id();
                        }
index fe5b61b975b52f92de93b2ecdde0928612f8d868..f34695854974ff63b07e46168364c8c042fa94ab 100644 (file)
 /// for a single event together.
 
 #include "AliHLTMUONEvent.h"
+#include "AliHLTMUONRecHit.h"
+#include "AliHLTMUONTriggerRecord.h"
+#include "AliHLTMUONMansoTrack.h"
+#include "AliHLTMUONTrack.h"
 #include "AliHLTMUONDecision.h"
 #include "AliLog.h"
 #include <iostream>
+#include <map>
 
 ClassImp(AliHLTMUONEvent);
 
@@ -40,14 +45,8 @@ AliHLTMUONEvent::AliHLTMUONEvent(const AliHLTMUONEvent& event) :
 {
        /// Copy constructor performs a deep copy of the object.
        
-       fEventId = event.fEventId;
        fArray.SetOwner(kTRUE);
-       TIter next(&event.fArray);
-       TObject* obj = NULL;
-       while ( (obj = next()) != NULL )
-       {
-               fArray.Add(obj->Clone());
-       }
+       DeepCopy(event);
 }
 
 
@@ -56,15 +55,9 @@ AliHLTMUONEvent& AliHLTMUONEvent::operator = (const AliHLTMUONEvent& event)
        /// The assignment operator performs a deep copy of the object.
        
        if (this == &event) return *this;
-       TObject::operator = (event);
-       fEventId = event.fEventId;
        fArray.Clear();
-       TIter next(&event.fArray);
-       TObject* obj = NULL;
-       while ( (obj = next()) != NULL )
-       {
-               fArray.Add(obj->Clone());
-       }
+       TObject::operator = (event);
+       DeepCopy(event);
        return *this;
 }
 
@@ -127,13 +120,136 @@ void AliHLTMUONEvent::Copy(TObject& object) const
        
        TObject::Copy(object);
        AliHLTMUONEvent& event = static_cast<AliHLTMUONEvent&>(object);
-       event.fEventId = fEventId;
-       event.fArray.Clear();
-       TIter next(&fArray);
+       event.DeepCopy(*this);
+}
+
+
+void AliHLTMUONEvent::DeepCopy(const AliHLTMUONEvent& event)
+{
+       /// Performs a deep copy of the event.
+       
+       fEventId = event.fEventId;
+       TObjArray tocopy = event.fArray;
+       std::map<const TObject*, TObject*> objmap;
+       
+       // We need to copy all the objects from the old event while maintaining the
+       // pointer cross references contained in the track and decision objects:
+       // Start by looping over all objects and first copy the trigger records and hits.
+       TIter next(&tocopy);
        TObject* obj = NULL;
        while ( (obj = next()) != NULL )
        {
-               event.fArray.Add(obj->Clone());
+               if (obj->IsA() == AliHLTMUONTriggerRecord::Class() or
+                   obj->IsA() == AliHLTMUONRecHit::Class()
+                  )
+               {
+                       TObject* newobj = obj->Clone();
+                       objmap[obj] = newobj;
+                       fArray.Add(newobj);
+                       tocopy.Remove(obj);
+               }
+       }
+       
+       // Now loop over all objects that still need to be copied and copy the tracks.
+       next.Reset();
+       while ( (obj = next()) != NULL )
+       {
+               if (obj->IsA() == AliHLTMUONMansoTrack::Class())
+               {
+                       AliHLTMUONMansoTrack* track = static_cast<AliHLTMUONMansoTrack*>(obj);
+                       AliHLTMUONMansoTrack* newtrack = new AliHLTMUONMansoTrack(
+                               track->Id(), track->Sign(),
+                               track->Px(), track->Py(), track->Pz(),
+                               track->Chi2(),
+                               static_cast<const AliHLTMUONTriggerRecord*>( objmap[track->TriggerRecord()] ),
+                               static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(7)] ),
+                               static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(8)] ),
+                               static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(9)] ),
+                               static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(10)] ),
+                               track->Zmiddle(), track->QBL()
+                       );
+                       for (int i = 7; i <= 10; ++i)
+                       {
+                               const TVector3& b = track->RoICentre(i);
+                               newtrack->SetRoI(i, b.X(), b.Y(), b.Z(), track->RoIRadius(i));
+                       }
+                       objmap[obj] = newtrack;
+                       fArray.Add(newtrack);
+                       tocopy.Remove(obj);
+               }
+               else if (obj->IsA() == AliHLTMUONTrack::Class())
+               {
+                       AliHLTMUONTrack* track = static_cast<AliHLTMUONTrack*>(obj);
+                       
+                       const AliHLTMUONRecHit* newhits[16];
+                       for (int i = 0; i < 16; ++i)
+                       {
+                               newhits[i] = static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(i)] );
+                       }
+                       AliHLTMUONTrack* newtrack = new AliHLTMUONTrack(
+                               track->Id(), track->Sign(),
+                               track->Px(), track->Py(), track->Pz(),
+                               track->InverseBendingMomentum(),
+                               track->ThetaX(), track->ThetaY(),
+                               track->X(), track->Y(), track->Z(),
+                               track->Chi2(),
+                               static_cast<const AliHLTMUONTriggerRecord*>( objmap[track->TriggerRecord()] ),
+                               newhits
+                       );
+                       objmap[obj] = newtrack;
+                       fArray.Add(newtrack);
+                       tocopy.Remove(obj);
+               }
+       }
+       
+       // Finally copy over the decision objects.
+       next.Reset();
+       while ( (obj = next()) != NULL )
+       {
+               if (obj->IsA() == AliHLTMUONDecision::Class())
+               {
+                       AliHLTMUONDecision* dec = static_cast<AliHLTMUONDecision*>(obj);
+                       AliHLTMUONDecision* newdec = new AliHLTMUONDecision(
+                               dec->NumberOfLowPtTriggers(),
+                               dec->NumberOfHighPtTriggers(),
+                               dec->NumberOfUnlikePairs(),
+                               dec->NumberOfUnlikeLowPtPairs(),
+                               dec->NumberOfUnlikeHighPtPairs(),
+                               dec->NumberOfLikePairs(),
+                               dec->NumberOfLikeLowPtPairs(),
+                               dec->NumberOfLikeHighPtPairs(),
+                               dec->NumberOfMassTriggers(),
+                               dec->NumberOfLowMassTriggers(),
+                               dec->NumberOfHighMassTriggers()
+                       );
+                       for (Int_t i = 0; i < dec->NumberOfTracks(); ++i)
+                       {
+                               const AliHLTMUONDecision::AliTrackDecision* d = dec->SingleTrackDecision(i);
+                               newdec->AddDecision(
+                                       d->Pt(), d->PassedLowPtCut(), d->PassedHighPtCut(),
+                                       objmap[d->Track()]
+                               );
+                       }
+                       for (Int_t i = 0; i < dec->NumberOfPairs(); ++i)
+                       {
+                               const AliHLTMUONDecision::AliPairDecision* d = dec->TrackPairDecision(i);
+                               newdec->AddDecision(
+                                       d->Mass(), d->PassedLowMassCut(),
+                                       d->PassedHighMassCut(), d->UnlikeSign(),
+                                       d->NumberPassedLowPtCut(), d->NumberPassedHighPtCut(),
+                                       objmap[d->TrackA()], objmap[d->TrackB()]
+                               );
+                       }
+                       objmap[obj] = newdec;
+                       fArray.Add(newdec);
+                       tocopy.Remove(obj);
+               }
+       }
+       
+       // Copy all the remaining objects that we do not handle in a special way.
+       next.Reset();
+       while ( (obj = next()) != NULL )
+       {
+               fArray.Add(obj->Clone());
        }
 }
-
index cb35c8c5f9d25dd127e034f02f5ecb2c5349d910..46318aa7a942d8a89ff0622c2694f2a8d606bbdb 100644 (file)
@@ -90,6 +90,9 @@ public:
 
 private:
 
+       /// Performs a deep copy of the event. Assumes this event is already cleared and empty.
+       void DeepCopy(const AliHLTMUONEvent& event);
+
        AliHLTEventID_t fEventId;  ///< The event ID.
        TObjArray fArray;          ///< Array of event objects.
        
index 551bb32308974170259eaffb8179d346a93076cd..eec9112d2ca74aca761dc78d3dd1b4a312e6942b 100644 (file)
@@ -233,11 +233,11 @@ private:
        Float_t fChi2; ///< Chi squared of fit.
        const AliHLTMUONTriggerRecord* fTrigRec;  ///< Corresponding trigger record.
        const AliHLTMUONRecHit* fHit[4];   ///< Particle hits on tracking chambers 7 to 10.
-       TVector3 fRoICentre[4];  ///< Region of Interest centre points.
-       Float_t fRoIRadius[4];   ///< Region of Interest radii.
        
        // The following is debugging information and may not be filled if the
        // dHLT components were not set to produce this information.
+       TVector3 fRoICentre[4];  ///< Region of Interest centre points.
+       Float_t fRoIRadius[4];   ///< Region of Interest radii.
        
        // Parameters used in momentum estimation:
        Float_t fZmiddle; ///< Particle momentum X component in GeV/c.
index 4ffb90245de0b194a8e03f1230b2b5ebc2293be2..6f0639b42521775ec98801b8953caed6c1300a91 100644 (file)
@@ -74,7 +74,7 @@ bool AliHLTMUONAgent::IsMuonModuleLoaded()
                TObject* mod = NULL;
                while ((mod = next()) != NULL)
                {
-                       if (mod->IsA()->GetBaseClass("AliMUON") != NULL)
+                       if (mod->InheritsFrom(AliMUON::Class()))
                        {
                                fgMuonModuleLoaded = 1;
                                return true;
index 6f0e9165815f9e755e988308bfc602a11359ae13..31a17d5ea4d460c3d5016da7add383b48cdda1b1 100644 (file)
@@ -392,9 +392,12 @@ int AliHLTMUONRootifierComponent::DoEvent(
                                        );
                                }
                                
+                               // Add an new empty trigger record since none was found.
                                trigrec = new AliHLTMUONTriggerRecord(
                                                0, 0, 0, 0, 0, sourceDDL
                                        );
+                               triggerMap[triginfo.fTrigRecId] = trigrec;
+                               event.Add(trigrec);
                        }
                        else
                        {
@@ -742,6 +745,7 @@ int AliHLTMUONRootifierComponent::DoEvent(
                                AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackId);
                                event.Add(tr);
                                track = tr;
+                               mansoTrackMap[t.fTrackId] = tr;
                        }
                        
                        new (singlesDecisions[singlesDecisions.GetEntriesFast()])
@@ -809,12 +813,14 @@ int AliHLTMUONRootifierComponent::DoEvent(
                                AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackAId);
                                event.Add(tr);
                                trackA = tr;
+                               mansoTrackMap[t.fTrackAId] = tr;
                        }
                        if (trackB == NULL)
                        {
                                AliHLTMUONMansoTrack* tr = new AliHLTMUONMansoTrack(t.fTrackBId);
                                event.Add(tr);
                                trackB = tr;
+                               mansoTrackMap[t.fTrackBId] = tr;
                        }
                        
                        new (pairsDecisions[pairsDecisions.GetEntriesFast()])