LCOV - code coverage report
Current view: top level - HLT/MUON - AliHLTMUONEvent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 120 0.8 %
Date: 2016-06-14 17:26:59 Functions: 1 9 11.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        * 
       3             :  * All rights reserved.                                                   *
       4             :  *                                                                        *
       5             :  * Primary Authors:                                                       *
       6             :  *   Artur Szostak <artursz@iafrica.com>                                  *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          * 
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : // $Id: $
      18             : 
      19             : ///
      20             : /// @file   AliHLTMUONEvent.cxx
      21             : /// @author Artur Szostak <artursz@iafrica.com>
      22             : /// @date   29 Sep 2007
      23             : /// @brief  Implementation of the AliHLTMUONEvent class.
      24             : ///
      25             : /// The class is used to store all ROOTified data objects from the dHLT chain
      26             : /// for a single event together.
      27             : 
      28             : #include "AliHLTMUONEvent.h"
      29             : #include "AliHLTMUONRecHit.h"
      30             : #include "AliHLTMUONTriggerRecord.h"
      31             : #include "AliHLTMUONMansoTrack.h"
      32             : #include "AliHLTMUONTrack.h"
      33             : #include "AliHLTMUONDecision.h"
      34             : #include "AliLog.h"
      35             : #include <iostream>
      36             : #include <map>
      37             : 
      38           6 : ClassImp(AliHLTMUONEvent);
      39             : 
      40             : 
      41             : AliHLTMUONEvent::AliHLTMUONEvent(const AliHLTMUONEvent& event) :
      42           0 :         TObject(event),
      43           0 :         fEventId(event.fEventId),
      44           0 :         fArray()
      45           0 : {
      46             :         /// Copy constructor performs a deep copy of the object.
      47             :         
      48           0 :         fArray.SetOwner(kTRUE);
      49           0 :         DeepCopy(event);
      50           0 : }
      51             : 
      52             : 
      53             : AliHLTMUONEvent& AliHLTMUONEvent::operator = (const AliHLTMUONEvent& event)
      54             : {
      55             :         /// The assignment operator performs a deep copy of the object.
      56             :         
      57           0 :         if (this == &event) return *this;
      58           0 :         fArray.Clear();
      59           0 :         TObject::operator = (event);
      60           0 :         DeepCopy(event);
      61           0 :         return *this;
      62           0 : }
      63             : 
      64             : 
      65             : const AliHLTMUONDecision* AliHLTMUONEvent::FindDecision() const
      66             : {
      67             :         /// Finds the decision object in the event from the list of dHLT objects.
      68             :         /// There should only be one such object in the event. If not, then only
      69             :         /// the first object found is returned. You will need to manually search
      70             :         /// for the other objects.
      71             :         /// \returns  The AliHLTMUONDecision object in the event or NULL if none exists.
      72             :         
      73           0 :         for (Int_t i = 0; i < fArray.GetEntriesFast(); i++)
      74             :         {
      75           0 :                 if (fArray[i]->IsA() == AliHLTMUONDecision::Class())
      76             :                 {
      77           0 :                         return static_cast<const AliHLTMUONDecision*>(fArray[i]);
      78             :                 }
      79             :         }
      80             :         
      81           0 :         return NULL;
      82           0 : }
      83             : 
      84             : 
      85             : void AliHLTMUONEvent::Print(Option_t* option) const
      86             : {
      87             :         ///
      88             :         /// Inherited from TObject. Prints the contents of the event objects in fArray.
      89             :         /// \param option  This is an option string that is just passed on to individual
      90             :         ///     objects in the event's fArray list of objects.
      91             :         ///
      92             :         
      93           0 :         std::cout << "################## EVENT: " << fEventId << " ##################" << std::endl;
      94           0 :         for (Int_t i = 0; i < fArray.GetEntriesFast(); i++)
      95           0 :                 if (fArray[i] != NULL) fArray[i]->Print(option);
      96           0 : }
      97             : 
      98             : 
      99             : void AliHLTMUONEvent::Clear(Option_t* option)
     100             : {
     101             :         /// Clears the internal array of event objects.
     102             :         
     103           0 :         fEventId = AliHLTEventID_t(-1);
     104           0 :         fArray.Clear(option);
     105           0 : }
     106             : 
     107             : 
     108             : void AliHLTMUONEvent::Copy(TObject& object) const
     109             : {
     110             :         /// Deep copy this object to the target object.
     111             :         /// \param object  The target object to copy to.
     112             :         
     113           0 :         if (object.IsA() != this->IsA())
     114             :         {
     115           0 :                 AliError(Form("Cannot copy an object of type %s to a type of %s.",
     116             :                         this->ClassName(), object.ClassName()
     117             :                 ));
     118           0 :                 return;
     119             :         }
     120             :         
     121           0 :         TObject::Copy(object);
     122           0 :         AliHLTMUONEvent& event = static_cast<AliHLTMUONEvent&>(object);
     123           0 :         event.DeepCopy(*this);
     124           0 : }
     125             : 
     126             : 
     127             : void AliHLTMUONEvent::DeepCopy(const AliHLTMUONEvent& event)
     128             : {
     129             :         /// Performs a deep copy of the event.
     130             :         
     131           0 :         fEventId = event.fEventId;
     132           0 :         TObjArray tocopy = event.fArray;
     133           0 :         std::map<const TObject*, TObject*> objmap;
     134             :         
     135             :         // We need to copy all the objects from the old event while maintaining the
     136             :         // pointer cross references contained in the track and decision objects:
     137             :         // Start by looping over all objects and first copy the trigger records and hits.
     138           0 :         TIter next(&tocopy);
     139             :         TObject* obj = NULL;
     140           0 :         while ( (obj = next()) != NULL )
     141             :         {
     142           0 :                 if (obj->IsA() == AliHLTMUONTriggerRecord::Class() or
     143           0 :                     obj->IsA() == AliHLTMUONRecHit::Class()
     144             :                    )
     145             :                 {
     146           0 :                         TObject* newobj = obj->Clone();
     147           0 :                         objmap[obj] = newobj;
     148           0 :                         fArray.Add(newobj);
     149           0 :                         tocopy.Remove(obj);
     150           0 :                 }
     151             :         }
     152             :         
     153             :         // Now loop over all objects that still need to be copied and copy the tracks.
     154           0 :         next.Reset();
     155           0 :         while ( (obj = next()) != NULL )
     156             :         {
     157           0 :                 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
     158             :                 {
     159           0 :                         AliHLTMUONMansoTrack* track = static_cast<AliHLTMUONMansoTrack*>(obj);
     160           0 :                         AliHLTMUONMansoTrack* newtrack = new AliHLTMUONMansoTrack(
     161           0 :                                 track->Id(), track->Sign(),
     162           0 :                                 track->Px(), track->Py(), track->Pz(),
     163           0 :                                 track->Chi2(),
     164           0 :                                 static_cast<const AliHLTMUONTriggerRecord*>( objmap[track->TriggerRecord()] ),
     165           0 :                                 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(7)] ),
     166           0 :                                 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(8)] ),
     167           0 :                                 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(9)] ),
     168           0 :                                 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(10)] ),
     169           0 :                                 track->Zmiddle(), track->QBL()
     170             :                         );
     171           0 :                         for (int i = 7; i <= 10; ++i)
     172             :                         {
     173           0 :                                 const TVector3& b = track->RoICentre(i);
     174           0 :                                 newtrack->SetRoI(i, b.X(), b.Y(), b.Z(), track->RoIRadius(i));
     175             :                         }
     176           0 :                         objmap[obj] = newtrack;
     177           0 :                         fArray.Add(newtrack);
     178           0 :                         tocopy.Remove(obj);
     179           0 :                 }
     180           0 :                 else if (obj->IsA() == AliHLTMUONTrack::Class())
     181             :                 {
     182           0 :                         AliHLTMUONTrack* track = static_cast<AliHLTMUONTrack*>(obj);
     183             :                         
     184           0 :                         const AliHLTMUONRecHit* newhits[16];
     185           0 :                         for (int i = 0; i < 16; ++i)
     186             :                         {
     187           0 :                                 newhits[i] = static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(i)] );
     188             :                         }
     189           0 :                         AliHLTMUONTrack* newtrack = new AliHLTMUONTrack(
     190           0 :                                 track->Id(), track->Sign(),
     191           0 :                                 track->Px(), track->Py(), track->Pz(),
     192           0 :                                 track->InverseBendingMomentum(),
     193           0 :                                 track->ThetaX(), track->ThetaY(),
     194           0 :                                 track->X(), track->Y(), track->Z(),
     195           0 :                                 track->Chi2(),
     196           0 :                                 static_cast<const AliHLTMUONTriggerRecord*>( objmap[track->TriggerRecord()] ),
     197           0 :                                 newhits
     198             :                         );
     199           0 :                         objmap[obj] = newtrack;
     200           0 :                         fArray.Add(newtrack);
     201           0 :                         tocopy.Remove(obj);
     202           0 :                 }
     203             :         }
     204             :         
     205             :         // Finally copy over the decision objects.
     206           0 :         next.Reset();
     207           0 :         while ( (obj = next()) != NULL )
     208             :         {
     209           0 :                 if (obj->IsA() == AliHLTMUONDecision::Class())
     210             :                 {
     211           0 :                         AliHLTMUONDecision* dec = static_cast<AliHLTMUONDecision*>(obj);
     212           0 :                         AliHLTMUONDecision* newdec = new AliHLTMUONDecision(
     213           0 :                                 dec->NumberOfLowPtTriggers(),
     214           0 :                                 dec->NumberOfHighPtTriggers(),
     215           0 :                                 dec->NumberOfUnlikePairs(),
     216           0 :                                 dec->NumberOfUnlikeLowPtPairs(),
     217           0 :                                 dec->NumberOfUnlikeHighPtPairs(),
     218           0 :                                 dec->NumberOfLikePairs(),
     219           0 :                                 dec->NumberOfLikeLowPtPairs(),
     220           0 :                                 dec->NumberOfLikeHighPtPairs(),
     221           0 :                                 dec->NumberOfMassTriggers(),
     222           0 :                                 dec->NumberOfLowMassTriggers(),
     223           0 :                                 dec->NumberOfHighMassTriggers()
     224             :                         );
     225           0 :                         for (Int_t i = 0; i < dec->NumberOfTracks(); ++i)
     226             :                         {
     227           0 :                                 const AliHLTMUONDecision::AliTrackDecision* d = dec->SingleTrackDecision(i);
     228           0 :                                 newdec->AddDecision(
     229           0 :                                         d->Pt(), d->PassedLowPtCut(), d->PassedHighPtCut(),
     230           0 :                                         objmap[d->Track()]
     231             :                                 );
     232             :                         }
     233           0 :                         for (Int_t i = 0; i < dec->NumberOfPairs(); ++i)
     234             :                         {
     235           0 :                                 const AliHLTMUONDecision::AliPairDecision* d = dec->TrackPairDecision(i);
     236           0 :                                 newdec->AddDecision(
     237           0 :                                         d->Mass(), d->PassedLowMassCut(),
     238           0 :                                         d->PassedHighMassCut(), d->UnlikeSign(),
     239           0 :                                         d->NumberPassedLowPtCut(), d->NumberPassedHighPtCut(),
     240           0 :                                         objmap[d->TrackA()], objmap[d->TrackB()]
     241             :                                 );
     242             :                         }
     243           0 :                         objmap[obj] = newdec;
     244           0 :                         fArray.Add(newdec);
     245           0 :                         tocopy.Remove(obj);
     246           0 :                 }
     247             :         }
     248             :         
     249             :         // Copy all the remaining objects that we do not handle in a special way.
     250           0 :         next.Reset();
     251           0 :         while ( (obj = next()) != NULL )
     252             :         {
     253           0 :                 fArray.Add(obj->Clone());
     254             :         }
     255           0 : }

Generated by: LCOV version 1.11