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&) override;
45 
46  private:
49 
50 };
51 
52 // Constructor
54  inputTag_((char const *)"rawDataCollector")
55 {
56  produces<L1AcceptBunchCrossingCollection>();
57  produces<L1TriggerScalersCollection>();
58  produces<Level1TriggerScalersCollection>();
59  produces<LumiScalersCollection>();
60  produces<BeamSpotOnlineCollection>();
61  produces<DcsStatusCollection>();
62  if ( iConfig.exists("scalersInputTag") )
63  {
64  inputTag_ = iConfig.getParameter<edm::InputTag>("scalersInputTag");
65  }
66  fedToken_=consumes<FEDRawDataCollection>(inputTag_);
67 
68 }
69 
70 // Destructor
72 
73 // Method called to produce the data
75  const edm::EventSetup& iSetup)
76 {
77  using namespace edm;
78 
79  // Get a handle to the FED data collection
81  iEvent.getByToken(fedToken_, rawdata);
82 
83  std::auto_ptr<LumiScalersCollection> pLumi(new LumiScalersCollection());
84 
85  std::auto_ptr<L1TriggerScalersCollection>
86  pOldTrigger(new L1TriggerScalersCollection());
87 
88  std::auto_ptr<Level1TriggerScalersCollection>
89  pTrigger(new Level1TriggerScalersCollection());
90 
91  std::auto_ptr<L1AcceptBunchCrossingCollection>
92  pBunch(new L1AcceptBunchCrossingCollection());
93 
94  std::auto_ptr<BeamSpotOnlineCollection> pBeamSpotOnline(new BeamSpotOnlineCollection());
95  std::auto_ptr<DcsStatusCollection> pDcsStatus(new DcsStatusCollection());
96 
98  const FEDRawData & fedData = rawdata->FEDData(ScalersRaw::SCALERS_FED_ID);
99  unsigned short int length = fedData.size();
100  if ( length > 0 )
101  {
102  int nWords = length / 8;
103  int nBytesExtra = 0;
104 
105  const ScalersEventRecordRaw_v6 * raw
106  = (struct ScalersEventRecordRaw_v6 *)fedData.data();
107  if ( ( raw->version == 1 ) || ( raw->version == 2 ) )
108  {
109  L1TriggerScalers oldTriggerScalers(fedData.data());
110  pOldTrigger->push_back(oldTriggerScalers);
111  nBytesExtra = length - sizeof(struct ScalersEventRecordRaw_v1);
112  }
113  else if ( raw->version >= 3 )
114  {
115  Level1TriggerScalers triggerScalers(fedData.data());
116  pTrigger->push_back(triggerScalers);
117  if ( raw->version >= 6 )
118  {
119  nBytesExtra = ScalersRaw::N_BX_v6 * sizeof(unsigned long long);
120  }
121  else
122  {
123  nBytesExtra = ScalersRaw::N_BX_v2 * sizeof(unsigned long long);
124  }
125  }
126 
127  LumiScalers lumiScalers(fedData.data());
128  pLumi->push_back(lumiScalers);
129 
130  if (( nBytesExtra >= 8 ) && (( nBytesExtra % 8 ) == 0 ))
131  {
132  unsigned long long * data =
133  (unsigned long long *)fedData.data();
134 
135  int nWordsExtra = nBytesExtra / 8;
136  for ( int i=0; i<nWordsExtra; i++)
137  {
138  int index = nWords - (nWordsExtra + 1) + i;
139  L1AcceptBunchCrossing bc(i,data[index]);
140  pBunch->push_back(bc);
141  }
142  }
143 
144  if ( raw->version >= 4 )
145  {
146  BeamSpotOnline beamSpotOnline(fedData.data());
147  pBeamSpotOnline->push_back(beamSpotOnline);
148 
149  DcsStatus dcsStatus(fedData.data());
150  pDcsStatus->push_back(dcsStatus);
151  }
152  }
153  iEvent.put(pOldTrigger);
154  iEvent.put(pTrigger);
155  iEvent.put(pLumi);
156  iEvent.put(pBunch);
157  iEvent.put(pBeamSpotOnline);
158  iEvent.put(pDcsStatus);
159 }
160 
161 // Define this as a plug-in
std::vector< BeamSpotOnline > BeamSpotOnlineCollection
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#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:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ScalersRawToDigi(const edm::ParameterSet &)
std::vector< L1AcceptBunchCrossing > L1AcceptBunchCrossingCollection
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:116
virtual void produce(edm::Event &, const edm::EventSetup &) override
string const
Definition: compareJSON.py:14
std::vector< Level1TriggerScalers > Level1TriggerScalersCollection
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
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