]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONAlignmentRecord.cxx
In alignment classes:
[u/mrichter/AliRoot.git] / MUON / AliMUONAlignmentRecord.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 /* $Id$ */
17
18 //-----------------------------------------------------------------------------
19 // Class AliMUONAlignmentClusterRecord
20 // Class AliMUONAlignmentTrackRecord
21 //-----------------------------------------------------------------------------
22
23 #include "AliMUONAlignmentRecord.h"
24 #include "AliLog.h"
25
26 #include <iostream>
27
28 // class implementation in root context
29 ClassImp( AliMUONAlignmentClusterRecord )
30
31 // class implementation in root context
32 ClassImp( AliMUONAlignmentTrackRecord )
33
34 //__________________________________________________________________________
35 AliMUONAlignmentClusterRecord::AliMUONAlignmentClusterRecord( void ):
36   fDetElemId(0),
37   fDetElemNumber(0),
38   fMeas(0),
39   fSigma(0)
40 {
41
42   // initialize derivatives
43   for( Int_t index = 0; index < 4; ++index )
44   {
45     fLocalDerivatives[index] = 0;
46     fGlobalDerivatives[index] = 0;
47   }
48
49 }
50
51 //__________________________________________________________________________
52 void AliMUONAlignmentClusterRecord::Print( Option_t* ) const
53 {
54
55   // detector id and measurement
56   std::cout
57     << " AliMUONAlignmentClusterRecord::Print - fDetElemId: " << fDetElemId
58     << " fMeas: " << fMeas
59     << " fSigma: " << fSigma;
60
61   // local derivatives
62   std::cout << " fLocalDerivatives: ";
63   for( Int_t index = 0; index < 4; ++index )
64   { std::cout << fLocalDerivatives[index] << " "; }
65
66   // global derivatives
67   std::cout << " fGlobalDerivatives: ";
68   for( Int_t index = 0; index < 4; ++index )
69   { std::cout << fGlobalDerivatives[index] << " "; }
70
71   std::cout << std::endl;
72
73 }
74
75 //__________________________________________________________________________
76 AliMUONAlignmentTrackRecord::AliMUONAlignmentTrackRecord( void ):
77   fClusterRecords (new TClonesArray( "AliMUONAlignmentClusterRecord", fSize ) ),
78   fClusterCount( 0 )
79   {}
80
81 //__________________________________________________________________________
82 AliMUONAlignmentTrackRecord::AliMUONAlignmentTrackRecord( const AliMUONAlignmentTrackRecord& other ):
83   TObject(other),
84   fClusterRecords (new TClonesArray( "AliMUONAlignmentClusterRecord", fSize ) ),
85   fClusterCount( other.fClusterCount )
86 {
87
88   // deep copy of records
89   for( Int_t index = 0; index < other.GetNRecords(); ++index )
90   { new ((*fClusterRecords)[index]) AliMUONAlignmentClusterRecord( *static_cast<const AliMUONAlignmentClusterRecord*>( other.fClusterRecords->UncheckedAt( index ) ) ); }
91
92 }
93
94 //__________________________________________________________________________
95 AliMUONAlignmentTrackRecord& AliMUONAlignmentTrackRecord::operator = ( const AliMUONAlignmentTrackRecord& other )
96 {
97
98   if( this == &other ) return *this;
99   Clear();
100
101   TObject::operator =( other );
102
103   // copy number of cluster
104   fClusterCount = other.fClusterCount;
105
106   // deep copy of records
107   for( Int_t index = 0; index < other.GetNRecords(); ++index )
108   { new ((*fClusterRecords)[index]) AliMUONAlignmentClusterRecord( *static_cast<const AliMUONAlignmentClusterRecord*>( other.fClusterRecords->UncheckedAt( index ) ) ); }
109
110   return *this;
111
112 }
113
114
115 //__________________________________________________________________________
116 void AliMUONAlignmentTrackRecord::Print( Option_t* ) const
117 {
118
119   std::cout << "AliMUONAlignmentTrackRecord::Print - fClusterCount: " << fClusterCount << std::endl;
120   if( fClusterRecords )
121   {
122     for( Int_t index = 0; index < fClusterCount; ++index )
123     { static_cast<AliMUONAlignmentClusterRecord*>( fClusterRecords->UncheckedAt( index ) )->Print(); }
124   }
125
126 }
127
128 //__________________________________________________________________________
129 AliMUONAlignmentTrackRecord::~AliMUONAlignmentTrackRecord( void )
130 {
131
132   // note: it is safe to delete a NULL pointer, so no need to check.
133   delete fClusterRecords;
134
135 }
136
137 //__________________________________________________________________________
138 void AliMUONAlignmentTrackRecord::AddClusterRecord( const AliMUONAlignmentClusterRecord& record )
139 {
140
141   // append copy to array
142   new ((*fClusterRecords)[fClusterCount]) AliMUONAlignmentClusterRecord( record );
143   fClusterCount++;
144
145 }
146
147 //__________________________________________________________________________
148 void AliMUONAlignmentTrackRecord::RemoveClusterRecord( AliMUONAlignmentClusterRecord* record )
149 {
150
151   AliMUONAlignmentClusterRecord* local( static_cast<AliMUONAlignmentClusterRecord*>( fClusterRecords->Remove( record ) ) );
152
153   if( local )
154   {
155
156     delete local;
157     fClusterRecords->Compress();
158     fClusterCount--;
159
160   } else AliWarning("object to remove does not exist in array fClusterRecords");
161
162 }
163
164 //__________________________________________________________________________
165 void AliMUONAlignmentTrackRecord::Clear( Option_t* options )
166 {
167
168   TObject::Clear( options );
169
170   // only Clear, not delete, since fClusterRecords does not allocate memory
171   fClusterRecords->Clear();
172
173   // reset count
174   fClusterCount = 0;
175
176 }