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() :
40 // Default constructor
44 AliMixedEvent::AliMixedEvent(const AliMixedEvent& Evnt) :
50 { } // Copy constructor
52 AliMixedEvent& AliMixedEvent::operator=(const AliMixedEvent& vEvnt)
54 AliVEvent::operator=(vEvnt);
61 void AliMixedEvent::AddEvent(AliVEvent* evt)
63 // Add a new event to the list
68 void AliMixedEvent::Init()
70 // Initialize meta information
71 fNEvents = fEventList.GetEntries();
72 fNTracksCumul = new Int_t[fNEvents];
74 TIter next(&fEventList);
78 while((event = (AliVEvent*)next())) {
79 fNTracksCumul[iev++] = fNumberOfTracks;
80 fNumberOfTracks += (event->GetNumberOfTracks());
85 AliVParticle* AliMixedEvent::GetTrack(Int_t i) const
88 Int_t iEv = TMath::BinarySearch(fNEvents, fNTracksCumul, i);
89 while((iEv < (fNEvents - 1)) && (fNTracksCumul[iEv] == fNTracksCumul[iEv+1])) {iEv++;}
91 Int_t irel = i - fNTracksCumul[iEv];
92 AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv));
93 return (evt->GetTrack(irel));
97 void AliMixedEvent::Reset()
104 delete[] fNTracksCumul;
109 Int_t AliMixedEvent::EventIndex(Int_t itrack)
111 // Return the event index for track #itrack
112 return TMath::BinarySearch(fNEvents, fNTracksCumul, itrack);