1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 //-------------------------------------------------------------------------
20 // Class AliMixedEvent
21 // VEvent which is the container of several VEvents
22 // Use Case: Event Mixing
23 // Origin: Andreas Morsch, CERN, Andreas.Morsch@cern.ch
24 //-------------------------------------------------------------------------
27 #include "AliMixedEvent.h"
30 ClassImp(AliMixedEvent)
33 AliMixedEvent::AliMixedEvent() :
39 // Default constructor
43 AliMixedEvent::AliMixedEvent(const AliMixedEvent& Evnt) :
44 AliVEvent(Evnt) { } // Copy constructor
46 AliMixedEvent& AliMixedEvent::operator=(const AliMixedEvent& vEvnt)
48 AliVEvent::operator=(vEvnt);
55 void AliMixedEvent::AddEvent(AliVEvent* evt)
57 // Add a new event to the list
62 void AliMixedEvent::Init()
64 // Initialize meta information
65 fNEvents = fEventList.GetEntries();
66 fNTracksCumul = new Int_t[fNEvents];
68 TIter next(&fEventList);
72 while((event = (AliVEvent*)next())) {
73 fNTracksCumul[iev++] = fNumberOfTracks;
74 fNumberOfTracks += (event->GetNumberOfTracks());
79 AliVParticle* AliMixedEvent::GetTrack(Int_t i) const
82 Int_t iEv = TMath::BinarySearch(fNEvents, fNTracksCumul, i);
84 Int_t irel = i - fNTracksCumul[iEv];
85 AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv));
86 return (evt->GetTrack(irel));
90 void AliMixedEvent::Reset()
97 delete[] fNTracksCumul;
102 Int_t AliMixedEvent::EventIndex(Int_t itrack)
104 // Return the event index for track #itrack
105 return TMath::BinarySearch(fNEvents, fNTracksCumul, itrack);