CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

SiStripApvShotCleaner Class Reference

#include <SiStripApvShotCleaner.h>

List of all members.

Classes

struct  orderingByCharge

Public Member Functions

bool clean (const edmNew::DetSet< SiStripDigi > &in, edmNew::DetSet< SiStripDigi >::const_iterator &scan, edmNew::DetSet< SiStripDigi >::const_iterator &end)
bool clean (const edm::DetSet< SiStripDigi > &in, edm::DetSet< SiStripDigi >::const_iterator &scan, edm::DetSet< SiStripDigi >::const_iterator &end)
bool loop (const edmNew::DetSet< SiStripDigi > &in)
bool loop (const edm::DetSet< SiStripDigi > &in)
bool noShots ()
void refresh ()
void reset (edm::DetSet< SiStripDigi >::const_iterator &a, edm::DetSet< SiStripDigi >::const_iterator &b)
 SiStripApvShotCleaner ()
 ~SiStripApvShotCleaner ()

Private Member Functions

void dumpInVector (edm::DetSet< SiStripDigi >::const_iterator *, size_t)
void subtractCM ()

Private Attributes

std::vector< SiStripDigiapvDigis
uint32_t cacheDetId
unsigned short maxNumOfApvs
edm::DetSet< SiStripDigi > * pDetSet
edm::DetSet< SiStripDigi >
::const_iterator 
pFirstDigiOfApv [7]
bool shotApv_ [25]
bool shots_
unsigned short stripsForMedian
unsigned short stripsPerApv
std::vector< SiStripDigivdigis

Detailed Description

Definition at line 11 of file SiStripApvShotCleaner.h.


Constructor & Destructor Documentation

SiStripApvShotCleaner::SiStripApvShotCleaner ( )

Definition at line 9 of file SiStripApvShotCleaner.cc.

                       :
  pDetSet(0),
  maxNumOfApvs(6),  //FED Default: 6 (i.e. max num apvs )
  stripsPerApv(128),
  stripsForMedian(64){}
SiStripApvShotCleaner::~SiStripApvShotCleaner ( ) [inline]

Definition at line 16 of file SiStripApvShotCleaner.h.

{};

Member Function Documentation

bool SiStripApvShotCleaner::clean ( const edmNew::DetSet< SiStripDigi > &  in,
edmNew::DetSet< SiStripDigi >::const_iterator &  scan,
edmNew::DetSet< SiStripDigi >::const_iterator &  end 
) [inline]

Definition at line 20 of file SiStripApvShotCleaner.h.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_().

{return false;} //FIXME
bool SiStripApvShotCleaner::clean ( const edm::DetSet< SiStripDigi > &  in,
edm::DetSet< SiStripDigi >::const_iterator &  scan,
edm::DetSet< SiStripDigi >::const_iterator &  end 
)

Definition at line 18 of file SiStripApvShotCleaner.cc.

References loop(), reset(), and edm::DetSet< T >::size().

                                                                                                                              {
  if(in.size()<64)
    return false;
  
  if(loop(in)){
    reset(scan,end);
    return true;
  }
  return false;
}
void SiStripApvShotCleaner::dumpInVector ( edm::DetSet< SiStripDigi >::const_iterator *  pFirstDigiOfApv,
size_t  maxNumOfApvs 
) [private]

Definition at line 89 of file SiStripApvShotCleaner.cc.

References apvDigis, cacheDetId, i, maxNumOfApvs, shotApv_, strip(), subtractCM(), and vdigis.

Referenced by loop().

                                                                                       { 
  vdigis.clear();
  //loop on Apvs and remove shots. if an apv doesn't have shots, copy it
  for(size_t i=0;i<maxNumOfApvs;++i){
    apvDigis.clear();

    if(shotApv_[i]){
      apvDigis.insert(apvDigis.end(),pFirstDigiOfApv[i],pFirstDigiOfApv[i+1]);
      subtractCM();
      stable_sort(apvDigis.begin(),apvDigis.end());
      vdigis.insert(vdigis.end(),apvDigis.begin(),apvDigis.end());
    }else{
      vdigis.insert(vdigis.end(),pFirstDigiOfApv[i],pFirstDigiOfApv[i+1]);
    }
  }
  
#ifdef DEBUGME 
  std::stringstream ss;
  ss <<"detid " << cacheDetId << " new digi.size " << vdigis.size() << "\n";
  for(size_t i=0;i<vdigis.size();++i)
    ss << "\t " << i << " strip " << vdigis[i].strip() << " adc " << vdigis[i].adc() ;
  edm::LogInfo("ApvShot") << ss.str() << std::endl;
#endif
}
bool SiStripApvShotCleaner::loop ( const edmNew::DetSet< SiStripDigi > &  in) [inline]

Definition at line 23 of file SiStripApvShotCleaner.h.

Referenced by clean().

{return false;} //FIXME
bool SiStripApvShotCleaner::loop ( const edm::DetSet< SiStripDigi > &  in)

Definition at line 30 of file SiStripApvShotCleaner.cc.

References edm::DetSet< T >::begin(), cacheDetId, edm::DetSet< T >::detId(), dumpInVector(), edm::DetSet< T >::end(), i, maxNumOfApvs, pFirstDigiOfApv, shotApv_, shots_, edm::DetSet< T >::size(), stripsForMedian, and stripsPerApv.

                                      {

#ifdef DEBUGME 
  std::stringstream ss;  
  ss << __func__ << " working on detid " << in.detId() << " for a digi.size=" << in.size();
#endif
  
  shots_=false;
  BOOST_FOREACH(bool& val,shotApv_)
    val=false;
  
  cacheDetId=in.detId();

  //Find the position in the DetSet where the first strip of an apv should be inserted
  // needed to deduce if at least stripsForMedian strips per apv have been fired
  for(size_t i=0;i<=maxNumOfApvs;++i){
    
    SiStripDigi d(i*stripsPerApv,0); //Fake digi, at the edge of the apv
    pFirstDigiOfApv[i] = std::lower_bound(in.begin(),in.end(),d);

    //if satisfied it means that the number of digis in the apv i-1 is above stripsForMedia -> apvShot
    if(i>0 && pFirstDigiOfApv[i]-pFirstDigiOfApv[i-1]>stripsForMedian){
      shots_=true;
      shotApv_[i-1]=true;
#ifdef DEBUGME 
      ss << " found an apv shot of " << pFirstDigiOfApv[i]-pFirstDigiOfApv[i-1] << " digis in detid " << in.detId() << " apv " << i << std::endl;
#endif
    }
    
    //---------------------
    //Just for debug REMOVE
    /*
    if(i>0){
      ss << "detid " << in.detId() << " apv " << i-1 << " number digis " << pFirstDigiOfApv[i]-pFirstDigiOfApv[i-1] << " \t shot " << shotApv_[i-1] << std::endl;
      if(pFirstDigiOfApv[i]-pFirstDigiOfApv[i-1]>stripsForMedian-2){
        edm::DetSet<SiStripDigi>::const_iterator dig=pFirstDigiOfApv[i-1];
        while(dig!=pFirstDigiOfApv[i]){
          ss << "\t strip " << dig->strip() << " dig.adc " << dig->adc();
          dig++;
        }
        ss << std::endl;
      }
    }
    */
    //-------------------------------
  }
  
#ifdef DEBUGME 
  edm::LogInfo("ApvShot") << ss.str();
#endif

  if(!shots_)
    return false;

  dumpInVector(pFirstDigiOfApv,maxNumOfApvs);
  return true;
}
bool SiStripApvShotCleaner::noShots ( ) [inline]

Definition at line 18 of file SiStripApvShotCleaner.h.

References shots_.

{return !shots_;}
void SiStripApvShotCleaner::refresh ( )

Definition at line 162 of file SiStripApvShotCleaner.cc.

References NULL, and pDetSet.

Referenced by reset().

         {
  if(pDetSet!=NULL)
    delete pDetSet;
}
void SiStripApvShotCleaner::reset ( edm::DetSet< SiStripDigi >::const_iterator &  a,
edm::DetSet< SiStripDigi >::const_iterator &  b 
)
void SiStripApvShotCleaner::subtractCM ( ) [private]

Definition at line 114 of file SiStripApvShotCleaner.cc.

References ecalMGPA::adc(), apvDigis, cacheDetId, i, strip(), and stripsForMedian.

Referenced by dumpInVector().

                                      {

  //order by charge
  stable_sort(apvDigis.begin(),apvDigis.end(),orderingByCharge());

  //ignore case where 64th strip is 0ADC
  if(apvDigis[stripsForMedian].adc()==0){
#ifdef DEBUGME 
        std::stringstream ss;
        ss << "case with strip64=0 --> detid= "<<cacheDetId<< "\n";
        edm::LogInfo("ApvShot") << ss.str();
#endif
     return;
  }

  //Find the Median
  float CM = .5*(apvDigis[stripsForMedian].adc()+apvDigis[stripsForMedian-1].adc());
  
  
  if(CM<=0) 
    return;

  //Subtract the median
  size_t i=0;
  for(;i<stripsForMedian&&apvDigis[i].adc()>CM;++i){
    uint16_t adc=apvDigis[i].adc()>253?apvDigis[i].adc():(uint16_t)(apvDigis[i].adc()-CM);
    apvDigis[i]=SiStripDigi(apvDigis[i].strip(),adc);
  }
  apvDigis.resize(i);

#ifdef DEBUGME 
  std::stringstream ss;
  ss << "[subtractCM] detid " << cacheDetId << "  CM is " << CM << " the remaining strips after CM subtraction are  " << i;
  edm::LogInfo("ApvShot") << ss.str();
#endif
}

Member Data Documentation

Definition at line 46 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and subtractCM().

Definition at line 41 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), loop(), reset(), and subtractCM().

unsigned short SiStripApvShotCleaner::maxNumOfApvs [private]

Definition at line 48 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

Definition at line 47 of file SiStripApvShotCleaner.h.

Referenced by refresh(), and reset().

Definition at line 44 of file SiStripApvShotCleaner.h.

Referenced by loop().

bool SiStripApvShotCleaner::shotApv_[25] [private]

Definition at line 43 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and loop().

Definition at line 42 of file SiStripApvShotCleaner.h.

Referenced by loop(), and noShots().

unsigned short SiStripApvShotCleaner::stripsForMedian [private]

Definition at line 50 of file SiStripApvShotCleaner.h.

Referenced by loop(), and subtractCM().

unsigned short SiStripApvShotCleaner::stripsPerApv [private]

Definition at line 49 of file SiStripApvShotCleaner.h.

Referenced by loop().

Definition at line 46 of file SiStripApvShotCleaner.h.

Referenced by dumpInVector(), and reset().