Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:29

0001 #include "DQM/HcalCommon/interface/ContainerProf2D.h"
0002 
0003 namespace hcaldqm {
0004   using namespace mapper;
0005   using namespace quantity;
0006   using namespace constants;
0007 
0008   ContainerProf2D::ContainerProf2D() {
0009     _qx = nullptr;
0010     _qy = nullptr;
0011     _qz = nullptr;
0012   }
0013 
0014   ContainerProf2D::ContainerProf2D(
0015       std::string const &folder, hashfunctions::HashType hashtype, Quantity *qx, Quantity *qy, Quantity *qz)
0016       : Container2D(folder, hashtype, qx, qy, qz) {
0017     _qx->setAxisType(quantity::fXAxis);
0018     _qy->setAxisType(quantity::fYAxis);
0019     _qz->setAxisType(quantity::fZAxis);
0020   }
0021 
0022   /* virtual */ void ContainerProf2D::initialize(std::string const &folder,
0023                                                  hashfunctions::HashType hashtype,
0024                                                  Quantity *qx,
0025                                                  Quantity *qy,
0026                                                  Quantity *qz,
0027                                                  int debug /*=0*/) {
0028     Container2D::initialize(folder, hashtype, qx, qy, qz, debug);
0029     _qx->setAxisType(quantity::fXAxis);
0030     _qy->setAxisType(quantity::fYAxis);
0031     _qz->setAxisType(quantity::fZAxis);
0032   }
0033 
0034   /* virtual */ void ContainerProf2D::initialize(std::string const &folder,
0035                                                  std::string const &qname,
0036                                                  hashfunctions::HashType hashtype,
0037                                                  Quantity *qx,
0038                                                  Quantity *qy,
0039                                                  Quantity *qz,
0040                                                  int debug /*=0*/) {
0041     Container2D::initialize(folder, qname, hashtype, qx, qy, qz, debug);
0042     _qx->setAxisType(quantity::fXAxis);
0043     _qy->setAxisType(quantity::fYAxis);
0044     _qz->setAxisType(quantity::fZAxis);
0045   }
0046 
0047   /* virtual */ void ContainerProf2D::book(DQMStore::IBooker &ib,
0048                                            HcalElectronicsMap const *emap,
0049                                            std::string subsystem,
0050                                            std::string aux) {
0051     //  full path as in Container1D.cc
0052     //
0053     ib.setCurrentFolder(subsystem + "/" + _folder + "/" + _qname + (aux.empty() ? aux : "_" + aux) + "/" +
0054                         _hashmap.getHashTypeName());
0055     if (_hashmap.isDHash()) {
0056       //      for Detector Hashes
0057       std::vector<HcalGenericDetId> dids = emap->allPrecisionId();
0058       for (std::vector<HcalGenericDetId>::const_iterator it = dids.begin(); it != dids.end(); ++it) {
0059         //  skip trigger towers and calibration
0060         if (!it->isHcalDetId())
0061           continue;
0062 
0063         HcalDetId did = HcalDetId(it->rawId());
0064         uint32_t hash = _hashmap.getHash(did);
0065         MEMap::iterator mit = _mes.find(hash);
0066         if (mit != _mes.end())
0067           continue;
0068 
0069         _logger.debug(_hashmap.getName(did));
0070         _mes.insert(std::make_pair(hash,
0071                                    ib.bookProfile2D(_hashmap.getName(did),
0072                                                     _hashmap.getName(did),
0073                                                     _qx->nbins(),
0074                                                     _qx->min(),
0075                                                     _qx->max(),
0076                                                     _qy->nbins(),
0077                                                     _qy->min(),
0078                                                     _qy->max(),
0079                                                     _qz->min(),
0080                                                     _qz->max())));
0081         customize(_mes[hash]);
0082       }
0083     } else if (_hashmap.isEHash()) {
0084       //      for Electronics hashes
0085       std::vector<HcalElectronicsId> eids = emap->allElectronicsIdPrecision();
0086       for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
0087         HcalElectronicsId eid = HcalElectronicsId(it->rawId());
0088         uint32_t hash = _hashmap.getHash(eid);
0089         MEMap::iterator mit = _mes.find(hash);
0090         if (mit != _mes.end())
0091           continue;
0092 
0093         _logger.debug(_hashmap.getName(eid));
0094         _mes.insert(std::make_pair(hash,
0095                                    ib.bookProfile2D(_hashmap.getName(eid),
0096                                                     _hashmap.getName(eid),
0097                                                     _qx->nbins(),
0098                                                     _qx->min(),
0099                                                     _qx->max(),
0100                                                     _qy->nbins(),
0101                                                     _qy->min(),
0102                                                     _qy->max(),
0103                                                     _qz->min(),
0104                                                     _qz->max())));
0105         customize(_mes[hash]);
0106       }
0107     } else if (_hashmap.isTHash()) {
0108       //      for TrigTower hashes
0109       std::vector<HcalTrigTowerDetId> tids = emap->allTriggerId();
0110       for (std::vector<HcalTrigTowerDetId>::const_iterator it = tids.begin(); it != tids.end(); ++it) {
0111         HcalTrigTowerDetId tid = HcalTrigTowerDetId(it->rawId());
0112         uint32_t hash = _hashmap.getHash(tid);
0113         MEMap::iterator mit = _mes.find(hash);
0114         if (mit != _mes.end())
0115           continue;
0116 
0117         _logger.debug(_hashmap.getName(tid));
0118         _mes.insert(std::make_pair(hash,
0119                                    ib.bookProfile2D(_hashmap.getName(tid),
0120                                                     _hashmap.getName(tid),
0121                                                     _qx->nbins(),
0122                                                     _qx->min(),
0123                                                     _qx->max(),
0124                                                     _qy->nbins(),
0125                                                     _qy->min(),
0126                                                     _qy->max(),
0127                                                     _qz->min(),
0128                                                     _qz->max())));
0129         customize(_mes[hash]);
0130       }
0131     }
0132   }
0133 
0134   /* virtual */ void ContainerProf2D::book(DQMStore::IBooker &ib,
0135                                            HcalElectronicsMap const *emap,
0136                                            filter::HashFilter const &filter,
0137                                            std::string subsystem,
0138                                            std::string aux) {
0139     //  full path as in Container1D.cc
0140     //
0141     ib.setCurrentFolder(subsystem + "/" + _folder + "/" + _qname + (aux.empty() ? aux : "_" + aux) + "/" +
0142                         _hashmap.getHashTypeName());
0143     if (_hashmap.isDHash()) {
0144       //      for Detector Hashes
0145       std::vector<HcalGenericDetId> dids = emap->allPrecisionId();
0146       for (std::vector<HcalGenericDetId>::const_iterator it = dids.begin(); it != dids.end(); ++it) {
0147         //  skip trigger towers and calibration
0148         if (!it->isHcalDetId())
0149           continue;
0150 
0151         HcalDetId did = HcalDetId(it->rawId());
0152         uint32_t hash = _hashmap.getHash(did);
0153         MEMap::iterator mit = _mes.find(hash);
0154         if (mit != _mes.end())
0155           continue;
0156         if (filter.filter(did))
0157           continue;
0158 
0159         _logger.debug(_hashmap.getName(did));
0160         _mes.insert(std::make_pair(hash,
0161                                    ib.bookProfile2D(_hashmap.getName(did),
0162                                                     _hashmap.getName(did),
0163                                                     _qx->nbins(),
0164                                                     _qx->min(),
0165                                                     _qx->max(),
0166                                                     _qy->nbins(),
0167                                                     _qy->min(),
0168                                                     _qy->max(),
0169                                                     _qz->min(),
0170                                                     _qz->max())));
0171         customize(_mes[hash]);
0172       }
0173     } else if (_hashmap.isEHash()) {
0174       //      for Electronics hashes
0175       std::vector<HcalElectronicsId> eids = emap->allElectronicsIdPrecision();
0176       for (std::vector<HcalElectronicsId>::const_iterator it = eids.begin(); it != eids.end(); ++it) {
0177         HcalElectronicsId eid = HcalElectronicsId(it->rawId());
0178         uint32_t hash = _hashmap.getHash(eid);
0179         MEMap::iterator mit = _mes.find(hash);
0180         if (mit != _mes.end())
0181           continue;
0182         if (filter.filter(eid))
0183           continue;
0184 
0185         _logger.debug(_hashmap.getName(eid));
0186         _mes.insert(std::make_pair(hash,
0187                                    ib.bookProfile2D(_hashmap.getName(eid),
0188                                                     _hashmap.getName(eid),
0189                                                     _qx->nbins(),
0190                                                     _qx->min(),
0191                                                     _qx->max(),
0192                                                     _qy->nbins(),
0193                                                     _qy->min(),
0194                                                     _qy->max(),
0195                                                     _qz->min(),
0196                                                     _qz->max())));
0197         customize(_mes[hash]);
0198       }
0199     } else if (_hashmap.isTHash()) {
0200       //      for TrigTower hashes
0201       std::vector<HcalTrigTowerDetId> tids = emap->allTriggerId();
0202       for (std::vector<HcalTrigTowerDetId>::const_iterator it = tids.begin(); it != tids.end(); ++it) {
0203         HcalTrigTowerDetId tid = HcalTrigTowerDetId(it->rawId());
0204         uint32_t hash = _hashmap.getHash(tid);
0205         MEMap::iterator mit = _mes.find(hash);
0206         if (mit != _mes.end())
0207           continue;
0208         if (filter.filter(tid))
0209           continue;
0210 
0211         _logger.debug(_hashmap.getName(tid));
0212         _mes.insert(std::make_pair(hash,
0213                                    ib.bookProfile2D(_hashmap.getName(tid),
0214                                                     _hashmap.getName(tid),
0215                                                     _qx->nbins(),
0216                                                     _qx->min(),
0217                                                     _qx->max(),
0218                                                     _qy->nbins(),
0219                                                     _qy->min(),
0220                                                     _qy->max(),
0221                                                     _qz->min(),
0222                                                     _qz->max())));
0223         customize(_mes[hash]);
0224       }
0225     }
0226   }
0227 
0228   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did) {
0229     _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did));
0230   }
0231 
0232   //    HcalDetId based
0233   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did, int x) {
0234     if (_qx->isCoordinate() && _qy->isCoordinate())
0235       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did), x);
0236     else if (_qx->isCoordinate())
0237       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x));
0238     else if (_qy->isCoordinate())
0239       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did));
0240   }
0241 
0242   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did, double x) {
0243     if (_qx->isCoordinate() && _qy->isCoordinate())
0244       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did), x);
0245     else if (_qx->isCoordinate())
0246       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x));
0247     else if (_qy->isCoordinate())
0248       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did));
0249   }
0250 
0251   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did, int x, double y) {
0252     if (_qx->isCoordinate() && !_qy->isCoordinate())
0253       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0254     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0255       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0256     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0257       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0258   }
0259 
0260   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did, int x, int y) {
0261     if (_qx->isCoordinate() && !_qy->isCoordinate())
0262       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0263     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0264       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0265     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0266       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0267   }
0268 
0269   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did, double x, double y) {
0270     if (_qx->isCoordinate() && !_qy->isCoordinate())
0271       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0272     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0273       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0274     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0275       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0276   }
0277 
0278   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &did) {
0279     _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did));
0280   }
0281 
0282   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &did, int x) {
0283     if (_qx->isCoordinate() && _qy->isCoordinate())
0284       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did), x);
0285     else if (_qx->isCoordinate())
0286       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x));
0287     else if (_qy->isCoordinate())
0288       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did));
0289   }
0290 
0291   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &did, double x) {
0292     if (_qx->isCoordinate() && _qy->isCoordinate())
0293       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did), x);
0294     else if (_qx->isCoordinate())
0295       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x));
0296     else if (_qy->isCoordinate())
0297       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did));
0298   }
0299 
0300   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &did, int x, double y) {
0301     if (_qx->isCoordinate() && !_qy->isCoordinate())
0302       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0303     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0304       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0305     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0306       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0307   }
0308 
0309   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &did, int x, int y) {
0310     if (_qx->isCoordinate() && !_qy->isCoordinate())
0311       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0312     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0313       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0314     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0315       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0316   }
0317 
0318   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &did, double x, double y) {
0319     if (_qx->isCoordinate() && !_qy->isCoordinate())
0320       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0321     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0322       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0323     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0324       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0325   }
0326 
0327   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &did) {
0328     _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did));
0329   }
0330 
0331   //    HcalDetId based
0332   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &did, int x) {
0333     if (_qx->isCoordinate() && _qy->isCoordinate())
0334       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did), x);
0335     else if (_qx->isCoordinate())
0336       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x));
0337     else if (_qy->isCoordinate())
0338       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did));
0339   }
0340 
0341   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &did, double x) {
0342     if (_qx->isCoordinate() && _qy->isCoordinate())
0343       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(did), x);
0344     else if (_qx->isCoordinate())
0345       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x));
0346     else if (_qy->isCoordinate())
0347       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did));
0348   }
0349 
0350   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &did, int x, double y) {
0351     if (_qx->isCoordinate() && !_qy->isCoordinate())
0352       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0353     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0354       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0355     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0356       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0357   }
0358 
0359   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &did, int x, int y) {
0360     if (_qx->isCoordinate() && !_qy->isCoordinate())
0361       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0362     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0363       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0364     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0365       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0366   }
0367 
0368   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &did, double x, double y) {
0369     if (_qx->isCoordinate() && !_qy->isCoordinate())
0370       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(did), _qy->getValue(x), y);
0371     else if (!_qx->isCoordinate() && _qy->isCoordinate())
0372       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(did), y);
0373     else if (!_qx->isCoordinate() && !_qy->isCoordinate())
0374       _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y));
0375   }
0376 
0377   /* virtual */ void ContainerProf2D::fill(HcalDetId const &did, double x, double y, double z) {
0378     _mes[_hashmap.getHash(did)]->Fill(_qx->getValue(x), _qy->getValue(y), _qz->getValue(z));
0379   }
0380 
0381   /* virtual */ void ContainerProf2D::fill(HcalElectronicsId const &eid, double x, double y, double z) {
0382     _mes[_hashmap.getHash(eid)]->Fill(_qx->getValue(x), _qy->getValue(y), _qz->getValue(z));
0383   }
0384 
0385   /* virtual */ void ContainerProf2D::fill(HcalTrigTowerDetId const &tid, double x, double y, double z) {
0386     _mes[_hashmap.getHash(tid)]->Fill(_qx->getValue(x), _qy->getValue(y), _qz->getValue(z));
0387   }
0388 
0389 }  // namespace hcaldqm