]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSubEventTracker.cxx
inconsistency between TriggerCircuit and TriggerGeometryBuilder temporary fixed in...
[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  const Int_t AliMUONSubEventTracker::fgkHeaderLength = 4;
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   if(fData)
38     delete[] fData;
39 }
40
41 //___________________________________________
42 void AliMUONSubEventTracker::SetAlloc(Int_t size)
43 {
44   if (size < fBufSize) 
45     return;
46   else 
47     ResizeData(size);
48 }
49 //___________________________________________
50 void AliMUONSubEventTracker::AddData(UInt_t data)
51 {
52   // could have used class from ROOT
53   // but the structure must be as simple as possible
54   // to be written on disc blockwise, not so sure ?
55   if (fLength == fBufSize) 
56     ResizeData();
57   fData[fLength++] = data;
58   fTotalLength = fLength + 4;
59 }
60
61 //___________________________________________
62 void AliMUONSubEventTracker::ResizeData(Int_t size)
63 {
64   if (size == 0)
65     fBufSize *= 2;
66   else
67     fBufSize = size;
68   UInt_t* newData = new UInt_t[fBufSize];
69   for (Int_t i = 0; i < fLength; i++)
70     newData[i] = fData[i];
71   delete[] fData;
72   fData = newData;
73 }
74 //___________________________________________
75 AliMUONSubEventTracker::
76 AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
77 {
78   fTotalLength = event.fTotalLength;
79   fLength = event.fLength;
80   fBusPatchId = event.fBusPatchId;
81   fTriggerWord = event.fTriggerWord;
82
83   fData =  new UInt_t[event.fBufSize];
84   for (int i = 0; i < event.fBufSize; i++)
85     fData[i] = event.fData[i];
86 }
87 //___________________________________________
88 AliMUONSubEventTracker&
89 AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
90 {
91   if (this == &event) return *this;
92   fTotalLength = event.fTotalLength;
93   fLength = event.fLength;
94   fBusPatchId = event.fBusPatchId;
95   fTriggerWord = event.fTriggerWord;
96   
97   for (int i = 0; i < event.fLength; i++)
98     fData[i] = event.fData[i];
99
100   return *this;
101 }
102 //___________________________________________
103 Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const
104 {
105   AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj;
106   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
107 }