+ Block *block = &**i;
+ list<Sensor *> sensors;
+
+ /* Collect all sensors from the block in the order they are expected to
+ detrigger. */
+ for(TrackIter j=i->track_iter(); (j && &j->get_block()==block); j=j.next())
+ if(!j->get_attachments().empty())
+ {
+ Track::AttachmentList attachments = j->get_attachments_ordered(j.entry());
+ for(Track::AttachmentList::const_iterator k=attachments.begin(); k!=attachments.end(); ++k)
+ if(BeamGate *gate = dynamic_cast<BeamGate *>(*k))
+ sensors.push_back(gate);
+ }
+
+ if(Sensor *sensor = (*i)->get_sensor())
+ sensors.push_back(sensor);
+
+ /* See if any sensor is still active, and record the position of the
+ last inactive sensor. */
+ bool active_sensor = false;
+ for(list<Sensor *>::const_iterator j=sensors.begin(); (!active_sensor && j!=sensors.end()); ++j)