CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/EventFilter/RawDataCollector/src/RawDataCollectorModule.cc

Go to the documentation of this file.
00001 
00006 #include "EventFilter/RawDataCollector/interface/RawDataCollectorModule.h"
00007 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h> 
00008 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
00009 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
00010 
00011 #include <DataFormats/Common/interface/Handle.h>
00012 #include <FWCore/Framework/interface/Event.h>
00013 #include "DataFormats/Provenance/interface/ProcessHistory.h" 
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 
00019 #include <iostream>
00020 
00021 using namespace edm;
00022 
00023 RawDataCollectorModule::RawDataCollectorModule(const edm::ParameterSet& pset) {
00024 
00025   useCurrentProcessOnly_ = pset.getParameter<bool>("currentProcessOnly") ; 
00026     
00027   produces<FEDRawDataCollection>();
00028 }
00029 
00030 RawDataCollectorModule::~RawDataCollectorModule(){
00031 
00032 }
00033 
00034 
00035 void RawDataCollectorModule::produce(Event & e, const EventSetup& c){
00036 
00038  std::vector< Handle<FEDRawDataCollection> > rawData;
00039  e.getManyByType(rawData);
00040 
00041  std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);
00042 
00043  for (unsigned int i=0; i< rawData.size(); ++i ) { 
00044 
00045    const FEDRawDataCollection *rdc=rawData[i].product();
00046 
00047    if ( useCurrentProcessOnly_ &&
00048         ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) )
00049        continue ; // skip all raw collections not produced by the current process
00050 
00051    for ( int j=0; j< FEDNumbering::MAXFEDID; ++j ) {
00052      const FEDRawData & fedData = rdc->FEDData(j);
00053      size_t size=fedData.size();
00054 
00055      if ( size > 0 ) {
00056        // this fed has data -- lets copy it
00057        FEDRawData & fedDataProd = producedData->FEDData(j);
00058        if ( fedDataProd.size() != 0 ) {
00059          std::cout << " More than one FEDRawDataCollection with data in FED ";
00060          std::cout << j << " Skipping the 2nd\n";
00061          continue;
00062        } 
00063        fedDataProd.resize(size);
00064        unsigned char *dataProd=fedDataProd.data();
00065        const unsigned char *data=fedData.data();
00066        for ( unsigned int k=0; k<size; ++k ) {
00067          dataProd[k]=data[k];
00068        }
00069      }
00070    }
00071  }
00072 
00073  // Insert the new product in the event  
00074  e.put(producedData);  
00075 
00076 }
00077 
00078 
00079 
00080 
00081