Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:00:04

0001 /**
0002  *   
0003  * \author G. Franzoni
0004  *
0005  */
0006 
0007 #include "CaloOnlineTools/EcalTools/plugins/EcalHexDisplay.h"
0008 
0009 EcalHexDisplay::EcalHexDisplay(const edm::ParameterSet& ps)
0010     : verbosity_(ps.getUntrackedParameter<int>("verbosity", 1)),
0011       beg_fed_id_(ps.getUntrackedParameter<int>("beg_fed_id", 0)),
0012       end_fed_id_(ps.getUntrackedParameter<int>("end_fed_id", 654)),
0013       first_event_(ps.getUntrackedParameter<int>("first_event", 1)),
0014       last_event_(ps.getUntrackedParameter<int>("last_event", 9999999)),
0015       event_(0),
0016       writeDcc_(ps.getUntrackedParameter<bool>("writeDCC", false)),
0017       filename_(ps.getUntrackedParameter<std::string>("filename", "dump.bin")),
0018       fedRawDataCollectionToken_(
0019           consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("fedRawDataCollectionTag"))) {}
0020 
0021 void EcalHexDisplay::analyze(const edm::Event& e, const edm::EventSetup& c) {
0022   event_++;
0023   if (event_ < first_event_ || last_event_ < event_)
0024     return;
0025 
0026   const edm::Handle<FEDRawDataCollection>& rawdata = e.getHandle(fedRawDataCollectionToken_);
0027 
0028   std::ofstream dumpFile(filename_.c_str(), std::ios::app);
0029 
0030   for (int id = 0; id <= FEDNumbering::MAXFEDID; ++id) {
0031     if (id < beg_fed_id_ || end_fed_id_ < id)
0032       continue;
0033 
0034     const FEDRawData& data = rawdata->FEDData(id);
0035 
0036     if (data.size() > 4) {
0037       edm::LogVerbatim("EcalTools") << "\n\n\n[EcalHexDumperModule] Event: " << std::dec << event_ << " fed_id: " << id
0038                                     << " size_fed: " << data.size() << "\n";
0039 
0040       if ((data.size() % 16) != 0) {
0041         edm::LogVerbatim("EcalTools") << "***********************************************";
0042         edm::LogVerbatim("EcalTools") << "Fed size in bits not multiple of 64, strange.";
0043         edm::LogVerbatim("EcalTools") << "***********************************************";
0044       }
0045 
0046       int length = data.size();
0047       const unsigned long* pData = (reinterpret_cast<unsigned long*>(const_cast<unsigned char*>(data.data())));
0048       edm::LogVerbatim("EcalTools") << std::setfill('0');
0049       for (int words = 0; words < length / 4; (words += 2)) {
0050         edm::LogVerbatim("EcalTools") << std::setw(8) << std::hex << pData[words + 1] << " " << std::setw(8) << std::hex
0051                                       << pData[words];
0052       }
0053 
0054       edm::LogVerbatim("EcalTools") << "\n";
0055 
0056       if (beg_fed_id_ <= id && id <= end_fed_id_ && writeDcc_) {
0057         dumpFile.write(reinterpret_cast<const char*>(pData), length);
0058       }
0059     }
0060   }
0061   dumpFile.close();
0062   if (!writeDcc_)
0063     remove(filename_.c_str());
0064 }