Coverity fix for uninitialized variables and check for returned null value
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryConstituent.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 AliMUONGeometryConstituent
20 // -----------------------------
21 // Helper class for definititon of an assembly of volumes.
22 // Author: Ivana Hrivnacova, IPN Orsay
23 // 23/01/2004
24 //-----------------------------------------------------------------------------
25
26 #include <TGeoMatrix.h>
27
28 #include "AliMUONGeometryConstituent.h"
29 #include "AliLog.h"
30
31 /// \cond CLASSIMP
32 ClassImp(AliMUONGeometryConstituent)
33 /// \endcond
34
35 //______________________________________________________________________________
36 AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
37                                    Int_t copyNo, Int_t npar, Double_t* param)
38   : TNamed(name, name),
39     fCopyNo(copyNo),
40     fNpar(npar),
41     fParam(0), 
42     fTransformation(0)                             
43 {                                   
44 /// Standard constructor for a constituent without translation & rotation
45
46   // fTransformation = new TGeoCombiTrans(name);
47            // would be nice to be so simple 
48
49   // Create the constituent transformation
50   fTransformation = new TGeoCombiTrans("");
51
52   // Volume parameters
53   if (npar > 0) {
54     fParam = new Double_t[npar];
55     for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
56   }  
57 }
58
59 //______________________________________________________________________________
60 AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
61                                    Int_t copyNo, const TGeoTranslation& translation,
62                                    Int_t npar, Double_t* param)
63   : TNamed(name, name),
64     fCopyNo(copyNo),
65     fNpar(npar),
66     fParam(0),                             
67     fTransformation(0) 
68 {
69 /// Standard constructor for a constituent with translation
70
71   // Create the constituent transformation
72   fTransformation = new TGeoCombiTrans(translation, TGeoRotation());
73
74   // Volume parameters
75   if (npar > 0) {
76     fParam = new Double_t[npar];
77     for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
78   }  
79 }
80
81                          
82 //______________________________________________________________________________
83 AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
84                                    Int_t copyNo, const TGeoTranslation& translation, 
85                                    const TGeoRotation& rotation, 
86                                    Int_t npar, Double_t* param)
87                                    
88   : TNamed(name, name),
89     fCopyNo(copyNo),
90     fNpar(npar),
91     fParam(0),                             
92     fTransformation(0) 
93 {
94 /// Standard constructor for a constituent with translation and rotation
95
96   // Create the constituent transformation
97   fTransformation = new TGeoCombiTrans(translation, rotation);
98
99   // Volume parameters
100   if (npar > 0) {
101     fParam = new Double_t[npar];
102     for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
103   }  
104 }
105
106 //______________________________________________________________________________
107 AliMUONGeometryConstituent::AliMUONGeometryConstituent(const TString& name, 
108                                    Int_t copyNo, 
109                                    const TGeoCombiTrans& transform, 
110                                    Int_t npar, Double_t* param)
111                                    
112   : TNamed(name, name),
113     fCopyNo(copyNo),
114     fNpar(npar),
115     fParam(0),                             
116     fTransformation(0) 
117 {
118 /// Standard constructor for a constituent with translation and rotation
119 /// defined via TGeoCombiTrans
120
121   // Create the constituent transformation
122   fTransformation = new TGeoCombiTrans(transform);
123
124   // Volume parameters
125   if (npar > 0) {
126     fParam = new Double_t[npar];
127     for (Int_t i=0; i<npar; i++) fParam[i] = param[i];
128   }  
129 }
130
131 //______________________________________________________________________________
132 AliMUONGeometryConstituent::AliMUONGeometryConstituent()
133   : TNamed(),
134     fCopyNo(0),
135     fNpar(0),
136     fParam(0),                             
137     fTransformation(0) 
138 {
139 /// Default constructor
140 }
141
142 //______________________________________________________________________________
143 AliMUONGeometryConstituent::~AliMUONGeometryConstituent() 
144 {
145 /// Destructor
146
147   delete fTransformation;
148   delete [] fParam;
149 }