CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

SiStripDigitizerAlgorithm Class Reference

#include <SiStripDigitizerAlgorithm.h>

List of all members.

Public Types

typedef float Amplitude
typedef
SiDigitalConverter::DigitalRawVecType 
DigitalRawVecType
typedef
SiDigitalConverter::DigitalVecType 
DigitalVecType
typedef std::map< int, float,
std::less< int > > 
hit_map_type
typedef
SiPileUpSignals::SignalMapType 
SignalMapType

Public Member Functions

void accumulateSimHits (const std::vector< PSimHit >::const_iterator inputBegin, const std::vector< PSimHit >::const_iterator inputEnd, const StripGeomDetUnit *stripdet, const GlobalVector &bfield)
void digitize (edm::DetSet< SiStripDigi > &outDigis, edm::DetSet< SiStripRawDigi > &outRawDigis, const StripGeomDetUnit *stripdet, edm::ESHandle< SiStripGain > &, edm::ESHandle< SiStripThreshold > &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripPedestals > &)
void initializeDetUnit (StripGeomDetUnit *det, const edm::EventSetup &iSetup)
void initializeEvent (const edm::EventSetup &iSetup)
void setParticleDataTable (const ParticleDataTable *pardt)
 SiStripDigitizerAlgorithm (const edm::ParameterSet &conf, CLHEP::HepRandomEngine &)
 ~SiStripDigitizerAlgorithm ()

Private Attributes

std::map< unsigned int,
std::vector< bool > > 
allBadChannels
const bool APVSaturationFromHIP
const double APVSaturationProb
const bool BaselineShift
const double cmnRMStec
const double cmnRMStib
const double cmnRMStid
const double cmnRMStob
const bool CommonModeNoise
const double cosmicShift
std::map< unsigned int, size_t > firstChannelsWithSignal
const double inefficiency
std::map< unsigned int, size_t > lastChannelsWithSignal
edm::ESHandle
< SiStripLorentzAngle
lorentzAngleHandle
const std::string lorentzAngleName
const bool makeDigiSimLinks_
const bool noise
const ParticleDataparticle
const ParticleDataTablepdt
const bool peakMode
const double pedOffset
const bool RealPedestals
const bool SingleStripNoise
const double theElectronPerADC
const int theFedAlgo
const std::unique_ptr
< CLHEP::RandFlat > 
theFlatDistribution
const std::unique_ptr
< SiTrivialDigitalConverter
theSiDigitalConverter
const std::unique_ptr
< SiHitDigitizer
theSiHitDigitizer
const std::unique_ptr< const
SiGaussianTailNoiseAdder
theSiNoiseAdder
const std::unique_ptr
< SiPileUpSignals
theSiPileUpSignals
const std::unique_ptr
< SiStripFedZeroSuppression
theSiZeroSuppress
const double theThreshold
const double theTOFCutForDeconvolution
const double theTOFCutForPeak
const double tofCut
const bool zeroSuppression

Detailed Description

SiStripDigitizerAlgorithm converts hits to digis

Definition at line 46 of file SiStripDigitizerAlgorithm.h.


Member Typedef Documentation

Definition at line 52 of file SiStripDigitizerAlgorithm.h.

Definition at line 49 of file SiStripDigitizerAlgorithm.h.

Definition at line 48 of file SiStripDigitizerAlgorithm.h.

typedef std::map< int, float, std::less<int> > SiStripDigitizerAlgorithm::hit_map_type

Definition at line 51 of file SiStripDigitizerAlgorithm.h.

Definition at line 50 of file SiStripDigitizerAlgorithm.h.


Constructor & Destructor Documentation

SiStripDigitizerAlgorithm::SiStripDigitizerAlgorithm ( const edm::ParameterSet conf,
CLHEP::HepRandomEngine &  eng 
)

Definition at line 24 of file SiStripDigitizerAlgorithm.cc.

References LogDebug, and peakMode.

                                                                                                          :
  lorentzAngleName(conf.getParameter<std::string>("LorentzAngle")),
  theThreshold(conf.getParameter<double>("NoiseSigmaThreshold")),
  cmnRMStib(conf.getParameter<double>("cmnRMStib")),
  cmnRMStob(conf.getParameter<double>("cmnRMStob")),
  cmnRMStid(conf.getParameter<double>("cmnRMStid")),
  cmnRMStec(conf.getParameter<double>("cmnRMStec")),
  APVSaturationProb(conf.getParameter<double>("APVSaturationProb")),
  makeDigiSimLinks_(conf.getUntrackedParameter<bool>("makeDigiSimLinks", false)),
  peakMode(conf.getParameter<bool>("APVpeakmode")),
  noise(conf.getParameter<bool>("Noise")),
  RealPedestals(conf.getParameter<bool>("RealPedestals")), 
  SingleStripNoise(conf.getParameter<bool>("SingleStripNoise")),
  CommonModeNoise(conf.getParameter<bool>("CommonModeNoise")),
  BaselineShift(conf.getParameter<bool>("BaselineShift")),
  APVSaturationFromHIP(conf.getParameter<bool>("APVSaturationFromHIP")),
  theFedAlgo(conf.getParameter<int>("FedAlgorithm")),
  zeroSuppression(conf.getParameter<bool>("ZeroSuppression")),
  theElectronPerADC(conf.getParameter<double>( peakMode ? "electronPerAdcPeak" : "electronPerAdcDec" )),
  theTOFCutForPeak(conf.getParameter<double>("TOFCutForPeak")),
  theTOFCutForDeconvolution(conf.getParameter<double>("TOFCutForDeconvolution")),
  tofCut(peakMode ? theTOFCutForPeak : theTOFCutForDeconvolution),
  cosmicShift(conf.getUntrackedParameter<double>("CosmicDelayShift")),
  inefficiency(conf.getParameter<double>("Inefficiency")),
  pedOffset((unsigned int)conf.getParameter<double>("PedestalsOffset")),
  theSiHitDigitizer(new SiHitDigitizer(conf, eng)),
  theSiPileUpSignals(new SiPileUpSignals()),
  theSiNoiseAdder(new SiGaussianTailNoiseAdder(theThreshold, eng)),
  theSiDigitalConverter(new SiTrivialDigitalConverter(theElectronPerADC)),
  theSiZeroSuppress(new SiStripFedZeroSuppression(theFedAlgo)),
  theFlatDistribution(new CLHEP::RandFlat(eng, 0., 1.)) {

  if (peakMode) {
    LogDebug("StripDigiInfo")<<"APVs running in peak mode (poor time resolution)";
  } else {
    LogDebug("StripDigiInfo")<<"APVs running in deconvolution mode (good time resolution)";
  };
}
SiStripDigitizerAlgorithm::~SiStripDigitizerAlgorithm ( )

Definition at line 63 of file SiStripDigitizerAlgorithm.cc.

                                                     {
}

Member Function Documentation

void SiStripDigitizerAlgorithm::accumulateSimHits ( const std::vector< PSimHit >::const_iterator  inputBegin,
const std::vector< PSimHit >::const_iterator  inputEnd,
const StripGeomDetUnit stripdet,
const GlobalVector bfield 
)

Definition at line 102 of file SiStripDigitizerAlgorithm.cc.

References allBadChannels, APVSaturationFromHIP, APVSaturationProb, DeDxDiscriminatorTools::charge(), cosmicShift, gather_cfg::cout, firstChannelsWithSignal, GeomDet::geographicalId(), inefficiency, edm::ESHandleBase::isValid(), lastChannelsWithSignal, lorentzAngleHandle, mag(), NULL, particle, pdt, DetId::rawId(), StripGeomDetUnit::specificTopology(), strip(), GeomDet::surface(), theFlatDistribution, theSiHitDigitizer, theSiPileUpSignals, tofCut, Surface::toGlobal(), and zeroSuppression.

                                                                         {
  // produce SignalPoints for all SimHits in detector
  unsigned int detID = det->geographicalId().rawId();
  int numStrips = (det->specificTopology()).nstrips();  

  std::vector<bool>& badChannels = allBadChannels[detID];
  size_t thisFirstChannelWithSignal = numStrips;
  size_t thisLastChannelWithSignal = numStrips;

  float langle = (lorentzAngleHandle.isValid()) ? lorentzAngleHandle->getLorentzAngle(detID) : 0.;

  std::vector<double> locAmpl(numStrips, 0.);

  // Loop over hits

  uint32_t detId = det->geographicalId().rawId();
  // First: loop on the SimHits
  if(theFlatDistribution->fire()>inefficiency) {
    for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter) {
      // skip hits not in this detector.
      if((*simHitIter).detUnitId() != detId) {
        continue;
      }
      // check TOF
      if (std::fabs(simHitIter->tof() - cosmicShift - det->surface().toGlobal(simHitIter->localPosition()).mag()/30.) < tofCut && simHitIter->energyLoss()>0) {
        size_t localFirstChannel = numStrips;
        size_t localLastChannel  = 0;
        // process the hit
        theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel);
          
                  //APV Killer to simulate HIP effect
                  //------------------------------------------------------
                  
                  if(APVSaturationFromHIP&&!zeroSuppression){
                    int pdg_id = simHitIter->particleType();
                        particle = pdt->particle(pdg_id);
                        if(particle != NULL){
                                float charge = particle->charge();
                                bool isHadron = particle->isHadron();
                            if(charge!=0 && isHadron){
                                        if(theFlatDistribution->fire()<APVSaturationProb){
                                                int FirstAPV = localFirstChannel/128;
                                                int LastAPV = localLastChannel/128;
                                                std::cout << "-------------------HIP--------------" << std::endl;
                                                std::cout << "Killing APVs " << FirstAPV << " - " <<LastAPV << " " << detID <<std::endl;
                                                for(int strip = FirstAPV*128; strip < LastAPV*128 +128; ++strip) {
                                                        badChannels[strip] = true;
                                                }
                                                //doing like that I remove the signal information only after the 
                                                //stip that got the HIP but it remains the signal of the previous
                                                //one. I'll make a further loop to remove all signal
                                        }
                                }
                        }
              }             
                
    
        if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
        if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
      }
    } // end for
  }
  theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);

  if(firstChannelsWithSignal[detID] > thisFirstChannelWithSignal) firstChannelsWithSignal[detID] = thisFirstChannelWithSignal;
  if(lastChannelsWithSignal[detID] < thisLastChannelWithSignal) lastChannelsWithSignal[detID] = thisLastChannelWithSignal;
}
void SiStripDigitizerAlgorithm::digitize ( edm::DetSet< SiStripDigi > &  outDigis,
edm::DetSet< SiStripRawDigi > &  outRawDigis,
const StripGeomDetUnit stripdet,
edm::ESHandle< SiStripGain > &  gainHandle,
edm::ESHandle< SiStripThreshold > &  thresholdHandle,
edm::ESHandle< SiStripNoises > &  noiseHandle,
edm::ESHandle< SiStripPedestals > &  pedestalHandle 
)

Definition at line 174 of file SiStripDigitizerAlgorithm.cc.

References allBadChannels, BaselineShift, cmnRMStec, cmnRMStib, cmnRMStid, cmnRMStob, CommonModeNoise, edm::DetSet< T >::data, firstChannelsWithSignal, GeomDet::geographicalId(), lastChannelsWithSignal, noise, pedOffset, DetId::rawId(), RealPedestals, SingleStripNoise, StripGeomDetUnit::specificTopology(), strip(), DetId::subdetId(), theElectronPerADC, theSiDigitalConverter, theSiNoiseAdder, theSiPileUpSignals, theSiZeroSuppress, and zeroSuppression.

                                                                           {
  unsigned int detID = det->geographicalId().rawId();
  int numStrips = (det->specificTopology()).nstrips();  

  const SiPileUpSignals::SignalMapType* theSignal(theSiPileUpSignals->getSignal(detID));  

  std::vector<double> detAmpl(numStrips, 0.);
  if(theSignal) {
    for(const auto& amp : *theSignal) {
      detAmpl[amp.first] = amp.second;
    }
  }

  //removing signal from the dead (and HIP effected) strips
  std::vector<bool>& badChannels = allBadChannels[detID];
  for(int strip =0; strip < numStrips; ++strip) if(badChannels[strip]) detAmpl[strip] = 0.;

  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detID);
  SiStripApvGain::Range detGainRange = gainHandle->getRange(detID);
  SiStripPedestals::Range detPedestalRange = pedestalHandle->getRange(detID);

// -----------------------------------------------------------

  auto& firstChannelWithSignal = firstChannelsWithSignal[detID];
  auto& lastChannelWithSignal = lastChannelsWithSignal[detID];

  if(zeroSuppression){
    if(noise){
          int RefStrip = int(numStrips/2.);
          while(RefStrip<numStrips&&badChannels[RefStrip]){ //if the refstrip is bad, I move up to when I don't find it
                RefStrip++;
          }
          if(RefStrip<numStrips){
                float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange);
                float gainValue = gainHandle->getStripGain(RefStrip, detGainRange);
                theSiNoiseAdder->addNoise(detAmpl,firstChannelWithSignal,lastChannelWithSignal,numStrips,noiseRMS*theElectronPerADC/gainValue);
          }
        }
    DigitalVecType digis;
    theSiZeroSuppress->suppress(theSiDigitalConverter->convert(detAmpl, gainHandle, detID), digis, detID,noiseHandle,thresholdHandle);
    outdigi.data = digis;
  }
  
  
  if(!zeroSuppression){
    //if(noise){
      // the constant pedestal offset is needed because
      //   negative adc counts are not allowed in case
      //   Pedestal and CMN subtraction is performed.
      //   The pedestal value read from the conditions
      //   is pedValue and after the pedestal subtraction
      //   the baseline is zero. The Common Mode Noise
      //   is not subtracted from the negative adc counts
      //   channels. Adding pedOffset the baseline is set
      //   to pedOffset after pedestal subtraction and CMN
      //   is subtracted to all the channels since none of
      //   them has negative adc value. The pedOffset is
      //   treated as a constant component in the CMN
      //   estimation and subtracted as CMN.
      
         
                //calculating the charge deposited on each APV and subtracting the shift
                //------------------------------------------------------
                if(BaselineShift){
                   theSiNoiseAdder->addBaselineShift(detAmpl, badChannels);
                }
                
                //Adding the strip noise
                //------------------------------------------------------                                                 
                if(noise){
                    std::vector<float> noiseRMSv;
                        noiseRMSv.clear();
                    noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
                        
                    if(SingleStripNoise){
                            for(int strip=0; strip< numStrips; ++strip){
                                        if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))* theElectronPerADC;
                                }
                        
                } else {
                            int RefStrip = 0; //int(numStrips/2.);
                            while(RefStrip<numStrips&&badChannels[RefStrip]){ //if the refstrip is bad, I move up to when I don't find it
                                        RefStrip++;
                                }
                                if(RefStrip<numStrips){
                                        float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *theElectronPerADC;
                                        for(int strip=0; strip< numStrips; ++strip){
                                        if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
                                        }
                                }
                        }
                        
                        theSiNoiseAdder->addNoiseVR(detAmpl, noiseRMSv);
                }                       
                
                //adding the CMN
                //------------------------------------------------------
        if(CommonModeNoise){
                  float cmnRMS = 0.;
                  DetId  detId(detID);
                  uint32_t SubDet = detId.subdetId();
                  if(SubDet==3){
                    cmnRMS = cmnRMStib;
                  }else if(SubDet==4){
                    cmnRMS = cmnRMStid;
                  }else if(SubDet==5){
                    cmnRMS = cmnRMStob;
                  }else if(SubDet==6){
                    cmnRMS = cmnRMStec;
                  }
                  cmnRMS *= theElectronPerADC;
          theSiNoiseAdder->addCMNoise(detAmpl, cmnRMS, badChannels);
                }
                
                        
                //Adding the pedestals
                //------------------------------------------------------
                
                std::vector<float> vPeds;
                vPeds.clear();
                vPeds.insert(vPeds.begin(),numStrips,0.);
                
                if(RealPedestals){
                    for(int strip=0; strip< numStrips; ++strip){
                           if(!badChannels[strip]) vPeds[strip] = (pedestalHandle->getPed(strip,detPedestalRange)+pedOffset)* theElectronPerADC;
                    }
        } else {
                    for(int strip=0; strip< numStrips; ++strip){
                          if(!badChannels[strip]) vPeds[strip] = pedOffset* theElectronPerADC;
                        }
                }
                
                theSiNoiseAdder->addPedestals(detAmpl, vPeds);  
                
                 
        //if(!RealPedestals&&!CommonModeNoise&&!noise&&!BaselineShift&&!APVSaturationFromHIP){
    //  edm::LogWarning("SiStripDigitizer")<<"You are running the digitizer without Noise generation and without applying Zero Suppression. ARE YOU SURE???";
    //}else{                                                     
    
    DigitalRawVecType rawdigis = theSiDigitalConverter->convertRaw(detAmpl, gainHandle, detID);
    outrawdigi.data = rawdigis;
        
        //}
  }
}
void SiStripDigitizerAlgorithm::initializeDetUnit ( StripGeomDetUnit det,
const edm::EventSetup iSetup 
)

Definition at line 67 of file SiStripDigitizerAlgorithm.cc.

References allBadChannels, firstChannelsWithSignal, SiStripBadStrip::data::firstStrip, GeomDet::geographicalId(), edm::EventSetup::get(), lastChannelsWithSignal, SiStripBadStrip::data::range, DetId::rawId(), StripGeomDetUnit::specificTopology(), and strip().

                                                                                               {
  edm::ESHandle<SiStripBadStrip> deadChannelHandle;
  iSetup.get<SiStripBadChannelRcd>().get(deadChannelHandle);

  unsigned int detId = det->geographicalId().rawId();
  int numStrips = (det->specificTopology()).nstrips();  

  SiStripBadStrip::Range detBadStripRange = deadChannelHandle->getRange(detId);
  //storing the bad strip of the the module. the module is not removed but just signal put to 0
  std::vector<bool>& badChannels = allBadChannels[detId];
  badChannels.clear();
  badChannels.insert(badChannels.begin(), numStrips, false);
  for(SiStripBadStrip::ContainerIterator it = detBadStripRange.first; it != detBadStripRange.second; ++it) {
    SiStripBadStrip::data fs = deadChannelHandle->decode(*it);
    for(int strip = fs.firstStrip; strip < fs.firstStrip + fs.range; ++strip) badChannels[strip] = true;
  }
  firstChannelsWithSignal[detId] = numStrips;
  lastChannelsWithSignal[detId]= 0;
}
void SiStripDigitizerAlgorithm::initializeEvent ( const edm::EventSetup iSetup)
void SiStripDigitizerAlgorithm::setParticleDataTable ( const ParticleDataTable pardt) [inline]

Definition at line 80 of file SiStripDigitizerAlgorithm.h.

References pdt, and theSiHitDigitizer.

Referenced by initializeEvent().

                                                             {
        theSiHitDigitizer->setParticleDataTable(pardt); 
        pdt= pardt; 
  }

Member Data Documentation

std::map<unsigned int, std::vector<bool> > SiStripDigitizerAlgorithm::allBadChannels [private]

Definition at line 124 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), digitize(), and initializeDetUnit().

Definition at line 100 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

Definition at line 92 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

Definition at line 99 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStec [private]

Definition at line 91 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStib [private]

Definition at line 88 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStid [private]

Definition at line 90 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStob [private]

Definition at line 89 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 98 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 108 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

std::map<unsigned int, size_t> SiStripDigitizerAlgorithm::firstChannelsWithSignal [private]

Definition at line 126 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), digitize(), and initializeDetUnit().

Definition at line 109 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

std::map<unsigned int, size_t> SiStripDigitizerAlgorithm::lastChannelsWithSignal [private]

Definition at line 127 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), digitize(), and initializeDetUnit().

Definition at line 130 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), and initializeEvent().

const std::string SiStripDigitizerAlgorithm::lorentzAngleName [private]

Definition at line 86 of file SiStripDigitizerAlgorithm.h.

Referenced by initializeEvent().

Definition at line 93 of file SiStripDigitizerAlgorithm.h.

const bool SiStripDigitizerAlgorithm::noise [private]

Definition at line 95 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 113 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

Definition at line 94 of file SiStripDigitizerAlgorithm.h.

Referenced by SiStripDigitizerAlgorithm().

const double SiStripDigitizerAlgorithm::pedOffset [private]

Definition at line 110 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 96 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 97 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 104 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 102 of file SiStripDigitizerAlgorithm.h.

const std::unique_ptr<CLHEP::RandFlat> SiStripDigitizerAlgorithm::theFlatDistribution [private]

Definition at line 121 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

Definition at line 118 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 115 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), and setParticleDataTable().

Definition at line 117 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 116 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), digitize(), and initializeEvent().

Definition at line 119 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

Definition at line 87 of file SiStripDigitizerAlgorithm.h.

Definition at line 106 of file SiStripDigitizerAlgorithm.h.

Definition at line 105 of file SiStripDigitizerAlgorithm.h.

const double SiStripDigitizerAlgorithm::tofCut [private]

Definition at line 107 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

Definition at line 103 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), and digitize().