CMS 3D CMS Logo

Public Member Functions | Private Attributes

EventWithHistory Class Reference

#include <EventWithHistory.h>

Inheritance diagram for EventWithHistory:
TinyEvent

List of all members.

Public Member Functions

long long absoluteBX (const unsigned int ev1) const
long long absoluteBX () const
long long absoluteBXinCycle (const unsigned int ev1, const int bx0) const
long long absoluteBXinCycle (const int bx0) const
int add (const EventWithHistory &he, const int idepth)
int add (const TinyEvent &he, const int idepth)
const int bx () const
long long deltaBX (const unsigned int ev2, const unsigned int ev1) const
long long deltaBX () const
long long deltaBX (const unsigned int ev1) const
long long deltaBX (const TinyEvent &se) const
long long deltaBXinCycle (const int bx0) const
long long deltaBXinCycle (const unsigned int ev2, const unsigned int ev1, const int bx0) const
long long deltaBXinCycle (const unsigned int ev1, const int bx0) const
long long deltaBXinCycle (const TinyEvent &se, const int bx0) const
unsigned int depth () const
const unsigned int event () const
 EventWithHistory (const TinyEvent &se)
 EventWithHistory (const unsigned int event, const unsigned int orbit, const int bx)
 EventWithHistory ()
 EventWithHistory (const std::vector< edm::EventAuxiliary > &he)
 EventWithHistory (const edm::Event &event)
 EventWithHistory (const edm::Event &event, const L1AcceptBunchCrossingCollection &l11bcc, const long long orbitoffset=0, const int bxoffset=0)
 EventWithHistory (const EventWithHistory &he)
 EventWithHistory (const unsigned int event, const int orbit, const int bx)
const TinyEventget (const unsigned int ev) const
bool isFutureHistory () const
EventWithHistoryoperator= (const EventWithHistory &he)
int operator== (const EventWithHistory &other) const
const unsigned int orbit () const

Private Attributes

std::vector< TinyEvent_prevse

Detailed Description

Definition at line 16 of file EventWithHistory.h.


Constructor & Destructor Documentation

EventWithHistory::EventWithHistory ( )

Definition at line 8 of file EventWithHistory.cc.

: TinyEvent(), _prevse() { }
EventWithHistory::EventWithHistory ( const TinyEvent se) [explicit]

Definition at line 10 of file EventWithHistory.cc.

: TinyEvent(se), _prevse() { }
EventWithHistory::EventWithHistory ( const unsigned int  event,
const int  orbit,
const int  bx 
) [explicit]

Definition at line 12 of file EventWithHistory.cc.

EventWithHistory::EventWithHistory ( const unsigned int  event,
const unsigned int  orbit,
const int  bx 
) [explicit]

Definition at line 15 of file EventWithHistory.cc.

EventWithHistory::EventWithHistory ( const edm::Event event) [explicit]

Definition at line 18 of file EventWithHistory.cc.

                                                       : 
  TinyEvent(event), _prevse() { }
EventWithHistory::EventWithHistory ( const std::vector< edm::EventAuxiliary > &  he)

Definition at line 21 of file EventWithHistory.cc.

References _prevse.

                                                                           :
  TinyEvent((veaux.size()>0) ? veaux[veaux.size()-1]: TinyEvent()), _prevse() 
{
  for(std::vector<edm::EventAuxiliary>::const_reverse_iterator eaux=veaux.rbegin();eaux!=veaux.rend();eaux++) {
    if(eaux!=veaux.rbegin()) {
      _prevse.push_back(*eaux);
    }
  }
}
EventWithHistory::EventWithHistory ( const edm::Event event,
const L1AcceptBunchCrossingCollection l11bcc,
const long long  orbitoffset = 0,
const int  bxoffset = 0 
)

Definition at line 31 of file EventWithHistory.cc.

References _prevse, deltaBX(), edm::EventID::event(), edm::EventBase::id(), and operator=().

                                                                                   :
  TinyEvent(), _prevse()
{
  
  std::map<int,TinyEvent> tmpmap;
  
  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=l1abcc.begin();l1abc!=l1abcc.end();++l1abc) {
    if(event.id().event() > (unsigned int)(-1*l1abc->l1AcceptOffset()) ) {
      unsigned int evnumb = event.id().event()+l1abc->l1AcceptOffset();
      if(orbitoffset < (long long)l1abc->orbitNumber()) {
        unsigned int neworbit = l1abc->orbitNumber() - orbitoffset;
        int newbx = l1abc->bunchCrossing() - bxoffset;
        
        while(newbx > 3563) {
          ++neworbit;
          newbx -= 3564;
        }
        while(newbx < 0) {
          --neworbit;
          newbx += 3564;
        }
        
        if(l1abc->eventType()!=0) {
          TinyEvent tmpse(evnumb,neworbit,newbx);
          tmpmap[l1abc->l1AcceptOffset()]=tmpse;
        }
        else {
          edm::LogWarning("L1AcceptBunchCrossingNoType") << "L1AcceptBunchCrossing with no type found: ";
          for(L1AcceptBunchCrossingCollection::const_iterator debu=l1abcc.begin();debu!=l1abcc.end();++debu) {
            edm::LogPrint("L1AcceptBunchCrossingNoType") << *debu;
          }
        }
      }
      else {
        edm::LogError("L1AcceptBunchCrossingOffsetTooLarge") << " Too large orbit offset "
                                                             << orbitoffset << " " 
                                                             << l1abc->orbitNumber();
      }
    }
    else {
      edm::LogInfo("L1AcceptBunchCrossingNegativeEvent") << "L1AcceptBunchCrossing with negative event: ";
      for(L1AcceptBunchCrossingCollection::const_iterator debu=l1abcc.begin();debu!=l1abcc.end();++debu) {
        edm::LogVerbatim("L1AcceptBunchCrossingNegativeEvent") << *debu;
      }
    }
  }
  // look for the event itself
  if(tmpmap.find(0)!=tmpmap.end()) {
    
    TinyEvent::operator=(tmpmap[0]);
  
    // loop on the rest of the map and stop when it is missing
    // check that the events are in the right order and break if not

    int counter=-1;
    while(tmpmap.find(counter)!=tmpmap.end()) {

      if(tmpmap[counter+1].deltaBX(tmpmap[counter]) > 0) {
        _prevse.push_back(tmpmap[counter]);
        --counter;
      }
      else {
        edm::LogWarning("L1AcceptBunchCrossingNotInOrder") << "L1AcceptBunchCrossing not in order: ";
        for(L1AcceptBunchCrossingCollection::const_iterator debu=l1abcc.begin();debu!=l1abcc.end();++debu) {
          edm::LogPrint("L1AcceptBunchCrossingNotInOrder") << *debu;
        }
        break;
      }
    }
  }
  else {
    TinyEvent::operator=(event);
    edm::LogWarning("L1AcceptBunchCrossingNoCollection") << " L1AcceptBunchCrossing with offset=0 not found "
                                                         << " likely L1ABCCollection is empty ";
  }
  
}
EventWithHistory::EventWithHistory ( const EventWithHistory he)

Definition at line 110 of file EventWithHistory.cc.

: TinyEvent(he), _prevse(he._prevse) { }

Member Function Documentation

long long EventWithHistory::absoluteBX ( const unsigned int  ev1) const

Definition at line 225 of file EventWithHistory.cc.

References _prevse, and absoluteBX().

Referenced by EventWithHistoryFilter::is_selected().

                                                                   {

  if(ev1==0) return TinyEvent::absoluteBX();
  if(ev1<=_prevse.size()) return _prevse[ev1-1].absoluteBX();

  return -1;

}
long long EventWithHistory::absoluteBX ( ) const

Reimplemented from TinyEvent.

Definition at line 234 of file EventWithHistory.cc.

Referenced by absoluteBX().

                                             {

  return TinyEvent::absoluteBX();

}
long long EventWithHistory::absoluteBXinCycle ( const unsigned int  ev1,
const int  bx0 
) const

Definition at line 240 of file EventWithHistory.cc.

References _prevse.

Referenced by absoluteBXinCycle(), and EventWithHistoryFilter::is_selected().

                                                                                         {

  if(ev1==0) return TinyEvent::absoluteBXinCycle(bx0);
  if(ev1<=_prevse.size()) return _prevse[ev1-1].absoluteBXinCycle(bx0);

  return -1;

}
long long EventWithHistory::absoluteBXinCycle ( const int  bx0) const

Reimplemented from TinyEvent.

Definition at line 249 of file EventWithHistory.cc.

References absoluteBXinCycle().

                                                                 {

  return TinyEvent::absoluteBXinCycle(bx0);

}
int EventWithHistory::add ( const TinyEvent he,
const int  idepth 
)

Definition at line 150 of file EventWithHistory.cc.

References _prevse, abs, depth(), isFutureHistory(), and TinyEvent::isNextOf().

                                                               {

  bool isfuture = (idepth <0);
  const unsigned int adepth = abs(idepth);

  // protect against the possibility of filling with past and future history

  if( depth()>0 && ((isfuture && !isFutureHistory()) || (!isfuture && isFutureHistory()))) return 0; 

  if(adepth==0) return 0;
  if(_prevse.size()>= adepth) return 0;

  if(_prevse.size()==0) {
    if((!isfuture && isNextOf(se)) || (isfuture && se.isNextOf(*this))) {
      _prevse.push_back(se);
      return 1;
    }
    else {
      return 0;
    }
  }
  else {
    if((!isfuture && _prevse[_prevse.size()-1].isNextOf(se)) || (isfuture && se.isNextOf(_prevse[_prevse.size()-1]))) {
      _prevse.push_back(se);
      return 1;
    }
    else {
      return 0;
    }
  }    
  return 0;
}
int EventWithHistory::add ( const EventWithHistory he,
const int  idepth 
)

Definition at line 140 of file EventWithHistory.cc.

                                                                      {

  if(!add((const TinyEvent&) he,idepth)) return 0;

  for(std::vector<TinyEvent>::const_iterator ev=he._prevse.begin();ev!=he._prevse.end();ev++) {
    if(!add(*ev,idepth)) return 0;
  }
  return 1;
}
const int EventWithHistory::bx ( ) const

Definition at line 185 of file EventWithHistory.cc.

References TinyEvent::_bx.

{ return TinyEvent::_bx; } 
long long EventWithHistory::deltaBX ( const unsigned int  ev2,
const unsigned int  ev1 
) const

Definition at line 203 of file EventWithHistory.cc.

References _prevse, and deltaBX().

Referenced by EventWithHistoryFilter::is_selected().

                                                                                        {

  if(ev2==ev1) return 0;

  if(ev2<ev1 && ev1<=_prevse.size()) {
    if(ev2==0) return  TinyEvent::deltaBX(_prevse[ev1-1]);
    return _prevse[ev2-1].deltaBX(_prevse[ev1-1]);
  }

  return -1;
}
long long EventWithHistory::deltaBX ( const unsigned int  ev1) const

Definition at line 215 of file EventWithHistory.cc.

References deltaBX().

{  return deltaBX(0,ev1); }
long long EventWithHistory::deltaBX ( ) const

Definition at line 217 of file EventWithHistory.cc.

Referenced by deltaBX(), and EventWithHistory().

{  return deltaBX(0,1); }
long long EventWithHistory::deltaBX ( const TinyEvent se) const

Reimplemented from TinyEvent.

Definition at line 219 of file EventWithHistory.cc.

References deltaBX().

                                                             { 

 return TinyEvent::deltaBX(se); 

}
long long EventWithHistory::deltaBXinCycle ( const int  bx0) const

Definition at line 274 of file EventWithHistory.cc.

References deltaBXinCycle().

                                                              {
  return deltaBXinCycle(0,1,bx0);
}
long long EventWithHistory::deltaBXinCycle ( const TinyEvent se,
const int  bx0 
) const

Reimplemented from TinyEvent.

Definition at line 278 of file EventWithHistory.cc.

References deltaBXinCycle().

                                                                                   {

  return TinyEvent::deltaBXinCycle(se,bx0);

}
long long EventWithHistory::deltaBXinCycle ( const unsigned int  ev2,
const unsigned int  ev1,
const int  bx0 
) const

Definition at line 255 of file EventWithHistory.cc.

References _prevse.

Referenced by deltaBXinCycle(), and EventWithHistoryFilter::is_selected().

                                                                                                              {

  if(ev2==ev1 && ev1<=_prevse.size()) {
    if(ev2==0) return TinyEvent::deltaBXinCycle(*this,bx0);
    return _prevse[ev2-1].deltaBXinCycle(_prevse[ev1-1],bx0);
  }

  if(ev2<ev1 && ev1<=_prevse.size()) {
    if(ev2==0) return  TinyEvent::deltaBXinCycle(_prevse[ev1-1],bx0);
    return _prevse[ev2-1].deltaBXinCycle(_prevse[ev1-1],bx0);
  }

  return -1;
}
long long EventWithHistory::deltaBXinCycle ( const unsigned int  ev1,
const int  bx0 
) const

Definition at line 270 of file EventWithHistory.cc.

References deltaBXinCycle().

                                                                                      {
  return deltaBXinCycle(0,ev1,bx0);
}
unsigned int EventWithHistory::depth ( void  ) const

Definition at line 195 of file EventWithHistory.cc.

References _prevse.

Referenced by add(), EventWithHistoryFilter::is_selected(), isFutureHistory(), and operator==().

{ return _prevse.size(); }
const unsigned int EventWithHistory::event ( ) const

Definition at line 183 of file EventWithHistory.cc.

References TinyEvent::_event.

{ return TinyEvent::_event; } 
const TinyEvent * EventWithHistory::get ( const unsigned int  ev) const

Definition at line 187 of file EventWithHistory.cc.

References _prevse.

                                                                  {

  if(ev==0) return this;
  if(ev<=_prevse.size()) return &_prevse[ev-1];
  return 0;

}
bool EventWithHistory::isFutureHistory ( ) const

Definition at line 197 of file EventWithHistory.cc.

References _prevse, depth(), and TinyEvent::isNextOf().

Referenced by add().

                                             { 

  return (depth()>0 && _prevse[0].isNextOf(*this));

}
EventWithHistory & EventWithHistory::operator= ( const EventWithHistory he)

Definition at line 112 of file EventWithHistory.cc.

References _prevse.

Referenced by EventWithHistory().

                                                                        {

  if(this != &he) {
    TinyEvent::operator=(he);
    _prevse = he._prevse;
  }
  return *this;
}
int EventWithHistory::operator== ( const EventWithHistory other) const

Definition at line 123 of file EventWithHistory.cc.

References _prevse, depth(), and i.

                                                                    {

  int equal = TinyEvent::operator==(other);

  // depth is not checked anymore

  //  equal = equal && (depth() == other.depth());

  if(equal) {
    for(unsigned int i=0;i<((depth()<other.depth())?depth():other.depth());i++) {
      equal = equal && (_prevse[i] == other._prevse[i]);
    }
  }

  return equal;
}
const unsigned int EventWithHistory::orbit ( ) const

Definition at line 184 of file EventWithHistory.cc.

References TinyEvent::_orbit.

{ return TinyEvent::_orbit; } 

Member Data Documentation

std::vector<TinyEvent> EventWithHistory::_prevse [private]