CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ScalersRawToDigi.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EventFilter/ScalersRawToDigi
4 // Class: ScalersRawToDigi
5 //
12 //
13 // Original Author: William Badgett
14 // Created: Wed Nov 14 07:47:59 CDT 2006
15 //
16 
17 #include <memory>
18 
23 
24 // FEDRawData
27 
28 // Scalers classes
37 
39 {
40  public:
41  explicit ScalersRawToDigi(const edm::ParameterSet&);
43 
44  virtual void produce(edm::Event&, const edm::EventSetup&);
45 
46  private:
48 };
49 
50 // Constructor
52  inputTag_((char const *)"rawDataCollector")
53 {
54  produces<L1AcceptBunchCrossingCollection>();
55  produces<L1TriggerScalersCollection>();
56  produces<Level1TriggerScalersCollection>();
57  produces<LumiScalersCollection>();
58  produces<BeamSpotOnlineCollection>();
59  produces<DcsStatusCollection>();
60  if ( iConfig.exists("scalersInputTag") )
61  {
62  inputTag_ = iConfig.getParameter<edm::InputTag>("scalersInputTag");
63  }
64 }
65 
66 // Destructor
68 
69 // Method called to produce the data
71  const edm::EventSetup& iSetup)
72 {
73  using namespace edm;
74 
75  // Get a handle to the FED data collection
77  iEvent.getByLabel(inputTag_, rawdata);
78 
79  std::auto_ptr<LumiScalersCollection> pLumi(new LumiScalersCollection());
80 
81  std::auto_ptr<L1TriggerScalersCollection>
82  pOldTrigger(new L1TriggerScalersCollection());
83 
84  std::auto_ptr<Level1TriggerScalersCollection>
85  pTrigger(new Level1TriggerScalersCollection());
86 
87  std::auto_ptr<L1AcceptBunchCrossingCollection>
88  pBunch(new L1AcceptBunchCrossingCollection());
89 
90  std::auto_ptr<BeamSpotOnlineCollection> pBeamSpotOnline(new BeamSpotOnlineCollection());
91  std::auto_ptr<DcsStatusCollection> pDcsStatus(new DcsStatusCollection());
92 
94  const FEDRawData & fedData = rawdata->FEDData(ScalersRaw::SCALERS_FED_ID);
95  unsigned short int length = fedData.size();
96  if ( length > 0 )
97  {
98  int nWords = length / 8;
99  int nBytesExtra = 0;
100 
101  const ScalersEventRecordRaw_v6 * raw
102  = (struct ScalersEventRecordRaw_v6 *)fedData.data();
103  if ( ( raw->version == 1 ) || ( raw->version == 2 ) )
104  {
105  L1TriggerScalers oldTriggerScalers(fedData.data());
106  pOldTrigger->push_back(oldTriggerScalers);
107  nBytesExtra = length - sizeof(struct ScalersEventRecordRaw_v1);
108  }
109  else if ( raw->version >= 3 )
110  {
111  Level1TriggerScalers triggerScalers(fedData.data());
112  pTrigger->push_back(triggerScalers);
113  if ( raw->version >= 6 )
114  {
115  nBytesExtra = ScalersRaw::N_BX_v6 * sizeof(unsigned long long);
116  }
117  else
118  {
119  nBytesExtra = ScalersRaw::N_BX_v2 * sizeof(unsigned long long);
120  }
121  }
122 
123  LumiScalers lumiScalers(fedData.data());
124  pLumi->push_back(lumiScalers);
125 
126  if (( nBytesExtra >= 8 ) && (( nBytesExtra % 8 ) == 0 ))
127  {
128  unsigned long long * data =
129  (unsigned long long *)fedData.data();
130 
131  int nWordsExtra = nBytesExtra / 8;
132  for ( int i=0; i<nWordsExtra; i++)
133  {
134  int index = nWords - (nWordsExtra + 1) + i;
135  L1AcceptBunchCrossing bc(i,data[index]);
136  pBunch->push_back(bc);
137  }
138  }
139 
140  if ( raw->version >= 4 )
141  {
142  BeamSpotOnline beamSpotOnline(fedData.data());
143  pBeamSpotOnline->push_back(beamSpotOnline);
144 
145  DcsStatus dcsStatus(fedData.data());
146  pDcsStatus->push_back(dcsStatus);
147  }
148  }
149  iEvent.put(pOldTrigger);
150  iEvent.put(pTrigger);
151  iEvent.put(pLumi);
152  iEvent.put(pBunch);
153  iEvent.put(pBeamSpotOnline);
154  iEvent.put(pDcsStatus);
155 }
156 
157 // Define this as a plug-in
std::vector< BeamSpotOnline > BeamSpotOnlineCollection
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual void produce(edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag inputTag_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
ScalersRawToDigi(const edm::ParameterSet &)
std::vector< L1AcceptBunchCrossing > L1AcceptBunchCrossingCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:116
string const
Definition: compareJSON.py:14
std::vector< Level1TriggerScalers > Level1TriggerScalersCollection
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:160
std::vector< L1TriggerScalers > L1TriggerScalersCollection
dictionary rawdata
Definition: lumiPlot.py:393