]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSDCSDataSDD.cxx
Fix coding convention violations
[u/mrichter/AliRoot.git] / ITS / AliITSDCSDataSDD.cxx
index 09538bb8ef3461729bedeb807dbdd2ace1eda156..30d34b5e1d1e755e3c6a6cf0e40e90558e14e183 100644 (file)
@@ -16,7 +16,6 @@
 /* $Id$ */
 
 ///////////////////////////////////////////////////////////////////
-//                                                               //
 // Implementation of the class containing SDD DCS data           //
 // Origin: F.Prino, Torino, prino@to.infn.it                     //
 //         V. Pospisil, CTU Praguem gdermog@seznam.cz            //
@@ -29,6 +28,9 @@
 
 ClassImp(AliITSDCSDataSDD)
 
+const Float_t AliITSDCSDataSDD::fgkTPrec = 100.0;
+const Float_t AliITSDCSDataSDD::fgkMVPrec = 1000.0;
+
 //---------------------------------------------------------------------------
 AliITSDCSDataSDD::AliITSDCSDataSDD(): TObject(),
 fTempLeft(0),
@@ -59,7 +61,9 @@ fStatusSetPoints(0)
 
 void AliITSDCSDataSDD::SetNPointsTempLeft( Int_t npts )
 {
+  // dimension arrays with left side temperatures
   //
+
   if( npts < fTempLeftSetPoints)
   {                     // Cannot resize arrays - some elements would be lost
     AliWarning("Attemp to reduce size of full array (SDD DCS _TEMP_L)"); 
@@ -78,7 +82,9 @@ void AliITSDCSDataSDD::SetNPointsTempLeft( Int_t npts )
 
 void AliITSDCSDataSDD::SetNPointsTempRight( Int_t npts )
 {
+  // dimension arrays with right side temperatures
   //
+
   if( npts < fTempRightSetPoints)
   {                     // Cannot resize arrays - some elements would be lost
     AliWarning("Attemp to reduce size of full array (SDD DCS _TEMP_R)");
@@ -97,7 +103,9 @@ void AliITSDCSDataSDD::SetNPointsTempRight( Int_t npts )
 
 void AliITSDCSDataSDD::SetNPointsHV( Int_t npts )
 {
+  // dimension arrays with HV values
   //
+
   if( npts < fHVSetPoints)
   {                     // Cannot resize arrays - some elements would be lost
     AliWarning("Attemp to reduce size of full array (SDD DCS _HV)");
@@ -116,7 +124,9 @@ void AliITSDCSDataSDD::SetNPointsHV( Int_t npts )
 
 void AliITSDCSDataSDD::SetNPointsMV( Int_t npts )
 {
+  // dimension arrays with   MV values
   //
+
   if( npts < fMVSetPoints)
   {                     // Cannot resize arrays - some elements would be lost
     AliWarning("Attemp to reduce size of full array (SDD DCS _MV)");
@@ -135,7 +145,9 @@ void AliITSDCSDataSDD::SetNPointsMV( Int_t npts )
 
 void AliITSDCSDataSDD::SetNPointsStatus( Int_t npts )
 {
+  // dimension arrays withn DCS channel status
   //
+
   if( npts < fStatusSetPoints)
   {                     // Cannot resize arrays - some elements would be lost
     AliWarning("Attemp to reduce size of full array (SDD DCS Status)");
@@ -154,7 +166,9 @@ void AliITSDCSDataSDD::SetNPointsStatus( Int_t npts )
 //---------------------------------------------------------------------------
 void AliITSDCSDataSDD::SetValueTempLeft(Int_t time, Float_t temperature )
 {
+  // insert a value for left temperature data point
   //
+
    if( fTempLeftMaxPoints == fTempLeftSetPoints )
     SetNPointsTempLeft( fTempLeftMaxPoints + AUTORESIZE );
                         // Enlarges arrays if necessary
@@ -170,12 +184,12 @@ void AliITSDCSDataSDD::SetValueTempLeft(Int_t time, Float_t temperature )
 
    if( i < fTempLeftSetPoints )
    {
-      Float_t *fromPtrF = fTempLeft.GetArray() + i;
+      Short_t *fromPtrF = fTempLeft.GetArray() + i;
                        // Sets pointer to cell which have to be filled by new value
-      Float_t *toPtrF = fromPtrF + 1;
+      Short_t *toPtrF = fromPtrF + 1;
                        // Sets pointer to cell where the array content have to be shifted 
 
-      memmove( toPtrF, fromPtrF, (fTempLeftSetPoints - i)*sizeof(Float_t) );
+      memmove( toPtrF, fromPtrF, (fTempLeftSetPoints - i)*sizeof(Short_t) );
                        // Shifts array content. Now there is vacant place for new value to be inserted
 
       Int_t *fromPtrI = fTempLeftTimeStamp.GetArray() + i;
@@ -184,7 +198,10 @@ void AliITSDCSDataSDD::SetValueTempLeft(Int_t time, Float_t temperature )
                        // Do the same for time stamp array
    } /*if*/
 
-   fTempLeft.AddAt( temperature, i );
+   UShort_t val = (UShort_t)( temperature * fgkTPrec );
+                       // Float value of temperature is stored as UShort_t with given precision
+
+   fTempLeft.AddAt( (Short_t)val, i );
    fTempLeftTimeStamp.AddAt( time, i );
    fTempLeftSetPoints++;
                        // New values are inserted
@@ -194,7 +211,9 @@ void AliITSDCSDataSDD::SetValueTempLeft(Int_t time, Float_t temperature )
 
 void AliITSDCSDataSDD::SetValueTempRight(Int_t time, Float_t temperature )
 {
+  // insert a value for right temperature data point
   //
+
    if( fTempRightMaxPoints == fTempRightSetPoints )
     SetNPointsTempRight( fTempRightMaxPoints + AUTORESIZE );
                         // Enlarges arrays if necessary
@@ -210,12 +229,12 @@ void AliITSDCSDataSDD::SetValueTempRight(Int_t time, Float_t temperature )
 
    if( i < fTempRightSetPoints )
    {                    // Some values have to be moved
-      Float_t *fromPtrF = fTempRight.GetArray() + i;
+      Short_t *fromPtrF = fTempRight.GetArray() + i;
                        // Sets pointer to cell which have to be filled by new value
-      Float_t *toPtrF = fromPtrF + 1;
+      Short_t *toPtrF = fromPtrF + 1;
                        // Sets pointer to cell where the array content have to be shifted 
 
-      memmove( toPtrF, fromPtrF, (fTempRightSetPoints - i)*sizeof(Float_t) );
+      memmove( toPtrF, fromPtrF, (fTempRightSetPoints - i)*sizeof(Short_t) );
                        // Shifts array content. Now there is vacant place for new value to be inserted
 
       Int_t *fromPtrI = fTempRightTimeStamp.GetArray() + i;
@@ -224,7 +243,10 @@ void AliITSDCSDataSDD::SetValueTempRight(Int_t time, Float_t temperature )
                        // Do the same for time stamp array
    } /*if*/
 
-   fTempRight.AddAt( temperature, i );
+   UShort_t val = (UShort_t)( temperature * fgkTPrec );
+                       // Float value of temperature is stored as UShort_t with given precision
+
+   fTempRight.AddAt( (Short_t)val, i );
    fTempRightTimeStamp.AddAt( time, i );
    fTempRightSetPoints++;
                        // New values are inserted
@@ -234,7 +256,9 @@ void AliITSDCSDataSDD::SetValueTempRight(Int_t time, Float_t temperature )
 
 void AliITSDCSDataSDD::SetValueHV(Int_t time, Float_t voltage )
 {
+  // insert a value for HV data point
   //
+
    if( fHVMaxPoints == fHVSetPoints )
     SetNPointsHV( fHVMaxPoints + AUTORESIZE );
                         // Enlarges arrays if necessary
@@ -274,7 +298,9 @@ void AliITSDCSDataSDD::SetValueHV(Int_t time, Float_t voltage )
 
 void AliITSDCSDataSDD::SetValueMV(Int_t time, Float_t voltage )
 {
+  // insert a value for MV data point
   //
+
    if( fMVMaxPoints == fMVSetPoints )
     SetNPointsMV( fMVMaxPoints + AUTORESIZE );
                         // Enlarges arrays if necessary
@@ -290,12 +316,12 @@ void AliITSDCSDataSDD::SetValueMV(Int_t time, Float_t voltage )
 
    if( i < fMVSetPoints )
    {
-      Float_t *fromPtrF = fMV.GetArray() + i;
+      Short_t *fromPtrF = fMV.GetArray() + i;
                        // Sets pointer to cell which have to be filled by new value
-      Float_t *toPtrF = fromPtrF + 1;
+      Short_t *toPtrF = fromPtrF + 1;
                        // Sets pointer to cell where the array content have to be shifted 
 
-      memmove( toPtrF, fromPtrF, (fMVSetPoints - i)*sizeof(Float_t) );
+      memmove( toPtrF, fromPtrF, (fMVSetPoints - i)*sizeof(Short_t) );
                        // Shifts array content. Now there is vacant place for new value to be inserted
 
       Int_t *fromPtrI = fMVTimeStamp.GetArray() + i;
@@ -304,7 +330,10 @@ void AliITSDCSDataSDD::SetValueMV(Int_t time, Float_t voltage )
                        // Do the same for time stamp array
    } /*if*/
 
-   fMV.AddAt( voltage, i );
+   UShort_t val = (UShort_t)( voltage * fgkMVPrec );
+                       // Float value of temperature is stored as UShort_t with given precision
+
+   fMV.AddAt( (Short_t)val, i );
    fMVTimeStamp.AddAt( time, i );
    fMVSetPoints++;
                        // New values are inserted
@@ -314,7 +343,9 @@ void AliITSDCSDataSDD::SetValueMV(Int_t time, Float_t voltage )
 
 void AliITSDCSDataSDD::SetValueStatus(Int_t time, Char_t status )
 {
+  // insert a value for channel status
   //
+
    if( fStatusMaxPoints == fStatusSetPoints )
     SetNPointsStatus( fStatusMaxPoints + AUTORESIZE );
                         // Enlarges arrays if necessary
@@ -352,48 +383,11 @@ void AliITSDCSDataSDD::SetValueStatus(Int_t time, Char_t status )
 } /*AliITSDCSDataSDD::SetValueStatus*/
 
 
-//---------------------------------------------------------------------------
-
-Float_t AliITSDCSDataSDD::GetTempLeft( Int_t time )
-{ 
-  //
-   Int_t i = FindIndex( time, fTempLeftTimeStamp, fTempLeftSetPoints ); 
-   return ( i < 0 ) ? -1.0 : fTempLeft.At(i); 
-} /*AliITSDCSDataSDD::GetTempLeft*/
-
-Float_t AliITSDCSDataSDD::GetTempRight( Int_t time )
-{ 
-  //
-   Int_t i = FindIndex( time, fTempRightTimeStamp, fTempRightSetPoints ); 
-   return ( i < 0 ) ? -1.0 : fTempRight.At(i); 
-} /*AliITSDCSDataSDD::GetTempRight*/
-
-Float_t AliITSDCSDataSDD::GetHV( Int_t time )
-{
-  //
-   Int_t i = FindIndex( time, fHVTimeStamp, fHVSetPoints ); 
-   return ( i < 0 ) ? -1.0 : fHV.At(i);
-} /*AliITSDCSDataSDD::GetHV*/
-
-Float_t AliITSDCSDataSDD::GetMV( Int_t time )
-{
-  //
-   Int_t i = FindIndex( time, fMVTimeStamp, fMVSetPoints ); 
-   return ( i < 0 ) ? -1.0 : fMV.At(i); 
-} /*AliITSDCSDataSDD::GetMV*/
-
-Char_t AliITSDCSDataSDD::GetStatus( Int_t time )
-{ 
-  //
-   Int_t i = FindIndex( time, fStatusTimeStamp, fStatusSetPoints ); 
-   return ( i < 0 ) ? -1 : fStatus.At(i);
-} /*AliITSDCSDataSDD::GetStatus*/
-
 //---------------------------------------------------------------------------
 
 void AliITSDCSDataSDD::Compress()
 {
-  // Tries to minimize array sizes
+// Minimize array sizes
 
    SetNPointsTempLeft( fTempLeftSetPoints );
    SetNPointsTempRight( fTempRightSetPoints );
@@ -405,8 +399,8 @@ void AliITSDCSDataSDD::Compress()
 
 //---------------------------------------------------------------------------
 
-Float_t AliITSDCSDataSDD::GetDriftField( Int_t timeStamp )
-{                      
+Float_t AliITSDCSDataSDD::GetDriftField( Int_t timeStamp ) const
+{
 // Returns drift field counted for specific time
 
    Int_t   cathodesNumber = 291;
@@ -426,10 +420,12 @@ Float_t AliITSDCSDataSDD::GetDriftField( Int_t timeStamp )
 
 
 Float_t AliITSDCSDataSDD::GetDriftSpeed( Int_t /*timeStamp*/ ) const
-{                      
-// Returns drift speed counted for specific time. This metod is not dedicated
-//  for normal usage - it should be used only in cases that the injectors for
-                       //  given module fails
+{
+// Returns drift speed counted for specific time. Calculation is based on temerature
+//  taken  from DCS. This metod is not dedicated for normal usage, it should be used
+//  only in cases that the injectors for given module fails.
+//
+// Presently only a prototype, returns -1.0.
 
    /* PROTOTYPE */
 
@@ -441,7 +437,7 @@ Float_t AliITSDCSDataSDD::GetDriftSpeed( Int_t /*timeStamp*/ ) const
 
 
 void AliITSDCSDataSDD:: PrintValues( FILE *output ) const
-{                       
+{
 // Prints array contents
 
     Int_t nTLEntries = GetTempLeftRecords();
@@ -450,13 +446,13 @@ void AliITSDCSDataSDD:: PrintValues( FILE *output ) const
     Int_t nMVEntries = GetMVRecords();
     Int_t nStatEntries = GetStatusRecords();
 
-    fprintf( output, "+-----------------------------------------------------------------------------------------------------------+\n");
-    fprintf( output, "|                                               DCS content                                                 |\n" ); 
-    fprintf( output, "+----------------------+----------------------+---------------------+---------------------+-----------------+\n");
-    fprintf( output, "|    %05i  records    |    %05i  records    |    %05i  records   |    %05i  records   |  %05i records  |\n",
+    fprintf( output, "+------------------------------------------------------------------------------------------------------------+\n");
+    fprintf( output, "|                                                DCS content                                                 |\n" ); 
+    fprintf( output, "+----------------------+-----------------------+---------------------+---------------------+-----------------+\n");
+    fprintf( output, "|    %05i  records    |    %05i   records    |    %05i  records   |    %05i  records   |  %05i records  |\n",
                           nHVEntries, nMVEntries, nTLEntries, nTREntries, nStatEntries );
-    fprintf( output, "|  time (s)     HV     |  time (s)      MV    |  time (s)     TL    |  time (s)     TR    | time (s)   Stat |\n" );
-    fprintf( output, "+----------------------+----------------------+---------------------+---------------------+-----------------+\n");
+    fprintf( output, "|  time (s)     HV     |  time (s)      MV     |  time (s)     TL    |  time (s)     TR    | time (s)   Stat |\n" );
+    fprintf( output, "+----------------------+-----------------------+---------------------+---------------------+-----------------+\n");
 
     Int_t a = (nHVEntries > nMVEntries ) ? nHVEntries : nMVEntries;
     Int_t b = (nTLEntries > nTREntries ) ? nTLEntries : nTREntries;
@@ -473,9 +469,9 @@ void AliITSDCSDataSDD:: PrintValues( FILE *output ) const
          fprintf( output, "|                      | ");
 
         if( entryLoop < nMVEntries )
-         fprintf( output, " %12i  %2.2f | ", GetMVTimeIdx(entryLoop), GetMVIdx(entryLoop) );
+         fprintf( output, " %12i  %2.3f | ", GetMVTimeIdx(entryLoop), GetMVIdx(entryLoop) );
         else
-         fprintf( output, "                     | ");
+         fprintf( output, "                      | ");
 
         if( entryLoop < nTLEntries )
          fprintf( output, "%12i  %2.2f | ", GetTempLeftTimeIdx(entryLoop), GetTempLeftIdx(entryLoop) );
@@ -499,18 +495,20 @@ void AliITSDCSDataSDD:: PrintValues( FILE *output ) const
 
 //---------------------------------------------------------------------------
 
-Int_t AliITSDCSDataSDD::FindIndex( Int_t time, TArrayI &timeArray, Int_t n ) const
-{                       
-// Provides binary search in the time array
+Int_t AliITSDCSDataSDD::FindIndex( Int_t timeStamp, const TArrayI &timeStampArray, Int_t n ) const
+{
+// Provides binary search in the time array. Returns index in the array of time 
+//  stamps by selected value. Returns -1 if the time is less than time stamp in 
+//  the timeArray[0]
 
   if( n < 1 ) return -1;// Empty array or wrong value of array size
 
-  if( time >= timeArray.At(n-1) ) return n-1;
+  if( timeStamp >= timeStampArray.At(n-1) ) return n-1;
                         // Time is larger than last timestamp - last value in the array have
                         //  to be used. This is the most frequent case, so it have sense
                         //  to check it and avoid searching.
 
-  if( time < timeArray.At(0) ) return -1;
+  if( timeStamp < timeStampArray.At(0) ) return -1;
                         // Time is less than all time stamp stored in the array
 
   Int_t left = 0;
@@ -520,14 +518,14 @@ Int_t AliITSDCSDataSDD::FindIndex( Int_t time, TArrayI &timeArray, Int_t n ) con
   while( !( middle == left || middle == right) )
   {                     // Binary search in the time stamp array
 
-     if( timeArray.At(middle) < time )
+     if( timeStampArray.At(middle) < timeStamp )
       left = middle;
      else
       right = middle;
      middle = (left + right)/2;
   } /*while*/
 
-  if( time >= timeArray.At(right) )
+  if( timeStamp >= timeStampArray.At(right) )
    return right;
   else
    return left;