1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
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 **************************************************************************/
20 /// @file AliHLTMUONEvent.cxx
21 /// @author Artur Szostak <artursz@iafrica.com>
23 /// @brief Implementation of the AliHLTMUONEvent class.
25 /// The class is used to store all ROOTified data objects from the dHLT chain
26 /// for a single event together.
28 #include "AliHLTMUONEvent.h"
29 #include "AliHLTMUONRecHit.h"
30 #include "AliHLTMUONTriggerRecord.h"
31 #include "AliHLTMUONMansoTrack.h"
32 #include "AliHLTMUONTrack.h"
33 #include "AliHLTMUONDecision.h"
38 ClassImp(AliHLTMUONEvent);
41 AliHLTMUONEvent::AliHLTMUONEvent(const AliHLTMUONEvent& event) :
43 fEventId(event.fEventId),
46 /// Copy constructor performs a deep copy of the object.
48 fArray.SetOwner(kTRUE);
53 AliHLTMUONEvent& AliHLTMUONEvent::operator = (const AliHLTMUONEvent& event)
55 /// The assignment operator performs a deep copy of the object.
57 if (this == &event) return *this;
59 TObject::operator = (event);
65 const AliHLTMUONDecision* AliHLTMUONEvent::FindDecision() const
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.
73 for (Int_t i = 0; i < fArray.GetEntriesFast(); i++)
75 if (fArray[i]->IsA() == AliHLTMUONDecision::Class())
77 return static_cast<const AliHLTMUONDecision*>(fArray[i]);
85 void AliHLTMUONEvent::Print(Option_t* option) const
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.
93 std::cout << "################## EVENT: " << fEventId << " ##################" << std::endl;
94 for (Int_t i = 0; i < fArray.GetEntriesFast(); i++)
95 if (fArray[i] != NULL) fArray[i]->Print(option);
99 void AliHLTMUONEvent::Clear(Option_t* option)
101 /// Clears the internal array of event objects.
103 fEventId = AliHLTEventID_t(-1);
104 fArray.Clear(option);
108 void AliHLTMUONEvent::Copy(TObject& object) const
110 /// Deep copy this object to the target object.
111 /// \param object The target object to copy to.
113 if (object.IsA() != this->IsA())
115 AliError(Form("Cannot copy an object of type %s to a type of %s.",
116 this->ClassName(), object.ClassName()
121 TObject::Copy(object);
122 AliHLTMUONEvent& event = static_cast<AliHLTMUONEvent&>(object);
123 event.DeepCopy(*this);
127 void AliHLTMUONEvent::DeepCopy(const AliHLTMUONEvent& event)
129 /// Performs a deep copy of the event.
131 fEventId = event.fEventId;
132 TObjArray tocopy = event.fArray;
133 std::map<const TObject*, TObject*> objmap;
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.
140 while ( (obj = next()) != NULL )
142 if (obj->IsA() == AliHLTMUONTriggerRecord::Class() or
143 obj->IsA() == AliHLTMUONRecHit::Class()
146 TObject* newobj = obj->Clone();
147 objmap[obj] = newobj;
153 // Now loop over all objects that still need to be copied and copy the tracks.
155 while ( (obj = next()) != NULL )
157 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
159 AliHLTMUONMansoTrack* track = static_cast<AliHLTMUONMansoTrack*>(obj);
160 AliHLTMUONMansoTrack* newtrack = new AliHLTMUONMansoTrack(
161 track->Id(), track->Sign(),
162 track->Px(), track->Py(), track->Pz(),
164 static_cast<const AliHLTMUONTriggerRecord*>( objmap[track->TriggerRecord()] ),
165 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(7)] ),
166 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(8)] ),
167 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(9)] ),
168 static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(10)] ),
169 track->Zmiddle(), track->QBL()
171 for (int i = 7; i <= 10; ++i)
173 const TVector3& b = track->RoICentre(i);
174 newtrack->SetRoI(i, b.X(), b.Y(), b.Z(), track->RoIRadius(i));
176 objmap[obj] = newtrack;
177 fArray.Add(newtrack);
180 else if (obj->IsA() == AliHLTMUONTrack::Class())
182 AliHLTMUONTrack* track = static_cast<AliHLTMUONTrack*>(obj);
184 const AliHLTMUONRecHit* newhits[16];
185 for (int i = 0; i < 16; ++i)
187 newhits[i] = static_cast<const AliHLTMUONRecHit*>( objmap[track->Hit(i)] );
189 AliHLTMUONTrack* newtrack = new AliHLTMUONTrack(
190 track->Id(), track->Sign(),
191 track->Px(), track->Py(), track->Pz(),
192 track->InverseBendingMomentum(),
193 track->ThetaX(), track->ThetaY(),
194 track->X(), track->Y(), track->Z(),
196 static_cast<const AliHLTMUONTriggerRecord*>( objmap[track->TriggerRecord()] ),
199 objmap[obj] = newtrack;
200 fArray.Add(newtrack);
205 // Finally copy over the decision objects.
207 while ( (obj = next()) != NULL )
209 if (obj->IsA() == AliHLTMUONDecision::Class())
211 AliHLTMUONDecision* dec = static_cast<AliHLTMUONDecision*>(obj);
212 AliHLTMUONDecision* newdec = new AliHLTMUONDecision(
213 dec->NumberOfLowPtTriggers(),
214 dec->NumberOfHighPtTriggers(),
215 dec->NumberOfUnlikePairs(),
216 dec->NumberOfUnlikeLowPtPairs(),
217 dec->NumberOfUnlikeHighPtPairs(),
218 dec->NumberOfLikePairs(),
219 dec->NumberOfLikeLowPtPairs(),
220 dec->NumberOfLikeHighPtPairs(),
221 dec->NumberOfMassTriggers(),
222 dec->NumberOfLowMassTriggers(),
223 dec->NumberOfHighMassTriggers()
225 for (Int_t i = 0; i < dec->NumberOfTracks(); ++i)
227 const AliHLTMUONDecision::AliTrackDecision* d = dec->SingleTrackDecision(i);
229 d->Pt(), d->PassedLowPtCut(), d->PassedHighPtCut(),
233 for (Int_t i = 0; i < dec->NumberOfPairs(); ++i)
235 const AliHLTMUONDecision::AliPairDecision* d = dec->TrackPairDecision(i);
237 d->Mass(), d->PassedLowMassCut(),
238 d->PassedHighMassCut(), d->UnlikeSign(),
239 d->NumberPassedLowPtCut(), d->NumberPassedHighPtCut(),
240 objmap[d->TrackA()], objmap[d->TrackB()]
243 objmap[obj] = newdec;
249 // Copy all the remaining objects that we do not handle in a special way.
251 while ( (obj = next()) != NULL )
253 fArray.Add(obj->Clone());