CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
APVCyclePhaseProducerFromL1TS Class Reference

#include <DPGAnalysis/SiStripTools/plugins/APVCyclePhaseProducerFromL1TS.cc>

Inheritance diagram for APVCyclePhaseProducerFromL1TS:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 APVCyclePhaseProducerFromL1TS (const edm::ParameterSet &)
 
 ~APVCyclePhaseProducerFromL1TS ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void beginRun (edm::Run &, const edm::EventSetup &)
 
virtual void endJob ()
 
virtual void endRun (edm::Run &, const edm::EventSetup &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

const std::vector< std::string > _defpartnames
 
const std::vector< int > _defphases
 
const unsigned int _firstgoodrun
 
TH1F * _hdlec0lresync
 
TH1F * _hdlresynclHR
 
TH1F * _hlEC0
 
TH1F * _hlHR
 
TH1F * _hlOC0
 
TH1F * _hlresync
 
TH1F * _hlstart
 
TH1F * _hlTE
 
TH1F * _hsize
 
const edm::InputTag _l1tscollection
 
long long _lastEventCounter0
 
long long _lastHardReset
 
long long _lastOrbitCounter0
 
long long _lastResync
 
long long _lastStart
 
long long _lastTestEnable
 
const int _magicOffset
 
const bool _useEC0
 
const bool _wantHistos
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: EDproducer for APVCyclePhaseCollection which uses the configuration file to assign a phase to the run

Implementation: <Notes on="" implementation>="">

Definition at line 55 of file APVCyclePhaseProducerFromL1TS.cc.

Constructor & Destructor Documentation

APVCyclePhaseProducerFromL1TS::APVCyclePhaseProducerFromL1TS ( const edm::ParameterSet iConfig)
explicit

Definition at line 111 of file APVCyclePhaseProducerFromL1TS.cc.

111  :
112  _l1tscollection(iConfig.getParameter<edm::InputTag>("l1TSCollection")),
113  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
114  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
115  _wantHistos(iConfig.getUntrackedParameter<bool>("wantHistos",false)),
116  _useEC0(iConfig.getUntrackedParameter<bool>("useEC0",false)),
117  _magicOffset(iConfig.getUntrackedParameter<int>("magicOffset",8)),
118  _firstgoodrun(131768),
121 {
122 
123  produces<APVCyclePhaseCollection,edm::InEvent>();
124 
125  //now do what ever other initialization is needed
126 
127 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > _defpartnames
APVCyclePhaseProducerFromL1TS::~APVCyclePhaseProducerFromL1TS ( )

Definition at line 130 of file APVCyclePhaseProducerFromL1TS.cc.

131 {
132 
133  // do anything here that needs to be done at desctruction time
134  // (e.g. close files, deallocate resources etc.)
135 
136 }

Member Function Documentation

void APVCyclePhaseProducerFromL1TS::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 301 of file APVCyclePhaseProducerFromL1TS.cc.

302 {
303 }
void APVCyclePhaseProducerFromL1TS::beginRun ( edm::Run iRun,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 145 of file APVCyclePhaseProducerFromL1TS.cc.

References _firstgoodrun, _hdlec0lresync, _hdlresynclHR, _hlEC0, _hlHR, _hlOC0, _hlresync, _hlstart, _hlTE, _hsize, _wantHistos, LogDebug, TFileDirectory::mkdir(), and edm::RunBase::run().

147 {
148 
149  // reset offset vector
150 
151  if(_wantHistos) {
152 
154 
155  char dirname[300];
156  sprintf(dirname,"run_%d",iRun.run());
157  TFileDirectory subrun = tfserv->mkdir(dirname);
158 
159  _hsize = subrun.make<TH1F>("size","Level1TriggerScalers Collection size",20,-0.5,19.5);
160 
161  _hlresync = subrun.make<TH1F>("lresync","Orbit of last resync",3600,0.,3600*11223);
162  _hlresync->GetXaxis()->SetTitle("Orbit"); _hlresync->GetYaxis()->SetTitle("Events");
163  _hlresync->SetBit(TH1::kCanRebin);
164 
165  _hlOC0 = subrun.make<TH1F>("lOC0","Orbit of last OC0",3600,0.,3600*11223);
166  _hlOC0->GetXaxis()->SetTitle("Orbit"); _hlOC0->GetYaxis()->SetTitle("Events");
167  _hlOC0->SetBit(TH1::kCanRebin);
168 
169  _hlTE = subrun.make<TH1F>("lTE","Orbit of last TestEnable",3600,0.,3600*11223);
170  _hlTE->GetXaxis()->SetTitle("Orbit"); _hlTE->GetYaxis()->SetTitle("Events");
171  _hlTE->SetBit(TH1::kCanRebin);
172 
173  _hlstart = subrun.make<TH1F>("lstart","Orbit of last Start",3600,0.,3600*11223);
174  _hlstart->GetXaxis()->SetTitle("Orbit"); _hlstart->GetYaxis()->SetTitle("Events");
175  _hlstart->SetBit(TH1::kCanRebin);
176 
177  _hlEC0 = subrun.make<TH1F>("lEC0","Orbit of last EC0",3600,0.,3600*11223);
178  _hlEC0->GetXaxis()->SetTitle("Orbit"); _hlEC0->GetYaxis()->SetTitle("Events");
179  _hlEC0->SetBit(TH1::kCanRebin);
180 
181  _hlHR = subrun.make<TH1F>("lHR","Orbit of last HardReset",3600,0.,3600*11223);
182  _hlHR->GetXaxis()->SetTitle("Orbit"); _hlHR->GetYaxis()->SetTitle("Events");
183  _hlHR->SetBit(TH1::kCanRebin);
184 
185  _hdlec0lresync = subrun.make<TH1F>("dlec0lresync","Orbit difference EC0-Resync",4000,-1999.5,2000.5);
186  _hdlec0lresync->GetXaxis()->SetTitle("lastEC0-lastResync");
187 
188  _hdlresynclHR = subrun.make<TH1F>("dlresynclHR","Orbit difference Resync-HR",4000,-1999.5,2000.5);
189  _hdlresynclHR->GetXaxis()->SetTitle("lastEC0-lastResync");
190 
191  }
192 
193  if(iRun.run() < _firstgoodrun) {
194  LogDebug("UnreliableMissingL1TriggerScalers") <<
195  "In this run L1TriggerScalers is missing or unreliable for phase determination: default phases will be used";
196  }
197 
198 }
#define LogDebug(id)
RunNumber_t run() const
Definition: RunBase.h:44
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
void APVCyclePhaseProducerFromL1TS::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 307 of file APVCyclePhaseProducerFromL1TS.cc.

307  {
308 }
void APVCyclePhaseProducerFromL1TS::endRun ( edm::Run ,
const edm::EventSetup  
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 201 of file APVCyclePhaseProducerFromL1TS.cc.

202 {
203  // summary of absolute bx offset vector
204 
205 }
void APVCyclePhaseProducerFromL1TS::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 209 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _firstgoodrun, _hdlec0lresync, _hdlresynclHR, _hlEC0, _hlHR, _hlOC0, _hlresync, _hlstart, _hlTE, _hsize, _l1tscollection, _lastEventCounter0, _lastHardReset, _lastOrbitCounter0, _lastResync, _lastStart, _lastTestEnable, _magicOffset, _useEC0, _wantHistos, edm::hlt::Exception, edm::Event::getByLabel(), LogDebug, edm::Event::put(), and edm::Event::run().

Referenced by python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

209  {
210 
211  using namespace edm;
212 
213  std::auto_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection() );
214 
215 
216  const std::vector<int>& phases = _defphases;
217  const std::vector<std::string>& partnames = _defpartnames;
218 
219  int phasechange = 0;
220 
221  if(iEvent.run() >= _firstgoodrun ) {
222 
224  iEvent.getByLabel(_l1tscollection,l1ts);
225 
226  if(_wantHistos) _hsize->Fill(l1ts->size());
227 
228  // offset computation
229 
230  long long orbitoffset = 0;
231 
232  if(l1ts->size()>0) {
233 
234  if((*l1ts)[0].lastResync()!=0) {
235  orbitoffset = _useEC0 ? (*l1ts)[0].lastEventCounter0() + _magicOffset : (*l1ts)[0].lastResync() + _magicOffset;
236  }
237 
238  if(_wantHistos) {
239  _hlresync->Fill((*l1ts)[0].lastResync());
240  _hlOC0->Fill((*l1ts)[0].lastOrbitCounter0());
241  _hlTE->Fill((*l1ts)[0].lastTestEnable());
242  _hlstart->Fill((*l1ts)[0].lastStart());
243  _hlEC0->Fill((*l1ts)[0].lastEventCounter0());
244  _hlHR->Fill((*l1ts)[0].lastHardReset());
245  }
246 
247  if(_lastResync != (*l1ts)[0].lastResync()) {
248  _lastResync = (*l1ts)[0].lastResync();
249  if(_wantHistos) _hdlec0lresync->Fill((*l1ts)[0].lastEventCounter0()-(*l1ts)[0].lastResync());
250  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync ;
251  }
252  if(_lastHardReset != (*l1ts)[0].lastHardReset()) {
253  _lastHardReset = (*l1ts)[0].lastHardReset();
254  if(_wantHistos) _hdlresynclHR->Fill((*l1ts)[0].lastResync()-(*l1ts)[0].lastHardReset());
255  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset ;
256  }
257  if(_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
258  _lastTestEnable = (*l1ts)[0].lastTestEnable();
259  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
260  }
261  if(_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
262  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
263  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0 ;
264  }
265  if(_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
266  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
267  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0 ;
268  }
269  if(_lastStart != (*l1ts)[0].lastStart()) {
270  _lastStart = (*l1ts)[0].lastStart();
271  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart ;
272  }
273 
274  phasechange = ((long long)(orbitoffset*3564))%70;
275 
276  }
277  }
278 
279 
280  if(phases.size() < partnames.size() ) {
281  // throw exception
282  throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: "
283  << phases.size() << " "
284  << partnames.size();
285  }
286 
287  for(unsigned int ipart=0;ipart<partnames.size();++ipart) {
288  if(phases[ipart]>=0) {
289  apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
290 
291  }
292  }
293 
294 
295  iEvent.put(apvphases);
296 
297 }
#define LogDebug(id)
const std::vector< std::string > _defpartnames
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
RunNumber_t run() const
Definition: Event.h:66
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355

Member Data Documentation

const std::vector<std::string> APVCyclePhaseProducerFromL1TS::_defpartnames
private

Definition at line 70 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const std::vector<int> APVCyclePhaseProducerFromL1TS::_defphases
private

Definition at line 71 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const unsigned int APVCyclePhaseProducerFromL1TS::_firstgoodrun
private

Definition at line 87 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hdlec0lresync
private

Definition at line 84 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hdlresynclHR
private

Definition at line 85 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hlEC0
private

Definition at line 80 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hlHR
private

Definition at line 82 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hlOC0
private

Definition at line 78 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hlresync
private

Definition at line 77 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hlstart
private

Definition at line 81 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hlTE
private

Definition at line 79 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1TS::_hsize
private

Definition at line 76 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().

const edm::InputTag APVCyclePhaseProducerFromL1TS::_l1tscollection
private

Definition at line 69 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastEventCounter0
private

Definition at line 92 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastHardReset
private

Definition at line 90 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastOrbitCounter0
private

Definition at line 93 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastResync
private

Definition at line 89 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastStart
private

Definition at line 91 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastTestEnable
private

Definition at line 94 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const int APVCyclePhaseProducerFromL1TS::_magicOffset
private

Definition at line 74 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const bool APVCyclePhaseProducerFromL1TS::_useEC0
private

Definition at line 73 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const bool APVCyclePhaseProducerFromL1TS::_wantHistos
private

Definition at line 72 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), and produce().