Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-05 02:38:56

0001 
0002 /*----------------------------------------------------------------------
0003 
0004 Toy EDAnalyzer for testing purposes only.
0005 
0006 ----------------------------------------------------------------------*/
0007 
0008 #include <stdexcept>
0009 #include <iostream>
0010 #include <fstream>
0011 #include <map>
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "CoralBase/TimeStamp.h"
0015 #include "CondTools/DT/test/stubs/DTHVDump.h"
0016 #include "CondFormats/DTObjects/interface/DTHVStatus.h"
0017 #include "CondFormats/DataRecord/interface/DTHVStatusRcd.h"
0018 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0019 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0020 
0021 namespace edmtest {
0022 
0023   DTHVDump::DTHVDump(edm::ParameterSet const& p) : dthvstatusToken_(esConsumes()) {
0024     // parameters to setup
0025   }
0026 
0027   DTHVDump::DTHVDump(int i) : dthvstatusToken_(esConsumes()) {}
0028 
0029   void DTHVDump::analyze(const edm::Event& e, const edm::EventSetup& context) {
0030     using namespace edm::eventsetup;
0031     // Context is not used.
0032     std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0033     std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl;
0034 
0035     // get configuration for current run
0036     auto hv = context.getHandle(dthvstatusToken_);
0037     std::cout << hv->version() << std::endl;
0038     std::cout << std::distance(hv->begin(), hv->end()) << " data in the container" << std::endl;
0039     edm::ValidityInterval iov(context.get<DTHVStatusRcd>().validityInterval());
0040     /*
0041     unsigned int currValidityStart = iov.first().eventID().run();
0042     unsigned int currValidityEnd   = iov.last( ).eventID().run();
0043     std::cout << "valid since run " << currValidityStart
0044               << " to run "         << currValidityEnd << std::endl;
0045 */
0046     std::cout << "end of time: " << edm::Timestamp::endOfTime().value() << std::endl;
0047     long long int currValidityStart = iov.first().time().value();
0048     long long int currValidityEnd = iov.last().time().value();
0049     std::cout << "valid since " << currValidityStart << " to " << currValidityEnd << std::endl;
0050     long long int iTimeStart =
0051         ((((currValidityStart >> 32) & 0xFFFFFFFF) * 1000000000) + ((currValidityStart & 0xFFFFFFFF) * 1000));
0052     long long int iTimeEnd =
0053         ((((currValidityEnd >> 32) & 0xFFFFFFFF) * 1000000000) + ((currValidityEnd & 0xFFFFFFFF) * 1000));
0054     coral::TimeStamp cTimeStart(iTimeStart);
0055     coral::TimeStamp cTimeEnd(iTimeEnd);
0056     std::cout << " ( " << cTimeStart.year() << " , " << cTimeStart.month() << " , " << cTimeStart.day() << " h "
0057               << cTimeStart.hour() << ":" << cTimeStart.minute() << ":" << cTimeStart.second() << " to "
0058               << cTimeEnd.year() << " , " << cTimeEnd.month() << " , " << cTimeEnd.day() << " h " << cTimeEnd.hour()
0059               << ":" << cTimeEnd.minute() << ":" << cTimeEnd.second() << " ) " << std::endl;
0060 
0061     /*
0062     DTHVStatus::const_iterator iter = hv->begin();
0063     DTHVStatus::const_iterator iend = hv->end();
0064     while ( iter != iend ) {
0065       const DTHVStatusId&   hvId   = iter->first;
0066       const DTHVStatusData& hvData = iter->second;
0067       std::cout << hvId.wheelId   << " "
0068                 << hvId.stationId << " "
0069                 << hvId.sectorId  << " "
0070                 << hvId.slId      << " "
0071                 << hvId.layerId   << " "
0072                 << hvId.partId    << " -> "
0073                 << hvData.fCell  << " "
0074                 << hvData.lCell  << " "
0075                 << hvData.flagA  << " "
0076                 << hvData.flagC  << " "
0077                 << hvData.flagS  << std::endl;
0078       iter++;
0079     }
0080 */
0081     std::cout << "============" << std::endl;
0082     int whe;
0083     int sta;
0084     int sec;
0085     int qua;
0086     int lay;
0087     int cel;
0088     int flagA;
0089     int flagC;
0090     int flagS;
0091     std::ifstream fcel("cellList.txt");
0092     while (fcel >> whe >> sta >> sec >> qua >> lay >> cel) {
0093       DTWireId id(whe, sta, sec, qua, lay, cel);
0094       hv->get(id, flagA, flagC, flagS);
0095       std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << " -> " << flagA << " "
0096                 << flagC << " " << flagS << std::endl;
0097     }
0098 
0099     std::cout << "============" << std::endl;
0100     std::ifstream fcha("chamList.txt");
0101     while (fcha >> whe >> sta >> sec) {
0102       DTChamberId id(whe, sta, sec);
0103       std::cout << "chamber " << whe << " " << sta << " " << sec << " has " << hv->badChannelsNumber(id)
0104                 << " bad cells and " << hv->offChannelsNumber(id) << " off cells" << std::endl;
0105     }
0106     std::cout << "============" << std::endl;
0107     std::cout << "total " << hv->badChannelsNumber() << " bad cells and " << hv->offChannelsNumber() << " off cells"
0108               << std::endl;
0109   }
0110   DEFINE_FWK_MODULE(DTHVDump);
0111 }  // namespace edmtest