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
APVCyclePhaseProducerFromL1ABC Class Reference

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

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

Public Member Functions

 APVCyclePhaseProducerFromL1ABC (const edm::ParameterSet &)
 
 ~APVCyclePhaseProducerFromL1ABC ()
 
- 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

unsigned int _curroffevent
 
long long _curroffset
 
const std::vector< std::string > _defpartnames
 
const std::vector< int > _defphases
 
const unsigned int _firstgoodrun
 
TH1F * _hbx
 
TH1F * _hdbx
 
TH1F * _hdorbit
 
const edm::InputTag _l1abccollection
 
std::map< unsigned int, long long > _offsets
 
const int _orbitoffsetSOR
 
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)
 
static void prevalidate (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 APVCyclePhaseProducerFromL1ABC.cc.

Constructor & Destructor Documentation

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

Definition at line 96 of file APVCyclePhaseProducerFromL1ABC.cc.

96  :
97  _l1abccollection(iConfig.getParameter<edm::InputTag>("l1ABCCollection")),
98  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
99  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
100  _orbitoffsetSOR(iConfig.getParameter<int>("StartOfRunOrbitOffset")),
101  _wantHistos(iConfig.getUntrackedParameter<bool>("wantHistos",false)),
102  _hbx(0),_hdbx(0),_hdorbit(0),_firstgoodrun(110878),
104 {
105 
106  produces<APVCyclePhaseCollection,edm::InEvent>();
107 
108  //now do what ever other initialization is needed
109 
110 }
std::map< unsigned int, long long > _offsets
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > _defpartnames
APVCyclePhaseProducerFromL1ABC::~APVCyclePhaseProducerFromL1ABC ( )

Definition at line 113 of file APVCyclePhaseProducerFromL1ABC.cc.

114 {
115 
116  // do anything here that needs to be done at desctruction time
117  // (e.g. close files, deallocate resources etc.)
118 
119 }

Member Function Documentation

void APVCyclePhaseProducerFromL1ABC::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 278 of file APVCyclePhaseProducerFromL1ABC.cc.

279 {
280 }
void APVCyclePhaseProducerFromL1ABC::beginRun ( edm::Run iRun,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 128 of file APVCyclePhaseProducerFromL1ABC.cc.

References _firstgoodrun, _hbx, _hdbx, _hdorbit, _offsets, _wantHistos, combineCards::dirname, TFileDirectory::mkdir(), and edm::RunBase::run().

130 {
131 
132  // reset offset vector
133 
134  _offsets.clear();
135  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
136 
137 
138  if(_wantHistos) {
139 
141 
142  char dirname[300];
143  sprintf(dirname,"run_%d",iRun.run());
144  TFileDirectory subrun = tfserv->mkdir(dirname);
145 
146  _hbx = subrun.make<TH1F>("l1abcbx","BX number from L1ABC",4096,-0.5,4095.5);
147  _hbx->GetXaxis()->SetTitle("BX"); _hbx->GetYaxis()->SetTitle("Events");
148 
149  _hdbx = subrun.make<TH1F>("dbx","BX number difference",4096*2-1,-4095.5,4095.5);
150  _hdbx->GetXaxis()->SetTitle("#DeltaBX"); _hdbx->GetYaxis()->SetTitle("Events");
151 
152  _hdorbit = subrun.make<TH1F>("dorbit","Orbit Number difference",9999,-4999.5,4999.5);
153  _hdorbit->GetXaxis()->SetTitle("#Deltaorbit"); _hdorbit->GetYaxis()->SetTitle("Events");
154 
155  }
156 
157  if(iRun.run() < _firstgoodrun) {
158  edm::LogInfo("UnreliableMissingL1AcceptBunchCrossingCollection") <<
159  "In this run L1AcceptBunchCrossingCollection is missing or unreliable: default phases will be used";
160  }
161 
162 }
std::map< unsigned int, long long > _offsets
RunNumber_t run() const
Definition: RunBase.h:42
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
void APVCyclePhaseProducerFromL1ABC::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 284 of file APVCyclePhaseProducerFromL1ABC.cc.

284  {
285 }
void APVCyclePhaseProducerFromL1ABC::endRun ( edm::Run ,
const edm::EventSetup  
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 165 of file APVCyclePhaseProducerFromL1ABC.cc.

References _offsets, and evf::evtn::offset().

166 {
167  // summary of absolute bx offset vector
168 
169  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
170  for(std::map<unsigned int, long long>::const_iterator offset=_offsets.begin();offset!=_offsets.end();++offset) {
171  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
172  }
173 
174 }
std::map< unsigned int, long long > _offsets
unsigned int offset(bool)
void APVCyclePhaseProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 178 of file APVCyclePhaseProducerFromL1ABC.cc.

References _curroffevent, _curroffset, _defpartnames, _defphases, _firstgoodrun, _hbx, _hdbx, _hdorbit, _l1abccollection, _offsets, _orbitoffsetSOR, _wantHistos, edm::EventBase::bunchCrossing(), edm::EventID::event(), edm::hlt::Exception, edm::Event::getByLabel(), edm::EventBase::id(), edm::EventBase::orbitNumber(), edm::Event::put(), and edm::Event::run().

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

178  {
179 
180  using namespace edm;
181 
182  std::auto_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection() );
183 
184 
185  const std::vector<int>& phases = _defphases;
186  const std::vector<std::string>& partnames = _defpartnames;
187 
188  // Look for the L1AcceptBunchCrossingCollection
189 
190  int phasechange = 0;
191 
192  if(iEvent.run() >= _firstgoodrun ) {
193 
195  iEvent.getByLabel(_l1abccollection,pIn);
196 
197  // offset computation
198 
199  long long orbitoffset = _orbitoffsetSOR;
200  int bxoffset = 0;
201 
202  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
203  if(l1abc->l1AcceptOffset()==0) {
204  if(l1abc->eventType()!=0) {
205  orbitoffset = (long long)iEvent.orbitNumber() - (long long)l1abc->orbitNumber() ;
206  bxoffset = iEvent.bunchCrossing() - l1abc->bunchCrossing();
207 
208  if(_wantHistos) {
209  _hbx->Fill(l1abc->bunchCrossing());
210  _hdbx->Fill(bxoffset);
211  _hdorbit->Fill(orbitoffset);
212  }
213  }
214  else {
215  edm::LogWarning("L1AcceptBunchCrossingNoType") << "L1AcceptBunchCrossing with no type found: ";
216  for(L1AcceptBunchCrossingCollection::const_iterator debu=pIn->begin();debu!=pIn->end();++debu) {
217  edm::LogPrint("L1AcceptBunchCrossingNoType") << *debu;
218  }
219  }
220  }
221  }
222 
223  long long absbxoffset = orbitoffset*3564 + bxoffset;
224 
225  if(orbitoffset != _orbitoffsetSOR) phasechange = (orbitoffset*3564)%70;
226 
227  if(_offsets.size()==0) {
228  _curroffset = absbxoffset;
229  _curroffevent = iEvent.id().event();
230  _offsets[iEvent.id().event()] = absbxoffset;
231  }
232  else {
233  if(_curroffset != absbxoffset || iEvent.id().event() < _curroffevent ) {
234 
235  if( _curroffset != absbxoffset) {
236  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetChanged") << "Absolute BX offset changed from "
237  << _curroffset << " to "
238  << absbxoffset << " at orbit "
239  << iEvent.orbitNumber() << " and BX "
240  << iEvent.bunchCrossing();
241  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
242  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetChanged") << *l1abc;
243  }
244  }
245 
246  _curroffset = absbxoffset;
247  _curroffevent = iEvent.id().event();
248  _offsets[iEvent.id().event()] = absbxoffset;
249  }
250  }
251 
252 
253  }
254 
255 
256 
257  if(phases.size() < partnames.size() ) {
258  // throw exception
259  throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: "
260  << phases.size() << " "
261  << partnames.size();
262  }
263 
264  for(unsigned int ipart=0;ipart<partnames.size();++ipart) {
265  if(phases[ipart]>=0) {
266  apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
267 
268  }
269  }
270 
271 
272  iEvent.put(apvphases);
273 
274 }
std::map< unsigned int, long long > _offsets
EventNumber_t event() const
Definition: EventID.h:44
const std::vector< std::string > _defpartnames
int bunchCrossing() const
Definition: EventBase.h:62
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
RunNumber_t run() const
Definition: Event.h:67
int orbitNumber() const
Definition: EventBase.h:63
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::EventID id() const
Definition: EventBase.h:56

Member Data Documentation

unsigned int APVCyclePhaseProducerFromL1ABC::_curroffevent
private

Definition at line 80 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1ABC::_curroffset
private

Definition at line 79 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 70 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 71 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const unsigned int APVCyclePhaseProducerFromL1ABC::_firstgoodrun
private

Definition at line 77 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1ABC::_hbx
private

Definition at line 74 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1ABC::_hdbx
private

Definition at line 75 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().

TH1F* APVCyclePhaseProducerFromL1ABC::_hdorbit
private

Definition at line 76 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().

const edm::InputTag APVCyclePhaseProducerFromL1ABC::_l1abccollection
private

Definition at line 69 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

std::map<unsigned int, long long> APVCyclePhaseProducerFromL1ABC::_offsets
private

Definition at line 78 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), endRun(), and produce().

const int APVCyclePhaseProducerFromL1ABC::_orbitoffsetSOR
private

Definition at line 72 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const bool APVCyclePhaseProducerFromL1ABC::_wantHistos
private

Definition at line 73 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().