]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/Alieve/TPCSectorData.cxx
Fix effc++ warnings.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSectorData.cxx
index 06c3adf214af0a0e82e0e8c73b4021d0a43c9a2d..0c5e0aa89c3717f555c8ef591980b8c24c10d57b 100644 (file)
 using namespace Reve;
 using namespace Alieve;
 
-ClassImp(TPCSectorData);
+ClassImp(TPCSectorData)
 
 AliTPCParam* TPCSectorData::fgParam    = 0;
+Float_t      TPCSectorData::fgZLength  = 0;
 Int_t        TPCSectorData::fgNAllRows = 0;
 Int_t        TPCSectorData::fgNAllPads = 0;
 Int_t*       TPCSectorData::fgRowBegs  = 0;
@@ -43,6 +44,7 @@ void TPCSectorData::InitStatics()
   if(fgParam != 0) return;
 
   fgParam    = new AliTPCParamSR;
+  fgZLength  = fgParam->GetZLength();
   fgNAllRows = fgParam->GetNRowLow() + fgParam->GetNRowUp();
   fgNAllPads = 0;
   fgRowBegs  = new Int_t[fgNAllRows + 1];
@@ -152,9 +154,10 @@ void TPCSectorData::NewBlock()
 /**************************************************************************/
 
 TPCSectorData::TPCSectorData(Int_t sector, Int_t bsize) :
-  fSectorID(sector), fNPadsFilled(0),
-  fBlockSize(bsize), fBlockPos(0),
-  fCurrentRow(0), fCurrentPad(0), fCurrentPos(0)
+  fSectorID(sector), fNPadsFilled(0), fPads(),
+  fBlockSize(bsize), fBlockPos(0),    fBlocks(),
+  fCurrentRow(0), fCurrentPad(0), fCurrentPos(0), fCurrentStep(0),
+  fPadRowHackSet(0)
 {
   if(fgParam == 0) InitStatics();
 
@@ -168,6 +171,16 @@ TPCSectorData::~TPCSectorData()
 {
   for(std::vector<Short_t*>::iterator b=fBlocks.begin(); b!=fBlocks.end(); ++b)
     delete [] *b;
+  DeletePadRowHack();
+}
+
+void TPCSectorData::DropData()
+{
+  fPads.assign(fgNAllPads, PadData());
+  for(std::vector<Short_t*>::iterator b=fBlocks.begin(); b!=fBlocks.end(); ++b)
+    delete [] *b;
+  fBlocks.clear();
+  fBlockPos = fBlockSize; // Enforce creation of a new block.
 }
 
 /**************************************************************************/
@@ -191,9 +204,12 @@ void TPCSectorData::BeginPad(Int_t row, Int_t pad, Bool_t reverseTime)
     fCurrentPos  = 0;
     fCurrentStep = 2;
   }
+  //printf("begpad for row=%d pad=%d\n  buf=%p pos=%d step=%d\n",
+  //     fCurrentRow, fCurrentPad,
+  //     fPadBuffer, fCurrentPos, fCurrentStep);
 }
 
-void TPCSectorData::EndPad()
+void TPCSectorData::EndPad(Bool_t autoPedestal, Short_t threshold)
 {
   Short_t *beg, *end;
   if(fCurrentStep > 0) {
@@ -203,6 +219,40 @@ void TPCSectorData::EndPad()
     beg = fPadBuffer + fCurrentPos + 2;
     end = fPadBuffer + 2048;
   }
+
+  //printf("endpad for row=%d pad=%d\n  buf=%p beg=%p end=%p pos=%d step=%d\n",
+  //     fCurrentRow, fCurrentPad,
+  //     fPadBuffer, beg, end, fCurrentPos, fCurrentStep);
+  if(beg >= end)
+    return;
+
+  if(autoPedestal) {
+    Short_t array[1024];
+    Short_t* val;
+    val = beg + 1;    
+    while(val <= end) {
+      array[(val-beg)/2] = *val;
+      val += 2;
+    }    
+    Short_t pedestal = TMath::Nint(TMath::Median((end-beg)/2, array));
+    val = beg + 1;
+    while(val <= end) {
+      *val -= pedestal;
+      val += 2;
+    }
+    Short_t* wpos = beg;
+    Short_t* rpos = beg;
+    while(rpos < end) {
+      if(rpos[1] > threshold) {
+       wpos[0] = rpos[0];
+       wpos[1] = rpos[1];
+       wpos += 2;
+      }
+      rpos += 2;
+    }
+    end = wpos;
+  }
+
   Short_t* wpos = beg;
   Short_t* rpos = beg;
 
@@ -394,9 +444,60 @@ void TPCSectorData::RowIterator::Test()
 // TPCSectorData::SegmentInfo
 /**************************************************************************/
 
-ClassImp(TPCSectorData::SegmentInfo);
+ClassImp(TPCSectorData::SegmentInfo)
 
-TPCSectorData::SegmentInfo::SegmentInfo()
+TPCSectorData::SegmentInfo::SegmentInfo() :
+  TObject(),
+
+  fPadWidth(0), fPadHeight(0),
+  fRLow(0), fNRows(0), fFirstRow(0), fLastRow(0),
+  fNMaxPads(0),
+  fNYSteps(0)
 {
-  memset(this, sizeof(SegmentInfo), 0);
+  memset(fYStep, sizeof(fYStep), 0);
+}
+
+/**************************************************************************/
+// TPCSectorData::PadRowHack
+/**************************************************************************/
+
+#include <set>
+
+TPCSectorData::PadRowHack* TPCSectorData::GetPadRowHack(Int_t r, Int_t p)
+{
+  if(fPadRowHackSet == 0) return 0;
+  std::set<PadRowHack>* hs = static_cast<std::set<PadRowHack>*>(fPadRowHackSet);
+  std::set<PadRowHack>::iterator i = hs->find(PadRowHack(r,p));
+  return (i == hs->end()) ? 0 : const_cast<PadRowHack*>(&*i);
+}
+
+void TPCSectorData::AddPadRowHack(Int_t r, Int_t p, Int_t te, Float_t tf)
+{
+  if(fPadRowHackSet == 0) fPadRowHackSet = new std::set<PadRowHack>;
+
+  PadRowHack* prh = GetPadRowHack(r, p);
+  if(prh == 0) {
+    std::set<PadRowHack>* hs = static_cast<std::set<PadRowHack>*>(fPadRowHackSet);
+    hs->insert(PadRowHack(r, p, te, tf));
+  } else {
+    prh->fThrExt += te;
+    prh->fThrFac *= tf;
+  }
+}
+
+void TPCSectorData::RemovePadRowHack(Int_t r, Int_t p)
+{
+  if(fPadRowHackSet == 0) return;
+  std::set<PadRowHack>*hs = static_cast<std::set<PadRowHack>*>(fPadRowHackSet);
+  std::set<PadRowHack>::iterator i = hs->find(PadRowHack(r,p));
+  if(i != hs->end()) hs->erase(i);
+}
+
+void TPCSectorData::DeletePadRowHack()
+{
+  if(fPadRowHackSet != 0) {
+    std::set<PadRowHack>*hs = static_cast<std::set<PadRowHack>*>(fPadRowHackSet);
+    delete hs;
+    fPadRowHackSet = 0;
+  }
 }