Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:39

0001 #include "CalibTracker/SiStripAPVAnalysis/interface/ApvAnalysis.h"
0002 #include "CalibTracker/SiStripAPVAnalysis/interface/TkApvMask.h"
0003 #include "CalibTracker/SiStripAPVAnalysis/interface/TkNoiseCalculator.h"
0004 #include "CalibTracker/SiStripAPVAnalysis/interface/TkPedestalCalculator.h"
0005 #include "CalibTracker/SiStripAPVAnalysis/interface/TkCommonModeCalculator.h"
0006 #include <algorithm>
0007 
0008 using namespace std;
0009 ApvAnalysis::ApvAnalysis(int nEvForUpdate) {
0010   theTkCommonModeCalculator = nullptr;
0011   theTkPedestalCalculator = nullptr;
0012   theTkNoiseCalculator = nullptr;
0013   theTkApvMask = nullptr;
0014   nEventsForNoiseCalibration_ = 0;
0015   eventsRequiredToUpdate_ = nEvForUpdate;
0016 }
0017 void ApvAnalysis::newEvent() const {
0018   theTkPedestalCalculator->newEvent();
0019   theTkNoiseCalculator->newEvent();
0020   theTkCommonModeCalculator->newEvent();
0021 }
0022 
0023 void ApvAnalysis::updateCalibration(edm::DetSet<SiStripRawDigi>& in) {
0024   theTkPedestalCalculator->updatePedestal(in);
0025 
0026   PedestalType noise;
0027   if (theTkPedestalCalculator->status()->isUpdating()) {
0028     nEventsForNoiseCalibration_++;
0029 
0030     if (theTkNoiseCalculator->noise().empty()) {
0031       noise = theTkPedestalCalculator->rawNoise();
0032       theTkNoiseCalculator->setStripNoise(noise);
0033       theTkApvMask->calculateMask(noise);
0034     }
0035 
0036     PedestalType pedestal = theTkPedestalCalculator->pedestal();
0037     PedestalType tmp;
0038     tmp.clear();
0039     edm::DetSet<SiStripRawDigi>::const_iterator it = in.data.begin();
0040     int i = 0;
0041     for (; it != in.data.end(); it++) {
0042       tmp.push_back((*it).adc() - pedestal[i]);
0043       i++;
0044     }
0045     PedestalType tmp2 = theTkCommonModeCalculator->doIt(tmp);
0046     if (!tmp2.empty()) {
0047       theTkNoiseCalculator->updateNoise(tmp2);
0048     }
0049     if (nEventsForNoiseCalibration_ % eventsRequiredToUpdate_ == 1 && nEventsForNoiseCalibration_ > 1) {
0050       noise = theTkNoiseCalculator->noise();
0051       theTkApvMask->calculateMask(noise);
0052     }
0053   }
0054 }