]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSubEventTracker.cxx
Simplifying calling test, explicite functions for each type of test
[u/mrichter/AliRoot.git] / MUON / AliMUONSubEventTracker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 #include "AliMUONSubEventTracker.h"
17
18 const Int_t AliMUONSubEventTracker::fgkHeaderLength = 4;
19
20 ClassImp(AliMUONSubEventTracker)
21
22 //___________________________________________
23 AliMUONSubEventTracker::AliMUONSubEventTracker()
24   :  TObject(),
25      fTotalLength(0),
26      fLength(0),
27      fBusPatchId(0),
28      fTriggerWord(0),
29      fBufSize(1024)
30 {
31   //ctor
32   fData = new UInt_t[fBufSize];
33 }
34 //___________________________________________
35 AliMUONSubEventTracker::~AliMUONSubEventTracker()
36 {
37   delete[] fData;
38 }
39
40 //___________________________________________
41 void AliMUONSubEventTracker::SetAlloc(Int_t size)
42 {
43   if (size < fBufSize) 
44     return;
45   else 
46     ResizeData(size);
47 }
48 //___________________________________________
49 void AliMUONSubEventTracker::AddData(UInt_t data)
50 {
51   // could have used class from ROOT
52   // but the structure must be as simple as possible
53   // to be written on disc blockwise, not so sure ?
54   if (fLength == fBufSize) 
55     ResizeData();
56   fData[fLength++] = data;
57   fTotalLength = fLength + 4;
58 }
59
60 //___________________________________________
61 void AliMUONSubEventTracker::ResizeData(Int_t size)
62 {
63   if (size == 0)
64     fBufSize *= 2;
65   else
66     fBufSize = size;
67   UInt_t* newData = new UInt_t[fBufSize];
68   for (Int_t i = 0; i < fLength; i++)
69     newData[i] = fData[i];
70   delete[] fData;
71   fData = newData;
72 }
73 //___________________________________________
74 AliMUONSubEventTracker::
75 AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
76 {
77   fTotalLength = event.fTotalLength;
78   fLength = event.fLength;
79   fBusPatchId = event.fBusPatchId;
80   fTriggerWord = event.fTriggerWord;
81
82   fData =  new UInt_t[event.fBufSize];
83   for (int i = 0; i < event.fBufSize; i++)
84     fData[i] = event.fData[i];
85 }
86 //___________________________________________
87 AliMUONSubEventTracker&
88 AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
89 {
90   if (this == &event) return *this;
91   fTotalLength = event.fTotalLength;
92   fLength = event.fLength;
93   fBusPatchId = event.fBusPatchId;
94   fTriggerWord = event.fTriggerWord;
95   
96   for (int i = 0; i < event.fLength; i++)
97     fData[i] = event.fData[i];
98
99   return *this;
100 }
101 //___________________________________________
102 Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const
103 {
104   AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj;
105   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
106 }