Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:56

0001 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0002 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
0003 #include "DataFormats/SiStripCommon/interface/ConstantsForHardwareSystems.h"
0004 
0005 #include "DQM/SiStripMonitorHardware/interface/CMHistograms.hh"
0006 
0007 CMHistograms::CMHistograms() {
0008   for (unsigned int i(0); i < 500; i++) {
0009     doFed_[i] = false;
0010   }
0011 }
0012 
0013 CMHistograms::~CMHistograms() {}
0014 
0015 void CMHistograms::initialise(const edm::ParameterSet& iConfig, std::ostringstream* pDebugStream) {
0016   getConfigForHistogram(medianAPV1vsAPV0_, "MedianAPV1vsAPV0", iConfig, pDebugStream);
0017   getConfigForHistogram(medianAPV0minusAPV1_, "MedianAPV0minusAPV1", iConfig, pDebugStream);
0018 
0019   getConfigForHistogram(meanCMPerFedvsFedId_, "MeanCMPerFedvsFedId", iConfig, pDebugStream);
0020   getConfigForHistogram(meanCMPerFedvsTime_, "MeanCMPerFedvsTime", iConfig, pDebugStream);
0021   getConfigForHistogram(variationsPerFedvsFedId_, "VariationsPerFedvsFedId", iConfig, pDebugStream);
0022   getConfigForHistogram(variationsPerFedvsTime_, "VariationsPerFedvsTime", iConfig, pDebugStream);
0023 
0024   getConfigForHistogram(medianAPV1vsAPV0perFED_, "MedianAPV1vsAPV0perFED", iConfig, pDebugStream);
0025   getConfigForHistogram(medianAPV0minusAPV1perFED_, "MedianAPV0minusAPV1perFED", iConfig, pDebugStream);
0026 
0027   getConfigForHistogram(medianperChannel_, "MedianperChannel", iConfig, pDebugStream);
0028   getConfigForHistogram(medianAPV0minusAPV1perChannel_, "MedianAPV0minusAPV1perChannel", iConfig, pDebugStream);
0029 
0030   getConfigForHistogram(tkMapConfig_, "TkHistoMap", iConfig, pDebugStream);
0031 
0032   if (iConfig.exists("FedIdVec")) {
0033     std::vector<unsigned int> lIdVec = iConfig.getUntrackedParameter<std::vector<unsigned int> >("FedIdVec");
0034     for (unsigned int i(0); i < lIdVec.size(); i++) {
0035       if (lIdVec.at(i) < 500)
0036         doFed_[lIdVec.at(i)] = true;
0037     }
0038   }
0039 }
0040 
0041 void CMHistograms::fillHistograms(const std::vector<CMvalues>& aVec, float aTime, unsigned int aFedId) {
0042   float lMean = 0;
0043   float lPrevMean = 0;
0044 
0045   for (unsigned iEle(0); iEle < aVec.size(); iEle++) {  //loop on elements
0046 
0047     CMvalues lVal = aVec[iEle];
0048 
0049     if (lVal.Medians.first >= 1024 || lVal.Medians.second >= 1024) {
0050       std::cout << "----- WARNING ! New max found: " << lVal.Medians.first << " " << lVal.Medians.second << " "
0051                 << __FILE__ << " " << __LINE__ << std::endl;
0052     }
0053 
0054     fillHistogram(medianAPV1vsAPV0_, lVal.Medians.first, lVal.Medians.second);
0055     fillHistogram(medianAPV0minusAPV1_, lVal.Medians.first - lVal.Medians.second);
0056 
0057     lMean += lVal.Medians.first + lVal.Medians.second;
0058     lPrevMean += lVal.PreviousMedians.first + lVal.PreviousMedians.second;
0059 
0060     if (doFed_[aFedId]) {
0061       fillHistogram(medianAPV1vsAPV0perFEDMap_[aFedId], lVal.Medians.first, lVal.Medians.second);
0062       fillHistogram(medianAPV0minusAPV1perFEDMap_[aFedId], lVal.Medians.first - lVal.Medians.second);
0063       fillHistogram(medianperChannelMap_[aFedId][lVal.ChannelID], lVal.Medians.first);
0064       fillHistogram(medianAPV0minusAPV1perChannelMap_[aFedId][lVal.ChannelID],
0065                     lVal.Medians.first - lVal.Medians.second);
0066     }
0067 
0068   }  //loop on elements
0069 
0070   if (!aVec.empty()) {
0071     lMean = lMean / (2 * aVec.size());
0072     lPrevMean = lPrevMean / (2 * aVec.size());
0073   }
0074 
0075   fillHistogram(meanCMPerFedvsFedId_, aFedId, lMean);
0076   fillHistogram(meanCMPerFedvsTime_, aTime, lMean);
0077   fillHistogram(variationsPerFedvsFedId_, aFedId, lMean - lPrevMean);
0078   fillHistogram(variationsPerFedvsTime_, aTime, lMean - lPrevMean);
0079 }
0080 
0081 void CMHistograms::bookTopLevelHistograms(DQMStore::IBooker& ibooker, const TkDetMap* tkDetMap) {
0082   //book FED level histograms
0083   //get FED IDs
0084   //const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
0085   const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
0086   histosBooked_.resize(siStripFedIdMax + 1, false);
0087 
0088   std::string lDir = ibooker.pwd() + "/";
0089 
0090   ibooker.cd(lDir);
0091 
0092   ibooker.setCurrentFolder(lDir);
0093 
0094   book2DHistogram(ibooker,
0095                   medianAPV1vsAPV0_,
0096                   "MedianAPV1vsAPV0",
0097                   "median APV1 vs APV0",
0098                   250,
0099                   0,
0100                   1024,
0101                   250,
0102                   0,
0103                   1024,
0104                   "median APV0",
0105                   "median APV1");
0106 
0107   bookHistogram(ibooker,
0108                 medianAPV0minusAPV1_,
0109                 "MedianAPV0minusAPV1",
0110                 "median APV0 - median APV1",
0111                 500,
0112                 -500,
0113                 500,
0114                 "median APV0 - median APV1");
0115 
0116   bookProfile(ibooker,
0117               meanCMPerFedvsFedId_,
0118               "MeanCMPerFedvsFedId",
0119               "<CM> vs fedID",
0120               440,
0121               50,
0122               490,
0123               -1000,
0124               1000,
0125               "fedID",
0126               "<CM>^{FED}");
0127 
0128   bookProfile(ibooker, meanCMPerFedvsTime_, "MeanCMPerFedvsTime", "<CM> vs time", 0, 1000, "Time", "<CM>^{FED}");
0129 
0130   bookProfile(ibooker,
0131               variationsPerFedvsFedId_,
0132               "VariationsPerFedvsFedId",
0133               "<CM> vs fedID",
0134               440,
0135               50,
0136               490,
0137               -1000,
0138               1000,
0139               "fedID",
0140               "<CM>^{FED}_{t}-<CM>^{FED}_{t-1}");
0141 
0142   bookProfile(ibooker,
0143               variationsPerFedvsTime_,
0144               "VariationsPerFedvsTime",
0145               "<CM> vs time",
0146               0,
0147               1000,
0148               "Time",
0149               "<CM>^{FED}_{t}-<CM>^{FED}_{t-1}");
0150 
0151   ibooker.cd(lDir);
0152 
0153   //book map after, as it creates a new folder...
0154   if (tkMapConfig_.enabled) {
0155     tkmapCM_[0] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_MeanCMAPV", 0., true);
0156     tkmapCM_[1] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_RmsCMAPV", 0., true);
0157     tkmapCM_[2] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_MeanCMAPV0minusAPV1", -500., true);
0158     tkmapCM_[3] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_RmsCMAPV0minusAPV1", -500., true);
0159   } else {
0160     tkmapCM_[0] = nullptr;
0161     tkmapCM_[1] = nullptr;
0162     tkmapCM_[2] = nullptr;
0163     tkmapCM_[3] = nullptr;
0164   }
0165 
0166   for (unsigned int i = sistrip::FED_ID_MIN; i <= sistrip::FED_ID_MAX; i++)
0167     if (doFed_[i])
0168       bookFEDHistograms(ibooker, i);
0169 }
0170 
0171 void CMHistograms::bookFEDHistograms(DQMStore::IBooker& ibooker, unsigned int fedId) {
0172   if (!histosBooked_[fedId]) {
0173     //will do that only once
0174 
0175     SiStripFedKey fedKey(fedId, 0, 0, 0);
0176     std::stringstream fedIdStream;
0177     fedIdStream << fedId;
0178 
0179     ibooker.setCurrentFolder(fedKey.path());
0180 
0181     book2DHistogram(ibooker,
0182                     medianAPV1vsAPV0perFED_,
0183                     medianAPV1vsAPV0perFEDMap_[fedId],
0184                     "MedianAPV1vsAPV0forFED" + fedIdStream.str(),
0185                     "median APV1 vs APV0 for FED " + fedIdStream.str(),
0186                     250,
0187                     0,
0188                     500,
0189                     250,
0190                     0,
0191                     500,
0192                     "APV0",
0193                     "APV1");
0194 
0195     bookHistogram(ibooker,
0196                   medianAPV0minusAPV1perFED_,
0197                   medianAPV0minusAPV1perFEDMap_[fedId],
0198                   "MedianAPV0minusAPV1forFED" + fedIdStream.str(),
0199                   "median APV0 - median APV1 for FED " + fedIdStream.str(),
0200                   500,
0201                   -500,
0202                   500,
0203                   "#Delta(medians)");
0204 
0205     bookChannelsHistograms(ibooker, fedId);
0206 
0207     histosBooked_[fedId] = true;
0208   }
0209 }
0210 
0211 void CMHistograms::bookChannelsHistograms(DQMStore::IBooker& ibooker, unsigned int fedId) {
0212   SiStripFedKey fedKey(fedId, 0, 0, 0);
0213   std::stringstream fedIdStream;
0214   fedIdStream << fedId;
0215 
0216   ibooker.setCurrentFolder(fedKey.path());
0217   medianperChannelMap_[fedId].resize(sistrip::FEDCH_PER_FED, nullptr);
0218   medianAPV0minusAPV1perChannelMap_[fedId].resize(sistrip::FEDCH_PER_FED, nullptr);
0219 
0220   for (unsigned int iCh(0); iCh < sistrip::FEDCH_PER_FED; iCh++) {
0221     std::ostringstream lName0, lTitle0, lName1, lTitle1, lName2, lTitle2;
0222     lName0 << "MedianForFed" << fedId << "Channel" << iCh;
0223     lTitle0 << "Median for FED/Ch " << fedId << "/" << iCh;
0224     lName2 << "MedianAPV0minusAPV1ForFed" << fedId << "Channel" << iCh;
0225     lTitle2 << "Median APV0-APV1 for FED/Ch " << fedId << "/" << iCh;
0226 
0227     bookHistogram(ibooker,
0228                   medianperChannel_,
0229                   medianperChannelMap_[fedId][iCh],
0230                   lName0.str(),
0231                   lTitle0.str(),
0232                   250,
0233                   0,
0234                   500,
0235                   "median APVs");
0236 
0237     bookHistogram(ibooker,
0238                   medianAPV0minusAPV1perChannel_,
0239                   medianAPV0minusAPV1perChannelMap_[fedId][iCh],
0240                   lName2.str(),
0241                   lTitle2.str(),
0242                   250,
0243                   -500,
0244                   500,
0245                   "median APV0-APV1");
0246   }
0247 }
0248 
0249 void CMHistograms::bookAllFEDHistograms(DQMStore::IBooker& ibooker) {
0250   //get FED IDs
0251   const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
0252   const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
0253   //book them
0254   for (unsigned int iFed = siStripFedIdMin; iFed <= siStripFedIdMax; iFed++) {
0255     bookFEDHistograms(ibooker, iFed);
0256   }
0257 }
0258 
0259 bool CMHistograms::tkHistoMapEnabled(unsigned int aIndex) { return tkMapConfig_.enabled; }
0260 
0261 TkHistoMap* CMHistograms::tkHistoMapPointer(unsigned int aIndex) {
0262   assert(aIndex < 4);
0263   return tkmapCM_[aIndex].get();
0264 }