CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

TT6CommonModeCalculator Class Reference

#include <TT6CommonModeCalculator.h>

Inheritance diagram for TT6CommonModeCalculator:
TkCommonModeCalculator

List of all members.

Public Member Functions

TkCommonModecommonMode ()
ApvAnalysis::PedestalType doIt (ApvAnalysis::PedestalType)
float getCMSlope ()
void newEvent ()
void setCM (std::vector< float > in)
void setCM (TkCommonMode *in)
 TT6CommonModeCalculator (TkNoiseCalculator *noise_calc, TkApvMask *mask_calc, float sig_cut)
virtual ~TT6CommonModeCalculator ()

Protected Member Functions

void calculateCMSlope (ApvAnalysis::PedestalType &)
void calculateCommonMode (ApvAnalysis::PedestalType &)

Protected Attributes

bool alreadyUsedEvent
float cutToAvoidSignal
float slope
TkApvMasktheApvMask
std::vector< float > theCommonModeValues
TkNoiseCalculatortheNoiseCalculator
TkCommonModetheTkCommonMode

Detailed Description

Concrete implementation of TkCommonModeCalculator for TT6.

Definition at line 11 of file TT6CommonModeCalculator.h.


Constructor & Destructor Documentation

TT6CommonModeCalculator::TT6CommonModeCalculator ( TkNoiseCalculator noise_calc,
TkApvMask mask_calc,
float  sig_cut 
)

Definition at line 5 of file TT6CommonModeCalculator.cc.

References gather_cfg::cout, and cutToAvoidSignal.

                                                                                                                   : 
  theNoiseCalculator(noise_calc),
  theApvMask(mask_calc),
  alreadyUsedEvent(false)
{
  if (0) cout << "Constructing TT6CommonMode Calculator ..." << endl;
  cutToAvoidSignal = sig_cut;
}
TT6CommonModeCalculator::~TT6CommonModeCalculator ( ) [virtual]

Definition at line 16 of file TT6CommonModeCalculator.cc.

References gather_cfg::cout.

                                                  {
  if (0) cout << "Destructing TT6CommonModeCalculator " << endl;
}

Member Function Documentation

void TT6CommonModeCalculator::calculateCMSlope ( ApvAnalysis::PedestalType indat) [protected]

Definition at line 84 of file TT6CommonModeCalculator.cc.

References asciidump::s, slope, and python::multivaluedict::sort().

Referenced by calculateCommonMode().

                                                                             {
  if (indat.size() != 128) {
    slope = -100.0;
    return;
  }
  ApvAnalysis::PedestalType diffVec;
  diffVec.clear();
  for(int s=0;s<64;s++) diffVec.push_back(indat[s+64]-indat[s]);
  std::sort(diffVec.begin(),diffVec.end());
  slope = (diffVec[31]+diffVec[32])/2./64.;
}
void TT6CommonModeCalculator::calculateCommonMode ( ApvAnalysis::PedestalType indat) [protected]

Definition at line 41 of file TT6CommonModeCalculator.cc.

References alreadyUsedEvent, calculateCMSlope(), cutToAvoidSignal, TkCommonModeTopology::finalStrips(), i, TkCommonModeTopology::initialStrips(), j, TkApvMask::mask(), TkNoiseCalculator::noise(), TkCommonModeTopology::numberOfSets(), TkApvMask::ok, setCM(), theApvMask, theCommonModeValues, theNoiseCalculator, theTkCommonMode, and TkCommonMode::topology().

{ 
  if (alreadyUsedEvent == false) {
    alreadyUsedEvent = true;
    //  cout<< "I am inside the calculateCommonMode"<<endl;
    TkApvMask::MaskType strip_mask = theApvMask->mask();
    ApvAnalysis::PedestalType strip_noise = theNoiseCalculator->noise();
    theCommonModeValues.clear();
    
    if(strip_noise.size() > 0) {
      int nSet = theTkCommonMode->topology().numberOfSets();
      for (int i=0; i<nSet; i++){
        int initial   = theTkCommonMode->topology().initialStrips()[i];
        int final     = theTkCommonMode->topology().finalStrips()[i];
        double sumVal = 0.0;
        double sumWt =  0.0;
        for (int j = initial; j <= final; j++) {
          if (strip_mask[j] == TkApvMask::ok ) {
            if(fabs(indat[j]) < cutToAvoidSignal*strip_noise[j]) { 
              double nWeight = 1/(strip_noise[j]*strip_noise[j]);
              sumVal += (indat[j]*nWeight);
              sumWt += nWeight;
            }
          }
        }
        double avVal = (sumWt) ? sumVal/sumWt :0.0;
        theCommonModeValues.push_back(static_cast<float>(avVal));
        //cout <<"Setting CM values"<<endl;
      }
    }
  }
  TT6CommonModeCalculator::setCM(theCommonModeValues);
  calculateCMSlope(indat);     
}
TkCommonMode* TT6CommonModeCalculator::commonMode ( ) [inline, virtual]

Get CM value

Implements TkCommonModeCalculator.

Definition at line 23 of file TT6CommonModeCalculator.h.

References theTkCommonMode.

{return theTkCommonMode;}
ApvAnalysis::PedestalType TT6CommonModeCalculator::doIt ( ApvAnalysis::PedestalType  ) [virtual]

Return CM-subtracted data in APV

Implements TkCommonModeCalculator.

Definition at line 23 of file TT6CommonModeCalculator.cc.

References i, and dbtoconf::out.

{
  ApvAnalysis::PedestalType out;
  calculateCommonMode(indat);
  int setNumber;
  if(theCommonModeValues.size() >0) {
    for (unsigned int i=0; i<indat.size(); i++){
      setNumber = theTkCommonMode->topology().setOfStrip(i);
      out.push_back(indat[i] - theCommonModeValues[setNumber]);
    }  
  }else{
    out = indat;
  }
  return out;
}
float TT6CommonModeCalculator::getCMSlope ( ) [inline, virtual]

Get Slope

Implements TkCommonModeCalculator.

Definition at line 26 of file TT6CommonModeCalculator.h.

References slope.

{ return slope;}
void TT6CommonModeCalculator::newEvent ( ) [virtual]

Tell CM calculator that a new event is available

Reimplemented from TkCommonModeCalculator.

Definition at line 78 of file TT6CommonModeCalculator.cc.

References alreadyUsedEvent.

                                       {
  alreadyUsedEvent = false;
}
void TT6CommonModeCalculator::setCM ( std::vector< float >  in) [inline, virtual]
void TT6CommonModeCalculator::setCM ( TkCommonMode in) [inline, virtual]

Implements TkCommonModeCalculator.

Definition at line 21 of file TT6CommonModeCalculator.h.

References recoMuon::in, and theTkCommonMode.

Referenced by calculateCommonMode().


Member Data Documentation

Definition at line 37 of file TT6CommonModeCalculator.h.

Referenced by calculateCommonMode(), and newEvent().

Definition at line 41 of file TT6CommonModeCalculator.h.

Referenced by calculateCommonMode(), and TT6CommonModeCalculator().

float TT6CommonModeCalculator::slope [protected]

Definition at line 38 of file TT6CommonModeCalculator.h.

Referenced by calculateCMSlope(), and getCMSlope().

Definition at line 36 of file TT6CommonModeCalculator.h.

Referenced by calculateCommonMode().

std::vector<float> TT6CommonModeCalculator::theCommonModeValues [protected]

Definition at line 34 of file TT6CommonModeCalculator.h.

Referenced by calculateCommonMode().

Definition at line 35 of file TT6CommonModeCalculator.h.

Referenced by calculateCommonMode().

Definition at line 33 of file TT6CommonModeCalculator.h.

Referenced by calculateCommonMode(), commonMode(), and setCM().