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