Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // user include files
0002 #include "DataFormats/EcalDigi/interface/EcalConstants.h"
0003 #include "FWCore/Framework/interface/ESProducer.h"
0004 #include "FWCore/Framework/interface/ModuleFactory.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/FileInPath.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 //
0010 #include "CondFormats/DataRecord/interface/EcalTPGCrystalStatusRcd.h"
0011 #include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h"
0012 #include "CondFormats/DataRecord/interface/EcalTPGStripStatusRcd.h"
0013 // commented lines are for a reminder that in future we might need to implement something alike
0014 //#include "CondFormats/DataRecord/interface/EcalTPGSpikeRcd.h"
0015 //#include "CondFormats/DataRecord/interface/EcalTPGTowerStatusRcd.h"
0016 #include "CondFormats/DataRecord/interface/EcalEBPhase2TPGLinearizationConstRcd.h"
0017 #include "CondFormats/DataRecord/interface/EcalTPGWeightGroupRcd.h"
0018 #include "CondFormats/DataRecord/interface/EcalEBPhase2TPGAmplWeightIdMapRcd.h"
0019 #include "CondFormats/DataRecord/interface/EcalEBPhase2TPGTimeWeightIdMapRcd.h"
0020 #include "CondFormats/DataRecord/interface/EcalEBPhase2TPGPedestalsRcd.h"
0021 #include "CondFormats/EcalObjects/interface/EcalTPGCrystalStatus.h"
0022 #include "CondFormats/EcalObjects/interface/EcalEBPhase2TPGLinearizationConst.h"
0023 #include "CondFormats/EcalObjects/interface/EcalEBPhase2TPGPedestals.h"
0024 #include "CondFormats/EcalObjects/interface/EcalTPGPhysicsConst.h"
0025 //#include "CondFormats/EcalObjects/interface/EcalTPGSpike.h"
0026 //#include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
0027 #include "CondFormats/EcalObjects/interface/EcalTPGStripStatus.h"
0028 #include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.h"
0029 #include "CondFormats/EcalObjects/interface/EcalEBPhase2TPGAmplWeightIdMap.h"
0030 #include "CondFormats/EcalObjects/interface/EcalEBPhase2TPGTimeWeightIdMap.h"
0031 
0032 #include "zlib.h"
0033 #include <TMath.h>
0034 #include <fstream>
0035 #include <iostream>
0036 #include <sstream>
0037 
0038 //
0039 // class declaration
0040 //
0041 
0042 /** \class EcalEBTrigPrimPhase2ESProducer
0043 \author L. Lutton, N. Marinelli - Univ. of Notre Dame
0044  Description: forPhase II
0045 */
0046 
0047 class EcalEBTrigPrimPhase2ESProducer : public edm::ESProducer {
0048 public:
0049   EcalEBTrigPrimPhase2ESProducer(const edm::ParameterSet &);
0050   ~EcalEBTrigPrimPhase2ESProducer() override;
0051 
0052   std::unique_ptr<EcalEBPhase2TPGLinearizationConst> produceLinearizationConst(
0053       const EcalEBPhase2TPGLinearizationConstRcd &);
0054   std::unique_ptr<EcalEBPhase2TPGPedestalsMap> producePedestals(const EcalEBPhase2TPGPedestalsRcd &);
0055   std::unique_ptr<EcalEBPhase2TPGAmplWeightIdMap> produceAmpWeight(const EcalEBPhase2TPGAmplWeightIdMapRcd &);
0056   std::unique_ptr<EcalEBPhase2TPGTimeWeightIdMap> produceTimeWeight(const EcalEBPhase2TPGTimeWeightIdMapRcd &);
0057   std::unique_ptr<EcalTPGWeightGroup> produceWeightGroup(const EcalTPGWeightGroupRcd &);
0058   std::unique_ptr<EcalTPGPhysicsConst> producePhysicsConst(const EcalTPGPhysicsConstRcd &);
0059   std::unique_ptr<EcalTPGCrystalStatus> produceBadX(const EcalTPGCrystalStatusRcd &);
0060 
0061   // These commented lines are a reminder that in the future we might need to implement something alike
0062   //std::unique_ptr<EcalTPGLutGroup> produceLutGroup(const EcalTPGLutGroupRcd &);
0063   //std::uniq//std::unique_ptr<EcalTPGStripStatus> produceBadStrip(const EcalTPGStripStatusRcd &);
0064   //std::unique_ptr<EcalTPGTowerStatus> produceBadTT(const EcalTPGTowerStatusRcd &);
0065   //std::unique_ptr<EcalTPGSpike> produceSpike(const EcalTPGSpikeRcd &);
0066 
0067 private:
0068   void parseTextFile();
0069   std::vector<int> getRange(int subdet, int smNb, int towerNbInSm, int stripNbInTower = 0, int xtalNbInStrip = 0);
0070   void parseWeightsFile();
0071 
0072   // ----------member data ---------------------------
0073   std::string dbFilename_;
0074   //  std::string configFilename_;
0075   const edm::FileInPath configFilename_;
0076   bool flagPrint_;
0077   std::map<uint32_t, std::vector<uint32_t>> mapXtal_;
0078   std::map<uint32_t, std::vector<uint32_t>> mapStrip_[2];
0079   std::map<uint32_t, std::vector<uint32_t>> mapTower_[2];
0080   std::map<uint32_t, std::vector<uint32_t>> mapWeight_;
0081   std::map<uint32_t, std::vector<uint32_t>> mapTimeWeight_;
0082   std::map<int, std::vector<unsigned int>> mapXtalToGroup_;
0083   std::map<int, std::vector<unsigned int>> mapXtalToLin_;
0084   std::map<uint32_t, std::vector<float>> mapPhys_;
0085   static const int maxSamplesUsed_;
0086   static const int nLinConst_;
0087 };
0088 
0089 //
0090 // input stream from a gz file
0091 //
0092 
0093 struct GzInputStream {
0094   gzFile gzf;
0095   char buffer[256];
0096   std::istringstream iss;
0097   bool eof;
0098   GzInputStream(const char *file) : eof(false) {
0099     gzf = gzopen(file, "rb");
0100     edm::LogInfo("EcalEBTrigPrimPhase2ESProducer") << " New weight file " << file;
0101     if (gzf == Z_NULL) {
0102       eof = true;
0103       edm::LogWarning("EcalEBTrigPrimPhase2ESProducer") << "Database file " << file << " not found!!!";
0104     } else
0105       readLine();
0106   }
0107   void readLine() {
0108     char *res = gzgets(gzf, buffer, 256);
0109     eof = (res == Z_NULL);
0110     if (!eof) {
0111       iss.clear();
0112       iss.str(buffer);
0113     }
0114   }
0115   ~GzInputStream() { gzclose(gzf); }
0116   explicit operator bool() const { return ((eof == true) ? false : !iss.fail()); }
0117 };
0118 
0119 template <typename T>
0120 GzInputStream &operator>>(GzInputStream &gis, T &var) {
0121   while ((bool)gis && !(gis.iss >> var)) {
0122     gis.readLine();
0123   }
0124   return gis;
0125 }
0126 
0127 //
0128 // constructors and destructor
0129 //
0130 
0131 const int EcalEBTrigPrimPhase2ESProducer::maxSamplesUsed_ = 12;
0132 const int EcalEBTrigPrimPhase2ESProducer::nLinConst_ = 8;
0133 
0134 EcalEBTrigPrimPhase2ESProducer::EcalEBTrigPrimPhase2ESProducer(const edm::ParameterSet &iConfig)
0135     : dbFilename_(iConfig.getUntrackedParameter<std::string>("DatabaseFile", "")),
0136       configFilename_(iConfig.getParameter<edm::FileInPath>("WeightTextFile")),
0137       flagPrint_(iConfig.getParameter<bool>("WriteInFile")) {
0138   parseWeightsFile();
0139 
0140   // the following lines are needed to tell the framework what
0141   // data is being produced
0142   setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceLinearizationConst);
0143   setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::producePedestals);
0144   setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceAmpWeight);
0145   setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceTimeWeight);
0146   setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceWeightGroup);
0147   setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceBadX);
0148   // the following commented lines as a reminder for items which might need to be implemented for Phase2
0149   //setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::producePhysicsConst);
0150   //setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceBadStrip);
0151   //setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceBadTT);
0152   //setWhatProduced(this, &EcalEBTrigPrimPhase2ESProducer::produceSpike);
0153 }
0154 
0155 EcalEBTrigPrimPhase2ESProducer::~EcalEBTrigPrimPhase2ESProducer() {}
0156 
0157 //
0158 // member functions
0159 //
0160 
0161 // ------------ method called to produce the data  ------------
0162 
0163 std::unique_ptr<EcalEBPhase2TPGPedestalsMap> EcalEBTrigPrimPhase2ESProducer::producePedestals(
0164     const EcalEBPhase2TPGPedestalsRcd &iRecord) {
0165   auto prod = std::make_unique<EcalEBPhase2TPGPedestalsMap>();
0166 
0167   std::map<int, std::vector<unsigned int>>::const_iterator it;
0168   for (it = mapXtalToLin_.begin(); it != mapXtalToLin_.end(); it++) {
0169     EBDetId myEBDetId = EBDetId(it->first);
0170     EcalEBPhase2TPGPedestal ped;
0171 
0172     ped.mean_x10 = (it->second)[0];
0173     ped.mean_x1 = (it->second)[3];
0174     prod->insert(std::make_pair(myEBDetId, ped));
0175   }
0176 
0177   return prod;
0178 }
0179 
0180 std::unique_ptr<EcalEBPhase2TPGLinearizationConst> EcalEBTrigPrimPhase2ESProducer::produceLinearizationConst(
0181     const EcalEBPhase2TPGLinearizationConstRcd &iRecord) {
0182   auto prod = std::make_unique<EcalEBPhase2TPGLinearizationConst>();
0183 
0184   std::map<int, std::vector<unsigned int>>::const_iterator it;
0185   for (it = mapXtalToLin_.begin(); it != mapXtalToLin_.end(); it++) {
0186     EcalEBPhase2TPGLinearizationConstant param;
0187 
0188     param.mult_x10 = (it->second)[1];
0189     param.mult_x1 = (it->second)[5];
0190     param.shift_x10 = (it->second)[2];
0191     param.shift_x1 = (it->second)[6];
0192     param.i2cSub_x10 = (it->second)[3];
0193     param.i2cSub_x1 = (it->second)[7];
0194     prod->setValue(it->first, param);
0195   }
0196 
0197   return prod;
0198 }
0199 
0200 std::unique_ptr<EcalEBPhase2TPGAmplWeightIdMap> EcalEBTrigPrimPhase2ESProducer::produceAmpWeight(
0201     const EcalEBPhase2TPGAmplWeightIdMapRcd &iRecord) {
0202   auto prod = std::make_unique<EcalEBPhase2TPGAmplWeightIdMap>();
0203 
0204   EcalEBPhase2TPGAmplWeights weights;
0205   std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
0206   for (it = mapWeight_.begin(); it != mapWeight_.end(); it++) {
0207     weights.setValues((it->second)[0],
0208                       (it->second)[1],
0209                       (it->second)[2],
0210                       (it->second)[3],
0211                       (it->second)[4],
0212                       (it->second)[5],
0213                       (it->second)[6],
0214                       (it->second)[7],
0215                       (it->second)[8],
0216                       (it->second)[9],
0217                       (it->second)[10],
0218                       (it->second)[11]);
0219     prod->setValue(it->first, weights);
0220   }
0221 
0222   return prod;
0223 }
0224 
0225 std::unique_ptr<EcalEBPhase2TPGTimeWeightIdMap> EcalEBTrigPrimPhase2ESProducer::produceTimeWeight(
0226     const EcalEBPhase2TPGTimeWeightIdMapRcd &iRecord) {
0227   auto prod = std::make_unique<EcalEBPhase2TPGTimeWeightIdMap>();
0228 
0229   EcalEBPhase2TPGTimeWeights weights_time;
0230   std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
0231   for (it = mapTimeWeight_.begin(); it != mapTimeWeight_.end(); it++) {
0232     weights_time.setValues((it->second)[0],
0233                            (it->second)[1],
0234                            (it->second)[2],
0235                            (it->second)[3],
0236                            (it->second)[4],
0237                            (it->second)[5],
0238                            (it->second)[6],
0239                            (it->second)[7],
0240                            (it->second)[8],
0241                            (it->second)[9],
0242                            (it->second)[10],
0243                            (it->second)[11]);
0244     prod->setValue(it->first, weights_time);
0245   }
0246 
0247   return prod;
0248 }
0249 
0250 std::unique_ptr<EcalTPGWeightGroup> EcalEBTrigPrimPhase2ESProducer::produceWeightGroup(
0251     const EcalTPGWeightGroupRcd &iRecord) {
0252   auto prod = std::make_unique<EcalTPGWeightGroup>();
0253 
0254   const int NGROUPS = 61200;
0255 
0256   for (int iGroup = 0; iGroup < NGROUPS; iGroup++) {
0257     std::map<int, std::vector<unsigned int>>::const_iterator it;
0258     for (it = mapXtalToGroup_.begin(); it != mapXtalToGroup_.end(); it++) {
0259       prod->setValue(it->first, it->second[0]);
0260     }
0261   }
0262 
0263   return prod;
0264 }
0265 
0266 std::unique_ptr<EcalTPGPhysicsConst> EcalEBTrigPrimPhase2ESProducer::producePhysicsConst(
0267     const EcalTPGPhysicsConstRcd &iRecord) {
0268   auto prod = std::make_unique<EcalTPGPhysicsConst>();
0269   // EcalEBTrigPrimPhase2ESProducer::producePhysicsConst Needs updating if we want to keep it
0270 
0271   parseTextFile();
0272   std::map<uint32_t, std::vector<float>>::const_iterator it;
0273   for (it = mapPhys_.begin(); it != mapPhys_.end(); it++) {
0274     EcalTPGPhysicsConst::Item item;
0275     item.EtSat = (it->second)[0];
0276     item.ttf_threshold_Low = (it->second)[1];
0277     item.ttf_threshold_High = (it->second)[2];
0278     item.FG_lowThreshold = (it->second)[3];
0279     item.FG_highThreshold = (it->second)[4];
0280     item.FG_lowRatio = (it->second)[5];
0281     item.FG_highRatio = (it->second)[6];
0282     prod->setValue(it->first, item);
0283   }
0284 
0285   return prod;
0286 }
0287 
0288 std::unique_ptr<EcalTPGCrystalStatus> EcalEBTrigPrimPhase2ESProducer::produceBadX(
0289     const EcalTPGCrystalStatusRcd &iRecord) {
0290   auto prod = std::make_unique<EcalTPGCrystalStatus>();
0291 
0292   parseTextFile();
0293   std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
0294   for (it = mapXtal_.begin(); it != mapXtal_.end(); it++) {
0295     EcalTPGCrystalStatusCode badXValue;
0296     badXValue.setStatusCode(0);
0297     prod->setValue(it->first, badXValue);
0298   }
0299   return prod;
0300 }
0301 
0302 void EcalEBTrigPrimPhase2ESProducer::parseWeightsFile() {
0303   uint32_t id;
0304   std::string dataCard;
0305   std::vector<unsigned int> param;
0306 
0307   int data;
0308   std::string filename = configFilename_.fullPath();
0309   ;
0310   std::string finalFileName;
0311   size_t slash = filename.find('/');
0312   if (slash != 0) {
0313     edm::FileInPath fileInPath(filename);
0314     finalFileName = fileInPath.fullPath();
0315   } else {
0316     finalFileName = filename;
0317     edm::LogWarning("EcalEBTPGESProducer")
0318         << "Couldnt find database file via fileinpath trying with pathname directly!!";
0319   }
0320 
0321   GzInputStream gis(finalFileName.c_str());
0322   while (gis >> dataCard) {
0323     if (dataCard == "WEIGHTAMP") {
0324       gis >> std::dec >> id;
0325 
0326       if (flagPrint_) {
0327         std::cout << dataCard << " " << std::dec << id << std::endl;
0328       }
0329 
0330       param.clear();
0331 
0332       std::string st6;
0333       for (int i = 0; i < maxSamplesUsed_; i++) {
0334         gis >> std::hex >> data;
0335         param.push_back(data);
0336         /// debug
0337 
0338         if (flagPrint_) {
0339           std::ostringstream oss;
0340           oss << std::hex << data;
0341           std::string result4 = oss.str();
0342 
0343           st6.append("0x");
0344           st6.append(result4);
0345           st6.append(" ");
0346         }
0347       }
0348 
0349       // debug
0350       if (flagPrint_) {
0351         std::cout << st6 << std::endl;
0352         std::cout << std::endl;
0353       }
0354 
0355       // std::cout << " WEIGHTAMP id " << id << std::endl;
0356       mapWeight_[id] = param;
0357     }
0358 
0359     if (dataCard == "WEIGHTTIME") {
0360       gis >> std::dec >> id;
0361 
0362       if (flagPrint_) {
0363         std::cout << dataCard << " " << std::dec << id << std::endl;
0364       }
0365 
0366       param.clear();
0367 
0368       std::string st6;
0369       for (int i = 0; i < maxSamplesUsed_; i++) {
0370         gis >> std::hex >> data;
0371         //std::cout << " Parse time weight filling data " << data;
0372         param.push_back(data);
0373         /// debug
0374 
0375         if (flagPrint_) {
0376           std::ostringstream oss;
0377           oss << std::hex << data;
0378           std::string result4 = oss.str();
0379 
0380           st6.append("0x");
0381           st6.append(result4);
0382           st6.append(" ");
0383         }
0384       }
0385 
0386       // debug
0387       if (flagPrint_) {
0388         std::cout << st6 << std::endl;
0389         std::cout << std::endl;
0390       }
0391       mapTimeWeight_[id] = param;
0392     }
0393 
0394     if (dataCard == "CRYSTAL") {
0395       gis >> std::dec >> id;
0396 
0397       if (flagPrint_) {
0398         std::cout << dataCard << " " << std::dec << id << std::endl;
0399       }
0400 
0401       param.clear();
0402       std::string st6;
0403       gis >> std::dec >> data;
0404       param.push_back(data);
0405 
0406       if (flagPrint_) {
0407         std::ostringstream oss;
0408         oss << std::dec << data;
0409         std::string result4 = oss.str();
0410         st6.append(result4);
0411         st6.append(" ");
0412         std::cout << st6 << std::endl;
0413         std::cout << std::endl;
0414       }
0415       mapXtalToGroup_[id] = param;
0416     }
0417 
0418     if (dataCard == "LINCONST") {
0419       gis >> std::dec >> id;
0420 
0421       if (flagPrint_) {
0422         std::cout << dataCard << " " << std::dec << id << std::endl;
0423       }
0424 
0425       param.clear();
0426       std::string st6;
0427       std::string st7;
0428 
0429       for (int i = 0; i < nLinConst_; i++) {
0430         gis >> std::hex >> data;
0431         param.push_back(data);
0432 
0433         if (flagPrint_) {
0434           if (i < 4) {
0435             std::ostringstream oss;
0436             oss << std::hex << data;
0437             std::string result6 = oss.str();
0438             st6.append("0x");
0439             st6.append(result6);
0440             if (i != 3)
0441               st6.append(" ");
0442           } else if (i < 8) {
0443             std::ostringstream oss;
0444             oss << std::hex << data;
0445             std::string result7 = oss.str();
0446             st7.append("0x");
0447             st7.append(result7);
0448             if (i != 7)
0449               st7.append(" ");
0450           }
0451         }
0452       }
0453       if (flagPrint_) {
0454         std::cout << st6 << std::endl;
0455         std::cout << st7 << std::endl;
0456       }
0457       mapXtalToLin_[id] = param;
0458     }
0459   }
0460 }
0461 
0462 void EcalEBTrigPrimPhase2ESProducer::parseTextFile() {
0463   if (!mapXtal_.empty())
0464     return;  // just parse the file once!
0465 
0466   uint32_t id;
0467   std::string dataCard;
0468   std::string line;
0469   std::ifstream infile;
0470   std::vector<unsigned int> param;
0471   std::vector<float> paramF;
0472   int NBstripparams[2] = {4, 4};
0473   unsigned int data;
0474 
0475   std::string bufString;
0476   std::string iString;
0477   std::string fString;
0478   std::string filename = "SimCalorimetry/EcalTrigPrimProducers/data/" + dbFilename_;
0479   std::string finalFileName;
0480   size_t slash = dbFilename_.find('/');
0481   if (slash != 0) {
0482     edm::FileInPath fileInPath(filename);
0483     finalFileName = fileInPath.fullPath();
0484   } else {
0485     finalFileName = dbFilename_;
0486     edm::LogWarning("EcalTPG") << "Couldnt find database file via fileinpath, "
0487                                   "trying with pathname directly!!";
0488   }
0489 
0490   int k = 0;
0491 
0492   GzInputStream gis(finalFileName.c_str());
0493   while (gis >> dataCard) {
0494     if (dataCard == "CRYSTAL") {
0495       gis >> std::dec >> id;
0496 
0497       std::string st3;
0498       std::string st4;
0499       std::string st5;
0500 
0501       if (flagPrint_) {
0502         // Print this comment only one time
0503         if (k == 0)
0504           std::cout << "COMMENT ====== barrel crystals ====== " << std::endl;
0505 
0506         if (k == 61200)
0507           std::cout << "COMMENT ====== endcap crystals ====== " << std::endl;
0508 
0509         k = k + 1;
0510 
0511         std::cout << dataCard << " " << std::dec << id << std::endl;
0512       }
0513 
0514       param.clear();
0515       for (int i = 0; i < 9; i++) {
0516         gis >> std::hex >> data;
0517         param.push_back(data);
0518 
0519         if (flagPrint_) {
0520           if (i < 3) {
0521             std::ostringstream oss;
0522             oss << std::hex << data;
0523             std::string result1 = oss.str();
0524 
0525             st3.append("0x");
0526             st3.append(result1);
0527             if (i != 2)
0528               st3.append(" ");
0529 
0530           } else if (i > 2 && i < 6) {
0531             std::ostringstream oss;
0532             oss << std::hex << data;
0533             std::string result2 = oss.str();
0534 
0535             st4.append("0x");
0536             st4.append(result2);
0537             if (i != 5)
0538               st4.append(" ");
0539           } else if (i > 5 && i < 9) {
0540             std::ostringstream oss;
0541             oss << std::hex << data;
0542             std::string result3 = oss.str();
0543 
0544             st5.append("0x");
0545             st5.append(result3);
0546             if (i != 8)
0547               st5.append(" ");
0548           }
0549         }
0550 
0551       }  // end for
0552 
0553       if (flagPrint_) {
0554         std::cout << " " << st3 << std::endl;
0555         std::cout << " " << st4 << std::endl;
0556         std::cout << " " << st5 << std::endl;
0557       }
0558 
0559       mapXtal_[id] = param;
0560     }
0561 
0562     if (dataCard == "STRIP_EB") {
0563       gis >> std::dec >> id;
0564 
0565       std::string st1;
0566 
0567       if (flagPrint_)
0568         std::cout << dataCard << " " << std::dec << id << std::endl;
0569 
0570       param.clear();
0571       for (int i = 0; i < NBstripparams[0]; i++) {
0572         gis >> std::hex >> data;
0573         param.push_back(data);
0574 
0575         if (flagPrint_) {
0576           if (i == 0) {
0577             std::cout << "0x" << std::hex << data << std::endl;
0578           } else if (i == 1) {
0579             std::cout << "" << std::hex << data << std::endl;
0580           } else if (i > 1) {
0581             std::ostringstream oss;
0582             if (i == 2) {
0583               oss << "0x" << std::hex << data;
0584               std::string result4 = oss.str();
0585               st1.append(result4);
0586             } else if (i == 3) {
0587               std::ostringstream oss;
0588               oss << " 0x" << std::hex << data;
0589               std::string result5 = oss.str();
0590 
0591               st1.append(result5);
0592               std::cout << "" << st1 << std::endl;
0593             }
0594           }
0595         }
0596       }
0597 
0598       mapStrip_[0][id] = param;
0599     }
0600 
0601     if (dataCard == "STRIP_EE") {
0602       gis >> std::dec >> id;
0603 
0604       std::string st6;
0605 
0606       if (flagPrint_) {
0607         std::cout << dataCard << " " << std::dec << id << std::endl;
0608       }
0609 
0610       param.clear();
0611       for (int i = 0; i < NBstripparams[1]; i++) {
0612         gis >> std::hex >> data;
0613         param.push_back(data);
0614 
0615         if (flagPrint_) {
0616           if (i == 0) {
0617             std::cout << "0x" << std::hex << data << std::endl;
0618           } else if (i == 1) {
0619             std::cout << " " << std::hex << data << std::endl;
0620           } else if (i > 1) {
0621             std::ostringstream oss;
0622             if (i == 2) {
0623               oss << "0x" << std::hex << data;
0624               std::string result4 = oss.str();
0625               st6.append(result4);
0626             } else if (i == 3) {
0627               std::ostringstream oss;
0628               oss << " 0x" << std::hex << data;
0629               std::string result5 = oss.str();
0630 
0631               st6.append(result5);
0632               std::cout << "" << st6 << std::endl;
0633             }
0634           }
0635         }
0636       }
0637 
0638       mapStrip_[1][id] = param;
0639     }
0640 
0641     if (dataCard == "TOWER_EE") {
0642       gis >> std::dec >> id;
0643 
0644       if (flagPrint_)
0645         std::cout << dataCard << " " << std::dec << id << std::endl;
0646 
0647       param.clear();
0648       for (int i = 0; i < 2; i++) {
0649         gis >> std::hex >> data;
0650         param.push_back(data);
0651 
0652         if (flagPrint_) {
0653           if (i == 1) {
0654             std::cout << "0x" << std::dec << data << std::endl;
0655           } else {
0656             std::cout << " " << std::dec << data << std::endl;
0657           }
0658         }
0659       }
0660 
0661       mapTower_[1][id] = param;
0662     }
0663 
0664     if (dataCard == "TOWER_EB") {
0665       gis >> std::dec >> id;
0666 
0667       if (flagPrint_)
0668         std::cout << dataCard << " " << std::dec << id << std::endl;
0669 
0670       param.clear();
0671       for (int i = 0; i < 3; i++) {
0672         gis >> std::dec >> data;
0673 
0674         if (flagPrint_) {
0675           std::cout << " " << std::dec << data << std::endl;
0676         }
0677 
0678         param.push_back(data);
0679       }
0680 
0681       mapTower_[0][id] = param;
0682     }
0683   }
0684 }
0685 
0686 /// This method is not used at all, however is a reminder that something alike will probably be needed once the mapping EB to BCPs will be in place
0687 std::vector<int> EcalEBTrigPrimPhase2ESProducer::getRange(
0688     int subdet, int tccNb, int towerNbInTcc, int stripNbInTower, int xtalNbInStrip) {
0689   std::vector<int> range;
0690   if (subdet == 0) {
0691     // Barrel
0692     range.push_back(37);  // stccNbMin
0693     range.push_back(73);  // tccNbMax
0694     range.push_back(1);   // towerNbMin
0695     range.push_back(69);  // towerNbMax
0696     range.push_back(1);   // stripNbMin
0697     range.push_back(6);   // stripNbMax
0698     range.push_back(1);   // xtalNbMin
0699     range.push_back(6);   // xtalNbMax
0700   }
0701 
0702   if (tccNb > 0) {
0703     range[0] = tccNb;
0704     range[1] = tccNb + 1;
0705   }
0706   if (towerNbInTcc > 0) {
0707     range[2] = towerNbInTcc;
0708     range[3] = towerNbInTcc + 1;
0709   }
0710   if (stripNbInTower > 0) {
0711     range[4] = stripNbInTower;
0712     range[5] = stripNbInTower + 1;
0713   }
0714   if (xtalNbInStrip > 0) {
0715     range[6] = xtalNbInStrip;
0716     range[7] = xtalNbInStrip + 1;
0717   }
0718 
0719   return range;
0720 }
0721 
0722 DEFINE_FWK_EVENTSETUP_MODULE(EcalEBTrigPrimPhase2ESProducer);