void TimeWindowCreator::exec()
{
  //getting the data from event in apropriate format
  //const is commented because this class has inproper architecture:
  // all get-methods aren't tagged with const modifier
  if (auto evt = dynamic_cast </*const*/ EventIII * const > (getEvent())) {
    int ntdc = evt->GetTotalNTDCChannels();
    getStatistics().getHisto1D("ChannelsPerEvt").Fill( ntdc );
    JPetTimeWindow tslot;
    tslot.setIndex(fCurrEventNumber);
    auto tdcHits = evt->GetTDCChannelsArray();
    for (int i = 0; i < ntdc; ++i) {
      //const is commented because this class has inproper architecture:
      // all get-methods aren't tagged with const modifier
      auto tdcChannel = dynamic_cast </*const*/ TDCChannel * const > (tdcHits->At(i));
      auto tomb_number =  tdcChannel->GetChannel();
      if (tomb_number % 65 == 0) { // skip trigger signals from TRB
        continue;
      }
      if ( getParamBank().getTOMBChannels().count(tomb_number) == 0 ) {
        WARNING(Form("DAQ Channel %d appears in data but does not exist in the setup from DB.", tomb_number));
        continue;
      }
      JPetTOMBChannel& tomb_channel = getParamBank().getTOMBChannel(tomb_number);
      // one TDC channel may record multiple signals in one TSlot
      // iterate over all signals from one TDC channel
      // analyze number of hits per channel
      getStatistics().getHisto1D("HitsPerEvtCh").Fill( tdcChannel->GetHitsNum() );
      const int kNumHits = tdcChannel->GetHitsNum();
      for (int j = 0; j < kNumHits; ++j) {

        // check for unreasonable times
        // the times should be negative (measured w.r.t end of time window)
        // and not smaller than -1*timeWindowWidth (which can vary for different)
        // data but shoudl not exceed 1 ms, i.e. 1.e6 ns)
        if ( tdcChannel->GetLeadTime(j) > fMaxTime ||
             tdcChannel->GetLeadTime(j) < fMinTime )continue;
        if ( tdcChannel->GetTrailTime(j) > fMaxTime ||
             tdcChannel->GetTrailTime(j) < fMinTime )continue;

        JPetSigCh sigChTmpLead = generateSigCh(tomb_channel, JPetSigCh::Leading);
        JPetSigCh sigChTmpTrail = generateSigCh(tomb_channel, JPetSigCh::Trailing);

        // finally, set the times in ps [raw times are in ns]
        sigChTmpLead.setValue(tdcChannel->GetLeadTime(j) * 1000.);
        sigChTmpTrail.setValue(tdcChannel->GetTrailTime(j) * 1000.);
        tslot.addCh(sigChTmpLead);
        tslot.addCh(sigChTmpTrail);
      }
    }
    saveTimeWindow(tslot);
    fCurrEventNumber++;
  }
}
/**
* Sets up Signal Channel fields
*/
JPetSigCh TimeWindowCreatorTools::generateSigCh(
  double tdcChannelTime, const JPetTOMBChannel& channel,
  map<unsigned int, vector<double>>& timeCalibrationMap,
  map<unsigned int, vector<double>>& thresholdsMap,
  JPetSigCh::EdgeType edge, bool setTHRValuesFromChannels
) {
  JPetSigCh sigCh;
  sigCh.setValue(1000.*(tdcChannelTime
    + UniversalFileLoader::getConfigurationParameter(timeCalibrationMap, channel.getChannel())
  ));
  sigCh.setType(edge);
  sigCh.setTOMBChannel(channel);
  sigCh.setPM(channel.getPM());
  sigCh.setFEB(channel.getFEB());
  sigCh.setTRB(channel.getTRB());
  sigCh.setDAQch(channel.getChannel());
  sigCh.setThresholdNumber(channel.getLocalChannelNumber());
  if(setTHRValuesFromChannels) {
    sigCh.setThreshold(channel.getThreshold());
  } else {
    sigCh.setThreshold(
      UniversalFileLoader::getConfigurationParameter(thresholdsMap, channel.getChannel())
    );
  }
  return sigCh;
}