CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CaloOnlineTools/EcalTools/plugins/EcalHexDisplay.cc

Go to the documentation of this file.
00001 
00007 #include "CaloOnlineTools/EcalTools/plugins/EcalHexDisplay.h"
00008 
00009 EcalHexDisplay::EcalHexDisplay(const edm::ParameterSet& ps) :
00010     verbosity_ (ps.getUntrackedParameter<int>("verbosity",1)),
00011     beg_fed_id_ (ps.getUntrackedParameter<int>("beg_fed_id",0)),
00012     end_fed_id_ (ps.getUntrackedParameter<int>("end_fed_id",654)),
00013     first_event_ (ps.getUntrackedParameter<int>("first_event",1)),
00014     last_event_  (ps.getUntrackedParameter<int>("last_event",9999999)),
00015     event_ (0),
00016     writeDcc_ (ps.getUntrackedParameter<bool>("writeDCC",false)),
00017     filename_ (ps.getUntrackedParameter<std::string>("filename","dump.bin"))
00018 {  
00019 }
00020 
00021 void EcalHexDisplay::analyze( const edm::Event & e, const  edm::EventSetup& c){
00022   
00023   event_++;
00024   if (event_ < first_event_ || last_event_ < event_) return;
00025   
00026 
00027   edm::Handle<FEDRawDataCollection> rawdata;
00028   e.getByType(rawdata);  
00029 
00030   std::ofstream dumpFile (filename_.c_str(),std::ios::app );
00031   
00032   for (int id= 0; id<=FEDNumbering::MAXFEDID; ++id){ 
00033     
00034     if (id < beg_fed_id_ || end_fed_id_ < id) continue;
00035 
00036     const FEDRawData& data = rawdata->FEDData(id);
00037     
00038     if (data.size()>4){      
00039       
00040       std::cout << "\n\n\n[EcalHexDumperModule] Event: " 
00041                 << std::dec << event_ 
00042                 << " fed_id: " << id 
00043                 << " size_fed: " << data.size() << "\n"<< std::endl;
00044       
00045       if ( ( data.size() %16 ) !=0)
00046         {
00047           std::cout << "***********************************************" << std::endl;
00048           std::cout<< "Fed size in bits not multiple of 64, strange." << std::endl;
00049           std::cout << "***********************************************" << std::endl;
00050         }
00051       
00052       
00053       int length = data.size();
00054       const unsigned long               * pData     = ( reinterpret_cast<unsigned long*>(const_cast<unsigned char*> ( data.data())));
00055       std::cout << std::setfill('0');
00056       for (int words=0; words < length/4; (words+=2)  )
00057         {
00058           std::cout << std::setw(8)   << std::hex << pData[words+1] << " ";
00059           std::cout << std::setw(8)   << std::hex << pData[words] << std::endl;
00060         }
00061 
00062       std::cout << "\n";
00063 
00064 
00065       if (beg_fed_id_ <= id && id <= end_fed_id_ && writeDcc_)
00066         {
00067           dumpFile.write( reinterpret_cast <const char *> (pData), length);
00068         }
00069     }
00070     
00071   }
00072   dumpFile.close();    
00073   if (! writeDcc_) remove(filename_.c_str()); 
00074 }
00075