CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1O2OTestAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1O2OTestAnalyzer
4 // Class: L1O2OTestAnalyzer
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Thu Nov 6 23:00:43 CET 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <iostream>
22 #include <memory>
23 #include <sstream>
24 
25 // user include files
28 
33 
35 
40 
43 
44 //
45 // class decleration
46 //
47 
49  public:
50  explicit L1O2OTestAnalyzer(const edm::ParameterSet&);
52 
53 
54  private:
55  virtual void beginJob() override ;
56  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
57  virtual void endJob() override ;
58 
59  // ----------member data ---------------------------
64  std::vector< std::string > m_recordsToPrint ;
65 };
66 
67 //
68 // constants, enums and typedefs
69 //
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79  : m_printL1TriggerKey( iConfig.getParameter<bool> ("printL1TriggerKey") ),
80  m_printL1TriggerKeyList( iConfig.getParameter<bool> ("printL1TriggerKeyList") ),
81  m_printESRecords( iConfig.getParameter<bool> ("printESRecords") ),
82  m_printPayloadTokens( iConfig.getParameter<bool> ("printPayloadTokens") ),
83  m_recordsToPrint( iConfig.getParameter< std::vector< std::string > >(
84  "recordsToPrint" ) )
85 {
86  //now do what ever initialization is needed
87 }
88 
89 
91 {
92 
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 
96 }
97 
98 
99 //
100 // member functions
101 //
102 
103 // ------------ method called to for each event ------------
104 void
106 {
107  using namespace edm;
108 
110  {
111 // ESHandle< L1TriggerKeyList > pList ;
112 // iSetup.get< L1TriggerKeyListRcd >().get( pList ) ;
113  L1TriggerKeyList pList ;
114  l1t::DataWriter dataWriter ;
115  if( !dataWriter.fillLastTriggerKeyList( pList ) )
116  {
117  edm::LogError( "L1-O2O" )
118  << "Problem getting last L1TriggerKeyList" ;
119  }
120 
121  std::cout << "Found " << pList.tscKeyToTokenMap().size() << " TSC keys:"
122  << std::endl ;
123 
124  L1TriggerKeyList::KeyToToken::const_iterator iTSCKey =
125  pList.tscKeyToTokenMap().begin() ;
126  L1TriggerKeyList::KeyToToken::const_iterator eTSCKey =
127  pList.tscKeyToTokenMap().end() ;
128  for( ; iTSCKey != eTSCKey ; ++iTSCKey )
129  {
130  std::cout << iTSCKey->first ;
132  {
133  std::cout << " " << iTSCKey->second ;
134  }
135  std::cout << std::endl ;
136  }
137  std::cout << std::endl ;
138 
139  L1TriggerKeyList::RecordToKeyToToken::const_iterator iRec =
140  pList.recordTypeToKeyToTokenMap().begin() ;
141  L1TriggerKeyList::RecordToKeyToToken::const_iterator eRec =
142  pList.recordTypeToKeyToTokenMap().end() ;
143  for( ; iRec != eRec ; ++iRec )
144  {
145  const L1TriggerKeyList::KeyToToken& keyTokenMap = iRec->second ;
146  std::cout << "For record@type " << iRec->first << ", found "
147  << keyTokenMap.size() << " keys:" << std::endl ;
148 
149  L1TriggerKeyList::KeyToToken::const_iterator iKey = keyTokenMap.begin();
150  L1TriggerKeyList::KeyToToken::const_iterator eKey = keyTokenMap.end() ;
151  for( ; iKey != eKey ; ++iKey )
152  {
153  std::cout << iKey->first ;
155  {
156  std::cout << " " << iKey->second ;
157  }
158  std::cout << std::endl ;
159  }
160  std::cout << std::endl ;
161  }
162  }
163 
164  if( m_printL1TriggerKey )
165  {
166  try
167  {
169  iSetup.get< L1TriggerKeyRcd >().get( pKey ) ;
170 
171  std::cout << std::endl ;
172  std::cout << "Current TSC key = " << pKey->tscKey()
173  << std::endl << std::endl ;
174 
175  std::cout << "Current subsystem keys:" << std::endl ;
176  std::cout << "CSCTF " << pKey->subsystemKey( L1TriggerKey::kCSCTF )
177  << std::endl ;
178  std::cout << "DTTF " << pKey->subsystemKey( L1TriggerKey::kDTTF )
179  << std::endl ;
180  std::cout << "RPC " << pKey->subsystemKey( L1TriggerKey::kRPC )
181  << std::endl ;
182  std::cout << "GMT " << pKey->subsystemKey( L1TriggerKey::kGMT )
183  << std::endl ;
184  std::cout << "RCT " << pKey->subsystemKey( L1TriggerKey::kRCT )
185  << std::endl ;
186  std::cout << "GCT " << pKey->subsystemKey( L1TriggerKey::kGCT )
187  << std::endl ;
188  std::cout << "GT " << pKey->subsystemKey( L1TriggerKey::kGT )
189  << std::endl ;
190  std::cout << "TSP0 " << pKey->subsystemKey( L1TriggerKey::kTSP0 )
191  << std::endl << std::endl ;
192 
193  std::cout << "Object keys:" << std::endl ;
194  const L1TriggerKey::RecordToKey& recKeyMap = pKey->recordToKeyMap() ;
195  L1TriggerKey::RecordToKey::const_iterator iRec = recKeyMap.begin() ;
196  L1TriggerKey::RecordToKey::const_iterator eRec = recKeyMap.end() ;
197  for( ; iRec != eRec ; ++iRec )
198  {
199  std::cout << iRec->first << " " << iRec->second << std::endl ;
200  }
201  }
202  catch( cms::Exception& ex )
203  {
204  std::cout << "No L1TriggerKey found." << std::endl ;
205  }
206  }
207 
208  if( m_printESRecords )
209  {
210 // ESHandle< L1TriggerKeyList > pList ;
211 // iSetup.get< L1TriggerKeyListRcd >().get( pList ) ;
212 
213  L1TriggerKeyList pList ;
214  l1t::DataWriter dataWriter ;
215  if( !dataWriter.fillLastTriggerKeyList( pList ) )
216  {
217  edm::LogError( "L1-O2O" )
218  << "Problem getting last L1TriggerKeyList" ;
219  }
220 
221  // Start log string, convert run number into string
222  unsigned long long run = iEvent.id().run() ;
223  std::stringstream ss ;
224  ss << run ;
225  std::string log = "runNumber=" + ss.str() ;
226 
227  l1t::DataWriter writer ;
228 
229  std::cout << std::endl << "Run Settings keys:" << std::endl ;
230 
231  std::vector< std::string >::const_iterator iRec =
232  m_recordsToPrint.begin() ;
233  std::vector< std::string >::const_iterator iEnd =
234  m_recordsToPrint.end() ;
235  for( ; iRec != iEnd ; ++iRec )
236  {
237  std::string payloadToken = writer.payloadToken( *iRec,
238  iEvent.id().run() );
239  std::string key ;
240 
241  if( *iRec == "L1TriggerKeyRcd" )
242  {
243  key = pList.tscKey( payloadToken ) ;
244  }
245  else
246  {
247  key = pList.objectKey( *iRec, payloadToken ) ;
248  }
249 
250  std::cout << *iRec << " " << key ;
252  {
253  std::cout << " " << payloadToken ;
254  }
255  std::cout << std::endl ;
256 
257  // Replace spaces in key with ?s. Do reverse substitution when
258  // making L1TriggerKey.
259  replace( key.begin(), key.end(), ' ', '?' ) ;
260  log += " " + *iRec + "Key=" + key ;
261  }
262 
263  std::cout << std::endl << log << std::endl ;
264  }
265 }
266 
267 
268 // ------------ method called once each job just before starting event loop ------------
269 void
271 {
272 }
273 
274 // ------------ method called once each job just after ending the event loop ------------
275 void
277 }
278 
279 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKey.h:26
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< std::string, std::string > KeyToToken
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriter.cc:153
std::string tscKey(const std::string &triggerKeyPayloadToken) const
int iEvent
Definition: GenABIO.cc:230
virtual void beginJob() override
const RecordToKeyToToken & recordTypeToKeyToTokenMap() const
std::string objectKey(const std::string &recordName, const std::string &payloadToken) const
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:196
std::vector< std::string > m_recordsToPrint
const T & get() const
Definition: EventSetup.h:55
const KeyToToken & tscKeyToTokenMap() const
virtual void endJob() override
edm::EventID id() const
Definition: EventBase.h:56
list key
Definition: combine.py:13
L1O2OTestAnalyzer(const edm::ParameterSet &)
tuple cout
Definition: gather_cfg.py:121