]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMixedEvent.cxx
Fixing ompilation warnings
[u/mrichter/AliRoot.git] / STEER / AliMixedEvent.cxx
CommitLineData
7eb061fb 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18
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//-------------------------------------------------------------------------
25
26
27#include "AliMixedEvent.h"
28#include <TMath.h>
29
30ClassImp(AliMixedEvent)
31
32
33AliMixedEvent::AliMixedEvent() :
34 AliVEvent(),
a2813d8b 35 fEventList(),
7eb061fb 36 fNEvents(0),
37 fNumberOfTracks(0),
38 fNTracksCumul(0)
39{
40 // Default constructor
41}
42
43
44AliMixedEvent::AliMixedEvent(const AliMixedEvent& Evnt) :
a2813d8b 45 AliVEvent(Evnt),
46 fEventList(),
47 fNEvents(0),
48 fNumberOfTracks(0),
49 fNTracksCumul(0)
50{ } // Copy constructor
7eb061fb 51
52AliMixedEvent& AliMixedEvent::operator=(const AliMixedEvent& vEvnt)
53{ if (this!=&vEvnt) {
54 AliVEvent::operator=(vEvnt);
55 }
56
57 return *this;
58}
59
60
61void AliMixedEvent::AddEvent(AliVEvent* evt)
62{
63 // Add a new event to the list
64 fEventList.Add(evt);
65}
66
67
68void AliMixedEvent::Init()
69{
70 // Initialize meta information
71 fNEvents = fEventList.GetEntries();
72 fNTracksCumul = new Int_t[fNEvents];
73 fNumberOfTracks = 0;
74 TIter next(&fEventList);
75 AliVEvent* event;
76 Int_t iev = 0;
77
78 while((event = (AliVEvent*)next())) {
79 fNTracksCumul[iev++] = fNumberOfTracks;
80 fNumberOfTracks += (event->GetNumberOfTracks());
81 }
82}
83
84
85AliVParticle* AliMixedEvent::GetTrack(Int_t i) const
86{
87 // Return track # i
88 Int_t iEv = TMath::BinarySearch(fNEvents, fNTracksCumul, i);
89
90 Int_t irel = i - fNTracksCumul[iEv];
91 AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv));
92 return (evt->GetTrack(irel));
93}
94
95
96void AliMixedEvent::Reset()
97{
98 // Reset the event
99 fEventList.Clear();
100 fNEvents = 0;
101 fNumberOfTracks = 0;
102 if (fNTracksCumul) {
103 delete[] fNTracksCumul;
104 fNTracksCumul = 0;
105 }
106}
107
108Int_t AliMixedEvent::EventIndex(Int_t itrack)
109{
110 // Return the event index for track #itrack
111 return TMath::BinarySearch(fNEvents, fNTracksCumul, itrack);
112}