const ParseState * ParseState::operator()(Packet *pkt, const char *data, size_t *bytes_parsed) const { // TODO(antonin) // this is temporary while we experiment with the debugger DEBUGGER_NOTIFY_CTR( Debugger::PacketId::make(pkt->get_packet_id(), pkt->get_copy_id()), DBG_CTR_PARSE_STATE | get_id()); auto next_state = find_next_state(pkt, data, bytes_parsed); DEBUGGER_NOTIFY_CTR( Debugger::PacketId::make(pkt->get_packet_id(), pkt->get_copy_id()), DBG_CTR_EXIT(DBG_CTR_PARSE_STATE) | get_id()); return next_state; }
SimulatedTrack TrackSimulator::track_particle(Particle pt, const double final_en) const { std::vector<Vector3D> pos, mom; std::vector<double> time, en, de, azi, pol; double current_time {0}; double pos_step {1e-3}; pos.push_back(pt.position); mom.push_back(pt.get_momentum()); time.push_back(current_time); en.push_back(pt.energy / pt.charge_num); de.push_back(0); azi.push_back(pt.azimuth); pol.push_back(pt.polar); bool done {false}; for (int i = 0; not done; i++) { double tstep = pos_step / (pt.get_beta() * Constants::c_lgt); pt = find_next_state(pt, tstep); if (pt.energy <= final_en) { done = true; } pos.push_back(pt.position); mom.push_back(pt.get_momentum()); en.push_back(pt.energy / pt.mass_num); de.push_back(en[i-1] - en[i]); azi.push_back(pt.azimuth); pol.push_back(pt.polar); current_time += tstep; time.push_back(current_time); if (pt.position.z > 1 or pt.position.z < 0 or sqrt(pt.position.x*pt.position.x + pt.position.y*pt.position.y) > 0.275) { done = true; } } SimulatedTrack res {pos, mom, time, en, de, azi, pol}; return res; }
int lr_sort_dialog (lrnode *listhead, lrstat *stats) { int feedback = 0, actions, /* Nbr actions for this event */ scan; /* Index used for scanning */ lrnode *state, /* Pointer to state in dialog list */ *cmpstate, /* Pointer to state in dialog list */ *event, /* Pointer to event */ *nextstate, /* Pointer to next state */ *module; /* Pointer to module */ Bool used; /* State used in dialog? */ char *symptr; /* Pointer into symbol table */ ASSERT (listhead != NULL); ASSERT (stats != NULL); stats-> snames = (char **) Check (calloc (LR_STATEMAX, sizeof (char *))); stats-> enames = (char **) Check (calloc (LR_EVENTMAX, sizeof (char *))); stats-> mnames = (char **) Check (calloc (LR_MODULEMAX, sizeof (char *))); /* Remove any unused states from dialog */ for (state = listhead-> child; state; state = state-> next) { /* Ignore first state and defaults state */ if (state != listhead-> child && strneq (state-> name, OPT_DEFAULTS.value)) { used = FALSE; for (cmpstate = listhead-> child; cmpstate && !used; cmpstate = cmpstate-> next) if (cmpstate != state) for (event = cmpstate-> child; event && !used; event = event-> next) { nextstate = event-> child; if (streq (nextstate-> name, state-> name)) used = TRUE; } if (!used && OPT_COMPRESS.flags & OPT_ON) DeleteState (listhead, state); } } /* Collect and sort states, events, and modules */ stats-> states = collect_names (listhead, 's', stats-> snames, 0); stats-> events = collect_names (listhead, 'e', stats-> enames, 1); stats-> modules = collect_names (listhead, 'm', stats-> mnames, OPT_SORT.flags & OPT_ON? 1: 0); stats-> maxaction = 0; /* Find defaults state */ stats-> defaults = LR_NULL_STATE; /* Assume none defined */ for (scan = 0; stats-> snames [scan]; scan++) if (streq (stats-> snames [scan], OPT_DEFAULTS.value)) stats-> defaults = scan; /* Perform a few checks on the dialog */ /* - next state cannot be initial state */ /* - same state does not exist twice */ for (state = listhead-> child; state; state = state-> next) { for (cmpstate = state-> next; cmpstate; cmpstate = cmpstate-> next) if (streq (state-> name, cmpstate-> name)) PrintMessage (MSG_DUPLICATE_STATE, state-> name); for (event = state-> child; event; event = event-> next) { nextstate = event-> child; if (streq (listhead-> child-> name, nextstate-> name) && strneq (listhead-> child-> name, state-> name)) PrintMessage (MSG_NEXT_STATE_NFG, nextstate-> name); } } /* Insert numberings into list of states/events/modules */ for (state = listhead-> child; state; state = state-> next) { state-> number = GetSymNumber (state-> name); for (event = state-> child; event; event = event-> next) { event-> number = GetSymNumber (event-> name); actions = 0; nextstate = event-> child; find_next_state (nextstate, stats-> snames, state-> number); for (module = nextstate-> next; module; module = module-> next) { actions++; module-> number = GetSymNumber (module-> name); } if (stats-> maxaction < actions) stats-> maxaction = actions; } } /* Report dialog statistics if necessary */ if (OPT_STATS.flags & OPT_ON) { /* Find size of symbol table */ for (symptr = listhead-> name; *symptr; ) symptr = strchr (symptr + 3, 0) + 1; PrintMessage (MSG_STATS, stats-> states, stats-> events, stats-> modules); PrintMessage (MSG_SYM_USED, (int) (symptr - listhead-> name) / (LR_SYMBOLMAX / 100)); } return (feedback); }