CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/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     fedRawDataCollectionTag_(ps.getParameter<edm::InputTag>("fedRawDataCollectionTag"))
00019 {  
00020 }
00021 
00022 void EcalHexDisplay::analyze( const edm::Event & e, const  edm::EventSetup& c){
00023   
00024   event_++;
00025   if (event_ < first_event_ || last_event_ < event_) return;
00026   
00027 
00028   edm::Handle<FEDRawDataCollection> rawdata;
00029   e.getByLabel(fedRawDataCollectionTag_, rawdata);  
00030 
00031   std::ofstream dumpFile (filename_.c_str(),std::ios::app );
00032   
00033   for (int id= 0; id<=FEDNumbering::MAXFEDID; ++id){ 
00034     
00035     if (id < beg_fed_id_ || end_fed_id_ < id) continue;
00036 
00037     const FEDRawData& data = rawdata->FEDData(id);
00038     
00039     if (data.size()>4){      
00040       
00041       std::cout << "\n\n\n[EcalHexDumperModule] Event: " 
00042                 << std::dec << event_ 
00043                 << " fed_id: " << id 
00044                 << " size_fed: " << data.size() << "\n"<< std::endl;
00045       
00046       if ( ( data.size() %16 ) !=0)
00047         {
00048           std::cout << "***********************************************" << std::endl;
00049           std::cout<< "Fed size in bits not multiple of 64, strange." << std::endl;
00050           std::cout << "***********************************************" << std::endl;
00051         }
00052       
00053       
00054       int length = data.size();
00055       const unsigned long               * pData     = ( reinterpret_cast<unsigned long*>(const_cast<unsigned char*> ( data.data())));
00056       std::cout << std::setfill('0');
00057       for (int words=0; words < length/4; (words+=2)  )
00058         {
00059           std::cout << std::setw(8)   << std::hex << pData[words+1] << " ";
00060           std::cout << std::setw(8)   << std::hex << pData[words] << std::endl;
00061         }
00062 
00063       std::cout << "\n";
00064 
00065 
00066       if (beg_fed_id_ <= id && id <= end_fed_id_ && writeDcc_)
00067         {
00068           dumpFile.write( reinterpret_cast <const char *> (pData), length);
00069         }
00070     }
00071     
00072   }
00073   dumpFile.close();    
00074   if (! writeDcc_) remove(filename_.c_str()); 
00075 }
00076