]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSDigitUpgrade.cxx
- Coverity fixes
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSDigitUpgrade.cxx
1 /**************************************************************************
2  * Copyright(c) 2004-2006, 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 #include "AliITSDigitUpgrade.h"
19 #include "AliITSsegmentationUpgrade.h"
20 #include "AliLog.h"
21
22 ///////////////////////////////////////////////////////////////////
23 //                                                               //
24 // Class defining the digit object                               //
25 // for ITS upgrade                                               //
26 // Inherits from AliDigit                                        //
27 //                                                               //
28 ///////////////////////////////////////////////////////////////////
29
30 ClassImp(AliITSDigitUpgrade)
31 //______________________________________________________________________
32   AliITSDigitUpgrade::AliITSDigitUpgrade():
33     AliDigit(),
34     fPixId(9999),
35     fSignal(0),
36     fNLayer(0),
37     fModule(0),
38     fNelectrons(0),
39     fNTracksIdMC(0)
40 {
41  //
42  // default constructor
43  //
44   for(Int_t i=0; i<kMaxLab ; i++) {
45     fTrackIdMC[i]=-1;
46     fSignalID[i]=-1;
47   }
48
49 //_______________________________________________________________________
50 AliITSDigitUpgrade::AliITSDigitUpgrade(Int_t *digits): 
51   AliDigit(digits),
52   fPixId(9999), 
53   fSignal(0),
54   fNLayer(0),
55   fModule(0), 
56   fNelectrons(0),
57   fNTracksIdMC(0)
58 {
59  //
60  // constructor
61  // 
62   for(Int_t i=0; i<kMaxLab ; i++) {
63     fTrackIdMC[i]=-1;
64     fSignalID[i]=-1;
65   }
66
67 //____________________________________________________________________________________________________
68 AliITSDigitUpgrade::AliITSDigitUpgrade(ULong_t pixid, Float_t eloss): 
69   AliDigit(),
70   fPixId(pixid), 
71   fSignal(eloss),
72   fNLayer(0), 
73   fModule(0),
74   fNelectrons(0),
75   fNTracksIdMC(0)
76 {
77  //
78  // Used constructor in simulation
79  //
80   for(Int_t i=0; i<kMaxLab ; i++) {
81     fTrackIdMC[i]=-1;
82     fSignalID[i]=-1;
83   }
84
85 //____________________________________________________________________________________________________
86 AliITSDigitUpgrade::AliITSDigitUpgrade(const AliITSDigitUpgrade &d):
87   AliDigit(d),
88   fPixId(d.fPixId),
89   fSignal(d.fSignal),
90   fNLayer(d.fNLayer), 
91   fModule(d.fModule), 
92   fNelectrons(d.fNelectrons),
93   fNTracksIdMC(d.fNTracksIdMC)
94 {
95  // 
96  // copy constructor
97  //
98   for(Int_t i=0; i<kMaxLab ; i++) {
99     fTrackIdMC[i]=d.fTrackIdMC[i];
100     fSignalID[i]=d.fSignalID[i];
101   }
102   for(Int_t i=0; i<3 ; i++) fSignalID[i]=d.fSignalID[i];
103
104
105 //____________________________________________________________________________________________________
106 void AliITSDigitUpgrade::AddTrackID(Int_t tid) { 
107   // 
108   // Add an MC label (track ID) to the "expanded list"
109   //
110   if (fNTracksIdMC==kMaxLab) {
111     AliWarning("Max. numbers of labels reached!"); 
112   } else {
113     fTrackIdMC[fNTracksIdMC]=tid; 
114     fNTracksIdMC++;
115   } 
116 }
117
118 //____________________________________________________________________________________________________
119 void  AliITSDigitUpgrade::GetPosition(Int_t ilayer, Int_t nx, Int_t nz, Double_t &xloc, Double_t &zloc){
120   //
121   // Determines the local coordinates of the center of the pixel (a digit is a pixel)
122   //
123
124   AliITSsegmentationUpgrade *s =new AliITSsegmentationUpgrade();
125   if(s->GetCellSizeX(ilayer)!=0) xloc= (nx)*(s->GetCellSizeX(ilayer))+0.5*(s->GetCellSizeX(ilayer));
126   else AliError("Upgrade segmentation not initalized");
127
128   if(s->GetCellSizeZ(ilayer)!=0)
129     zloc=(nz)*(s->GetCellSizeZ(ilayer))+0.5*(s->GetCellSizeZ(ilayer))-(s->GetHalfLength(ilayer));
130   else AliError("Upgrade segmentation not initalized");
131   delete s;
132 }
133 //____________________________________________________________________________________________________
134 void AliITSDigitUpgrade::PrintInfo(){
135   //
136   //Standard output format for this class
137   //
138
139   Double_t xz[2]={-1,-1};
140   GetPosition(fNLayer,GetxPixelNumber(),GetzPixelNumber(),xz[0],xz[1]);
141    
142   printf("pixid  %10.0i (%6.3f,%6.3f) in layer %i \n",(Int_t)fPixId,xz[0],xz[1],fNLayer);
143   printf("pixid  %u ",(UInt_t)fPixId);
144   printf(" (xloc, zloc)= (%6.3f, %6.3f) in layer %i and module %i \n",xz[0],xz[1],fNLayer, fModule);
145   printf(" Eloss %f  Nel %f \n ",fSignal, fNelectrons);
146   printf(" MC Track Ids =(");
147   if (kMaxLab<=fNTracksIdMC) {
148     for (Int_t i=0; i<kMaxLab; i++) { printf("%d,",fTrackIdMC[i]); }
149     printf(")\n ElossID = (");
150     for (Int_t i=0; i<kMaxLab; i++) { printf("%lf,",fSignalID[i]); }
151   } else {
152     for (Int_t i=0; i<fNTracksIdMC; i++) { printf("%d,",fTrackIdMC[i]); }
153     printf(")\n ElossID = (");
154     for (Int_t i=0; i<fNTracksIdMC; i++) { printf("%lf,",fSignalID[i]); }
155   }
156   printf(")\n");
157 }
158