test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Types | Private Attributes
SiStripDigitizerAlgorithm Class Reference

#include <SiStripDigitizerAlgorithm.h>

Classes

struct  AssociationInfo
 

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, size_t inputBeginGlobalIndex, unsigned int tofBin, const StripGeomDetUnit *stripdet, const GlobalVector &bfield, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
 
void calculateInstlumiScale (PileupMixingContent *puInfo)
 
void digitize (edm::DetSet< SiStripDigi > &outDigis, edm::DetSet< SiStripRawDigi > &outRawDigis, edm::DetSet< StripDigiSimLink > &outLink, const StripGeomDetUnit *stripdet, edm::ESHandle< SiStripGain > &, edm::ESHandle< SiStripThreshold > &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripPedestals > &, std::vector< std::pair< int, std::bitset< 6 >>> &theAffectedAPVvector, CLHEP::HepRandomEngine *)
 
void initializeDetUnit (StripGeomDetUnit const *det, const edm::EventSetup &iSetup)
 
void initializeEvent (const edm::EventSetup &iSetup)
 
void setParticleDataTable (const ParticleDataTable *pardt)
 
 SiStripDigitizerAlgorithm (const edm::ParameterSet &conf)
 
 ~SiStripDigitizerAlgorithm ()
 

Private Types

typedef std::map< int,
std::vector< AssociationInfo > > 
AssociationInfoForChannel
 
typedef std::map< uint32_t,
AssociationInfoForChannel
AssociationInfoForDetId
 

Private Attributes

std::map< unsigned int,
std::vector< bool > > 
allBadChannels
 
std::ifstream APVProbaFile
 
const bool APVSaturationFromHIP
 
double APVSaturationProb_
 
const double APVSaturationProbScaling_
 
AssociationInfoForDetId associationInfoForDetId_
 Structure that holds the information on the SimTrack contributions. Only filled if makeDigiSimLinks_ is true. More...
 
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
 
bool FirstDigitize_
 
bool FirstLumiCalc_
 
const double inefficiency
 
std::map< unsigned int, size_t > lastChannelsWithSignal
 
edm::ESHandle
< SiStripLorentzAngle
lorentzAngleHandle
 
const std::string lorentzAngleName
 
const bool makeDigiSimLinks_
 
std::map< int, float > mapOfAPVprobabilities
 
const bool noise
 
int NumberOfBxBetweenHIPandEvent
 
const ParticleDataparticle
 
const ParticleDataTablepdt
 
const bool peakMode
 
const double pedOffset
 
const bool PreMixing_
 
const bool RealPedestals
 
const bool SingleStripNoise
 
std::map< int, std::bitset< 6 > > SiStripTrackerAffectedAPVMap
 
const double theElectronPerADC
 
const int theFedAlgo
 
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 53 of file SiStripDigitizerAlgorithm.h.

Member Typedef Documentation

Definition at line 59 of file SiStripDigitizerAlgorithm.h.

typedef std::map<int, std::vector<AssociationInfo> > SiStripDigitizerAlgorithm::AssociationInfoForChannel
private

Definition at line 162 of file SiStripDigitizerAlgorithm.h.

Definition at line 163 of file SiStripDigitizerAlgorithm.h.

Definition at line 56 of file SiStripDigitizerAlgorithm.h.

Definition at line 55 of file SiStripDigitizerAlgorithm.h.

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

Definition at line 58 of file SiStripDigitizerAlgorithm.h.

Definition at line 57 of file SiStripDigitizerAlgorithm.h.

Constructor & Destructor Documentation

SiStripDigitizerAlgorithm::SiStripDigitizerAlgorithm ( const edm::ParameterSet conf)

Definition at line 33 of file SiStripDigitizerAlgorithm.cc.

References APVSaturationFromHIP, CommonModeNoise, Exception, LogDebug, peakMode, PreMixing_, and SingleStripNoise.

33  :
34  lorentzAngleName(conf.getParameter<std::string>("LorentzAngle")),
35  theThreshold(conf.getParameter<double>("NoiseSigmaThreshold")),
36  cmnRMStib(conf.getParameter<double>("cmnRMStib")),
37  cmnRMStob(conf.getParameter<double>("cmnRMStob")),
38  cmnRMStid(conf.getParameter<double>("cmnRMStid")),
39  cmnRMStec(conf.getParameter<double>("cmnRMStec")),
40  APVSaturationProbScaling_(conf.getParameter<double>("APVSaturationProbScaling")),
41  makeDigiSimLinks_(conf.getUntrackedParameter<bool>("makeDigiSimLinks", false)),
42  peakMode(conf.getParameter<bool>("APVpeakmode")),
43  noise(conf.getParameter<bool>("Noise")),
44  RealPedestals(conf.getParameter<bool>("RealPedestals")),
45  SingleStripNoise(conf.getParameter<bool>("SingleStripNoise")),
46  CommonModeNoise(conf.getParameter<bool>("CommonModeNoise")),
47  BaselineShift(conf.getParameter<bool>("BaselineShift")),
48  APVSaturationFromHIP(conf.getParameter<bool>("APVSaturationFromHIP")),
49  theFedAlgo(conf.getParameter<int>("FedAlgorithm")),
50  zeroSuppression(conf.getParameter<bool>("ZeroSuppression")),
51  theElectronPerADC(conf.getParameter<double>( peakMode ? "electronPerAdcPeak" : "electronPerAdcDec" )),
52  theTOFCutForPeak(conf.getParameter<double>("TOFCutForPeak")),
53  theTOFCutForDeconvolution(conf.getParameter<double>("TOFCutForDeconvolution")),
55  cosmicShift(conf.getUntrackedParameter<double>("CosmicDelayShift")),
56  inefficiency(conf.getParameter<double>("Inefficiency")),
57  pedOffset((unsigned int)conf.getParameter<double>("PedestalsOffset")),
58  PreMixing_(conf.getParameter<bool>("PreMixingMode")),
64 
65  if (peakMode) {
66  LogDebug("StripDigiInfo")<<"APVs running in peak mode (poor time resolution)";
67  } else {
68  LogDebug("StripDigiInfo")<<"APVs running in deconvolution mode (good time resolution)";
69  };
70  if(SingleStripNoise) LogDebug("SiStripDigitizerAlgorithm")<<" SingleStripNoise: ON";
71  else LogDebug("SiStripDigitizerAlgorithm")<<" SingleStripNoise: OFF";
72  if(CommonModeNoise) LogDebug("SiStripDigitizerAlgorithm")<<" CommonModeNoise: ON";
73  else LogDebug("SiStripDigitizerAlgorithm")<<" CommonModeNoise: OFF";
74  if(PreMixing_ && APVSaturationFromHIP) throw cms::Exception("PreMixing does not work with HIP loss simulation yet");
75 }
#define LogDebug(id)
T getParameter(std::string const &) const
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
T getUntrackedParameter(std::string const &, T const &) const
const std::unique_ptr< const SiGaussianTailNoiseAdder > theSiNoiseAdder
const std::unique_ptr< SiHitDigitizer > theSiHitDigitizer
const std::unique_ptr< SiTrivialDigitalConverter > theSiDigitalConverter
const std::unique_ptr< SiStripFedZeroSuppression > theSiZeroSuppress
SiStripDigitizerAlgorithm::~SiStripDigitizerAlgorithm ( )

Definition at line 77 of file SiStripDigitizerAlgorithm.cc.

77  {
78 }

Member Function Documentation

void SiStripDigitizerAlgorithm::accumulateSimHits ( const std::vector< PSimHit >::const_iterator  inputBegin,
const std::vector< PSimHit >::const_iterator  inputEnd,
size_t  inputBeginGlobalIndex,
unsigned int  tofBin,
const StripGeomDetUnit stripdet,
const GlobalVector bfield,
const TrackerTopology tTopo,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 128 of file SiStripDigitizerAlgorithm.cc.

References associationInfoForDetId_, cosmicShift, firstChannelsWithSignal, GeomDet::geographicalId(), inefficiency, edm::ESHandleBase::isValid(), lastChannelsWithSignal, lorentzAngleHandle, mag(), makeDigiSimLinks_, DetId::rawId(), StripGeomDetUnit::specificTopology(), GeomDet::surface(), theSiHitDigitizer, theSiPileUpSignals, tofCut, and Surface::toGlobal().

135  {
136  // produce SignalPoints for all SimHits in detector
137  unsigned int detID = det->geographicalId().rawId();
138  int numStrips = (det->specificTopology()).nstrips();
139 
140  size_t thisFirstChannelWithSignal = numStrips;
141  size_t thisLastChannelWithSignal = 0;
142 
143  float langle = (lorentzAngleHandle.isValid()) ? lorentzAngleHandle->getLorentzAngle(detID) : 0.;
144 
145  std::vector<float> locAmpl(numStrips, 0.);
146 
147  // Loop over hits
148 
149  uint32_t detId = det->geographicalId().rawId();
150  // First: loop on the SimHits
151  if(CLHEP::RandFlat::shoot(engine) > inefficiency) {
152  AssociationInfoForChannel* pDetIDAssociationInfo; // I only need this if makeDigiSimLinks_ is true...
153  if( makeDigiSimLinks_ ) pDetIDAssociationInfo=&(associationInfoForDetId_[detId]); // ...so only search the map if that is the case
154  std::vector<float> previousLocalAmplitude; // Only used if makeDigiSimLinks_ is true. Needed to work out the change in amplitude.
155 
156  size_t simHitGlobalIndex=inputBeginGlobalIndex; // This needs to stored to create the digi-sim link later
157  for (std::vector<PSimHit>::const_iterator simHitIter = inputBegin; simHitIter != inputEnd; ++simHitIter, ++simHitGlobalIndex ) {
158  // skip hits not in this detector.
159  if((*simHitIter).detUnitId() != detId) {
160  continue;
161  }
162  // check TOF
163  if (std::fabs(simHitIter->tof() - cosmicShift - det->surface().toGlobal(simHitIter->localPosition()).mag()/30.) < tofCut && simHitIter->energyLoss()>0) {
164  if( makeDigiSimLinks_ ) previousLocalAmplitude=locAmpl; // Not needed except to make the sim link association.
165  size_t localFirstChannel = numStrips;
166  size_t localLastChannel = 0;
167  // process the hit
168  theSiHitDigitizer->processHit(&*simHitIter, *det, bfield, langle, locAmpl, localFirstChannel, localLastChannel, tTopo, engine);
169 
170  if(thisFirstChannelWithSignal > localFirstChannel) thisFirstChannelWithSignal = localFirstChannel;
171  if(thisLastChannelWithSignal < localLastChannel) thisLastChannelWithSignal = localLastChannel;
172 
173  if( makeDigiSimLinks_ ) { // No need to do any of this if truth association was turned off in the configuration
174  for( size_t stripIndex=0; stripIndex<locAmpl.size(); ++stripIndex ) {
175  // Work out the amplitude from this SimHit from the difference of what it was before and what it is now
176  float signalFromThisSimHit=locAmpl[stripIndex]-previousLocalAmplitude[stripIndex];
177  if( signalFromThisSimHit!=0 ) { // If this SimHit had any contribution I need to record it.
178  auto& associationVector=(*pDetIDAssociationInfo)[stripIndex];
179  bool addNewEntry=true;
180  // Make sure the hit isn't in already. I've seen this a few times, it always seems to happen in pairs so I think
181  // it's something to do with the stereo strips.
182  for( auto& associationInfo : associationVector ) {
183  if( associationInfo.trackID==simHitIter->trackId() && associationInfo.eventID==simHitIter->eventId() ) {
184  // The hit is already in, so add this second contribution and move on
185  associationInfo.contributionToADC+=signalFromThisSimHit;
186  addNewEntry=false;
187  break;
188  }
189  } // end of loop over associationVector
190  // If the hit wasn't already in create a new association info structure.
191  if( addNewEntry ) associationVector.push_back( AssociationInfo{ simHitIter->trackId(), simHitIter->eventId(), signalFromThisSimHit, simHitGlobalIndex, tofBin } );
192  } // end of "if( signalFromThisSimHit!=0 )"
193  } // end of loop over locAmpl strips
194  } // end of "if( makeDigiSimLinks_ )"
195  } // end of TOF check
196  } // end for
197  }
198  theSiPileUpSignals->add(detID, locAmpl, thisFirstChannelWithSignal, thisLastChannelWithSignal);
199 
200  if(firstChannelsWithSignal[detID] > thisFirstChannelWithSignal) firstChannelsWithSignal[detID] = thisFirstChannelWithSignal;
201  if(lastChannelsWithSignal[detID] < thisLastChannelWithSignal) lastChannelsWithSignal[detID] = thisLastChannelWithSignal;
202 }
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
edm::ESHandle< SiStripLorentzAngle > lorentzAngleHandle
AssociationInfoForDetId associationInfoForDetId_
Structure that holds the information on the SimTrack contributions. Only filled if makeDigiSimLinks_ ...
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const std::unique_ptr< SiHitDigitizer > theSiHitDigitizer
std::map< unsigned int, size_t > firstChannelsWithSignal
std::map< int, std::vector< AssociationInfo > > AssociationInfoForChannel
std::map< unsigned int, size_t > lastChannelsWithSignal
bool isValid() const
Definition: ESHandle.h:47
void SiStripDigitizerAlgorithm::calculateInstlumiScale ( PileupMixingContent puInfo)

Definition at line 205 of file SiStripDigitizerAlgorithm.cc.

References APVSaturationProb_, FirstLumiCalc_, PileupMixingContent::getMix_bunchCrossing(), PileupMixingContent::getMix_bunchSpacing(), PileupMixingContent::getMix_TrueInteractions(), and AlCaHLTBitMon_ParallelJobs::p.

205  {
206  //Instlumi scalefactor calculating for dynamic inefficiency
207 
208  if (puInfo && FirstLumiCalc_) {
209 
210  const std::vector<int> bunchCrossing = puInfo->getMix_bunchCrossing();
211  const std::vector<float> TrueInteractionList = puInfo->getMix_TrueInteractions();
212  const int bunchSpacing = puInfo->getMix_bunchSpacing();
213 
214  double RevFreq = 11245.;
215  double minBXsec = 70.0E-27; // use 70mb as an approximation
216  double Bunch = 2100.; // 2016 value
217  if (bunchSpacing == 50) Bunch = Bunch/2.;
218 
219  int pui = 0, p = 0;
220  std::vector<int>::const_iterator pu;
221  std::vector<int>::const_iterator pu0 = bunchCrossing.end();
222 
223  for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) {
224  if (*pu==0) {
225  pu0 = pu;
226  p = pui;
227  }
228  pui++;
229  }
230  if (pu0!=bunchCrossing.end()) { // found the in-time interaction
231  double Tintr = TrueInteractionList.at(p);
232  double instLumi = Bunch*Tintr*RevFreq/minBXsec;
233  APVSaturationProb_ = instLumi/6.0E33;
234  }
235  FirstLumiCalc_ = false;
236  }
237 }
const std::vector< float > & getMix_TrueInteractions() const
const std::vector< int > & getMix_bunchCrossing() const
const int & getMix_bunchSpacing() const
void SiStripDigitizerAlgorithm::digitize ( edm::DetSet< SiStripDigi > &  outDigis,
edm::DetSet< SiStripRawDigi > &  outRawDigis,
edm::DetSet< StripDigiSimLink > &  outLink,
const StripGeomDetUnit stripdet,
edm::ESHandle< SiStripGain > &  gainHandle,
edm::ESHandle< SiStripThreshold > &  thresholdHandle,
edm::ESHandle< SiStripNoises > &  noiseHandle,
edm::ESHandle< SiStripPedestals > &  pedestalHandle,
std::vector< std::pair< int, std::bitset< 6 >>> &  theAffectedAPVvector,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 243 of file SiStripDigitizerAlgorithm.cc.

References allBadChannels, APVSaturationFromHIP, APVSaturationProb_, associationInfoForDetId_, BaselineShift, cmnRMStec, cmnRMStib, cmnRMStid, cmnRMStob, CommonModeNoise, edm::DetSet< T >::data, firstChannelsWithSignal, FirstDigitize_, GeomDet::geographicalId(), lastChannelsWithSignal, mapOfAPVprobabilities, noise, NumberOfBxBetweenHIPandEvent, pedOffset, PreMixing_, edm::DetSet< T >::push_back(), DetId::rawId(), RealPedestals, SingleStripNoise, SiStripTrackerAffectedAPVMap, StripGeomDetUnit::specificTopology(), DetId::subdetId(), groupFilesInBlocks::temp, theElectronPerADC, theSiDigitalConverter, theSiNoiseAdder, theSiPileUpSignals, theSiZeroSuppress, and zeroSuppression.

253  {
254  unsigned int detID = det->geographicalId().rawId();
255  int numStrips = (det->specificTopology()).nstrips();
256 
257  const SiPileUpSignals::SignalMapType* theSignal(theSiPileUpSignals->getSignal(detID));
258 
259  std::vector<float> detAmpl(numStrips, 0.);
260  if(theSignal) {
261  for(const auto& amp : *theSignal) {
262  detAmpl[amp.first] = amp.second;
263  }
264  }
265 
266  //removing signal from the dead (and HIP effected) strips
267  std::vector<bool>& badChannels = allBadChannels[detID];
268 
269  for(int strip =0; strip < numStrips; ++strip) {
270  if(badChannels[strip]) {detAmpl[strip] = 0.;}
271  }
272 
274 
275  //Implementation of the proper charge scaling function. Need consider resaturation effect:
276  //The probability map gives the probability that at least one HIP happened during the last N bunch crossings (cfr APV recovery time).
277  //The impact on the charge depends on the clostest HIP occurance (in terms of bunch crossing).
278  //The function discribing the APV recovery is therefore the weighted average function which takes into account all possibilities of HIP occurances across the last bx's.
279 
280  // do this step here because we now have access to luminosity information
281  if(FirstDigitize_) {
282 
283  for(std::map<int,float>::iterator iter = mapOfAPVprobabilities.begin(); iter != mapOfAPVprobabilities.end(); ++iter){
284  std::bitset<6> bs;
285  for(int Napv=0;Napv<6;Napv++){
286  float cursor=CLHEP::RandFlat::shoot(engine);
287  bs[Napv]=cursor < iter->second*APVSaturationProb_ ? 1:0; //APVSaturationProb has been scaled by PU luminosity
288  }
289  SiStripTrackerAffectedAPVMap[iter->first]=bs;
290  }
291 
293  bool HasAtleastOneAffectedAPV=false;
294  while(!HasAtleastOneAffectedAPV){
295  for(int bx=floor(300.0/25.0);bx>0;bx--){ //Reminder: make these numbers not hard coded!!
296  float temp=CLHEP::RandFlat::shoot(engine)<0.5?1:0;
297  if(temp==1 && bx<NumberOfBxBetweenHIPandEvent){
299  HasAtleastOneAffectedAPV=true;
300  }
301  }
302  }
303 
304  FirstDigitize_ = false;
305  }
306 
307  std::bitset<6> & bs=SiStripTrackerAffectedAPVMap[detID];
308 
309  if(bs.any()){
310  // store this information so it can be saved to the event later
311  theAffectedAPVvector.push_back(std::make_pair(detID,bs));
312 
313  if(!PreMixing_) {
314 
315  // Here below is the scaling function which describes the evolution of the baseline (i.e. how the charge is suppressed).
316  // This must be replaced as soon as we have a proper modeling of the baseline evolution from VR runs
317  float Shift=1-NumberOfBxBetweenHIPandEvent/floor(300.0/25.0); //Reminder: make these numbers not hardcoded!!
318  float randomX=CLHEP::RandFlat::shoot(engine);
319  float scalingValue=(randomX-Shift)*10.0/7.0-3.0/7.0;
320 
321  for(int strip =0; strip < numStrips; ++strip) {
322  if(!badChannels[strip] && bs[strip/128]==1){
323  detAmpl[strip] *=scalingValue>0?scalingValue:0.0;
324  }
325  }
326  }
327  }
328  }
329 
330 
331 
332  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detID);
333  SiStripApvGain::Range detGainRange = gainHandle->getRange(detID);
334  SiStripPedestals::Range detPedestalRange = pedestalHandle->getRange(detID);
335 
336 // -----------------------------------------------------------
337 
338  auto& firstChannelWithSignal = firstChannelsWithSignal[detID];
339  auto& lastChannelWithSignal = lastChannelsWithSignal[detID];
340  auto iAssociationInfoByChannel=associationInfoForDetId_.find(detID); // Use an iterator so that I can easily remove it once finished
341 
342  if(zeroSuppression){
343 
344  //Adding the strip noise
345  //------------------------------------------------------
346  if(noise){
347 
348  if(SingleStripNoise){
349  std::vector<float> noiseRMSv;
350  noiseRMSv.clear();
351  noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
352  for(int strip=0; strip< numStrips; ++strip){
353  if(!badChannels[strip]){
354  float gainValue = gainHandle->getStripGain(strip, detGainRange);
355  noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))* theElectronPerADC/gainValue;
356  //std::cout<<"<SiStripDigitizerAlgorithm::digitize>: gainValue: "<<gainValue<<"\tnoiseRMSv["<<strip<<"]: "<<noiseRMSv[strip]<<std::endl;
357  }
358  }
359  theSiNoiseAdder->addNoiseVR(detAmpl, noiseRMSv, engine);
360  } else {
361  int RefStrip = int(numStrips/2.);
362  while(RefStrip<numStrips&&badChannels[RefStrip]){ //if the refstrip is bad, I move up to when I don't find it
363  RefStrip++;
364  }
365  if(RefStrip<numStrips){
366  float RefgainValue = gainHandle->getStripGain(RefStrip, detGainRange);
367  float RefnoiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *theElectronPerADC/RefgainValue;
368 
369  theSiNoiseAdder->addNoise(detAmpl,firstChannelWithSignal,lastChannelWithSignal,numStrips,RefnoiseRMS, engine);
370  //std::cout<<"<SiStripDigitizerAlgorithm::digitize>: RefgainValue: "<<RefgainValue<<"\tRefnoiseRMS: "<<RefnoiseRMS<<std::endl;
371  }
372  }
373  }//if noise
374 
375  DigitalVecType digis;
376  theSiZeroSuppress->suppress(theSiDigitalConverter->convert(detAmpl, gainHandle, detID), digis, detID,noiseHandle,thresholdHandle);
377  // Now do the association to truth. Note that if truth association was turned off in the configuration this map
378  // will be empty and the iterator will always equal associationInfoForDetId_.end().
379  if( iAssociationInfoByChannel!=associationInfoForDetId_.end() ) { // make sure the readings for this DetID aren't completely from noise
380  for( const auto& iDigi : digis ) {
381  auto& associationInfoByChannel=iAssociationInfoByChannel->second;
382  const std::vector<AssociationInfo>& associationInfo=associationInfoByChannel[iDigi.channel()];
383 
384  // Need to find the total from all sim hits, because this might not be the same as the total
385  // digitised due to noise or whatever.
386  float totalSimADC=0;
387  for( const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
388  // Now I know that I can loop again and create the links
389  for( const auto& iAssociationInfo : associationInfo ) {
390  // Note simHitGlobalIndex used to have +1 because TrackerHitAssociator (the only place I can find this value being used)
391  // expected counting to start at 1, not 0. Now changed.
392  outLink.push_back( StripDigiSimLink( iDigi.channel(), iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
393  } // end of loop over associationInfo
394  } // end of loop over the digis
395  } // end of check that iAssociationInfoByChannel is a valid iterator
396  outdigi.data = digis;
397  }//if zeroSuppression
398 
399  if(!zeroSuppression){
400  //if(noise){
401  // the constant pedestal offset is needed because
402  // negative adc counts are not allowed in case
403  // Pedestal and CMN subtraction is performed.
404  // The pedestal value read from the conditions
405  // is pedValue and after the pedestal subtraction
406  // the baseline is zero. The Common Mode Noise
407  // is not subtracted from the negative adc counts
408  // channels. Adding pedOffset the baseline is set
409  // to pedOffset after pedestal subtraction and CMN
410  // is subtracted to all the channels since none of
411  // them has negative adc value. The pedOffset is
412  // treated as a constant component in the CMN
413  // estimation and subtracted as CMN.
414 
415 
416  //calculating the charge deposited on each APV and subtracting the shift
417  //------------------------------------------------------
418  if(BaselineShift){
419  theSiNoiseAdder->addBaselineShift(detAmpl, badChannels);
420  }
421 
422  //Adding the strip noise
423  //------------------------------------------------------
424  if(noise){
425  std::vector<float> noiseRMSv;
426  noiseRMSv.clear();
427  noiseRMSv.insert(noiseRMSv.begin(),numStrips,0.);
428 
429  if(SingleStripNoise){
430  for(int strip=0; strip< numStrips; ++strip){
431  if(!badChannels[strip]) noiseRMSv[strip] = (noiseHandle->getNoise(strip,detNoiseRange))* theElectronPerADC;
432  }
433 
434  } else {
435  int RefStrip = 0; //int(numStrips/2.);
436  while(RefStrip<numStrips&&badChannels[RefStrip]){ //if the refstrip is bad, I move up to when I don't find it
437  RefStrip++;
438  }
439  if(RefStrip<numStrips){
440  float noiseRMS = noiseHandle->getNoise(RefStrip,detNoiseRange) *theElectronPerADC;
441  for(int strip=0; strip< numStrips; ++strip){
442  if(!badChannels[strip]) noiseRMSv[strip] = noiseRMS;
443  }
444  }
445  }
446 
447  theSiNoiseAdder->addNoiseVR(detAmpl, noiseRMSv, engine);
448  }
449 
450  //adding the CMN
451  //------------------------------------------------------
452  if(CommonModeNoise){
453  float cmnRMS = 0.;
454  DetId detId(detID);
455  uint32_t SubDet = detId.subdetId();
456  if(SubDet==3){
457  cmnRMS = cmnRMStib;
458  }else if(SubDet==4){
459  cmnRMS = cmnRMStid;
460  }else if(SubDet==5){
461  cmnRMS = cmnRMStob;
462  }else if(SubDet==6){
463  cmnRMS = cmnRMStec;
464  }
465  cmnRMS *= theElectronPerADC;
466  theSiNoiseAdder->addCMNoise(detAmpl, cmnRMS, badChannels, engine);
467  }
468 
469 
470  //Adding the pedestals
471  //------------------------------------------------------
472 
473  std::vector<float> vPeds;
474  vPeds.clear();
475  vPeds.insert(vPeds.begin(),numStrips,0.);
476 
477  if(RealPedestals){
478  for(int strip=0; strip< numStrips; ++strip){
479  if(!badChannels[strip]) vPeds[strip] = (pedestalHandle->getPed(strip,detPedestalRange)+pedOffset)* theElectronPerADC;
480  }
481  } else {
482  for(int strip=0; strip< numStrips; ++strip){
483  if(!badChannels[strip]) vPeds[strip] = pedOffset* theElectronPerADC;
484  }
485  }
486 
487  theSiNoiseAdder->addPedestals(detAmpl, vPeds);
488 
489 
490  //if(!RealPedestals&&!CommonModeNoise&&!noise&&!BaselineShift&&!APVSaturationFromHIP){
491  // edm::LogWarning("SiStripDigitizer")<<"You are running the digitizer without Noise generation and without applying Zero Suppression. ARE YOU SURE???";
492  //}else{
493 
494  DigitalRawVecType rawdigis = theSiDigitalConverter->convertRaw(detAmpl, gainHandle, detID);
495 
496  // Now do the association to truth. Note that if truth association was turned off in the configuration this map
497  // will be empty and the iterator will always equal associationInfoForDetId_.end().
498  if( iAssociationInfoByChannel!=associationInfoForDetId_.end() ) { // make sure the readings for this DetID aren't completely from noise
499  // N.B. For the raw digis the channel is inferred from the position in the vector.
500  // I'VE NOT TESTED THIS YET!!!!!
501  // ToDo Test this properly.
502  for( size_t channel=0; channel<rawdigis.size(); ++channel ) {
503  auto& associationInfoByChannel=iAssociationInfoByChannel->second;
504  const auto iAssociationInfo=associationInfoByChannel.find(channel);
505  if( iAssociationInfo==associationInfoByChannel.end() ) continue; // Skip if there is no sim information for this channel (i.e. it's all noise)
506  const std::vector<AssociationInfo>& associationInfo=iAssociationInfo->second;
507 
508  // Need to find the total from all sim hits, because this might not be the same as the total
509  // digitised due to noise or whatever.
510  float totalSimADC=0;
511  for( const auto& iAssociationInfo : associationInfo ) totalSimADC+=iAssociationInfo.contributionToADC;
512  // Now I know that I can loop again and create the links
513  for( const auto& iAssociationInfo : associationInfo ) {
514  // Note simHitGlobalIndex used to have +1 because TrackerHitAssociator (the only place I can find this value being used)
515  // expected counting to start at 1, not 0. Now changed.
516  outLink.push_back( StripDigiSimLink( channel, iAssociationInfo.trackID, iAssociationInfo.simHitGlobalIndex, iAssociationInfo.tofBin, iAssociationInfo.eventID, iAssociationInfo.contributionToADC/totalSimADC ) );
517  } // end of loop over associationInfo
518  } // end of loop over the digis
519  } // end of check that iAssociationInfoByChannel is a valid iterator
520 
521  outrawdigi.data = rawdigis;
522 
523  //}
524  }
525 
526  // Now that I've finished with this entry in the map of associations, I can remove it.
527  // Note that there might not be an association if the ADC reading is from noise in which
528  // case associationIsValid will be false.
529  if( iAssociationInfoByChannel!=associationInfoForDetId_.end() ) associationInfoForDetId_.erase(iAssociationInfoByChannel);
530 }
std::map< int, float > mapOfAPVprobabilities
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
void push_back(const T &t)
Definition: DetSet.h:68
AssociationInfoForDetId associationInfoForDetId_
Structure that holds the information on the SimTrack contributions. Only filled if makeDigiSimLinks_ ...
std::map< int, std::bitset< 6 > > SiStripTrackerAffectedAPVMap
SiDigitalConverter::DigitalRawVecType DigitalRawVecType
SiDigitalConverter::DigitalVecType DigitalVecType
std::pair< ContainerIterator, ContainerIterator > Range
const std::unique_ptr< const SiGaussianTailNoiseAdder > theSiNoiseAdder
std::map< unsigned int, size_t > firstChannelsWithSignal
std::map< int, Amplitude > SignalMapType
const std::unique_ptr< SiTrivialDigitalConverter > theSiDigitalConverter
const std::unique_ptr< SiStripFedZeroSuppression > theSiZeroSuppress
std::pair< ContainerIterator, ContainerIterator > Range
std::map< unsigned int, std::vector< bool > > allBadChannels
Definition: DetId.h:18
std::map< unsigned int, size_t > lastChannelsWithSignal
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:48
void SiStripDigitizerAlgorithm::initializeDetUnit ( StripGeomDetUnit const *  det,
const edm::EventSetup iSetup 
)

Definition at line 81 of file SiStripDigitizerAlgorithm.cc.

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

81  {
82  edm::ESHandle<SiStripBadStrip> deadChannelHandle;
83  iSetup.get<SiStripBadChannelRcd>().get(deadChannelHandle);
84 
85  unsigned int detId = det->geographicalId().rawId();
86  int numStrips = (det->specificTopology()).nstrips();
87 
88  SiStripBadStrip::Range detBadStripRange = deadChannelHandle->getRange(detId);
89  //storing the bad strip of the the module. the module is not removed but just signal put to 0
90  std::vector<bool>& badChannels = allBadChannels[detId];
91  badChannels.clear();
92  badChannels.insert(badChannels.begin(), numStrips, false);
93  for(SiStripBadStrip::ContainerIterator it = detBadStripRange.first; it != detBadStripRange.second; ++it) {
94  SiStripBadStrip::data fs = deadChannelHandle->decode(*it);
95  for(int strip = fs.firstStrip; strip < fs.firstStrip + fs.range; ++strip) badChannels[strip] = true;
96  }
97  firstChannelsWithSignal[detId] = numStrips;
98  lastChannelsWithSignal[detId]= 0;
99 
100  // if(APVSaturationFromHIP){
101  // std::bitset<6> &bs=SiStripTrackerAffectedAPVMap[detId];
102  // if(bs.any())theAffectedAPVvector.push_back(std::make_pair(detId,bs));
103  //}
104 }
unsigned short range
std::vector< unsigned int >::const_iterator ContainerIterator
std::map< unsigned int, size_t > firstChannelsWithSignal
std::map< unsigned int, std::vector< bool > > allBadChannels
unsigned short firstStrip
const T & get() const
Definition: EventSetup.h:56
std::pair< ContainerIterator, ContainerIterator > Range
std::map< unsigned int, size_t > lastChannelsWithSignal
void SiStripDigitizerAlgorithm::initializeEvent ( const edm::EventSetup iSetup)

Definition at line 107 of file SiStripDigitizerAlgorithm.cc.

References APVSaturationProb_, APVSaturationProbScaling_, associationInfoForDetId_, FirstDigitize_, FirstLumiCalc_, edm::EventSetup::get(), edm::EventSetup::getData(), lorentzAngleHandle, lorentzAngleName, pdt, setParticleDataTable(), SiStripTrackerAffectedAPVMap, and theSiPileUpSignals.

107  {
108  theSiPileUpSignals->reset();
109  // This should be clear by after all calls to digitize(), but I might as well make sure
110  associationInfoForDetId_.clear();
111 
112  APVSaturationProb_ = APVSaturationProbScaling_; // reset probability
114  FirstLumiCalc_ = true;
115  FirstDigitize_ = true;
116 
117  //get gain noise pedestal lorentzAngle from ES handle
119  iSetup.getData(pdt);
120  setParticleDataTable(&*pdt);
122 }
const std::unique_ptr< SiPileUpSignals > theSiPileUpSignals
edm::ESHandle< SiStripLorentzAngle > lorentzAngleHandle
AssociationInfoForDetId associationInfoForDetId_
Structure that holds the information on the SimTrack contributions. Only filled if makeDigiSimLinks_ ...
std::map< int, std::bitset< 6 > > SiStripTrackerAffectedAPVMap
void getData(T &iHolder) const
Definition: EventSetup.h:79
void setParticleDataTable(const ParticleDataTable *pardt)
const T & get() const
Definition: EventSetup.h:56
const ParticleDataTable * pdt
void SiStripDigitizerAlgorithm::setParticleDataTable ( const ParticleDataTable pardt)
inline

Definition at line 96 of file SiStripDigitizerAlgorithm.h.

References pdt, and theSiHitDigitizer.

Referenced by initializeEvent().

96  {
97  theSiHitDigitizer->setParticleDataTable(pardt);
98  pdt= pardt;
99  }
const std::unique_ptr< SiHitDigitizer > theSiHitDigitizer
const ParticleDataTable * pdt

Member Data Documentation

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

Definition at line 143 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and initializeDetUnit().

std::ifstream SiStripDigitizerAlgorithm::APVProbaFile
private

Definition at line 167 of file SiStripDigitizerAlgorithm.h.

const bool SiStripDigitizerAlgorithm::APVSaturationFromHIP
private

Definition at line 116 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and SiStripDigitizerAlgorithm().

double SiStripDigitizerAlgorithm::APVSaturationProb_
private

Definition at line 132 of file SiStripDigitizerAlgorithm.h.

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

const double SiStripDigitizerAlgorithm::APVSaturationProbScaling_
private

Definition at line 108 of file SiStripDigitizerAlgorithm.h.

Referenced by initializeEvent().

AssociationInfoForDetId SiStripDigitizerAlgorithm::associationInfoForDetId_
private

Structure that holds the information on the SimTrack contributions. Only filled if makeDigiSimLinks_ is true.

Definition at line 165 of file SiStripDigitizerAlgorithm.h.

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

const bool SiStripDigitizerAlgorithm::BaselineShift
private

Definition at line 115 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStec
private

Definition at line 107 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStib
private

Definition at line 104 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStid
private

Definition at line 106 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::cmnRMStob
private

Definition at line 105 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const bool SiStripDigitizerAlgorithm::CommonModeNoise
private

Definition at line 114 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and SiStripDigitizerAlgorithm().

const double SiStripDigitizerAlgorithm::cosmicShift
private

Definition at line 124 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

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

Definition at line 145 of file SiStripDigitizerAlgorithm.h.

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

bool SiStripDigitizerAlgorithm::FirstDigitize_
private

Definition at line 134 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and initializeEvent().

bool SiStripDigitizerAlgorithm::FirstLumiCalc_
private

Definition at line 133 of file SiStripDigitizerAlgorithm.h.

Referenced by calculateInstlumiScale(), and initializeEvent().

const double SiStripDigitizerAlgorithm::inefficiency
private

Definition at line 125 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

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

Definition at line 146 of file SiStripDigitizerAlgorithm.h.

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

edm::ESHandle<SiStripLorentzAngle> SiStripDigitizerAlgorithm::lorentzAngleHandle
private

Definition at line 149 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), and initializeEvent().

const std::string SiStripDigitizerAlgorithm::lorentzAngleName
private

Definition at line 102 of file SiStripDigitizerAlgorithm.h.

Referenced by initializeEvent().

const bool SiStripDigitizerAlgorithm::makeDigiSimLinks_
private

Definition at line 109 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

std::map< int , float> SiStripDigitizerAlgorithm::mapOfAPVprobabilities
private

Definition at line 168 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const bool SiStripDigitizerAlgorithm::noise
private

Definition at line 111 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

int SiStripDigitizerAlgorithm::NumberOfBxBetweenHIPandEvent
private

Definition at line 170 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const ParticleData* SiStripDigitizerAlgorithm::particle
private

Definition at line 130 of file SiStripDigitizerAlgorithm.h.

const ParticleDataTable* SiStripDigitizerAlgorithm::pdt
private

Definition at line 129 of file SiStripDigitizerAlgorithm.h.

Referenced by initializeEvent(), and setParticleDataTable().

const bool SiStripDigitizerAlgorithm::peakMode
private

Definition at line 110 of file SiStripDigitizerAlgorithm.h.

Referenced by SiStripDigitizerAlgorithm().

const double SiStripDigitizerAlgorithm::pedOffset
private

Definition at line 126 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const bool SiStripDigitizerAlgorithm::PreMixing_
private

Definition at line 127 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and SiStripDigitizerAlgorithm().

const bool SiStripDigitizerAlgorithm::RealPedestals
private

Definition at line 112 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const bool SiStripDigitizerAlgorithm::SingleStripNoise
private

Definition at line 113 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and SiStripDigitizerAlgorithm().

std::map< int , std::bitset<6> > SiStripDigitizerAlgorithm::SiStripTrackerAffectedAPVMap
private

Definition at line 169 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize(), and initializeEvent().

const double SiStripDigitizerAlgorithm::theElectronPerADC
private

Definition at line 120 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const int SiStripDigitizerAlgorithm::theFedAlgo
private

Definition at line 118 of file SiStripDigitizerAlgorithm.h.

const std::unique_ptr<SiTrivialDigitalConverter> SiStripDigitizerAlgorithm::theSiDigitalConverter
private

Definition at line 139 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const std::unique_ptr<SiHitDigitizer> SiStripDigitizerAlgorithm::theSiHitDigitizer
private

Definition at line 136 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits(), and setParticleDataTable().

const std::unique_ptr<const SiGaussianTailNoiseAdder> SiStripDigitizerAlgorithm::theSiNoiseAdder
private

Definition at line 138 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const std::unique_ptr<SiPileUpSignals> SiStripDigitizerAlgorithm::theSiPileUpSignals
private

Definition at line 137 of file SiStripDigitizerAlgorithm.h.

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

const std::unique_ptr<SiStripFedZeroSuppression> SiStripDigitizerAlgorithm::theSiZeroSuppress
private

Definition at line 140 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().

const double SiStripDigitizerAlgorithm::theThreshold
private

Definition at line 103 of file SiStripDigitizerAlgorithm.h.

const double SiStripDigitizerAlgorithm::theTOFCutForDeconvolution
private

Definition at line 122 of file SiStripDigitizerAlgorithm.h.

const double SiStripDigitizerAlgorithm::theTOFCutForPeak
private

Definition at line 121 of file SiStripDigitizerAlgorithm.h.

const double SiStripDigitizerAlgorithm::tofCut
private

Definition at line 123 of file SiStripDigitizerAlgorithm.h.

Referenced by accumulateSimHits().

const bool SiStripDigitizerAlgorithm::zeroSuppression
private

Definition at line 119 of file SiStripDigitizerAlgorithm.h.

Referenced by digitize().