#include <iostream>

#include "QFramework/TQCounter.h"
#include "QFramework/TQStringUtils.h"
#include "TMath.h"

////////////////////////////////////////////////////////////////////////////////////////////////
//
// TQCounter
//
// A TQCounter is a counter for events, counting weighted und
// unweighted event numbers. In essence, it is the same as a histogram
// with a single bin, with a simplified interface.
//
////////////////////////////////////////////////////////////////////////////////////////////////

ClassImp(TQCounter)


//__________________________________________________________________________________|___________

TQCounter::TQCounter() : TNamed() {
  // default constructor, required by ROOT streamer
  reset();
}


//__________________________________________________________________________________|___________

TQCounter::TQCounter(const char * name) : TNamed(name, "") {
  // constructor taking only the object name
  reset();
}

//__________________________________________________________________________________|___________

TQCounter::TQCounter(const char * name, const char* title) : TNamed(name, title) {
  // constructor taking only the object name and title
  reset();
}


//__________________________________________________________________________________|___________

TQCounter::TQCounter(const TString& name, double cnt, double err) : TNamed(name.Data(), "") {
  // constructor taking object name as well as value and uncertainty
  reset();

  setCounter(cnt);
  setErrorSquared(err * err);
}

//__________________________________________________________________________________|___________

TQCounter::TQCounter(const TString& name, double cnt, double err, int raw) : TNamed(name.Data(), "") {
  // constructor taking object name as well as value and uncertainty
  reset();

  setCounter(cnt);
  setErrorSquared(err * err);
  setRawCounter(raw);

}


//__________________________________________________________________________________|___________

TQCounter::TQCounter(const TQCounter * counter) : TNamed(counter ? counter->GetName() : "TQCounter", counter ? counter->GetTitle() : "") {
  // Create an exact copy of a counter
 
  reset();
 
  /* get the status of the foreign counter */
  if (counter) {
    add(counter);
  }
 
}


//__________________________________________________________________________________|___________

void TQCounter::reset() {
  // Reset this counter

  fCounter = 0.;
  fErrorSquared = 0.;
  fRawCounter = 0;
  fWarning = false;
}


//__________________________________________________________________________________|___________

TString TQCounter::getAsString(const TString& options) const {
  // retrieve the contents of this counter 
  // as a nicely formatted string

  TString flags;
  TString localOptions = options;

  int precision = -1;
  bool hasPrecision = false;

  /* read flags */
  bool stop = false;
  while (!stop) {
    /* read precision flag "p" */
    if (TQStringUtils::readToken(localOptions, flags, "p") > 0) {
      /* read precision definition after 'p' option */
      TString precisionStr;
      if (TQStringUtils::readToken(localOptions, precisionStr,
                                   TQStringUtils::getNumerals()) > 0 && !hasPrecision) {
        precision = precisionStr.Atoi();
        hasPrecision = true;
        continue;
      } else {
        return "";
      }
    }

    /* no valid tokens left to parse */
    stop = true;
  }

  /* unexpected options left? */
  if (localOptions.Length() > 0)
    return "";

  /* prepare string of numbers */
  TString cnt = TString::Format("%.*g", precision, (double)getCounter());
  TString err = TString::Format("%.*g", precision, (double)getError());
  TString raw = TString::Format("%.*g", precision, (double)getRawCounter());

  if (precision > 0)
    precision += 1;

  /* return a string representing this counter */
  return TString::Format("%*s +/- %*s [raw: %*s]", precision, cnt.Data(),
                         precision, err.Data(), precision, raw.Data());
}


//__________________________________________________________________________________|___________

void TQCounter::print(const TString& options) const {
  // print a string representing this counter 
  this->printCounter(options);
}

//__________________________________________________________________________________|___________

void TQCounter::printCounter(const TString& options) const {
  // print a string representing this counter 
  std::cout << TString::Format("TQCounter('%s'): %s\n", GetName(),getAsString(options).Data()).Data();
}

//__________________________________________________________________________________|___________

double TQCounter::getCounter() const {
  // retrieve the value of this counter
  return fCounter;
}


//__________________________________________________________________________________|___________

void TQCounter::setCounter(double counter) {
  // set the value of this counter
  fCounter = counter;
}


//__________________________________________________________________________________|___________

void TQCounter::setRawCounter(int raw) {
  // set the raw value of this counter
  fRawCounter = raw;
}


//__________________________________________________________________________________|___________

double TQCounter::getError() const {
  // return the total error (uncertainty)

  return TMath::Sqrt(fErrorSquared);
}


//__________________________________________________________________________________|___________

double TQCounter::getErrorSquared() const {
  // return the total variance (square uncertainty)

  return fErrorSquared;
}


//__________________________________________________________________________________|___________

void TQCounter::setErrorSquared(double errorSquared) {
  // set the total variance (square uncertainty)
  if (errorSquared >= 0.)
    fErrorSquared = errorSquared;
}

//__________________________________________________________________________________|___________

void TQCounter::setError(double error) {
  // set the total uncertainty (sqrt(variance)). Please note that internally the 
  // squared value is stored, signs are therefore dropped
  fErrorSquared = pow(error,2);
}

//__________________________________________________________________________________|___________

double TQCounter::getStatError() const {
  // retrieve the statistical error
  // currently not implemented
  return 0.;
}


//__________________________________________________________________________________|___________

double TQCounter::getStatErrorSquared() const {
  // retrieve the statistical error
  // currently not implemented
  return 0.;
}


//__________________________________________________________________________________|___________

double TQCounter::getSysError() const {
  // retrieve the statistical error
  // currently not implemented
  return 0.;
}


//__________________________________________________________________________________|___________

double TQCounter::getSysErrorSquared() const {
  // retrieve the systematic error
  // currently not implemented
  return 0.;
}


//__________________________________________________________________________________|___________

int TQCounter::getRawCounter() const {
  // Return the number of raw counts

  return fRawCounter;
}


//__________________________________________________________________________________|___________

void TQCounter::setWarning(bool warning) {
  // set the 'warning' flag on this counter
  fWarning = warning;
}


//__________________________________________________________________________________|___________

bool TQCounter::getWarning()  const {
  // retrieve the value of the 'warning' flag
  return fWarning;
}


//__________________________________________________________________________________|___________

void TQCounter::add(double weight) {
  // add one entry with a given weight to this counter
  fCounter += weight;
  fErrorSquared += pow(weight, 2);
  fRawCounter += 1;
}


//__________________________________________________________________________________|___________

void TQCounter::add(const TQCounter * counter, double scale, double scaleUncertainty, double correlation, bool includeScaleUncertainty) {
  // add the contents of another counter to this one optionally including scale uncertainty and a possible correlation between the two counters.
  // "scale" is treated as being uncorrelated to "counter" and the TQCounter this method is called on.
  double scaleUncertSq = includeScaleUncertainty ? TMath::Power(scaleUncertainty,2) : 0. ;
  if (counter) {
    fCounter += scale * counter->getCounter();
    fErrorSquared += TMath::Power(scale, 2.) * counter->getErrorSquared() + TMath::Power(counter->getCounter(),2) * scaleUncertSq + 2. * correlation * scale * TMath::Sqrt(counter->getErrorSquared()) * TMath::Sqrt(fErrorSquared) ;
    fRawCounter += counter->getRawCounter();
    fWarning |= counter->getWarning();
  }
}

//__________________________________________________________________________________|___________

void TQCounter::add(const TQCounter * counter, TQCounter * scale, double correlation, bool includeScaleUncertainty) {
  // add the contents of another counter to this one optionally including scale uncertainty and a possible correlation between the two counters.
  // "scale" is treated as being uncorrelated to "counter" and the TQCounter this method is called on.
  if (counter) {
    this->add(counter, scale->getCounter(), scale->getError(), correlation, includeScaleUncertainty);
  }
}

//__________________________________________________________________________________|___________

void TQCounter::subtract(const TQCounter * counter, double scale, double scaleUncertainty, double correlation, bool includeScaleUncertainty) {
  // subtract the contents of another counter from this one optionally including scale uncertainty and a possible correlation between the two counters.
  // "scale" is treated as being uncorrelated to "counter" and the TQCounter this method is called on.
  double scaleUncertSq = includeScaleUncertainty ? TMath::Power(scaleUncertainty,2) : 0.;
  if (counter) {
    fCounter -= scale * counter->getCounter();
    fErrorSquared += TMath::Power(scale, 2.) * counter->getErrorSquared() + TMath::Power(counter->getCounter(),2) * scaleUncertSq - 2. * correlation * scale * TMath::Sqrt(counter->getErrorSquared()) * TMath::Sqrt(fErrorSquared) ; //note the -2*corrleation compared to +2*correlation in TQCounter::add(...) !
    fRawCounter += counter->getRawCounter();
    fWarning |= counter->getWarning();
  }
}

//__________________________________________________________________________________|___________

void TQCounter::subtract(const TQCounter * counter, TQCounter* scale, double correlation, bool includeScaleUncertainty) {
  // subtract the contents of another counter from this one optionally including scale uncertainty and a possible correlation between the two counters.
  // "scale" is treated as being uncorrelated to "counter" and the TQCounter this method is called on.
  if (counter) {
    this->subtract(counter, scale->getCounter(), scale->getError(), correlation, includeScaleUncertainty);
  }
}

//__________________________________________________________________________________|___________

void TQCounter::multiply(double factor, double uncertainty, double correlation, bool includeScaleUncertainty) {
  // multiply the contents of this counter with the contents of another one including correlation for the error propagation if given.
  double uncertSq = includeScaleUncertainty ? TMath::Power(uncertainty,2) : 0.;
  fErrorSquared = uncertSq*TMath::Power(fCounter,2) + TMath::Power(factor,2)*fErrorSquared + 2* correlation * factor * fCounter * TMath::Sqrt(uncertSq*fErrorSquared); //do not use the "easy to remember" version here, you might divide by zero!
  fCounter *= factor;
  fRawCounter = -1;
}

//__________________________________________________________________________________|___________

void TQCounter::multiply(const TQCounter * counter, double correlation, bool includeScaleUncertainty) {
  // multiply the contents of this counter with the contents of another one including correlation for the error propagation if given.
  if (counter) {
    this->multiply(counter->getCounter(), counter->getError(), correlation, includeScaleUncertainty);
    fWarning |= counter->getWarning();
  }
}

//__________________________________________________________________________________|___________

void TQCounter::divide(double denominator, double uncertainty, double correlation, bool includeScaleUncertainty) {
  // divide the contents of this counter by the contents of another one
  double uncertSq = includeScaleUncertainty ? TMath::Power(uncertainty,2) : 0.;
 
  fErrorSquared = TMath::Power(denominator,-2)*fErrorSquared + TMath::Power(fCounter/TMath::Power(denominator,2),2)*uncertSq - 2 * correlation * fCounter * TMath::Power(denominator,3) * TMath::Sqrt(fErrorSquared*uncertSq); //do not use the "easy to remember" version here, might divide by zero! (this version works if denominator != 0)
  fCounter /= denominator;
  fRawCounter = -1;
}

//__________________________________________________________________________________|___________

void TQCounter::divide(const TQCounter * counter, double correlation, bool includeScaleUncertainty) {
  // divide the contents of this counter by the contents of another one
  if (counter) {
    this->divide(counter->getCounter(), counter->getError(), correlation, includeScaleUncertainty);
    fWarning |= counter->getWarning();
  }
}

//__________________________________________________________________________________|___________

void TQCounter::scale(double factor, double scaleUncertainty, bool includeScaleUncertainty) {
  // scale this counter with some factor
  double uncertSq = includeScaleUncertainty ? TMath::Power(scaleUncertainty,2) : 0.;
  fErrorSquared = fErrorSquared * TMath::Power(factor,2) + uncertSq * TMath::Power(fCounter,2);
  fCounter *= factor;
}

//__________________________________________________________________________________|___________

void TQCounter::scale(const TQCounter * scalefactor, bool includeScaleUncertainty) {
  // scale this counter with some factor
  if (scalefactor) {
    this->scale(scalefactor->getCounter(), scalefactor->getError(), includeScaleUncertainty);
    fWarning |= scalefactor->getWarning();
  }
}
//__________________________________________________________________________________|___________

TString TQCounter::getComparison(TQCounter * cnt1, TQCounter * cnt2,
                                 bool colored, double order) {
  // compare to counters, retrieving an info string as result

  // the comparison string to return 
  TString comparison;

  // the color to apply 
  bool yellow = false;
  bool red = false;

  if (cnt1)
    comparison.Append("(1) ");
  else
    comparison.Append("( ) ");

  if (cnt1 && cnt2) {
    if (cnt1->isEqualTo(cnt2, order)) {
      comparison.Append("=");
    } else if (cnt1->isRawEqualTo(cnt2)) {
      comparison.Append("~");
      yellow = true;
    } else if (cnt1->getCounter() > cnt2->getCounter()) {
      comparison.Append(">");
      red = true;
    } else if (cnt1->getCounter() < cnt2->getCounter()) {
      comparison.Append("<");
      red = true;
    } else {
      comparison.Append("?");
      red = true;
    }
  } else {
    comparison.Append(" ");
    red = true;
  }

  if (cnt2)
    comparison.Append(" (2)");
  else
    comparison.Append(" ( )");

  // return the comparison string 
  if (!colored)
    return comparison;
  else if (yellow)
    return TQStringUtils::makeBoldYellow(comparison);
  else if (red)
    return TQStringUtils::makeBoldRed(comparison);
  else 
    return TQStringUtils::makeBoldGreen(comparison);
}


//__________________________________________________________________________________|___________

bool TQCounter::isEqualTo(TQCounter * counter, double order) {
  // check if two counters are equal (up to some precision)

  // stop if raw numbers are not equal 
  if (!isRawEqualTo(counter))
    return false;

  // stop if weighted numbers are not equal ~O(order) 
  if (!TMath::AreEqualRel(getCounter(), counter->getCounter(), order))
    return false;

  // stop if errors are not equal ~O(order) 
  if (!TMath::AreEqualRel(getError(), counter->getError(), order))
    return false;

  // counter seem to be equal 
  return true;
}


//__________________________________________________________________________________|___________

bool TQCounter::isRawEqualTo(TQCounter * counter) {
  // check if the raw counts of two counters are the same

  // stop if counter is invalid 
  if (!counter)
    return false;

  // stop if raw numbers are not equal 
  if (getRawCounter() != counter->getRawCounter())
    return false;

  // raw counter seem to be equal 
  return true;
}


//__________________________________________________________________________________|___________

TQCounter::~TQCounter() {
  // default destructor
}
 TQCounter.cxx:1
 TQCounter.cxx:2
 TQCounter.cxx:3
 TQCounter.cxx:4
 TQCounter.cxx:5
 TQCounter.cxx:6
 TQCounter.cxx:7
 TQCounter.cxx:8
 TQCounter.cxx:9
 TQCounter.cxx:10
 TQCounter.cxx:11
 TQCounter.cxx:12
 TQCounter.cxx:13
 TQCounter.cxx:14
 TQCounter.cxx:15
 TQCounter.cxx:16
 TQCounter.cxx:17
 TQCounter.cxx:18
 TQCounter.cxx:19
 TQCounter.cxx:20
 TQCounter.cxx:21
 TQCounter.cxx:22
 TQCounter.cxx:23
 TQCounter.cxx:24
 TQCounter.cxx:25
 TQCounter.cxx:26
 TQCounter.cxx:27
 TQCounter.cxx:28
 TQCounter.cxx:29
 TQCounter.cxx:30
 TQCounter.cxx:31
 TQCounter.cxx:32
 TQCounter.cxx:33
 TQCounter.cxx:34
 TQCounter.cxx:35
 TQCounter.cxx:36
 TQCounter.cxx:37
 TQCounter.cxx:38
 TQCounter.cxx:39
 TQCounter.cxx:40
 TQCounter.cxx:41
 TQCounter.cxx:42
 TQCounter.cxx:43
 TQCounter.cxx:44
 TQCounter.cxx:45
 TQCounter.cxx:46
 TQCounter.cxx:47
 TQCounter.cxx:48
 TQCounter.cxx:49
 TQCounter.cxx:50
 TQCounter.cxx:51
 TQCounter.cxx:52
 TQCounter.cxx:53
 TQCounter.cxx:54
 TQCounter.cxx:55
 TQCounter.cxx:56
 TQCounter.cxx:57
 TQCounter.cxx:58
 TQCounter.cxx:59
 TQCounter.cxx:60
 TQCounter.cxx:61
 TQCounter.cxx:62
 TQCounter.cxx:63
 TQCounter.cxx:64
 TQCounter.cxx:65
 TQCounter.cxx:66
 TQCounter.cxx:67
 TQCounter.cxx:68
 TQCounter.cxx:69
 TQCounter.cxx:70
 TQCounter.cxx:71
 TQCounter.cxx:72
 TQCounter.cxx:73
 TQCounter.cxx:74
 TQCounter.cxx:75
 TQCounter.cxx:76
 TQCounter.cxx:77
 TQCounter.cxx:78
 TQCounter.cxx:79
 TQCounter.cxx:80
 TQCounter.cxx:81
 TQCounter.cxx:82
 TQCounter.cxx:83
 TQCounter.cxx:84
 TQCounter.cxx:85
 TQCounter.cxx:86
 TQCounter.cxx:87
 TQCounter.cxx:88
 TQCounter.cxx:89
 TQCounter.cxx:90
 TQCounter.cxx:91
 TQCounter.cxx:92
 TQCounter.cxx:93
 TQCounter.cxx:94
 TQCounter.cxx:95
 TQCounter.cxx:96
 TQCounter.cxx:97
 TQCounter.cxx:98
 TQCounter.cxx:99
 TQCounter.cxx:100
 TQCounter.cxx:101
 TQCounter.cxx:102
 TQCounter.cxx:103
 TQCounter.cxx:104
 TQCounter.cxx:105
 TQCounter.cxx:106
 TQCounter.cxx:107
 TQCounter.cxx:108
 TQCounter.cxx:109
 TQCounter.cxx:110
 TQCounter.cxx:111
 TQCounter.cxx:112
 TQCounter.cxx:113
 TQCounter.cxx:114
 TQCounter.cxx:115
 TQCounter.cxx:116
 TQCounter.cxx:117
 TQCounter.cxx:118
 TQCounter.cxx:119
 TQCounter.cxx:120
 TQCounter.cxx:121
 TQCounter.cxx:122
 TQCounter.cxx:123
 TQCounter.cxx:124
 TQCounter.cxx:125
 TQCounter.cxx:126
 TQCounter.cxx:127
 TQCounter.cxx:128
 TQCounter.cxx:129
 TQCounter.cxx:130
 TQCounter.cxx:131
 TQCounter.cxx:132
 TQCounter.cxx:133
 TQCounter.cxx:134
 TQCounter.cxx:135
 TQCounter.cxx:136
 TQCounter.cxx:137
 TQCounter.cxx:138
 TQCounter.cxx:139
 TQCounter.cxx:140
 TQCounter.cxx:141
 TQCounter.cxx:142
 TQCounter.cxx:143
 TQCounter.cxx:144
 TQCounter.cxx:145
 TQCounter.cxx:146
 TQCounter.cxx:147
 TQCounter.cxx:148
 TQCounter.cxx:149
 TQCounter.cxx:150
 TQCounter.cxx:151
 TQCounter.cxx:152
 TQCounter.cxx:153
 TQCounter.cxx:154
 TQCounter.cxx:155
 TQCounter.cxx:156
 TQCounter.cxx:157
 TQCounter.cxx:158
 TQCounter.cxx:159
 TQCounter.cxx:160
 TQCounter.cxx:161
 TQCounter.cxx:162
 TQCounter.cxx:163
 TQCounter.cxx:164
 TQCounter.cxx:165
 TQCounter.cxx:166
 TQCounter.cxx:167
 TQCounter.cxx:168
 TQCounter.cxx:169
 TQCounter.cxx:170
 TQCounter.cxx:171
 TQCounter.cxx:172
 TQCounter.cxx:173
 TQCounter.cxx:174
 TQCounter.cxx:175
 TQCounter.cxx:176
 TQCounter.cxx:177
 TQCounter.cxx:178
 TQCounter.cxx:179
 TQCounter.cxx:180
 TQCounter.cxx:181
 TQCounter.cxx:182
 TQCounter.cxx:183
 TQCounter.cxx:184
 TQCounter.cxx:185
 TQCounter.cxx:186
 TQCounter.cxx:187
 TQCounter.cxx:188
 TQCounter.cxx:189
 TQCounter.cxx:190
 TQCounter.cxx:191
 TQCounter.cxx:192
 TQCounter.cxx:193
 TQCounter.cxx:194
 TQCounter.cxx:195
 TQCounter.cxx:196
 TQCounter.cxx:197
 TQCounter.cxx:198
 TQCounter.cxx:199
 TQCounter.cxx:200
 TQCounter.cxx:201
 TQCounter.cxx:202
 TQCounter.cxx:203
 TQCounter.cxx:204
 TQCounter.cxx:205
 TQCounter.cxx:206
 TQCounter.cxx:207
 TQCounter.cxx:208
 TQCounter.cxx:209
 TQCounter.cxx:210
 TQCounter.cxx:211
 TQCounter.cxx:212
 TQCounter.cxx:213
 TQCounter.cxx:214
 TQCounter.cxx:215
 TQCounter.cxx:216
 TQCounter.cxx:217
 TQCounter.cxx:218
 TQCounter.cxx:219
 TQCounter.cxx:220
 TQCounter.cxx:221
 TQCounter.cxx:222
 TQCounter.cxx:223
 TQCounter.cxx:224
 TQCounter.cxx:225
 TQCounter.cxx:226
 TQCounter.cxx:227
 TQCounter.cxx:228
 TQCounter.cxx:229
 TQCounter.cxx:230
 TQCounter.cxx:231
 TQCounter.cxx:232
 TQCounter.cxx:233
 TQCounter.cxx:234
 TQCounter.cxx:235
 TQCounter.cxx:236
 TQCounter.cxx:237
 TQCounter.cxx:238
 TQCounter.cxx:239
 TQCounter.cxx:240
 TQCounter.cxx:241
 TQCounter.cxx:242
 TQCounter.cxx:243
 TQCounter.cxx:244
 TQCounter.cxx:245
 TQCounter.cxx:246
 TQCounter.cxx:247
 TQCounter.cxx:248
 TQCounter.cxx:249
 TQCounter.cxx:250
 TQCounter.cxx:251
 TQCounter.cxx:252
 TQCounter.cxx:253
 TQCounter.cxx:254
 TQCounter.cxx:255
 TQCounter.cxx:256
 TQCounter.cxx:257
 TQCounter.cxx:258
 TQCounter.cxx:259
 TQCounter.cxx:260
 TQCounter.cxx:261
 TQCounter.cxx:262
 TQCounter.cxx:263
 TQCounter.cxx:264
 TQCounter.cxx:265
 TQCounter.cxx:266
 TQCounter.cxx:267
 TQCounter.cxx:268
 TQCounter.cxx:269
 TQCounter.cxx:270
 TQCounter.cxx:271
 TQCounter.cxx:272
 TQCounter.cxx:273
 TQCounter.cxx:274
 TQCounter.cxx:275
 TQCounter.cxx:276
 TQCounter.cxx:277
 TQCounter.cxx:278
 TQCounter.cxx:279
 TQCounter.cxx:280
 TQCounter.cxx:281
 TQCounter.cxx:282
 TQCounter.cxx:283
 TQCounter.cxx:284
 TQCounter.cxx:285
 TQCounter.cxx:286
 TQCounter.cxx:287
 TQCounter.cxx:288
 TQCounter.cxx:289
 TQCounter.cxx:290
 TQCounter.cxx:291
 TQCounter.cxx:292
 TQCounter.cxx:293
 TQCounter.cxx:294
 TQCounter.cxx:295
 TQCounter.cxx:296
 TQCounter.cxx:297
 TQCounter.cxx:298
 TQCounter.cxx:299
 TQCounter.cxx:300
 TQCounter.cxx:301
 TQCounter.cxx:302
 TQCounter.cxx:303
 TQCounter.cxx:304
 TQCounter.cxx:305
 TQCounter.cxx:306
 TQCounter.cxx:307
 TQCounter.cxx:308
 TQCounter.cxx:309
 TQCounter.cxx:310
 TQCounter.cxx:311
 TQCounter.cxx:312
 TQCounter.cxx:313
 TQCounter.cxx:314
 TQCounter.cxx:315
 TQCounter.cxx:316
 TQCounter.cxx:317
 TQCounter.cxx:318
 TQCounter.cxx:319
 TQCounter.cxx:320
 TQCounter.cxx:321
 TQCounter.cxx:322
 TQCounter.cxx:323
 TQCounter.cxx:324
 TQCounter.cxx:325
 TQCounter.cxx:326
 TQCounter.cxx:327
 TQCounter.cxx:328
 TQCounter.cxx:329
 TQCounter.cxx:330
 TQCounter.cxx:331
 TQCounter.cxx:332
 TQCounter.cxx:333
 TQCounter.cxx:334
 TQCounter.cxx:335
 TQCounter.cxx:336
 TQCounter.cxx:337
 TQCounter.cxx:338
 TQCounter.cxx:339
 TQCounter.cxx:340
 TQCounter.cxx:341
 TQCounter.cxx:342
 TQCounter.cxx:343
 TQCounter.cxx:344
 TQCounter.cxx:345
 TQCounter.cxx:346
 TQCounter.cxx:347
 TQCounter.cxx:348
 TQCounter.cxx:349
 TQCounter.cxx:350
 TQCounter.cxx:351
 TQCounter.cxx:352
 TQCounter.cxx:353
 TQCounter.cxx:354
 TQCounter.cxx:355
 TQCounter.cxx:356
 TQCounter.cxx:357
 TQCounter.cxx:358
 TQCounter.cxx:359
 TQCounter.cxx:360
 TQCounter.cxx:361
 TQCounter.cxx:362
 TQCounter.cxx:363
 TQCounter.cxx:364
 TQCounter.cxx:365
 TQCounter.cxx:366
 TQCounter.cxx:367
 TQCounter.cxx:368
 TQCounter.cxx:369
 TQCounter.cxx:370
 TQCounter.cxx:371
 TQCounter.cxx:372
 TQCounter.cxx:373
 TQCounter.cxx:374
 TQCounter.cxx:375
 TQCounter.cxx:376
 TQCounter.cxx:377
 TQCounter.cxx:378
 TQCounter.cxx:379
 TQCounter.cxx:380
 TQCounter.cxx:381
 TQCounter.cxx:382
 TQCounter.cxx:383
 TQCounter.cxx:384
 TQCounter.cxx:385
 TQCounter.cxx:386
 TQCounter.cxx:387
 TQCounter.cxx:388
 TQCounter.cxx:389
 TQCounter.cxx:390
 TQCounter.cxx:391
 TQCounter.cxx:392
 TQCounter.cxx:393
 TQCounter.cxx:394
 TQCounter.cxx:395
 TQCounter.cxx:396
 TQCounter.cxx:397
 TQCounter.cxx:398
 TQCounter.cxx:399
 TQCounter.cxx:400
 TQCounter.cxx:401
 TQCounter.cxx:402
 TQCounter.cxx:403
 TQCounter.cxx:404
 TQCounter.cxx:405
 TQCounter.cxx:406
 TQCounter.cxx:407
 TQCounter.cxx:408
 TQCounter.cxx:409
 TQCounter.cxx:410
 TQCounter.cxx:411
 TQCounter.cxx:412
 TQCounter.cxx:413
 TQCounter.cxx:414
 TQCounter.cxx:415
 TQCounter.cxx:416
 TQCounter.cxx:417
 TQCounter.cxx:418
 TQCounter.cxx:419
 TQCounter.cxx:420
 TQCounter.cxx:421
 TQCounter.cxx:422
 TQCounter.cxx:423
 TQCounter.cxx:424
 TQCounter.cxx:425
 TQCounter.cxx:426
 TQCounter.cxx:427
 TQCounter.cxx:428
 TQCounter.cxx:429
 TQCounter.cxx:430
 TQCounter.cxx:431
 TQCounter.cxx:432
 TQCounter.cxx:433
 TQCounter.cxx:434
 TQCounter.cxx:435
 TQCounter.cxx:436
 TQCounter.cxx:437
 TQCounter.cxx:438
 TQCounter.cxx:439
 TQCounter.cxx:440
 TQCounter.cxx:441
 TQCounter.cxx:442
 TQCounter.cxx:443
 TQCounter.cxx:444
 TQCounter.cxx:445
 TQCounter.cxx:446
 TQCounter.cxx:447
 TQCounter.cxx:448
 TQCounter.cxx:449
 TQCounter.cxx:450
 TQCounter.cxx:451
 TQCounter.cxx:452
 TQCounter.cxx:453
 TQCounter.cxx:454
 TQCounter.cxx:455
 TQCounter.cxx:456
 TQCounter.cxx:457
 TQCounter.cxx:458
 TQCounter.cxx:459
 TQCounter.cxx:460
 TQCounter.cxx:461
 TQCounter.cxx:462
 TQCounter.cxx:463
 TQCounter.cxx:464
 TQCounter.cxx:465
 TQCounter.cxx:466
 TQCounter.cxx:467
 TQCounter.cxx:468
 TQCounter.cxx:469
 TQCounter.cxx:470
 TQCounter.cxx:471
 TQCounter.cxx:472
 TQCounter.cxx:473
 TQCounter.cxx:474
 TQCounter.cxx:475
 TQCounter.cxx:476
 TQCounter.cxx:477
 TQCounter.cxx:478
 TQCounter.cxx:479
 TQCounter.cxx:480
 TQCounter.cxx:481
 TQCounter.cxx:482
 TQCounter.cxx:483
 TQCounter.cxx:484
 TQCounter.cxx:485
 TQCounter.cxx:486
 TQCounter.cxx:487
 TQCounter.cxx:488
 TQCounter.cxx:489
 TQCounter.cxx:490
 TQCounter.cxx:491
 TQCounter.cxx:492
 TQCounter.cxx:493
 TQCounter.cxx:494