CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/EventFilter/RawDataCollector/src/RawDataFEDSelector.cc

Go to the documentation of this file.
00001 //
00002 // Original Author:  Marco ZANETTI
00003 //         Created:  Mon Jan 28 18:22:13 CET 2008
00004 
00005 
00006 #include <EventFilter/RawDataCollector/interface/RawDataFEDSelector.h>
00007 
00008 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h> 
00009 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
00010 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
00011 
00012 #include <stdio.h>
00013 
00014 using namespace std;
00015 using namespace edm;
00016 
00017 auto_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection> & rawData) {
00018 
00019   auto_ptr<FEDRawDataCollection> selectedRawData(new FEDRawDataCollection);
00020 
00021   // if vector of FED indexes is defined, loop over it
00022   if (fedList.size()) {
00023     vector<int>::const_iterator it = fedList.begin();
00024     vector<int>::const_iterator itEnd = fedList.end();
00025     for (;it != itEnd; ++it) {  
00026     
00027       const FEDRawData & fedData = rawData->FEDData(*it);
00028       size_t size=fedData.size();
00029     
00030       FEDRawData & fedDataProd = selectedRawData->FEDData(*it);
00031       fedDataProd.resize(size);
00032     
00033       memcpy(fedDataProd.data(),fedData.data(),size);
00034     }
00035   }
00036 
00037   // if vector of FED indexes is NOT defined, loop over it FED range
00038   else {
00039     
00040     // FED range is <0,0> (i.e. neither the list nor the rage are defined) copy the entire payload 
00041     if (fedRange.second==0) setRange(pair<int,int>(0,FEDNumbering::lastFEDId()));
00042 
00043     for (int i = fedRange.first; i <= fedRange.second; ++i) {
00044 
00045       const FEDRawData & fedData = rawData->FEDData(i);
00046       size_t size=fedData.size();
00047     
00048       FEDRawData & fedDataProd = selectedRawData->FEDData(i);
00049       fedDataProd.resize(size);
00050     
00051       memcpy(fedDataProd.data(),fedData.data(),size);
00052     }
00053   }
00054   
00055   return selectedRawData; 
00056 } 
00057 
00058 
00059 auto_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection> & rawData, 
00060                                                        const pair<int,int> & range) {
00061   setRange(range);
00062   return select(rawData);
00063 }
00064 
00065 auto_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection> & rawData, 
00066                                                        const vector<int> & list) {
00067   setRange(list);
00068   return select(rawData);
00069 }
00070 
00071 
00072 
00073