void EventLog::printPartial(int n) { EL_Event* e = next; // find starting point if (n >= EventLogLength) n = EventLogLength - 1; for (int i = 0; i < n; i++, e = prevEvent(e, buf, bufEnd)) ; // skip empty entries i = 0; for (; e != next && e->name == noEvent; i++, e = nextEvent(e, buf, bufEnd)) ; int indent = 0; for (; i < n && e != next; i++, e = nextEvent(e, buf, bufEnd)) { char* s; switch (e->status) { case starting: s = "[ "; break; case ending: s = "] "; indent--; break; case atomic: s = "- "; break; } lprintf("%*.s%s", 2*indent, " ", s); lprintf(e->name, e->args[0], e->args[1], e->args[2]); lprintf("\n"); if (e->status == starting) indent++; } if (indent != nesting) lprintf("Actual event nesting is %ld greater than shown.\n", nesting - indent); }
void EventLog::printPartial(int32 n) { Event* e = next; // find starting point if (n >= EventLogLength) n = EventLogLength - 1; int32 i; for (i = 0; i < n; i++, e = prevEvent(e, buf, bufEnd)) ; // skip empty entries for (i = 0; e != next && e->name == noEvent; i++, e = nextEvent(e, buf, bufEnd)) ; int32 indent = 0; lprintf("Printing events from earliest to most recent:\n"); for (; i < n && e != next; i++, e = nextEvent(e, buf, bufEnd)) { const char* s; switch (e->status) { case starting: s = "{ "; break; case ending: s = "} "; indent--; break; case atomic: s = "= "; break; } lprintf("%*s%s", (void*)(2*indent), " ", s); lprintf(e->name, e->args[0], e->args[1], e->args[2]); lprintf("\n"); if (e->status == starting) indent++; } if (indent != nesting) lprintf("Actual event nesting is %ld greater than shown.\n", (void*)long(nesting - indent)); }
void EventLog::resize() { EL_Event* oldBuf = buf; EL_Event* oldEnd = bufEnd; EL_Event* oldNext = next; init(); // copy events for (EL_Event* e = nextEvent(oldNext, oldBuf, oldEnd); e != oldNext; e = nextEvent(e, oldBuf, oldEnd), next = nextEvent(next, buf, bufEnd)) { *next = *e; } FreeHeap( oldBuf); }
void EventLog::resize() { Event* oldBuf = buf; Event* oldEnd = bufEnd; Event* oldNext = next; init(); // copy events for (Event* e = nextEvent(oldNext, oldBuf, oldEnd); e != oldNext; e = nextEvent(e, oldBuf, oldEnd), next = nextEvent(next, buf, bufEnd)) { *next = *e; } FreeHeap( oldBuf); // cant use delete because this is an array -- dmu }
inline double nextEvent(const PolynomialFunction<3>& f) { if (f[3] == 0) return nextEvent(lowerOrder(f)); //Calculate and sort the roots of the overlap function std::array<double, 3> roots; const size_t nroots = magnet::math::cubicSolve(6 * f[2] / (2 * f[3]), 6 * f[1] / f[3], 6 * f[0] / f[3], roots[0], roots[1], roots[2]); std::sort(roots.begin(), roots.begin() + nroots); //Calculate and sort the roots of the overlap function's //derivative std::array<double, 2> derivroots; const size_t nderivroots = magnet::math::quadSolve(f[3], f[2], f[1], derivroots[0], derivroots[1]); if (derivroots[1] < derivroots[0]) std::swap(derivroots[0], derivroots[1]); if (f[3] > 0) { if (nderivroots == 0) return HUGE_VAL; if (derivroots[1] < 0) return HUGE_VAL; if ((nroots==1) && (roots[0] < derivroots[0])) return HUGE_VAL; return std::max(0.0, (nroots==3) ? roots[1] : derivroots[0]); } else /*(f[3] < 0)*/ { if (nderivroots == 0) return std::max(0.0, roots[0]); if ((derivroots[0] > 0) && (roots[0] < derivroots[0])) return std::max(0.0, roots[0]); return std::max(0.0, std::max(derivroots[1], roots[nroots-1])); } }
void ViewerDialog::createMenuAndActions() { title->getToolBar()->setVisible(true); mMenu = new QMenu(this); aBack = new QAction("&Previus", this); aBack->setStatusTip("Show previus item"); aBack->setIcon(QIcon(":/res/resources/back.png")); title->getToolBar()->addAction(aBack); mMenu->addAction(aBack); connect(aBack, SIGNAL(triggered()), this, SLOT(backEvent())); aNext = new QAction("&Next", this); aNext->setStatusTip("Show next item"); aNext->setIcon(QIcon(":/res/resources/next.png")); title->getToolBar()->addAction(aNext); mMenu->addAction(aNext); connect(aNext, SIGNAL(triggered()), this, SLOT(nextEvent())); aSlide = new QAction("&Start slide show", this); aSlide->setStatusTip("Start slide show"); aSlide->setIcon(QIcon(":/res/resources/play.png")); title->getToolBar()->addAction(aSlide); mMenu->addAction(aSlide); connect(aSlide, SIGNAL(triggered()), this, SLOT(slideEvent())); connect(title->getCloseAction(), SIGNAL(triggered()), this, SLOT(closeEvent())); }
int main(int argc, char** argv) { start_ana(argc, argv); /* -- We will save all in this tree --*/ TFile root_file("bMuD0X.root", "RECREATE"); TTree tree("tree", "all info."); EvtSaver evt_saver(tree); D0Finder d0_finder(tree); PtlFinder pi_finder("dpion", tree, false); PtlFinder mu_finder("muon", tree, true); BMuD0XFinder b_finder(tree, d0_finder, pi_finder, mu_finder); /* -- Initilization of geometry, field and beam spot. * Should be done after the fileLst or eventLst initilization -- */ AA::det.input(); AA::field.input(); AA::spot.input(); #if defined(P17) || defined(MC) // AA:ipcalib.input(); #endif AA::newEvent(); AA::newAnaEvent(); AA::newSelectEvent(); while (nextEvent()) { AA::setField(); //define beam-spot and field value AA::spot.set(); AA::analyse(); AA::select(AA::TAG); // std::cout << "Run:" << AA::runNumber << " Evt: " << AA::evtNumber << std::endl; if (!d0_finder.find()) continue; //std::cout << "JPsi" << std::endl; if (!pi_finder.find()) continue; //std::cout << "Phi" << std::endl; if (!mu_finder.find()) continue; if (!b_finder.find()) continue; b_finder.begin(); while (b_finder.next()){ b_finder.fill(); evt_saver.fill(); tree.Fill(); } AA::dst.outEventLst("bMuD0X_elist"); }//End while next event. tree.Write(); root_file.Write(); root_file.Close(); std::cout << argv[0] << " II: b_MuD0X_finder ended succesfully." << std::endl; std::exit(EXIT_SUCCESS); }
inline double nextEvent(const PolynomialFunction<4>& f, double f0char, double precision=1e-16) { if (f[4] == 0) return nextEvent(lowerOrder(f)); //Determine and sort the roots of the derivative std::array<double, 3> roots; const size_t rootCount = magnet::math::cubicSolve(3 * f[3] / f[4], 6 * f[2] / f[4], 6 * f[1] / f[4], roots[0], roots[1], roots[2]); std::sort(roots.begin(), roots.begin() + rootCount); const double rootthreshold = f0char * precision; auto bisectFunc = [&] (double t) { return f.eval(t); }; if (f[4] > 0) { if ((roots[0] > 0) && (f.eval(roots[0]) < 0)) { if (f.eval(0) <= 0) return 0; else return magnet::math::bisect(bisectFunc, 0, roots[0], rootthreshold); } if ((rootCount == 3) && (roots[2] > 0) && (f.eval(roots[2]) < 0)) { double tmin = std::max(0.0, roots[1]); if (f.eval(tmin) <= 0) return tmin; else return magnet::math::bisect(bisectFunc, tmin, roots[2], rootthreshold); } return HUGE_VAL; } else /*(f4 < 0)*/ { if ((rootCount == 3) && (roots[1] > 0) && (f.eval(roots[1]) < 0)) { double tmin = std::max(0.0, roots[0]); if (f.eval(tmin) <= 0) return tmin; else return magnet::math::bisect(bisectFunc, tmin, roots[1], rootthreshold); } double tlast = roots[rootCount - 1]; if (f.eval(tlast) <= 0) return std::max(0.0, tlast); if ((tlast < 0) && (f.eval(0) <= 0)) return 0; double t0 = std::max(0.0, tlast); double deltate = std::pow(- 24 * f0char / f[4], 0.25); while (f.eval(t0 + deltate) >= 0) { t0 += deltate; deltate *= 2; } return magnet::math::bisect(bisectFunc, t0, t0+deltate, rootthreshold); } }
EventViewer::EventViewer(QWidget *parent) : QWidget(parent) { EVLayout = new QVBoxLayout(this); m_data = 0; setMinimumHeight(500); titleLabel = new QLabel; setTitleLabel("DEMO"); EVLayout->addWidget(titleLabel); evt_plot = new Plot(this); rasterData = (SpectrogramData*) evt_plot->getSpectrogram()->data(); rasterData->resetData(); evt_plot->setMaximumSize(640,160); evt_plot->setMinimumSize(640,160); evt_plot->showContour(false); evt_plot->updateScale(); EVLayout->addWidget(evt_plot); btnLayout = new QHBoxLayout(); evtN_lab = new QLabel("Event N:",this); evtN_lcd = new QLCDNumber(6,this); integrate_chbx = new QCheckBox("Integrate",this); integrate_chbx->setProperty("isPixel",false); nextEvent_pbtn = new QPushButton(QIcon(":/images/next.png"),"Next",this); prevEvent_pbtn= new QPushButton(QIcon(":/images/prev.png"),"Prev",this);; rwd_pbtn = new QPushButton(QIcon(":/images/rew.png"),"RWD",this); fwd_pbtn = new QPushButton(QIcon(":/images/fwd.png"),"FWD",this); connect(nextEvent_pbtn, SIGNAL(clicked()), this, SLOT(nextEvent())); connect(prevEvent_pbtn, SIGNAL(clicked()), this, SLOT(prevEvent())); connect(rwd_pbtn, SIGNAL(clicked()), this, SLOT(rewindEvent())); connect(fwd_pbtn, SIGNAL(clicked()), this, SLOT(forwardEvent())); btnLayout->addWidget(evtN_lab); btnLayout->addWidget(evtN_lcd); btnLayout->addWidget(integrate_chbx); btnLayout->addWidget(prevEvent_pbtn); btnLayout->addWidget(nextEvent_pbtn); btnLayout->addWidget(rwd_pbtn); btnLayout->addWidget(fwd_pbtn); EVLayout->addLayout(btnLayout); evtView = new QTreeView(this); setupModel(); evtView->setColumnWidth(0 , 180); EVLayout->addWidget(evtView); }
bool LogFile::assertAfter(ACE_Time_Value const& _t) { bool valid = true; while (valid && coursor_->first <= _t) { valid = nextEvent(); } return valid; }
int getClick(){ XEvent event; XSync(display, true); // discard all previous clicks while(true){ nextEvent(event); if(event.type == ButtonPress){ return event.xbutton.x * 65536 + event.xbutton.y; } } }
void listen(){ ReplfsEvent event; ReplfsPacket packet; event.packet = &packet; while(true){ nextEvent(&event); if(event.type == HEARTBEAT_EVENT){ }else{ handlePacket(&(packet.body),packet.type); } } }
int main(void) { if (!openDisplay()) { return 1; } grab(getKeys(), getButtons()); while (1) { nextEvent(); processEvent(); } }
bool GtkClickCounter::shouldProcessButtonEvent(GdkEventButton* buttonEvent) { // For double and triple clicks GDK sends both a normal button press event // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press // coming up, ignore this event as it certainly generated the double or triple // click. The consequence of not eating this event is two DOM button press events // are generated. GUniquePtr<GdkEvent> nextEvent(gdk_event_peek()); if (!nextEvent) return true; if (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS) return false; return true; }
void ViewerDialog::tickEvent() { const QModelIndex& i2 = viewer->getModel().getNextItem(viewer->getCurrentRow()); if(isSlide && i2.isValid()) { nextEvent(); QTimer::singleShot(3000, this, SLOT(tickEvent())); } else { aSlide->setText("&Start slide show"); aSlide->setStatusTip("Start slide show"); aSlide->setIcon(QIcon(":/res/resources/play.png")); isSlide = false; } }
inline double nextEvent(const PolynomialFunction<2>& f) { if (f[2] == 0) return nextEvent(lowerOrder(f)); const double arg = f[1] * f[1] - 2 * f[2] * f[0]; if (f[2] < 0) { if (arg <= 0) return std::max(0.0, -f[1] / f[2]); if (f[1] > 0) return std::max(0.0, (-f[1] - std::sqrt(arg)) / f[2]); else return std::max(0.0, 2 * f[0] / (-f[1] + std::sqrt(arg))); } else /*(f[2] > 0)*/ { const double arg = f[1] * f[1] - 2 * f[2] * f[0]; if ((f[1] >= 0) || arg <= 0) return HUGE_VAL; return std::max(0.0, 2 * f[0] / (-f[1] + std::sqrt(arg))); } }
DECLARE_EXPORT Calendar::EventIterator& Calendar::EventIterator::operator++() { if (!theCalendar) throw LogicException("Can't walk forward on event iterator of NULL calendar."); // Go over all entries and ask them to update the iterator Date d = curDate; curDate = Date::infiniteFuture; for (const CalendarBucket *b = theCalendar->firstBucket; b; b = b->nextBucket) nextEvent(b, d); // Remember the bucket that won the evaluation lastBucket = curBucket; lastPriority = curPriority; return *this; }
void EventViewer::attachMatrixData(QPair<matrixData*, QString> inspectData) { m_data = inspectData.first; if (!matrixDataIsAvailable()) return; m_data->ResetReadPointer(); rasterData = new SpectrogramData(m_data->GetMatrixXSize(),m_data->GetMatrixYSize()); //setData delete previous rasterData if different evt_plot->getSpectrogram()->setData(rasterData); setTitleLabel(inspectData.second); //delete all children of matrixDataItem; deleteAllChildren(matrixDataItem); //set MData on model QList<QStandardItem *> row; row << new QStandardItem("X size")<< new QStandardItem(QString::number(m_data->GetMatrixXSize())); foreach (QStandardItem * item, row) item->setEditable(false); matrixDataItem->appendRow(row); row.clear(); row << new QStandardItem("Y size")<< new QStandardItem(QString::number(m_data->GetMatrixYSize())); foreach (QStandardItem * item, row) item->setEditable(false); matrixDataItem->appendRow(row); row.clear(); row << new QStandardItem("Events")<< new QStandardItem(QString::number(m_data->GetSize())); foreach (QStandardItem * item, row) item->setEditable(false); matrixDataItem->appendRow(row); eventsItem = row.at(0); row.clear(); nextEvent(); evtView->expandAll(); }
baseType pcoBase::callBack ( unsigned int eventSignature ) { if ( eventSignature == _fire_ ) { this->fire(); // return this->time + 1.0;// + gslNoise::getGaussian ( 0, numeric_limits<baseType>::epsilon() * 1000.0 ); this->upkeep(); return nextEvent() + period(); } else // if (eventSignature == _exciteRandomly_) { this->excite ( noiseIntensity() ); return this->time + gslNoise::getExponential ( noiseFrequency() ); } }
void CvPlayerAI::AI_doTurnPost() { AI_PERF_FORMAT("AI-perf.csv", ("CvPlayerAI::AI_doTurnPost, Turn %03d, %s", GC.getGame().getElapsedGameTurns(), getCivilizationShortDescription()) ); if(isHuman()) { return; } // EventEngine - v0.1, Snarko // DO NOT pass pEvent to AI_chooseEventOption. The event is deleted when an option has been chosen. int iLoop = 0; for(CvEvent* pEvent = firstEvent(&iLoop, false); pEvent != NULL; pEvent = nextEvent(&iLoop, false)) { AI_chooseEventOption(pEvent->GetID()); } // END EventEngine if(isBarbarian()) { return; } if(isMinorCiv()) { return; } for(int i = 0; i < GC.getNumVictoryInfos(); ++i) { AI_launch((VictoryTypes)i); } ProcessGreatPeople(); GetEspionageAI()->DoTurn(); GetTradeAI()->DoTurn(); }
double nextEvent() { return nextEvent(*this); }
int main(int argc, char** argv) { start_ana(argc, argv); /* -- We will save all in this tree --*/ TFile root_file("bs.root", "RECREATE"); TTree tree("tree", "all info."); #ifdef MC TTree treeMC("treeMC", "all mc info."); #endif EvtSaver evt_saver(tree); JPsiFinder jpsi_finder(tree); PhiFinder phi_finder(tree); #ifdef MC BsJPsiPhiMCFinder mc_finder(tree, treeMC); BsJPsiPhiFinder bs_finder(&jpsi_finder, &phi_finder, tree, &mc_finder); #else BsJPsiPhiFinder bs_finder(&jpsi_finder, &phi_finder, tree); #endif /* -- Initilization of geometry, field and beam spot. * Should be done after the fileLst or eventLst initilization -- */ AA::det.input(); AA::field.input(); AA::spot.input(); #if defined(P17) || defined(MC) AA:ipcalib.input(); #endif AA::newEvent(); AA::newAnaEvent(); AA::newSelectEvent(); while (nextEvent()) { AA::setField(); //define beam-spot and field value AA::spot.set(); AA::analyse(); AA::select(AA::TAG); //std::cout << "Run:" << AA::runNumber << " Evt: " << AA::evtNumber << std::endl; #ifdef MC mc_finder.find(); treeMC.Fill(); #endif if (!jpsi_finder.find()) continue; //std::cout << "JPsi" << std::endl; if (!phi_finder.find()) continue; //std::cout << "Phi" << std::endl; if (!bs_finder.find()) continue; bs_finder.begin(); while (bs_finder.next()){ bs_finder.fill(); evt_saver.fill(); tree.Fill(); } dst.outEventLst("bs_elist"); }//End while next event. tree.Write(); #ifdef MC treeMC.Write(); #endif root_file.Write(); root_file.Close(); std::cout << argv[0] << " II: bs_finder ended succesfully." << std::endl; std::exit(EXIT_SUCCESS); }
int main(int argc, char** argv) { static int mc = false; static int elist = false; const char *input_file = 0; int c; while (1) { static struct option long_options[] ={ /* These options set a flag. */ {"mc" , no_argument, &mc , 1}, {"elist" , no_argument, &elist , 1}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long(argc, argv, "i:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; case 'i': input_file = optarg; break; case '?': usage(); default: usage(); } } if (!input_file){ std::cout << argv[0] << " II: Missing input_file " << std::endl; usage(); } AA::newJob(); AA::newAnaJob(); AA::newSelectJob(); params(); AA::displayParameters(); bool ok = false; if (elist){ std::cout << argv[0] << " II: Doing event lists " << std::endl; ok = AA::dst.eventLst(input_file); } else { std::cout << argv[0] << " II: Doing sequential mode" << std::endl; ok = AA::dst.fileLst(input_file); } if (!ok) { std::cout << argv[0] << " EE: Input stream is not valid or is empty." << std::endl; exit(EXIT_FAILURE); } /* ================================ MAIN ===================================*/ /* -- We will save all in this tree --*/ TFile root_file("hh.root", "RECREATE"); TTree tree("tree", "all info."); TTree *treeMC=0; if (mc) treeMC = new TTree("treeMC", "all mc info."); EvtSaver evt_saver(tree); PtlFinder mu_finder("mu", tree, true); /* -- Initilization of geometry, field and beam spot. * Should be done after the fileLst or eventLst initilization -- */ AA::det.input(); AA::field.input(); AA::spot.input(); AA::newEvent(); AA::newAnaEvent(); AA::newSelectEvent(); while (nextEvent()) { AA::setField(); //define beam-spot and field value AA::spot.set(); AA::analyse(); AA::select(AA::TAG); //std::cout << "Run:" << AA::runNumber << " Evt: " << AA::evtNumber << std::endl; if (!mu_finder.find()) continue; while (mu_finder.next()){ AA::Ptl* muon = &mu_finder.getPtl(); if (muon->muon() /* || muon->muon()->nseg() != 3 */ || muon->pt() < 0.5) continue; double chi; AA::PtlMC* mc_muon = DecayMC::imatch(muon,chi); std::cout << "MU: " << DecayMC::getIdPdg(mc_muon) << ' '; AA::PtlMC* parent = mc_muon; while ( parent = DecayMC::getParent(parent) ) std::cout << DecayMC::getIdPdg(parent) << ' '; std::cout << std::endl; mu_finder.fill(); evt_saver.fill(); tree.Fill(); } AA::dst.outEventLst("hh_elist"); }//End while next event. tree.Write(); if (mc) treeMC->Write(); root_file.Write(); root_file.Close(); std::cout << argv[0] << " II: bs_finder ended succesfully." << std::endl; std::exit(EXIT_SUCCESS); }
bool OMXMLReaderExpat::next() { TRACE("OMXMLReaderExpat::next"); if (_status == false) { return _status; } while (_status && nextEvent() == NONE) { if (!_readNextChunk) { int ret = XML_ResumeParser(_parser); if (ret == XML_STATUS_ERROR) { XML_Error errorCode = XML_GetErrorCode(_parser); if (errorCode == XML_ERROR_NOT_SUSPENDED) { XML_ParsingStatus pStatus; XML_GetParsingStatus(_parser, &pStatus); if (pStatus.parsing == XML_FINISHED) { // finished _status = false; } else { _readNextChunk = true; } } else { throw OMException(getErrorString()); } } } if (_readNextChunk) { void* buffer = XML_GetBuffer(_parser, READ_CHUNK_SIZE); _numInBuffer = readNextChunk(buffer, READ_CHUNK_SIZE); int ret = XML_ParseBuffer(_parser, _numInBuffer, _numInBuffer < READ_CHUNK_SIZE); if (ret == XML_STATUS_ERROR) { throw OMException(getErrorString()); } if (_status) { XML_ParsingStatus pStatus; XML_GetParsingStatus(_parser, &pStatus); if (pStatus.parsing == XML_FINISHED) { if (_numInBuffer < READ_CHUNK_SIZE) { _status = false; } else { _readNextChunk = true; } } else { _readNextChunk = false; } } } } return _status; }
void inc() { next = nextEvent(next, buf, bufEnd); }
/* * doOperator - process an operator event */ static vi_rc doOperator( event *ev ) { event *next; vi_rc rc; long count; range range; int next_type; bool is_op_alias; rc = ERR_INVALID_OP; defaultRange( &range ); count = GetRepeatCount(); is_op_alias = ev->b.is_op_alias; if( is_op_alias ) { ev->rtn.alias( &ev, &next ); } else { next = nextEvent(); // a count is the only thing allowed to interfere between an op and // its argument so we just keep chewing... if( next != &EventList['0'] ) { while( next->b.is_number ) { if( EditFlags.Modeless ) { next->alt_rtn.old(); } else { next->rtn.old(); } next = nextEvent(); } } count *= GetRepeatCount(); } KillRepeatWindow(); if( EditFlags.Modeless ) { range.fix_range = next->alt_b.fix_range; next_type = next->alt_b.type; } else { range.fix_range = next->b.fix_range; next_type = next->b.type; } EditFlags.OperatorWantsMove = true; // was: if( count==1 ) if( next_type == EVENT_OP ) { // op/op only valid when ops are equal if( next == ev ) { rc = GetLineRange( &range, count, CurrentPos.line ); } } else { // it had better be a move operation if( next_type == EVENT_REL_MOVE || next_type == EVENT_ABS_MOVE ) { /* * Kluge! want 'ce' instead of 'cw' - this sucks. * * - even better kludge: if we are currently on white * space, then treat 'cw' as 'cw'. arrrrr. cge. */ if( ( ev == &EventList['c'] || ev == &EventList[VI_KEY( ALT_F1 )] ) && LastEvent == 'w' ) { EditFlags.IsChangeWord = true; if( CurrentLine != NULL ) { if( !isspace( CurrentLine->data[CurrentPos.column - 1] ) ) { next = &EventList['e']; range.fix_range = false; } } } if( EditFlags.Modeless ) { rc = next->alt_rtn.move( &range, count ); } else { rc = next->rtn.move( &range, count ); } EditFlags.IsChangeWord = false; } else { /* * Kluge! treat 'r' as a movement command. */ if( LastEvent == 'r' ) { rc = GetSelectedRegion( &range ); } else if( LastEvent == '0' ) { rc = MoveLineBegin( &range, 1 ); } else if( LastEvent == VI_KEY( ESC ) ) { rc = RANGE_REQUEST_CANCELLED; } } } EditFlags.OperatorWantsMove = false; if( rc == ERR_NO_ERR ) { if( ev->b.modifies ) { rc = ModificationTest(); } if( rc == ERR_NO_ERR ) { NormalizeRange( &range ); if( EditFlags.Modeless ) { rc = ev->alt_rtn.op( &range ); } else { rc = ev->rtn.op( &range ); } } } return( rc ); } /* doOperator */
static void * alarm_loop(void * closure) { schedule *sched = TheSchedule(); bitvector signalled; signalled.size = 4; signalled.bits = malloc(signalled.size*sizeof(int)); signalled.high = 0; pthread_mutex_lock(&mutex); /* for condition variable */ DEBUG(1, Sdprintf("Iterating alarm_loop()\n")); while( !sched->stop ) { Event ev = nextEvent(sched); struct timeval now; signalled.high = 0; gettimeofday(&now, NULL); for(; ev; ev = ev->next) { struct timeval left; left.tv_sec = ev->at.tv_sec - now.tv_sec; left.tv_usec = ev->at.tv_usec - now.tv_usec; if ( left.tv_usec < 0 ) { left.tv_sec--; left.tv_usec += 1000000; } if ( left.tv_sec < 0 || (left.tv_sec == 0 && left.tv_usec == 0) ) { if ( !is_set(&signalled, ev->pl_thread_id) ) { DEBUG(1, Sdprintf("Signalling (left = %ld) %d ...\n", (long)left.tv_sec, ev->pl_thread_id)); set_bit(&signalled, ev->pl_thread_id); #ifdef __WINDOWS__ PL_thread_raise(ev->pl_thread_id, SIG_TIME); #else pthread_kill(ev->thread_id, SIG_TIME); #endif } } else break; } if ( ev ) { int rc; struct timespec timeout; timeout.tv_sec = ev->at.tv_sec; timeout.tv_nsec = ev->at.tv_usec*1000; retry_timed_wait: DEBUG(1, Sdprintf("Waiting ...\n")); rc = pthread_cond_timedwait(&cond, &mutex, &timeout); switch( rc ) { case ETIMEDOUT: case 0: continue; case EINTR: goto retry_timed_wait; default: Sdprintf("alarm/4: pthread_cond_timedwait(): %s\n", strerror(rc)); assert(0); } } else { int rc; retry_wait: DEBUG(1, Sdprintf("No waiting events\n")); rc = pthread_cond_wait(&cond, &mutex); switch(rc) { case EINTR: goto retry_wait; case 0: continue; default: Sdprintf("alarm/4: pthread_cond_timedwait(): %s\n", strerror(rc)); assert(0); } } } return NULL; }
double nextEvent() const { return nextEvent(*this); }
int eEventDisplay::eventHandler(const eWidgetEvent &event) { int addtype=-1; switch (event.type) { case eWidgetEvent::evtAction: if (event.action == &i_cursorActions->left) { if (events) prevEvent(); else close(1); // this go the prev event and call exec() (in epgwindow.cpp) } else if (event.action == &i_cursorActions->right) { if (events) nextEvent(); else close(2); // this go the next event and call exec() (in epgwindow.cpp) } else if (total && event.action == &i_cursorActions->up) { ePoint curPos = long_description->getPosition(); if ( curPos.y() < 0 ) { long_description->move( ePoint( curPos.x(), curPos.y() + pageHeight ) ); updateScrollbar(); } } else if (total && event.action == &i_cursorActions->down) { ePoint curPos = long_description->getPosition(); if ( (total - pageHeight ) >= abs( curPos.y() - pageHeight ) ) { long_description->move( ePoint( curPos.x(), curPos.y() - pageHeight ) ); updateScrollbar(); } } else if (event.action == &i_enigmaEventViewActions->close) close(0); else if ( (addtype = i_epgSelectorActions->checkTimerActions( event.action )) != -1 ) ; else if ( event.action == &i_epgSelectorActions->removeTimerEvent) { if ((evt || events) && eTimerManager::getInstance()->removeEventFromTimerList( this, &ref, evt?evt:*events ) ) timer_icon->hide(); } else break; if ( valid >= 7 && addtype != -1 && (evt || events) && !eTimerManager::getInstance()->eventAlreadyInList(this, evt?*evt:*events, ref) ) { hide(); eTimerEditView v( evt?*evt:*events, addtype, ref ); v.show(); v.exec(); v.hide(); checkTimerIcon(evt?evt:*events); show(); } return 1; default: break; } return eWindow::eventHandler(event); }
int main(int argc, char** argv) { static int mc = false; static int elist = false; const char *input_file = 0; int c; while (1) { static struct option long_options[] ={ /* These options set a flag. */ {"mc" , no_argument, &mc , 1}, {"elist" , no_argument, &elist , 1}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long(argc, argv, "i:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; case 'i': input_file = optarg; break; case '?': usage(); default: usage(); } } if (!input_file){ std::cout << argv[0] << " II: Missing input_file " << std::endl; usage(); } AA::newJob(); AA::newAnaJob(); AA::newSelectJob(); params(); AA::displayParameters(); bool ok = false; if (elist){ std::cout << argv[0] << " II: Doing event lists " << std::endl; ok = AA::dst.eventLst(input_file); } else { std::cout << argv[0] << " II: Doing sequential mode" << std::endl; ok = AA::dst.fileLst(input_file); } if (!ok) { std::cout << argv[0] << " EE: Input stream is not valid or is empty." << std::endl; exit(EXIT_FAILURE); } /* ================================ MAIN ===================================*/ /* -- We will save all in this tree --*/ TFile root_file("upsilon.root", "RECREATE"); TTree tree("tree", "all info."); TTree *treeMC=0; if (mc) treeMC = new TTree("treeMC", "all mc info."); EvtSaver evt_saver(tree); UpsilonFinder upsilon_finder(tree); /* -- Initilization of geometry, field and beam spot. * Should be done after the fileLst or eventLst initilization -- */ AA::det.input(); AA::field.input(); AA::spot.input(); AA::newEvent(); AA::newAnaEvent(); AA::newSelectEvent(); unsigned long p_events = 0; while (nextEvent()) { p_events++; AA::setField(); //define beam-spot and field value AA::spot.set(); AA::analyse(); AA::select(AA::TAG); //std::cout << "Run:" << AA::runNumber << " Evt: " << AA::evtNumber << std::endl; if (!upsilon_finder.find()) continue; while (upsilon_finder.next()){ // std::cout << xyg_finder.getMass() << ' ' << std::endl; upsilon_finder.fill(); evt_saver.fill(); tree.Fill(); } AA::dst.outEventLst("upsilon_elist"); }//End while next event. tree.Write(); if (mc) treeMC->Write(); root_file.Write(); root_file.Close(); std::cout << argv[0] << " II: upsilon_finder ended. " << p_events << " events seen."<< std::endl; std::exit(EXIT_SUCCESS); }