CMS 3D CMS Logo

CSCFileDumper Class Reference

#include <IORawData/CSCCommissioning/src/CSCFileDumper.h>

Inheritance diagram for CSCFileDumper:

edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 CSCFileDumper (const edm::ParameterSet &pset)
virtual ~CSCFileDumper (void)

Public Attributes

std::map< int, FILE * > dump_files
int fedID_first
int fedID_last
std::string output


Detailed Description

Definition at line 13 of file CSCFileDumper.h.


Constructor & Destructor Documentation

CSCFileDumper::CSCFileDumper ( const edm::ParameterSet pset  ) 

Definition at line 22 of file CSCFileDumper.cc.

References fedID_first, fedID_last, FEDNumbering::getCSCFEDIds(), FEDNumbering::getCSCTFFEDIds(), edm::ParameterSet::getUntrackedParameter(), and output.

00022                                                         {
00023         output = pset.getUntrackedParameter<std::string>("output");
00024         fedID_first = FEDNumbering::getCSCFEDIds().first;
00025         fedID_last  = FEDNumbering::getCSCTFFEDIds().second;
00026         //std::string cur_pos = type.rfind(","), prev_pos = std::string::npos;
00027 }

CSCFileDumper::~CSCFileDumper ( void   )  [virtual]

Definition at line 29 of file CSCFileDumper.cc.

References dump_files.

00029                                  {
00030         std::map<int,FILE*>::const_iterator stream = dump_files.begin();
00031         while( stream != dump_files.end() ){
00032                 fclose(stream->second);
00033                 stream++;
00034         }
00035 }


Member Function Documentation

void CSCFileDumper::analyze ( const edm::Event e,
const edm::EventSetup c 
) [virtual]

Take a reference to this FED's data

Implements edm::EDAnalyzer.

Definition at line 37 of file CSCFileDumper.cc.

References GenMuonPlsPt100GeV_cfg::cout, FEDRawData::data(), dump_files, lat::endl(), lat::ends(), fedID_first, fedID_last, file, edm::Event::getByType(), id, name, NULL, output, FEDRawData::size(), and size.

00037                                                                      {
00038         // Get a handle to the FED data collection
00039         edm::Handle<FEDRawDataCollection> rawdata;
00040 
00041         // Get a handle to the FED data collection
00042         e.getByType(rawdata);
00043 
00044         for(int id=fedID_first; id<=fedID_last; ++id){ //for each of our DCCs
00045                 std::map<int,FILE*>::const_iterator stream = dump_files.find(id);
00046                 if( stream == dump_files.end() ){
00047                         std::ostringstream name;
00048                         name<<output<<"_"<<id<<std::ends;
00049                         FILE *file;
00050                         if( (file = fopen(name.str().c_str(),"wt"))==NULL ){
00051                                 std::cout<<"Cannot open the file: "<<name.str()<<std::endl;
00052                                 continue;
00053                         } else
00054                                 dump_files[id] = file;
00055                         stream = dump_files.find(id);
00056                 }
00057 
00059                 const FEDRawData& fedData = rawdata->FEDData(id);
00060                 unsigned short int length = fedData.size();
00061 
00062                 if(length){
00063                         //std::cout<<"Event found for fed id:"<<id<<std::endl;
00064                         // Event buffer
00065                         size_t size=length/2;
00066                         const unsigned short *buf = (unsigned short *)fedData.data();
00067                         fwrite(buf,2,size,stream->second);
00068                 }
00069         }
00070 }


Member Data Documentation

std::map<int,FILE*> CSCFileDumper::dump_files

Definition at line 15 of file CSCFileDumper.h.

Referenced by analyze(), and ~CSCFileDumper().

int CSCFileDumper::fedID_first

Definition at line 18 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

int CSCFileDumper::fedID_last

Definition at line 18 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

std::string CSCFileDumper::output

Definition at line 17 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:18 2009 for CMSSW by  doxygen 1.5.4