#include "hstart2cal.h"
#include "TBuffer.h"
ClassImp(HStart2Cal)
Float_t HStart2Cal::getTime(const Int_t n) const
{
   
   switch (n) {
      case 1:
         return fTime1;
      case 2:
         return fTime2;
      case 3:
         return fTime3;
      case 4:
         return fTime4;
      case 5:
         return fTime5;
      case 6:
         return fTime6;
      case 7:
         return fTime7;
      case 8:
         return fTime8;
      case 9:
         return fTime9;
      case 10:
         return fTime10;
      default:
         Error("getTime", "hit number: %i out of range [1,%i]", n,STARTCALMAX);
         return -1.;
   }
}
Float_t HStart2Cal::getWidth(const Int_t n) const
{
   
   switch (n) {
      case 1:
         return fWidth1;
      case 2:
         return fWidth2;
      case 3:
         return fWidth3;
      case 4:
         return fWidth4;
      case 5:
         return fWidth5;
      case 6:
         return fWidth6;
      case 7:
         return fWidth7;
      case 8:
         return fWidth8;
      case 9:
         return fWidth9;
      case 10:
         return fWidth10;
      default:
         Error("getWidth", "hit number: %i out of range [1,%i]", n,STARTCALMAX);
         return -1.;
   }
}
void HStart2Cal::getTimeAndWidth(const Int_t n, Float_t& time, Float_t& width)
{
   
   switch (n) {
      case 1:
         time = fTime1;
         width  = fWidth1;
         return;
      case 2:
         time = fTime2;
         width  = fWidth2;
         return;
      case 3:
         time = fTime3;
         width  = fWidth3;
         return;
      case 4:
         time = fTime4;
         width  = fWidth4;
         return;
      case 5:
         time = fTime5;
         width  = fWidth5;
         return;
      case 6:
         time = fTime6;
         width  = fWidth6;
         return;
      case 7:
         time = fTime7;
         width  = fWidth7;
         return;
      case 8:
         time = fTime8;
         width  = fWidth8;
         return;
      case 9:
         time = fTime9;
         width  = fWidth9;
         return;
      case 10:
         time = fTime10;
         width  = fWidth10;
         return;
      default:
         Error("getTimeAndWidth", "hit number: %i out of range [1,%i]", n,STARTCALMAX);
         time = -1.;
         width  = -1.;
         return;
   }
}
Bool_t HStart2Cal::setTimeAndWidth(const Float_t time, const Float_t width)
{
   
   
   
   switch (fMultiplicity) {
      case 0:
         fTime1 = time;
         fWidth1  = width;
         ++fMultiplicity;
         return kTRUE;
      case 1:
         fTime2 = time;
         fWidth2  = width;
         ++fMultiplicity;
         return kTRUE;
      case 2:
         fTime3 = time;
         fWidth3  = width;
         ++fMultiplicity;
         return kTRUE;
      case 3:
         fTime4 = time;
         fWidth4  = width;
         ++fMultiplicity;
         return kTRUE;
      case 4:
         fTime5 = time;
         fWidth5  = width;
         ++fMultiplicity;
         return kTRUE;
      case 5:
         fTime6 = time;
         fWidth6  = width;
         ++fMultiplicity;
         return kTRUE;
      case 6:
         fTime7 = time;
         fWidth7  = width;
         ++fMultiplicity;
         return kTRUE;
      case 7:
         fTime8 = time;
         fWidth8  = width;
         ++fMultiplicity;
         return kTRUE;
      case 8:
         fTime9 = time;
         fWidth9  = width;
         ++fMultiplicity;
         return kTRUE;
      case 9:
         fTime10 = time;
         fWidth10  = width;
         ++fMultiplicity;
         return kTRUE;
      default:
         if (fMultiplicity >= STARTCALMAX) {
            ++fMultiplicity; 
         }
         return kFALSE;
   }
   return kTRUE;
}
void HStart2Cal::Streamer(TBuffer &R__b)
{
   
   UInt_t R__s, R__c;
   if (R__b.IsReading()) {
      Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
      TObject::Streamer(R__b);
      R__b >> fMultiplicity;
      R__b >> fModule;
      R__b >> fStrip;
      R__b >> fTime1;
      R__b >> fWidth1;
      R__b >> fTime2;
      R__b >> fWidth2;
      R__b >> fTime3;
      R__b >> fWidth3;
      R__b >> fTime4;
      R__b >> fWidth4;
      if(R__v > 4){
	  R__b >> fTime5;
	  R__b >> fWidth5;
	  R__b >> fTime6;
	  R__b >> fWidth6;
	  R__b >> fTime7;
	  R__b >> fWidth7;
	  R__b >> fTime8;
	  R__b >> fWidth8;
	  R__b >> fTime9;
	  R__b >> fWidth9;
	  R__b >> fTime10;
	  R__b >> fWidth10;
      } else {
	  fTime5=fTime6=fTime7=fTime8=fTime9=fTime10=-1000000.;
          fWidth5=fWidth6=fWidth7=fWidth8=fWidth9=fWidth10=-1000000.;
      }
      R__b.CheckByteCount(R__s, R__c, HStart2Cal::IsA());
   } else {
      R__c = R__b.WriteVersion(HStart2Cal::IsA(), kTRUE);
      TObject::Streamer(R__b);
      R__b << fMultiplicity;
      R__b << fModule;
      R__b << fStrip;
      R__b << fTime1;
      R__b << fWidth1;
      R__b << fTime2;
      R__b << fWidth2;
      R__b << fTime3;
      R__b << fWidth3;
      R__b << fTime4;
      R__b << fWidth4;
      R__b << fTime5;
      R__b << fWidth5;
      R__b << fTime6;
      R__b << fWidth6;
      R__b << fTime7;
      R__b << fWidth7;
      R__b << fTime8;
      R__b << fWidth8;
      R__b << fTime9;
      R__b << fWidth9;
      R__b << fTime10;
      R__b << fWidth10;
      R__b.SetByteCount(R__c, kTRUE);
   }
}