CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RawDataCollectorByLabel.cc
Go to the documentation of this file.
1 
10 
16 
18 
19 #include <iostream>
20 
21 using namespace edm;
22 
24 
25  inputTags_ = pset.getParameter<std::vector<InputTag> >("RawCollectionList");
26  verbose_ = pset.getUntrackedParameter<int>("verbose",0);
27 
28  inputTokens_.reserve(inputTags_.size());
29  for(tag_iterator_t inputTag = inputTags_.begin(); inputTag != inputTags_.end(); ++inputTag ) {
30  inputTokens_.push_back(consumes<FEDRawDataCollection>(*inputTag));
31  }
32  produces<FEDRawDataCollection>();
33 }
34 
36 
37 }
38 
39 
41 
43  std::vector< Handle<FEDRawDataCollection> > rawData;
44  rawData.reserve(inputTokens_.size());
45  for(tok_iterator_t inputTok = inputTokens_.begin(); inputTok != inputTokens_.end(); ++inputTok ) {
47  if (e.getByToken(*inputTok,input)){
48  rawData.push_back(input);
49  }
50  //else{ //skipping the inputtag requested. but this is a normal operation to bare data & MC. silent warning }
51  }
52 
53  std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);
54 
55  for (unsigned int i=0; i< rawData.size(); ++i ) {
56 
57  const FEDRawDataCollection *rdc=rawData[i].product();
58 
59  if ( verbose_ > 0 ) {
60  std::cout << "\nRAW collection #" << i+1 << std::endl;
61  std::cout << "branch name = " << rawData[i].provenance()->branchName() << std::endl;
62  std::cout << "process index = " << rawData[i].provenance()->productID().processIndex() << std::endl;
63  }
64 
65  for ( int j=0; j< FEDNumbering::MAXFEDID; ++j ) {
66  const FEDRawData & fedData = rdc->FEDData(j);
67  size_t size=fedData.size();
68 
69  if ( size > 0 ) {
70  // this fed has data -- lets copy it
71  if(verbose_ > 1) std::cout << "Copying data from FED #" << j << std::endl;
72  FEDRawData & fedDataProd = producedData->FEDData(j);
73  if ( fedDataProd.size() != 0 ) {
74  if(verbose_ > 1) {
75  std::cout << " More than one FEDRawDataCollection with data in FED ";
76  std::cout << j << " Skipping the 2nd\n";
77  }
78  continue;
79  }
80  fedDataProd.resize(size);
81  unsigned char *dataProd=fedDataProd.data();
82  const unsigned char *data=fedData.data();
83  for ( unsigned int k=0; k<size; ++k ) {
84  dataProd[k]=data[k];
85  }
86  }
87  }
88  }
89 
90  // Insert the new product in the event
91  e.put(producedData);
92 
93 }
94 
95 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag >::const_iterator tag_iterator_t
std::vector< edm::EDGetTokenT< FEDRawDataCollection > >::const_iterator tok_iterator_t
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
static std::string const input
Definition: EdmProvDump.cc:43
void produce(edm::Event &e, const edm::EventSetup &c)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
int j
Definition: DBlmapReader.cc:9
virtual ~RawDataCollectorByLabel()
Destructor.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
RawDataCollectorByLabel(const edm::ParameterSet &pset)
Constructor.
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.