diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 0dc60e35..2616ea1b 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -38,7 +38,6 @@ #include #include -using namespace std; #include #include @@ -93,9 +92,9 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UIn fPacking = fMsrInfo->GetMsrGlobal()->GetPacking(); } if (fPacking == -1) { // this should NOT happen, somethin is severely wrong - cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **SEVERE ERROR**: Couldn't find any packing information!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PRunAsymmetry(): **SEVERE ERROR**: Couldn't find any packing information!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; return; } @@ -106,16 +105,16 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UIn // check if alpha is given if (fRunInfo->GetAlphaParamNo() == -1) { // no alpha given - cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!"; + std::cerr << std::endl; fValid = false; return; } // check if alpha parameter is within proper bounds - if ((fRunInfo->GetAlphaParamNo() < 0) || (fRunInfo->GetAlphaParamNo() > (Int_t)param->size())) { - cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** alpha parameter no = " << fRunInfo->GetAlphaParamNo(); - cerr << endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; - cerr << endl; + if ((fRunInfo->GetAlphaParamNo() < 0) || (fRunInfo->GetAlphaParamNo() > static_cast(param->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** alpha parameter no = " << fRunInfo->GetAlphaParamNo(); + std::cerr << std::endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; + std::cerr << std::endl; fValid = false; return; } @@ -129,10 +128,10 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UIn Bool_t betaFixedToOne = false; if (fRunInfo->GetBetaParamNo() == -1) { // no beta given hence assuming beta == 1 betaFixedToOne = true; - } else if ((fRunInfo->GetBetaParamNo() < 0) || (fRunInfo->GetBetaParamNo() > (Int_t)param->size())) { // check if beta parameter is within proper bounds - cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** beta parameter no = " << fRunInfo->GetBetaParamNo(); - cerr << endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; - cerr << endl; + } else if ((fRunInfo->GetBetaParamNo() < 0) || (fRunInfo->GetBetaParamNo() > static_cast(param->size()))) { // check if beta parameter is within proper bounds + std::cerr << std::endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** beta parameter no = " << fRunInfo->GetBetaParamNo(); + std::cerr << std::endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; + std::cerr << std::endl; fValid = false; return; } else { // check if beta is fixed @@ -210,7 +209,7 @@ Double_t PRunAsymmetry::CalcChiSquare(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,diff,asymFcnValue,a,b,f) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); switch (fAlphaBetaTag) { case 1: // alpha == 1, beta == 1 asymFcnValue = fTheory->Func(time, par, fFuncValues); @@ -268,7 +267,7 @@ Double_t PRunAsymmetry::CalcChiSquareExpected(const std::vector& par) */ Double_t PRunAsymmetry::CalcMaxLikelihood(const std::vector& par) { - cout << endl << "PRunAsymmetry::CalcMaxLikelihood(): not implemented yet ..." << endl; + std::cout << std::endl << "PRunAsymmetry::CalcMaxLikelihood(): not implemented yet ..." << std::endl; return 1.0; } @@ -304,8 +303,8 @@ UInt_t PRunAsymmetry::GetNoOfFitBins() */ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) { - TObjArray *tok = 0; - TObjString *ostr = 0; + TObjArray *tok = nullptr; + TObjString *ostr = nullptr; TString str; Ssiz_t idx = -1; Int_t offset = 0; @@ -314,7 +313,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 // handle fgb+n0 entry - ostr = (TObjString*) tok->At(1); + ostr = dynamic_cast(tok->At(1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -326,7 +325,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(2); + ostr = dynamic_cast(tok->At(2)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -340,11 +339,11 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) Int_t pos = 2*(fRunNo+1)-1; if (pos + 1 >= tok->GetEntries()) { - cerr << endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } else { // handle fgb+n0 entry - ostr = (TObjString*) tok->At(pos); + ostr = static_cast(tok->At(pos)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -356,7 +355,7 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(pos+1); + ostr = static_cast(tok->At(pos+1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -368,8 +367,8 @@ void PRunAsymmetry::SetFitRangeBin(const TString fitRange) fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; } } else { // error - cerr << endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } // clean up @@ -395,7 +394,7 @@ void PRunAsymmetry::CalcNoOfFitBins() fEndTimeBin = fData.GetValue()->size(); if (fEndTimeBin > fStartTimeBin) - fNoOfFitBins = fEndTimeBin - fStartTimeBin; + fNoOfFitBins = static_cast(fEndTimeBin - fStartTimeBin); else fNoOfFitBins = 0; } @@ -424,7 +423,7 @@ void PRunAsymmetry::CalcTheory() Double_t a, b, f; Double_t time; for (UInt_t i=0; isize(); i++) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); switch (fAlphaBetaTag) { case 1: // alpha == 1, beta == 1 asymFcnValue = fTheory->Func(time, par, fFuncValues); @@ -487,8 +486,8 @@ Bool_t PRunAsymmetry::PrepareData() // get the correct run PRawRunData *runData = fRawData->GetRunData(*(fRunInfo->GetRunName())); if (!runData) { // run not found - cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + std::cerr << std::endl; return false; } @@ -499,10 +498,10 @@ Bool_t PRunAsymmetry::PrepareData() forwardHistoNo.push_back(fRunInfo->GetForwardHistoNo(i)); if (!runData->IsPresent(forwardHistoNo[i])) { - cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> forwardHistoNo found = " << forwardHistoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> forwardHistoNo found = " << forwardHistoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; // clean up forwardHistoNo.clear(); backwardHistoNo.clear(); @@ -513,10 +512,10 @@ Bool_t PRunAsymmetry::PrepareData() backwardHistoNo.push_back(fRunInfo->GetBackwardHistoNo(i)); if (!runData->IsPresent(backwardHistoNo[i])) { - cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> backwardHistoNo found = " << backwardHistoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> backwardHistoNo found = " << backwardHistoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; // clean up forwardHistoNo.clear(); backwardHistoNo.clear(); @@ -524,10 +523,10 @@ Bool_t PRunAsymmetry::PrepareData() } } if (forwardHistoNo.size() != backwardHistoNo.size()) { - cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> # of forward histograms different from # of backward histograms."; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> # of forward histograms different from # of backward histograms."; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; // clean up forwardHistoNo.clear(); backwardHistoNo.clear(); @@ -536,8 +535,8 @@ Bool_t PRunAsymmetry::PrepareData() // keep the time resolution in (us) fTimeResolution = runData->GetTimeResolution()/1.0e3; - cout.precision(10); - cout << endl << ">> PRunAsymmetry::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl; + std::cout.precision(10); + std::cout << std::endl << ">> PRunAsymmetry::PrepareData(): time resolution=" << std::fixed << runData->GetTimeResolution() << "(ns)" << std::endl; // get all the proper t0's and addt0's for the current RUN block if (!GetProperT0(runData, globalBlock, forwardHistoNo, backwardHistoNo)) { @@ -545,7 +544,7 @@ Bool_t PRunAsymmetry::PrepareData() } // keep the histo of each group at this point (addruns handled below) - vector forward, backward; + std::vector forward, backward; forward.resize(forwardHistoNo.size()); // resize to number of groups backward.resize(backwardHistoNo.size()); // resize to numer of groups for (UInt_t i=0; iGetRunNameSize(); i++) { // get run to be added to the main one addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -574,8 +573,9 @@ Bool_t PRunAsymmetry::PrepareData() addRunSize = addRunData->GetDataBin(forwardHistoNo[k])->size(); for (UInt_t j=0; jGetDataBin(forwardHistoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if (((Int_t)j+(Int_t)fAddT0s[i-1][2*k]-(Int_t)fT0s[2*k] >= 0) && (j+(Int_t)fAddT0s[i-1][2*k]-(Int_t)fT0s[2*k] < addRunSize)) { - forward[k][j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j+(Int_t)fAddT0s[i-1][2*k]-(Int_t)fT0s[2*k]); + if ((static_cast(j)+static_cast(fAddT0s[i-1][2*k])-static_cast(fT0s[2*k]) >= 0) && + (j+static_cast(fAddT0s[i-1][2*k])-static_cast(fT0s[2*k]) < addRunSize)) { + forward[k][j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j+static_cast(fAddT0s[i-1][2*k])-static_cast(fT0s[2*k])); } } } @@ -585,8 +585,9 @@ Bool_t PRunAsymmetry::PrepareData() addRunSize = addRunData->GetDataBin(backwardHistoNo[k])->size(); for (UInt_t j=0; jGetDataBin(backwardHistoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if (((Int_t)j+(Int_t)fAddT0s[i-1][2*k+1]-(Int_t)fT0s[2*k+1] >= 0) && (j+(Int_t)fAddT0s[i-1][2*k+1]-(Int_t)fT0s[2*k+1] < addRunSize)) { - backward[k][j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j+(Int_t)fAddT0s[i-1][2*k+1]-(Int_t)fT0s[2*k+1]); + if ((static_cast(j)+static_cast(fAddT0s[i-1][2*k+1])-static_cast(fT0s[2*k+1]) >= 0) && + (j+static_cast(fAddT0s[i-1][2*k+1])-static_cast(fT0s[2*k+1]) < addRunSize)) { + backward[k][j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j+static_cast(fAddT0s[i-1][2*k+1])-static_cast(fT0s[2*k+1])); } } } @@ -606,7 +607,7 @@ Bool_t PRunAsymmetry::PrepareData() for (UInt_t j=0; jGetDataBin(forwardHistoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range if ((j+fT0s[2*i]-fT0s[0] >= 0) && (j+fT0s[2*i]-fT0s[0] < runData->GetDataBin(forwardHistoNo[i])->size())) { - fForward[j] += forward[i][j+(Int_t)fT0s[2*i]-(Int_t)fT0s[0]]; + fForward[j] += forward[i][j+static_cast(fT0s[2*i])-static_cast(fT0s[0])]; } } } @@ -616,7 +617,7 @@ Bool_t PRunAsymmetry::PrepareData() for (UInt_t j=0; jGetDataBin(backwardHistoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range if ((j+fT0s[2*i+1]-fT0s[1] >= 0) && (j+fT0s[2*i+1]-fT0s[1] < runData->GetDataBin(backwardHistoNo[i])->size())) { - fBackward[j] += backward[i][j+(Int_t)fT0s[2*i+1]-(Int_t)fT0s[1]]; + fBackward[j] += backward[i][j+static_cast(fT0s[2*i+1])-static_cast(fT0s[1])]; } } } @@ -631,12 +632,12 @@ Bool_t PRunAsymmetry::PrepareData() fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); fRunInfo->SetBkgRange(static_cast(fT0s[1]*0.1), 2); fRunInfo->SetBkgRange(static_cast(fT0s[1]*0.6), 3); - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << ">> Will try the following:"; - cerr << endl << ">> forward: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << ">> backward: bkg start = " << fRunInfo->GetBkgRange(2) << ", bkg end = " << fRunInfo->GetBkgRange(3); - cerr << endl << ">> NO GUARANTEE THAT THIS MAKES ANY SENSE! Better check ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; + std::cerr << std::endl << ">> Will try the following:"; + std::cerr << std::endl << ">> forward: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + std::cerr << std::endl << ">> backward: bkg start = " << fRunInfo->GetBkgRange(2) << ", bkg end = " << fRunInfo->GetBkgRange(3); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + std::cerr << std::endl; if (!SubtractEstimatedBkg()) return false; } @@ -761,7 +762,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() Int_t end[2] = {fRunInfo->GetBkgRange(1), fRunInfo->GetBkgRange(3)}; for (UInt_t i=0; i<2; i++) { if (end[i] < start[i]) { - cout << endl << "PRunAsymmetry::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!"; + std::cout << std::endl << "PRunAsymmetry::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!"; UInt_t keep = end[i]; end[i] = start[i]; start[i] = keep; @@ -771,11 +772,11 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() // calculate proper background range for (UInt_t i=0; i<2; i++) { if (beamPeriod != 0.0) { - Double_t timeBkg = (Double_t)(end[i]-start[i])*(fTimeResolution*fPacking); // length of the background intervall in time - UInt_t fullCycles = (UInt_t)(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall + Double_t timeBkg = static_cast(end[i]-start[i])*(fTimeResolution*fPacking); // length of the background intervall in time + UInt_t fullCycles = static_cast(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall // correct the end of the background intervall such that the background is as close as possible to a multiple of the proton cylce - end[i] = start[i] + (UInt_t) ((fullCycles*beamPeriod)/(fTimeResolution*fPacking)); - cout << "PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << endl; + end[i] = start[i] + static_cast((fullCycles*beamPeriod)/(fTimeResolution*fPacking)); + std::cout << "PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << std::endl; if (end[i] == start[i]) end[i] = fRunInfo->GetBkgRange(2*i+1); } @@ -784,18 +785,18 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() // check if start is within histogram bounds if ((start[0] < 0) || (start[0] >= fForward.size()) || (start[1] < 0) || (start[1] >= fBackward.size())) { - cerr << endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; - cerr << endl << ">> background start (f/b) = (" << start[0] << "/" << start[1] << ")."; + std::cerr << std::endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; + std::cerr << std::endl << ">> background start (f/b) = (" << start[0] << "/" << start[1] << ")."; return false; } // check if end is within histogram bounds if ((end[0] < 0) || (end[0] >= fForward.size()) || (end[1] < 0) || (end[1] >= fBackward.size())) { - cerr << endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; - cerr << endl << ">> background end (f/b) = (" << end[0] << "/" << end[1] << ")."; + std::cerr << std::endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; + std::cerr << std::endl << ">> background end (f/b) = (" << end[0] << "/" << end[1] << ")."; return false; } @@ -808,14 +809,14 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() bkg[0] += fForward[i]; errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1); bkg[0] /= static_cast(end[0] - start[0] + 1); - cout << endl << ">> estimated forward histo background: " << bkg[0]; + std::cout << std::endl << ">> estimated forward histo background: " << bkg[0]; // backward for (UInt_t i=start[1]; i<=end[1]; i++) bkg[1] += fBackward[i]; errBkg[1] = TMath::Sqrt(bkg[1])/(end[1] - start[1] + 1); bkg[1] /= static_cast(end[1] - start[1] + 1); - cout << endl << ">> estimated backward histo background: " << bkg[1] << endl; + std::cout << std::endl << ">> estimated backward histo background: " << bkg[1] << std::endl; // correct error for forward, backward Double_t errVal = 0.0; @@ -925,8 +926,8 @@ Bool_t PRunAsymmetry::PrepareFitData() Double_t f, b, ef, eb; // fill data time start, and step // data start at data_start-t0 shifted by (pack-1)/2 - fData.SetDataTimeStart(fTimeResolution*((Double_t)fGoodBins[0]-fT0s[0]+(Double_t)(fPacking-1)/2.0)); - fData.SetDataTimeStep(fTimeResolution*(Double_t)fPacking); + fData.SetDataTimeStart(fTimeResolution*(static_cast(fGoodBins[0])-fT0s[0]+static_cast(fPacking-1)/2.0)); + fData.SetDataTimeStep(fTimeResolution*static_cast(fPacking)); for (UInt_t i=0; iat(i); @@ -997,7 +998,7 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) // first get start data, end data, and t0 Int_t start[2] = {fGoodBins[0], fGoodBins[2]}; Int_t end[2] = {fGoodBins[1], fGoodBins[3]}; - Int_t t0[2] = {(Int_t)fT0s[0], (Int_t)fT0s[1]}; + Int_t t0[2] = {static_cast(fT0s[0]), static_cast(fT0s[1])}; // check if the data ranges and t0's between forward/backward are compatible Int_t fgb[2]; @@ -1005,13 +1006,13 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) if (abs(start[0]-t0[0]) > abs(start[1]-t0[1])) { fgb[0] = start[0]; fgb[1] = t0[1] + start[0]-t0[0]; - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** needed to shift backward fgb from "; - cerr << start[1] << " to " << fgb[1] << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** needed to shift backward fgb from "; + std::cerr << start[1] << " to " << fgb[1] << std::endl; } else { fgb[0] = t0[0] + start[1]-t0[1]; fgb[1] = start[1]; - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** needed to shift forward fgb from "; - cerr << start[0] << " to " << fgb[0] << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** needed to shift forward fgb from "; + std::cerr << start[0] << " to " << fgb[0] << std::endl; } } else { // fgb aligning is correct fgb[0] = start[0]; @@ -1044,21 +1045,21 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) start[i] = keep; } // 2nd check if start is within proper bounds - if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start[i] < 0) || (start[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds - if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; - cerr << endl; + if ((end[i] < 0) || (end[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 4th check if t0 is within proper bounds - if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; - cerr << endl; + if ((t0[i] < 0) || (t0[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1127,8 +1128,8 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) Double_t f, b, ef, eb, alpha = 1.0, beta = 1.0; // set data time start, and step // data start at data_start-t0 - fData.SetDataTimeStart(fTimeResolution*((Double_t)start[0]-t0[0]+(Double_t)(packing-1)/2.0)); - fData.SetDataTimeStep(fTimeResolution*(Double_t)packing); + fData.SetDataTimeStart(fTimeResolution*(static_cast(start[0])-t0[0]+static_cast(packing-1)/2.0)); + fData.SetDataTimeStep(fTimeResolution*static_cast(packing)); // get the proper alpha and beta switch (fAlphaBetaTag) { @@ -1192,12 +1193,12 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) Double_t factor = 1.0; if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo[0])->size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)runData->GetDataBin(histoNo[0])->size() / (Double_t)size; + factor = static_cast(runData->GetDataBin(histoNo[0])->size()) / static_cast(size); } fData.SetTheoryTimeStart(fData.GetDataTimeStart()); fData.SetTheoryTimeStep(fTimeResolution*factor); for (UInt_t i=0; i(i)*fTimeResolution*factor; value = fTheory->Func(time, par, fFuncValues); if (fabs(value) > 10.0) { // dirty hack needs to be fixed!! value = 0.0; @@ -1244,7 +1245,7 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2] // first get start data, end data, and t0 Int_t start[2] = {fGoodBins[0], fGoodBins[2]}; Int_t end[2] = {fGoodBins[1], fGoodBins[3]}; - Int_t t0[2] = {(Int_t)fT0s[0], (Int_t)fT0s[1]}; + Int_t t0[2] = {static_cast(fT0s[0]), static_cast(fT0s[1])}; UInt_t packing = fMsrInfo->GetMsrPlotList()->at(0).fRRFPacking; // check if the data ranges and t0's between forward/backward are compatible @@ -1253,13 +1254,13 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2] if (abs(start[0]-t0[0]) > abs(start[1]-t0[1])) { fgb[0] = start[0]; fgb[1] = t0[1] + start[0]-t0[0]; - cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** needed to shift backward fgb from "; - cerr << start[1] << " to " << fgb[1] << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** needed to shift backward fgb from "; + std::cerr << start[1] << " to " << fgb[1] << std::endl; } else { fgb[0] = t0[0] + start[1]-t0[1]; fgb[1] = start[1]; - cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** needed to shift forward fgb from "; - cerr << start[1] << " to " << fgb[0] << endl; + std::cerr << std::endl << ">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** needed to shift forward fgb from "; + std::cerr << start[1] << " to " << fgb[0] << std::endl; } } else { // fgb aligning is correct fgb[0] = start[0]; @@ -1292,21 +1293,21 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2] start[i] = keep; } // 2nd check if start is within proper bounds - if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start[i] < 0) || (start[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds - if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** end data bin doesn't make any sense!"; - cerr << endl; + if ((end[i] < 0) || (end[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** end data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 4th check if t0 is within proper bounds - if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** t0 data bin doesn't make any sense!"; - cerr << endl; + if ((t0[i] < 0) || (t0[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** t0 data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1582,11 +1583,11 @@ Bool_t PRunAsymmetry::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalB fT0s[2*i] = runData->GetT0BinEstimated(forwardHistoNo[i]); fRunInfo->SetT0Bin(fT0s[2*i], 2*i); - cerr << endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(forwardHistoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(forwardHistoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } for (UInt_t i=0; iGetT0BinEstimated(backwardHistoNo[i]); fRunInfo->SetT0Bin(fT0s[2*i+1], 2*i+1); - cerr << endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t i=0; i (Int_t)runData->GetDataBin(forwardHistoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::GetProperT0(): **ERROR** t0 data bin (" << fT0s[2*i] << ") doesn't make any sense!"; - cerr << endl << ">> forwardHistoNo " << forwardHistoNo[i]; - cerr << endl; + if ((fT0s[2*i] < 0) || (fT0s[2*i] > static_cast(runData->GetDataBin(forwardHistoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperT0(): **ERROR** t0 data bin (" << fT0s[2*i] << ") doesn't make any sense!"; + std::cerr << std::endl << ">> forwardHistoNo " << forwardHistoNo[i]; + std::cerr << std::endl; return false; } - if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > (Int_t)runData->GetDataBin(backwardHistoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; - cerr << endl << ">> backwardHistoNo " << backwardHistoNo[i]; - cerr << endl; + if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast(runData->GetDataBin(backwardHistoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; + std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i]; + std::cerr << std::endl; return false; } } @@ -1626,8 +1627,8 @@ Bool_t PRunAsymmetry::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalB // get run to be added to the main one addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunAsymmetry::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -1666,11 +1667,11 @@ Bool_t PRunAsymmetry::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalB fAddT0s[i-1][2*j] = addRunData->GetT0BinEstimated(forwardHistoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][2*j], i-1, 2*j); - cerr << endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(forwardHistoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(forwardHistoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } for (UInt_t j=0; jGetT0BinEstimated(backwardHistoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][2*j+1], i-1, 2*j+1); - cerr << endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } } @@ -1727,36 +1728,36 @@ Bool_t PRunAsymmetry::GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2] } Double_t t0[2] = {fT0s[0], fT0s[1]}; - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); // needed in case first good bin is not given, default = 10ns + Int_t offset = static_cast((10.0e-3/fTimeResolution)); // needed in case first good bin is not given, default = 10ns // check if data range has been provided, and if not try to estimate them if (start[0] < 0) { - start[0] = (Int_t)t0[0]+offset; + start[0] = static_cast(t0[0])+offset; fRunInfo->SetDataRange(start[0], 0); - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[0] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[0] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (start[1] < 0) { - start[1] = (Int_t)t0[1]+offset; + start[1] = static_cast(t0[1])+offset; fRunInfo->SetDataRange(start[1], 2); - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[1] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[1] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end[0] < 0) { end[0] = runData->GetDataBin(histoNo[0])->size(); fRunInfo->SetDataRange(end[0], 1); - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end[1] < 0) { end[1] = runData->GetDataBin(histoNo[1])->size(); fRunInfo->SetDataRange(end[1], 3); - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start, end, and t0 make any sense @@ -1768,27 +1769,27 @@ Bool_t PRunAsymmetry::GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2] start[i] = keep; } // 2nd check if start is within proper bounds - if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start[i] < 0) || (start[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds if (end[i] < 0) { - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** end data bin (" << end[i] << ") doesn't make any sense!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** end data bin (" << end[i] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } - if (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size()) { - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** end data bin (" << end[i] << ") > histo length (" << (Int_t)runData->GetDataBin(histoNo[i])->size() << ")."; - cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; - cerr << endl; - end[i] = (Int_t)runData->GetDataBin(histoNo[i])->size()-1; + if (end[i] > static_cast(runData->GetDataBin(histoNo[i])->size())) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **WARNING** end data bin (" << end[i] << ") > histo length (" << static_cast(runData->GetDataBin(histoNo[i])->size()) << ")."; + std::cerr << std::endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << std::endl; + std::cerr << std::endl; + end[i] = static_cast(runData->GetDataBin(histoNo[i])->size())-1; } // 4th check if t0 is within proper bounds - if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!"; - cerr << endl; + if ((t0[i] < 0) || (t0[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1797,18 +1798,18 @@ Bool_t PRunAsymmetry::GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2] if (fabs(static_cast(start[0])-t0[0]) > fabs(static_cast(start[1])-t0[1])){ start[1] = static_cast(t0[1] + static_cast(start[0]) - t0[0]); end[1] = static_cast(t0[1] + static_cast(end[0]) - t0[0]); - cerr << endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift backward data range."; - cerr << endl << ">> given: " << fRunInfo->GetDataRange(2) << ", " << fRunInfo->GetDataRange(3); - cerr << endl << ">> used : " << start[1] << ", " << end[1]; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift backward data range."; + std::cerr << std::endl << ">> given: " << fRunInfo->GetDataRange(2) << ", " << fRunInfo->GetDataRange(3); + std::cerr << std::endl << ">> used : " << start[1] << ", " << end[1]; + std::cerr << std::endl; } if (fabs(static_cast(start[0])-t0[0]) < fabs(static_cast(start[1])-t0[1])){ start[0] = static_cast(t0[0] + static_cast(start[1]) - t0[1]); end[0] = static_cast(t0[0] + static_cast(end[1]) - t0[1]); - cerr << endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift forward data range."; - cerr << endl << ">> given: " << fRunInfo->GetDataRange(0) << ", " << fRunInfo->GetDataRange(1); - cerr << endl << ">> used : " << start[0] << ", " << end[0]; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift forward data range."; + std::cerr << std::endl << ">> given: " << fRunInfo->GetDataRange(0) << ", " << fRunInfo->GetDataRange(1); + std::cerr << std::endl << ">> used : " << start[0] << ", " << end[0]; + std::cerr << std::endl; } // keep good bins for potential latter use @@ -1863,7 +1864,7 @@ void PRunAsymmetry::GetProperFitRange(PMsrGlobalBlock *globalBlock) if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) { fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt - cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl; - cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl; + std::cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl; + std::cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << std::endl; } } diff --git a/src/classes/PRunAsymmetryRRF.cpp b/src/classes/PRunAsymmetryRRF.cpp index 38811c93..64d2fdc2 100644 --- a/src/classes/PRunAsymmetryRRF.cpp +++ b/src/classes/PRunAsymmetryRRF.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -39,7 +39,6 @@ #include #include -using namespace std; #include #include @@ -85,9 +84,9 @@ PRunAsymmetryRRF::PRunAsymmetryRRF(PMsrHandler *msrInfo, PRunDataHandler *rawDat fRRFPacking = fMsrInfo->GetMsrGlobal()->GetRRFPacking(); if (fRRFPacking == -1) { // this should NOT happen, somethin is severely wrong - cerr << endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **SEVERE ERROR**: Couldn't find any RRF packing information!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **SEVERE ERROR**: Couldn't find any RRF packing information!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; return; } @@ -98,16 +97,16 @@ PRunAsymmetryRRF::PRunAsymmetryRRF(PMsrHandler *msrInfo, PRunDataHandler *rawDat // check if alpha is given if (fRunInfo->GetAlphaParamNo() == -1) { // no alpha given - cerr << endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!"; + std::cerr << std::endl; fValid = false; return; } // check if alpha parameter is within proper bounds - if ((fRunInfo->GetAlphaParamNo() < 0) || (fRunInfo->GetAlphaParamNo() > (Int_t)param->size())) { - cerr << endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **ERROR** alpha parameter no = " << fRunInfo->GetAlphaParamNo(); - cerr << endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; - cerr << endl; + if ((fRunInfo->GetAlphaParamNo() < 0) || (fRunInfo->GetAlphaParamNo() > static_cast(param->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **ERROR** alpha parameter no = " << fRunInfo->GetAlphaParamNo(); + std::cerr << std::endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; + std::cerr << std::endl; fValid = false; return; } @@ -121,10 +120,10 @@ PRunAsymmetryRRF::PRunAsymmetryRRF(PMsrHandler *msrInfo, PRunDataHandler *rawDat Bool_t betaFixedToOne = false; if (fRunInfo->GetBetaParamNo() == -1) { // no beta given hence assuming beta == 1 betaFixedToOne = true; - } else if ((fRunInfo->GetBetaParamNo() < 0) || (fRunInfo->GetBetaParamNo() > (Int_t)param->size())) { // check if beta parameter is within proper bounds - cerr << endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **ERROR** beta parameter no = " << fRunInfo->GetBetaParamNo(); - cerr << endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; - cerr << endl; + } else if ((fRunInfo->GetBetaParamNo() < 0) || (fRunInfo->GetBetaParamNo() > static_cast(param->size()))) { // check if beta parameter is within proper bounds + std::cerr << std::endl << ">> PRunAsymmetryRRF::PRunAsymmetryRRF(): **ERROR** beta parameter no = " << fRunInfo->GetBetaParamNo(); + std::cerr << std::endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; + std::cerr << std::endl; fValid = false; return; } else { // check if beta is fixed @@ -202,7 +201,7 @@ Double_t PRunAsymmetryRRF::CalcChiSquare(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,diff,asymFcnValue,a,b,f) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); switch (fAlphaBetaTag) { case 1: // alpha == 1, beta == 1 asymFcnValue = fTheory->Func(time, par, fFuncValues); @@ -260,7 +259,7 @@ Double_t PRunAsymmetryRRF::CalcChiSquareExpected(const std::vector& pa */ Double_t PRunAsymmetryRRF::CalcMaxLikelihood(const std::vector& par) { - cout << endl << "PRunAsymmetryRRF::CalcMaxLikelihood(): not implemented yet ..." << endl; + std::cout << std::endl << "PRunAsymmetryRRF::CalcMaxLikelihood(): not implemented yet ..." << std::endl; return 1.0; } @@ -296,8 +295,8 @@ UInt_t PRunAsymmetryRRF::GetNoOfFitBins() */ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange) { - TObjArray *tok = 0; - TObjString *ostr = 0; + TObjArray *tok = nullptr; + TObjString *ostr = nullptr; TString str; Ssiz_t idx = -1; Int_t offset = 0; @@ -306,7 +305,7 @@ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange) if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 // handle fgb+n0 entry - ostr = (TObjString*) tok->At(1); + ostr = static_cast(tok->At(1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -318,7 +317,7 @@ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(2); + ostr = static_cast(tok->At(2)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -332,11 +331,11 @@ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange) Int_t pos = 2*(fRunNo+1)-1; if (pos + 1 >= tok->GetEntries()) { - cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } else { // handle fgb+n0 entry - ostr = (TObjString*) tok->At(pos); + ostr = static_cast(tok->At(pos)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -348,7 +347,7 @@ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(pos+1); + ostr = static_cast(tok->At(pos+1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -360,8 +359,8 @@ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange) fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; } } else { // error - cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } // clean up @@ -416,7 +415,7 @@ void PRunAsymmetryRRF::CalcTheory() Double_t a, b, f; Double_t time; for (UInt_t i=0; isize(); i++) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); switch (fAlphaBetaTag) { case 1: // alpha == 1, beta == 1 asymFcnValue = fTheory->Func(time, par, fFuncValues); @@ -479,8 +478,8 @@ Bool_t PRunAsymmetryRRF::PrepareData() // get the correct run PRawRunData *runData = fRawData->GetRunData(*(fRunInfo->GetRunName())); if (!runData) { // run not found - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + std::cerr << std::endl; return false; } @@ -491,10 +490,10 @@ Bool_t PRunAsymmetryRRF::PrepareData() forwardHistoNo.push_back(fRunInfo->GetForwardHistoNo(i)); if (!runData->IsPresent(forwardHistoNo[i])) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> forwardHistoNo found = " << forwardHistoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> forwardHistoNo found = " << forwardHistoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; // clean up forwardHistoNo.clear(); backwardHistoNo.clear(); @@ -505,10 +504,10 @@ Bool_t PRunAsymmetryRRF::PrepareData() backwardHistoNo.push_back(fRunInfo->GetBackwardHistoNo(i)); if (!runData->IsPresent(backwardHistoNo[i])) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> backwardHistoNo found = " << backwardHistoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> backwardHistoNo found = " << backwardHistoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; // clean up forwardHistoNo.clear(); backwardHistoNo.clear(); @@ -516,10 +515,10 @@ Bool_t PRunAsymmetryRRF::PrepareData() } } if (forwardHistoNo.size() != backwardHistoNo.size()) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> # of forward histograms different from # of backward histograms."; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> # of forward histograms different from # of backward histograms."; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; // clean up forwardHistoNo.clear(); backwardHistoNo.clear(); @@ -528,8 +527,8 @@ Bool_t PRunAsymmetryRRF::PrepareData() // keep the time resolution in (us) fTimeResolution = runData->GetTimeResolution()/1.0e3; - cout.precision(10); - cout << endl << ">> PRunAsymmetryRRF::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl; + std::cout.precision(10); + std::cout << std::endl << ">> PRunAsymmetryRRF::PrepareData(): time resolution=" << std::fixed << runData->GetTimeResolution() << "(ns)" << std::endl; // get all the proper t0's and addt0's for the current RUN block if (!GetProperT0(runData, globalBlock, forwardHistoNo, backwardHistoNo)) { @@ -537,7 +536,7 @@ Bool_t PRunAsymmetryRRF::PrepareData() } // keep the histo of each group at this point (addruns handled below) - vector forward, backward; + std::vector forward, backward; forward.resize(forwardHistoNo.size()); // resize to number of groups backward.resize(backwardHistoNo.size()); // resize to numer of groups for (UInt_t i=0; iGetRunNameSize(); i++) { // get run to be added to the main one addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -623,12 +622,12 @@ Bool_t PRunAsymmetryRRF::PrepareData() fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); fRunInfo->SetBkgRange(static_cast(fT0s[1]*0.1), 2); fRunInfo->SetBkgRange(static_cast(fT0s[1]*0.6), 3); - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << ">> Will try the following:"; - cerr << endl << ">> forward: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << ">> backward: bkg start = " << fRunInfo->GetBkgRange(2) << ", bkg end = " << fRunInfo->GetBkgRange(3); - cerr << endl << ">> NO GUARANTEE THAT THIS MAKES ANY SENSE! Better check ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; + std::cerr << std::endl << ">> Will try the following:"; + std::cerr << std::endl << ">> forward: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + std::cerr << std::endl << ">> backward: bkg start = " << fRunInfo->GetBkgRange(2) << ", bkg end = " << fRunInfo->GetBkgRange(3); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + std::cerr << std::endl; if (!SubtractEstimatedBkg()) return false; } @@ -746,11 +745,11 @@ Bool_t PRunAsymmetryRRF::SubtractEstimatedBkg() beamPeriod = 0.0; // check if start and end are in proper order - UInt_t start[2] = {(UInt_t)fRunInfo->GetBkgRange(0), (UInt_t)fRunInfo->GetBkgRange(2)}; - UInt_t end[2] = {(UInt_t)fRunInfo->GetBkgRange(1), (UInt_t)fRunInfo->GetBkgRange(3)}; + UInt_t start[2] = {static_cast(fRunInfo->GetBkgRange(0)), static_cast(fRunInfo->GetBkgRange(2))}; + UInt_t end[2] = {static_cast(fRunInfo->GetBkgRange(1)), static_cast(fRunInfo->GetBkgRange(3))}; for (UInt_t i=0; i<2; i++) { if (end[i] < start[i]) { - cout << endl << "PRunAsymmetryRRF::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!"; + std::cout << std::endl << "PRunAsymmetryRRF::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!"; UInt_t keep = end[i]; end[i] = start[i]; start[i] = keep; @@ -760,11 +759,11 @@ Bool_t PRunAsymmetryRRF::SubtractEstimatedBkg() // calculate proper background range for (UInt_t i=0; i<2; i++) { if (beamPeriod != 0.0) { - Double_t timeBkg = (Double_t)(end[i]-start[i])*fTimeResolution; // length of the background intervall in time - UInt_t fullCycles = (UInt_t)(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall + Double_t timeBkg = static_cast(end[i]-start[i])*fTimeResolution; // length of the background intervall in time + UInt_t fullCycles = static_cast(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall // correct the end of the background intervall such that the background is as close as possible to a multiple of the proton cylce - end[i] = start[i] + (UInt_t) ((fullCycles*beamPeriod)/fTimeResolution); - cout << "PRunAsymmetryRRF::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << endl; + end[i] = start[i] + static_cast((fullCycles*beamPeriod)/fTimeResolution); + std::cout << "PRunAsymmetryRRF::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << std::endl; if (end[i] == start[i]) end[i] = fRunInfo->GetBkgRange(2*i+1); } @@ -772,17 +771,17 @@ Bool_t PRunAsymmetryRRF::SubtractEstimatedBkg() // check if start is within histogram bounds if ((start[0] >= fForward.size()) || (start[1] >= fBackward.size())) { - cerr << endl << ">> PRunAsymmetryRRF::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; - cerr << endl << ">> background start (f/b) = (" << start[0] << "/" << start[1] << ")."; + std::cerr << std::endl << ">> PRunAsymmetryRRF::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; + std::cerr << std::endl << ">> background start (f/b) = (" << start[0] << "/" << start[1] << ")."; return false; } // check if end is within histogram bounds if ((end[0] >= fForward.size()) || (end[1] >= fBackward.size())) { - cerr << endl << ">> PRunAsymmetryRRF::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; - cerr << endl << ">> background end (f/b) = (" << end[0] << "/" << end[1] << ")."; + std::cerr << std::endl << ">> PRunAsymmetryRRF::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; + std::cerr << std::endl << ">> background end (f/b) = (" << end[0] << "/" << end[1] << ")."; return false; } @@ -795,14 +794,14 @@ Bool_t PRunAsymmetryRRF::SubtractEstimatedBkg() bkg[0] += fForward[i]; errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1); bkg[0] /= static_cast(end[0] - start[0] + 1); - cout << endl << ">> estimated forward histo background: " << bkg[0]; + std::cout << std::endl << ">> estimated forward histo background: " << bkg[0]; // backward for (UInt_t i=start[1]; i<=end[1]; i++) bkg[1] += fBackward[i]; errBkg[1] = TMath::Sqrt(bkg[1])/(end[1] - start[1] + 1); bkg[1] /= static_cast(end[1] - start[1] + 1); - cout << endl << ">> estimated backward histo background: " << bkg[1] << endl; + std::cout << std::endl << ">> estimated backward histo background: " << bkg[1] << std::endl; // correct error for forward, backward Double_t errVal = 0.0; @@ -845,17 +844,17 @@ Bool_t PRunAsymmetryRRF::PrepareFitData() // 1st: form the asymmetry of the original data // forward and backward detectors might have different fgb-t0 offset. Take the maximum of both. - Int_t fgbOffset = fGoodBins[0]-(Int_t)fT0s[0]; - if (fgbOffset < fGoodBins[2]-(Int_t)fT0s[1]) - fgbOffset = fGoodBins[2]-(Int_t)fT0s[1]; + Int_t fgbOffset = fGoodBins[0]-static_cast(fT0s[0]); + if (fgbOffset < fGoodBins[2]-static_cast(fT0s[1])) + fgbOffset = fGoodBins[2]-static_cast(fT0s[1]); // last good bin (lgb) is the minimum of forward/backward lgb - Int_t lgb_offset = fGoodBins[1]-(Int_t)fT0s[0]+fgbOffset; - if (lgb_offset < fGoodBins[3]-(Int_t)fT0s[1]+fgbOffset) - lgb_offset = fGoodBins[3]-(Int_t)fT0s[1]+fgbOffset; + Int_t lgb_offset = fGoodBins[1]-static_cast(fT0s[0])+fgbOffset; + if (lgb_offset < fGoodBins[3]-static_cast(fT0s[1])+fgbOffset) + lgb_offset = fGoodBins[3]-static_cast(fT0s[1])+fgbOffset; - Int_t fgb = (Int_t)fT0s[0]+fgbOffset; + Int_t fgb = static_cast(fT0s[0])+fgbOffset; Int_t lgb = fgb + lgb_offset; - Int_t dt0 = (Int_t)fT0s[0]-(Int_t)fT0s[1]; + Int_t dt0 = static_cast(fT0s[0])-static_cast(fT0s[1]); PDoubleVector asym; PDoubleVector asymErr; @@ -883,7 +882,7 @@ Bool_t PRunAsymmetryRRF::PrepareFitData() Double_t wRRF = globalBlock->GetRRFFreq("Mc"); Double_t phaseRRF = globalBlock->GetRRFPhase()*TMath::TwoPi()/180.0; - Double_t startTime = fTimeResolution * (Double_t)fgbOffset; + Double_t startTime = fTimeResolution * static_cast(fgbOffset); Double_t time=0.0; for (UInt_t i=0; i(fRRFPacking-1)/2.0)); + fData.SetDataTimeStep(fTimeResolution*static_cast(fRRFPacking)); for (UInt_t i=0; i(fT0s[0]), static_cast(fT0s[1])}; // check if the data ranges and t0's between forward/backward are compatible Int_t fgb[2]; @@ -973,13 +972,13 @@ Bool_t PRunAsymmetryRRF::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2] if (abs(start[0]-t0[0]) > abs(start[1]-t0[1])) { fgb[0] = start[0]; fgb[1] = t0[1] + start[0]-t0[0]; - cerr << endl << ">> PRunAsymmetryRRF::PrepareViewData(): **WARNING** needed to shift backward fgb from "; - cerr << start[1] << " to " << fgb[1] << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareViewData(): **WARNING** needed to shift backward fgb from "; + std::cerr << start[1] << " to " << fgb[1] << std::endl; } else { fgb[0] = t0[0] + start[1]-t0[1]; fgb[1] = start[1]; - cerr << endl << ">> PRunAsymmetryRRF::PrepareViewData(): **WARNING** needed to shift forward fgb from "; - cerr << start[0] << " to " << fgb[0] << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareViewData(): **WARNING** needed to shift forward fgb from "; + std::cerr << start[0] << " to " << fgb[0] << std::endl; } } else { // fgb aligning is correct fgb[0] = start[0]; @@ -999,21 +998,21 @@ Bool_t PRunAsymmetryRRF::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2] // check if start, end, and t0 make any sense for (UInt_t i=0; i<2; i++) { // 1st check if start is within proper bounds - if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start[i] < 0) || (start[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 2nd check if end is within proper bounds - if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; - cerr << endl; + if ((end[i] < 0) || (end[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if t0 is within proper bounds - if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; - cerr << endl; + if ((t0[i] < 0) || (t0[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1077,7 +1076,7 @@ Bool_t PRunAsymmetryRRF::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2] PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal(); Double_t wRRF = globalBlock->GetRRFFreq("Mc"); Double_t phaseRRF = globalBlock->GetRRFPhase()*TMath::TwoPi()/180.0; - Double_t startTime=fTimeResolution*((Double_t)start[0]-t0[0]); + Double_t startTime=fTimeResolution*(static_cast(start[0])-t0[0]); Double_t time = 0.0; for (UInt_t i=0; i(fRRFPacking-1)/2.0)); + fData.SetDataTimeStep(fTimeResolution*static_cast(fRRFPacking)); for (UInt_t i=0; isize() * 10 > runData->GetDataBin(histoNo[0])->size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)runData->GetDataBin(histoNo[0])->size() / (Double_t)size; + factor = static_cast(runData->GetDataBin(histoNo[0])->size()) / static_cast(size); } fData.SetTheoryTimeStart(fData.GetDataTimeStart()); fData.SetTheoryTimeStep(fTimeResolution*factor); for (UInt_t i=0; i(i)*fTimeResolution*factor; dval = fTheory->Func(time, par, fFuncValues); if (fabs(dval) > 10.0) { // dirty hack needs to be fixed!! dval = 0.0; @@ -1193,7 +1192,7 @@ Bool_t PRunAsymmetryRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glob // fill in the missing T0's from the GLOBAL block section (if present) for (UInt_t i=0; iGetT0BinSize(); i++) { - if (fT0s[i] == -1) { // i.e. not given in the RUN block section + if (fT0s[i] == -1.0) { // i.e. not given in the RUN block section fT0s[i] = globalBlock->GetT0Bin(i); } } @@ -1220,11 +1219,11 @@ Bool_t PRunAsymmetryRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glob fT0s[2*i] = runData->GetT0BinEstimated(forwardHistoNo[i]); fRunInfo->SetT0Bin(fT0s[2*i], 2*i); - cerr << endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(forwardHistoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(forwardHistoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } for (UInt_t i=0; iGetT0BinEstimated(backwardHistoNo[i]); fRunInfo->SetT0Bin(fT0s[2*i+1], 2*i+1); - cerr << endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t i=0; i (Int_t)runData->GetDataBin(forwardHistoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::GetProperT0(): **ERROR** t0 data bin (" << fT0s[2*i] << ") doesn't make any sense!"; - cerr << endl << ">> forwardHistoNo " << forwardHistoNo[i]; - cerr << endl; + if ((fT0s[2*i] < 0) || (fT0s[2*i] > static_cast(runData->GetDataBin(forwardHistoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperT0(): **ERROR** t0 data bin (" << fT0s[2*i] << ") doesn't make any sense!"; + std::cerr << std::endl << ">> forwardHistoNo " << forwardHistoNo[i]; + std::cerr << std::endl; return false; } - if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > (Int_t)runData->GetDataBin(backwardHistoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; - cerr << endl << ">> backwardHistoNo " << backwardHistoNo[i]; - cerr << endl; + if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast(runData->GetDataBin(backwardHistoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; + std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i]; + std::cerr << std::endl; return false; } } @@ -1263,9 +1262,9 @@ Bool_t PRunAsymmetryRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glob for (UInt_t i=1; iGetRunNameSize(); i++) { // get run to be added to the main one addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunAsymmetryRRF::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -1304,11 +1303,11 @@ Bool_t PRunAsymmetryRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glob fAddT0s[i-1][2*j] = addRunData->GetT0BinEstimated(forwardHistoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][2*j], i-1, 2*j); - cerr << endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(forwardHistoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(forwardHistoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } for (UInt_t j=0; jGetT0BinEstimated(backwardHistoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][2*j+1], i-1, 2*j+1); - cerr << endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } } @@ -1365,36 +1364,36 @@ Bool_t PRunAsymmetryRRF::GetProperDataRange(PRawRunData* runData, UInt_t histoNo } Double_t t0[2] = {fT0s[0], fT0s[1]}; - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); // needed in case first good bin is not given, default = 10ns + Int_t offset = static_cast(10.0e-3/fTimeResolution); // needed in case first good bin is not given, default = 10ns // check if data range has been provided, and if not try to estimate them if (start[0] < 0) { - start[0] = (Int_t)t0[0]+offset; + start[0] = static_cast(t0[0])+offset; fRunInfo->SetDataRange(start[0], 0); - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[0] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[0] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (start[1] < 0) { - start[1] = (Int_t)t0[1]+offset; + start[1] = static_cast(t0[1])+offset; fRunInfo->SetDataRange(start[1], 2); - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[1] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[1] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end[0] < 0) { end[0] = runData->GetDataBin(histoNo[0])->size(); fRunInfo->SetDataRange(end[0], 1); - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end[1] < 0) { end[1] = runData->GetDataBin(histoNo[1])->size(); fRunInfo->SetDataRange(end[1], 3); - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start, end, and t0 make any sense @@ -1406,27 +1405,27 @@ Bool_t PRunAsymmetryRRF::GetProperDataRange(PRawRunData* runData, UInt_t histoNo start[i] = keep; } // 2nd check if start is within proper bounds - if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start[i] < 0) || (start[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds if (end[i] < 0) { - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** end data bin (" << end[i] << ") doesn't make any sense!"; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** end data bin (" << end[i] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } - if (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size()) { - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** end data bin (" << end[i] << ") > histo length (" << (Int_t)runData->GetDataBin(histoNo[i])->size() << ")."; - cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; - cerr << endl; - end[i] = (Int_t)runData->GetDataBin(histoNo[i])->size()-1; + if (end[i] > static_cast(runData->GetDataBin(histoNo[i])->size())) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **WARNING** end data bin (" << end[i] << ") > histo length (" << (Int_t)runData->GetDataBin(histoNo[i])->size() << ")."; + std::cerr << std::endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << std::endl; + std::cerr << std::endl; + end[i] = static_cast(runData->GetDataBin(histoNo[i])->size())-1; } // 4th check if t0 is within proper bounds - if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!"; - cerr << endl; + if ((t0[i] < 0) || (t0[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1435,18 +1434,18 @@ Bool_t PRunAsymmetryRRF::GetProperDataRange(PRawRunData* runData, UInt_t histoNo if (fabs(static_cast(start[0])-t0[0]) > fabs(static_cast(start[1])-t0[1])){ start[1] = static_cast(t0[1] + static_cast(start[0]) - t0[0]); end[1] = static_cast(t0[1] + static_cast(end[0]) - t0[0]); - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange **WARNING** needed to shift backward data range."; - cerr << endl << ">> given: " << fRunInfo->GetDataRange(2) << ", " << fRunInfo->GetDataRange(3); - cerr << endl << ">> used : " << start[1] << ", " << end[1]; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange **WARNING** needed to shift backward data range."; + std::cerr << std::endl << ">> given: " << fRunInfo->GetDataRange(2) << ", " << fRunInfo->GetDataRange(3); + std::cerr << std::endl << ">> used : " << start[1] << ", " << end[1]; + std::cerr << std::endl; } if (fabs(static_cast(start[0])-t0[0]) < fabs(static_cast(start[1])-t0[1])){ start[0] = static_cast(t0[0] + static_cast(start[1]) - t0[1]); end[0] = static_cast(t0[0] + static_cast(end[1]) - t0[1]); - cerr << endl << ">> PRunAsymmetryRRF::GetProperDataRange **WARNING** needed to shift forward data range."; - cerr << endl << ">> given: " << fRunInfo->GetDataRange(0) << ", " << fRunInfo->GetDataRange(1); - cerr << endl << ">> used : " << start[0] << ", " << end[0]; - cerr << endl; + std::cerr << std::endl << ">> PRunAsymmetryRRF::GetProperDataRange **WARNING** needed to shift forward data range."; + std::cerr << std::endl << ">> given: " << fRunInfo->GetDataRange(0) << ", " << fRunInfo->GetDataRange(1); + std::cerr << std::endl << ">> used : " << start[0] << ", " << end[0]; + std::cerr << std::endl; } // keep good bins for potential latter use @@ -1501,7 +1500,7 @@ void PRunAsymmetryRRF::GetProperFitRange(PMsrGlobalBlock *globalBlock) if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) { fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt - cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl; - cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl; + std::cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl; + std::cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << std::endl; } } diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index d18ef587..b6be2530 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -41,7 +41,6 @@ #include #include #include -using namespace std; #include #include @@ -236,7 +235,7 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName) } if (i == fData.size()) - return 0; + return nullptr; else return &fData[i]; } @@ -256,7 +255,7 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName) PRawRunData* PRunDataHandler::GetRunData(const UInt_t idx) { if (idx >= fData.size()) - return 0; + return nullptr; else return &fData[idx]; } @@ -288,11 +287,11 @@ void PRunDataHandler::ReadData() } else if ((fFileFormat == "Wkm") || (fFileFormat == "wkm")) { fAllDataAvailable = ReadWkmFile(); } else { - cerr << endl << ">> PRunDataHandler::ReadData(): **ERROR** unkown file format \"" << fFileFormat << "\" found." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadData(): **ERROR** unkown file format \"" << fFileFormat << "\" found." << std::endl; fAllDataAvailable = false; } } else { - cerr << endl << ">> PRunDataHandler::ReadData(): **ERROR** Couldn't read files." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadData(): **ERROR** Couldn't read files." << std::endl; fAllDataAvailable = false; } } @@ -331,9 +330,9 @@ void PRunDataHandler::WriteData() void PRunDataHandler::Init(const Int_t tag) { if ((tag==PHR_INIT_ALL) || (tag==PHR_INIT_ANY2MANY)) - fMsrInfo = 0; + fMsrInfo = nullptr; if ((tag==PHR_INIT_ALL) || (tag==PHR_INIT_MSR)) - fAny2ManyInfo = 0; + fAny2ManyInfo = nullptr; fAllDataAvailable = false; if (tag!=PHR_INIT_ALL) fFileFormat = TString(""); @@ -357,15 +356,15 @@ Bool_t PRunDataHandler::ReadFilesMsr() Bool_t success = true; // loop over the full RUN list to see what needs to be read - PMsrRunList *runList = 0; + PMsrRunList *runList = nullptr; runList = fMsrInfo->GetMsrRunList(); - if (runList == 0) { - cerr << endl << ">> PRunDataHandler::ReadFilesMsr(): **ERROR** Couldn't obtain run list from PMsrHandler: something VERY fishy"; - cerr << endl; + if (runList == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::ReadFilesMsr(): **ERROR** Couldn't obtain run list from PMsrHandler: something VERY fishy"; + std::cerr << std::endl; return false; } - char str[1024], *p_str=0; + char str[1024], *p_str=nullptr; UInt_t year=0; TString musrRoot("musr-root"); @@ -379,7 +378,7 @@ Bool_t PRunDataHandler::ReadFilesMsr() // get year from string if LEM data file strcpy(str, fRunName.Data()); p_str = strstr(str, "lem"); - if (p_str != 0) + if (p_str != nullptr) sscanf(p_str, "lem%d_his", &year); // check special case for ROOT-NPP/ROOT-PPC (LEM) @@ -462,8 +461,8 @@ Bool_t PRunDataHandler::ReadFilesMsr() Bool_t PRunDataHandler::ReadWriteFilesList() { if ((fAny2ManyInfo->inFileName.size() == 0) && (fAny2ManyInfo->runList.size() == 0)) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't obtain run list from fAny2ManyInfo: something VERY fishy"; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't obtain run list from fAny2ManyInfo: something VERY fishy"; + std::cerr << std::endl; return false; } @@ -487,7 +486,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() inTag = A2M_UNDEFINED; if (inTag == A2M_UNDEFINED) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** no valid input data file format found: '" << fAny2ManyInfo->inFormat.Data() << "'" << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** no valid input data file format found: '" << fAny2ManyInfo->inFormat.Data() << "'" << std::endl; return false; } @@ -511,7 +510,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() outTag = A2M_UNDEFINED; if (outTag == A2M_UNDEFINED) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** no valid output data file format found: '" << fAny2ManyInfo->outFormat.Data() << "'" << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** no valid output data file format found: '" << fAny2ManyInfo->outFormat.Data() << "'" << std::endl; return false; } @@ -520,7 +519,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() // loop over all runs of the run list for (UInt_t i=0; iinFileName.size(); i++) { if (!FileExistsCheck(true, i)) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find file " << fAny2ManyInfo->inFileName[i].Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find file " << fAny2ManyInfo->inFileName[i].Data() << std::endl; return false; } @@ -549,7 +548,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() } if (!success) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fAny2ManyInfo->inFileName[i].Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fAny2ManyInfo->inFileName[i].Data() << std::endl; return false; } @@ -568,7 +567,6 @@ Bool_t PRunDataHandler::ReadWriteFilesList() else success = WriteMusrRootFile(fAny2ManyInfo->outFileName); break; - break; case A2M_PSIBIN: if (fAny2ManyInfo->outFileName.Length() == 0) success = WritePsiBinFile(); @@ -610,7 +608,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() } if (success == false) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << std::endl; return false; } @@ -624,7 +622,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() // loop over all runs of the run list for (UInt_t i=0; irunList.size(); i++) { if (!FileExistsCheck(false, i)) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find run " << fAny2ManyInfo->runList[i] << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find run " << fAny2ManyInfo->runList[i] << std::endl; return false; } @@ -653,7 +651,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() } if (!success) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fRunPathName.Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fRunPathName.Data() << std::endl; return false; } @@ -665,7 +663,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() Bool_t ok; TString fln = FileNameFromTemplate(fAny2ManyInfo->outTemplate, fAny2ManyInfo->runList[i], year, ok); if (!ok) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't create necessary output file name." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't create necessary output file name." << std::endl; return false; } @@ -701,7 +699,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() } if (success == false) { - cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << std::endl; return false; } @@ -750,24 +748,24 @@ Bool_t PRunDataHandler::ReadWriteFilesList() // check if the compressed file shall be streamed to the stdout if (fAny2ManyInfo->useStandardOutput) { // stream file to stdout - ifstream is; + std::ifstream is; int length=1024; char *buffer; - is.open(fln.Data(), ios::binary); + is.open(fln.Data(), std::ios::binary); if (!is.is_open()) { - cerr << endl << "PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't open the file for streaming." << endl; + std::cerr << std::endl << "PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't open the file for streaming." << std::endl; remove(fln.Data()); return false; } // get length of file - is.seekg(0, ios::end); + is.seekg(0, std::ios::end); length = is.tellg(); - is.seekg(0, ios::beg); + is.seekg(0, std::ios::beg); if (length == -1) { - cerr << endl << "PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't determine the file size." << endl; + std::cerr << std::endl << "PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't determine the file size." << std::endl; remove(fln.Data()); return false; } @@ -778,7 +776,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() // read data as a block while (!is.eof()) { is.read(buffer, length); - cout.write(buffer, length); + std::cout.write(buffer, length); } is.close(); @@ -942,28 +940,28 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) Bool_t success = true; // local init - TROOT root("PRunBase", "PRunBase", 0); + TROOT root("PRunBase", "PRunBase", nullptr); TString pathName = "???"; TString str, *pstr; TString ext; pstr = runInfo.GetBeamline(idx); - if (pstr == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain beamline data." << endl; + if (pstr == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain beamline data." << std::endl; assert(0); } pstr->ToLower(); runInfo.SetBeamline(*pstr, idx); pstr = runInfo.GetInstitute(idx); - if (pstr == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain institute data." << endl; + if (pstr == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain institute data." << std::endl; assert(0); } pstr->ToLower(); runInfo.SetInstitute(*pstr, idx); pstr = runInfo.GetFileFormat(idx); - if (pstr == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain file format data." << endl; + if (pstr == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain file format data." << std::endl; assert(0); } pstr->ToLower(); @@ -1002,25 +1000,25 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) // unkown file format found if (!success) { pstr = runInfo.GetFileFormat(idx); - if (pstr == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain file format data." << endl; + if (pstr == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain file format data." << std::endl; assert(0); } pstr->ToUpper(); - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** File Format '" << pstr->Data() << "' unsupported."; - cerr << endl << ">> support file formats are:"; - cerr << endl << ">> ROOT-NPP -> root not post pileup corrected for lem"; - cerr << endl << ">> ROOT-PPC -> root post pileup corrected for lem"; - cerr << endl << ">> MUSR-ROOT -> MusrRoot file format"; - cerr << endl << ">> NEXUS -> nexus file format, HDF4, HDF5, or XML"; - cerr << endl << ">> PSI-BIN -> psi bin file format"; - cerr << endl << ">> PSI-MDU -> psi mdu file format (see also MDU-ASCII)"; - cerr << endl << ">> MUD -> triumf mud file format"; - cerr << endl << ">> WKM -> wkm ascii file format"; - cerr << endl << ">> MDU-ASCII -> psi mdu ascii file format"; - cerr << endl << ">> ASCII -> column like file format"; - cerr << endl << ">> DB -> triumf db file \"format\""; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** File Format '" << pstr->Data() << "' unsupported."; + std::cerr << std::endl << ">> support file formats are:"; + std::cerr << std::endl << ">> ROOT-NPP -> root not post pileup corrected for lem"; + std::cerr << std::endl << ">> ROOT-PPC -> root post pileup corrected for lem"; + std::cerr << std::endl << ">> MUSR-ROOT -> MusrRoot file format"; + std::cerr << std::endl << ">> NEXUS -> nexus file format, HDF4, HDF5, or XML"; + std::cerr << std::endl << ">> PSI-BIN -> psi bin file format"; + std::cerr << std::endl << ">> PSI-MDU -> psi mdu file format (see also MDU-ASCII)"; + std::cerr << std::endl << ">> MUD -> triumf mud file format"; + std::cerr << std::endl << ">> WKM -> wkm ascii file format"; + std::cerr << std::endl << ">> MDU-ASCII -> psi mdu ascii file format"; + std::cerr << std::endl << ">> ASCII -> column like file format"; + std::cerr << std::endl << ">> DB -> triumf db file \"format\""; + std::cerr << std::endl; return success; } @@ -1071,7 +1069,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) // cleanup if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } @@ -1082,15 +1080,15 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) TObjArray *tokens = str.Tokenize(":"); TObjString *ostr; pstr = runInfo.GetInstitute(idx); - if (pstr == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain institute data." << endl; + if (pstr == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain institute data." << std::endl; assert(0); } pstr->ToUpper(); runInfo.SetInstitute(*pstr, idx); pstr = runInfo.GetBeamline(idx); - if (pstr == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain beamline data." << endl; + if (pstr == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain beamline data." << std::endl; assert(0); } pstr->ToUpper(); @@ -1110,18 +1108,18 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) // clean up if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } // no proper path name found if (pathName.CompareTo("???") == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << runInfo.GetRunName(idx)->Data() << "' in any standard path."; - cerr << endl << ">> standard search pathes are:"; - cerr << endl << ">> 1. the local directory"; - cerr << endl << ">> 2. the data directory given in the startup XML file"; - cerr << endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; - cerr << endl << ">> 4. default path construct which is described in the manual"; + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << runInfo.GetRunName(idx)->Data() << "' in any standard path."; + std::cerr << std::endl << ">> standard search pathes are:"; + std::cerr << std::endl << ">> 1. the local directory"; + std::cerr << std::endl << ">> 2. the data directory given in the startup XML file"; + std::cerr << std::endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; + std::cerr << std::endl << ">> 4. default path construct which is described in the manual"; return false; } @@ -1150,19 +1148,19 @@ Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx) TString fln(""); if (fileName) { // single input file name - if (idx >= (Int_t)fAny2ManyInfo->inFileName.size()) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx << " out of range. (inFileName.size()==" << fAny2ManyInfo->inFileName.size() << ")" << endl; + if (idx >= static_cast(fAny2ManyInfo->inFileName.size())) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx << " out of range. (inFileName.size()==" << fAny2ManyInfo->inFileName.size() << ")" << std::endl; return false; } fln = fAny2ManyInfo->inFileName[idx]; } else { // run file list entry shall be handled - if (idx >= (Int_t)fAny2ManyInfo->runList.size()) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx << " out of range. (inFileName.size()==" << fAny2ManyInfo->runList.size() << ")" << endl; + if (idx >= static_cast(fAny2ManyInfo->runList.size())) { + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx << " out of range. (inFileName.size()==" << fAny2ManyInfo->runList.size() << ")" << std::endl; return false; } // check for input/output templates if ((fAny2ManyInfo->inTemplate.Length() == 0) || (fAny2ManyInfo->outTemplate.Length() == 0)) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** when using run lists, input/output templates are needed as well." << endl; + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** when using run lists, input/output templates are needed as well." << std::endl; return false; } // make the input file name according to the input template @@ -1209,16 +1207,16 @@ Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx) // cleanup if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } // no proper path name found if (pathName.CompareTo("???") == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fln.Data() << "' in any standard path."; - cerr << endl << ">> standard search pathes are:"; - cerr << endl << ">> 1. the local directory"; - cerr << endl << ">> 2. the data directory given in the startup XML file"; - cerr << endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fln.Data() << "' in any standard path."; + std::cerr << std::endl << ">> standard search pathes are:"; + std::cerr << std::endl << ">> 1. the local directory"; + std::cerr << std::endl << ">> 2. the data directory given in the startup XML file"; + std::cerr << std::endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; return false; } @@ -1276,16 +1274,16 @@ Bool_t PRunDataHandler::FileExistsCheck(const TString fileName) // cleanup if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } // no proper path name found if (pathName.CompareTo("???") == 0) { - cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fileName.Data() << "' in any standard path."; - cerr << endl << ">> standard search pathes are:"; - cerr << endl << ">> 1. the local directory"; - cerr << endl << ">> 2. the data directory given in the startup XML file"; - cerr << endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; + std::cerr << std::endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fileName.Data() << "' in any standard path."; + std::cerr << std::endl << ">> standard search pathes are:"; + std::cerr << std::endl << ">> 1. the local directory"; + std::cerr << std::endl << ">> 2. the data directory given in the startup XML file"; + std::cerr << std::endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; return false; } @@ -1323,8 +1321,8 @@ Bool_t PRunDataHandler::ReadRootFile() if (!folder) { // either something is wrong, or it is a MusrRoot file f.GetObject("RunHeader", folder); if (!folder) { // something is wrong!! - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't neither obtain RunInfo (LEM),"; - cerr << endl << " nor RunHeader (MusrRoot) from " << fRunPathName.Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't neither obtain RunInfo (LEM),"; + std::cerr << std::endl << " nor RunHeader (MusrRoot) from " << fRunPathName.Data() << std::endl; f.Close(); return false; } else { @@ -1340,7 +1338,7 @@ Bool_t PRunDataHandler::ReadRootFile() // check if run header is valid if (!runHeader) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain run header info from ROOT file " << fRunPathName.Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain run header info from ROOT file " << fRunPathName.Data() << std::endl; f.Close(); return false; } @@ -1357,7 +1355,7 @@ Bool_t PRunDataHandler::ReadRootFile() runData.SetRunTitle(ostr.GetString()); // get run number - runData.SetRunNumber((Int_t)runHeader->GetRunNumber()); + runData.SetRunNumber(static_cast(runHeader->GetRunNumber())); // get temperature runData.ClearTemperature(); @@ -1377,7 +1375,7 @@ Bool_t PRunDataHandler::ReadRootFile() // get start time/date // start date - time_t idt = (time_t)runHeader->GetStartTime(); + time_t idt = static_cast(runHeader->GetStartTime()); runData.SetStartDateTime(idt); struct tm *dt = localtime(&idt); char str[128]; @@ -1392,7 +1390,7 @@ Bool_t PRunDataHandler::ReadRootFile() // get stop time/date // stop date - idt = (time_t)runHeader->GetStopTime(); + idt = static_cast(runHeader->GetStopTime()); runData.SetStopDateTime(idt); dt = localtime(&idt); memset(str, 0, sizeof(str)); @@ -1419,26 +1417,26 @@ Bool_t PRunDataHandler::ReadRootFile() // check if run summary is valid if (!runSummary) { - cout << endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; + std::cout << std::endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << std::endl; // this is not fatal... only RA-HV values are not available } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... //streaming of a ASCII-file would be more easy TString s; TObjArrayIter summIter(runSummary); TObjString *os(dynamic_cast(summIter.Next())); - TObjArray *oa(0); - TObjString *objTok(0); - while (os != 0) { + TObjArray *oa(nullptr); + TObjString *objTok(nullptr); + while (os != nullptr) { s = os->GetString(); // will put four parallel if's since it may be that more than one RA-values are on one line if (s.Contains("RA-L")) { oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0) { + while (objTok != nullptr) { if (!objTok->GetString().CompareTo("RA-L")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(0, objTok->GetString().Atof()); // fill RA-R value into the runData structure break; @@ -1449,7 +1447,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1457,10 +1455,10 @@ Bool_t PRunDataHandler::ReadRootFile() oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ + while (objTok != nullptr){ if (!objTok->GetString().CompareTo("RA-R")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if (objTok != nullptr && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(1, objTok->GetString().Atof()); // fill RA-R value into the runData structure break; @@ -1471,7 +1469,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1479,10 +1477,10 @@ Bool_t PRunDataHandler::ReadRootFile() oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ + while (objTok != nullptr){ if (!objTok->GetString().CompareTo("RA-T")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(2, objTok->GetString().Atof()); // fill RA-T value into the runData structure break; @@ -1493,7 +1491,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1501,10 +1499,10 @@ Bool_t PRunDataHandler::ReadRootFile() oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ + while (objTok != nullptr){ if (!objTok->GetString().CompareTo("RA-B")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(3, objTok->GetString().Atof()); // fill RA-B value into the runData structure break; @@ -1515,7 +1513,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1528,7 +1526,7 @@ Bool_t PRunDataHandler::ReadRootFile() // check if histos folder is found f.GetObject("histos", folder); if (!folder) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << std::endl; f.Close(); return false; } @@ -1539,8 +1537,8 @@ Bool_t PRunDataHandler::ReadRootFile() sprintf(histoName, "hDecay%02d", i); TH1F *histo = dynamic_cast(folder->FindObjectAny(histoName)); if (!histo) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; + std::cerr << std::endl; f.Close(); return false; } @@ -1556,7 +1554,7 @@ Bool_t PRunDataHandler::ReadRootFile() dataSet.SetHistoNo(i+1); dataSet.SetTimeZeroBin(t0[i]); dataSet.SetTimeZeroBinEstimated(histo->GetMaximumBin()); - dataSet.SetFirstGoodBin((Int_t)t0[i]); + dataSet.SetFirstGoodBin(static_cast(t0[i])); dataSet.SetLastGoodBin(histo->GetNbinsX()-1); dataSet.SetData(histoData); runData.SetDataSet(dataSet); @@ -1567,16 +1565,16 @@ Bool_t PRunDataHandler::ReadRootFile() // check if any post pileup histos are present at all (this is not the case for LEM data 2006 and earlier) sprintf(histoName, "hDecay%02d", POST_PILEUP_HISTO_OFFSET); if (!folder->FindObjectAny(histoName)) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **WARNING** Couldn't get histo " << histoName; - cerr << endl << ">> most probably this is an old (2006 or earlier) LEM file without post pileup histos."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **WARNING** Couldn't get histo " << histoName; + std::cerr << std::endl << ">> most probably this is an old (2006 or earlier) LEM file without post pileup histos."; + std::cerr << std::endl; } else { for (Int_t i=0; i(folder->FindObjectAny(histoName)); if (!histo) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; + std::cerr << std::endl; f.Close(); return false; } @@ -1591,7 +1589,7 @@ Bool_t PRunDataHandler::ReadRootFile() dataSet.SetHistoNo(i+1+POST_PILEUP_HISTO_OFFSET); dataSet.SetTimeZeroBin(t0[i]); dataSet.SetTimeZeroBinEstimated(histo->GetMaximumBin()); - dataSet.SetFirstGoodBin((Int_t)t0[i]); + dataSet.SetFirstGoodBin(static_cast(t0[i])); dataSet.SetLastGoodBin(histo->GetNbinsX()-1); dataSet.SetData(histoData); runData.SetDataSet(dataSet); @@ -1603,17 +1601,17 @@ Bool_t PRunDataHandler::ReadRootFile() } else { // MusrRoot file // invoke the MusrRoot header object TMusrRunHeader *header = new TMusrRunHeader(true); // read quite - if (header == 0) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fRunPathName; - cerr << endl; + if (header == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fRunPathName; + std::cerr << std::endl; f.Close(); return false; } // try to populate the MusrRoot header object if (!header->ExtractAll(folder)) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fRunPathName; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fRunPathName; + std::cerr << std::endl; f.Close(); return false; } @@ -1744,7 +1742,7 @@ Bool_t PRunDataHandler::ReadRootFile() else if (!prop.GetUnit().CompareTo("us") || !prop.GetUnit().CompareTo("microsec")) dval = prop.GetValue()*1.0e3; else - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Found unrecognized Time Resolution unit: " << prop.GetUnit() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Found unrecognized Time Resolution unit: " << prop.GetUnit() << std::endl; runData.SetTimeResolution(dval); } @@ -1764,8 +1762,8 @@ Bool_t PRunDataHandler::ReadRootFile() found = true; } if (!found) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** requested histo group " << fAny2ManyInfo->groupHistoList[i]; - cerr << endl << ">> which is NOT present in the data file." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** requested histo group " << fAny2ManyInfo->groupHistoList[i]; + std::cerr << std::endl << ">> which is NOT present in the data file." << std::endl; return false; } } @@ -1812,26 +1810,26 @@ Bool_t PRunDataHandler::ReadRootFile() // check if run summary is valid if (!runSummary) { - cout << endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; + std::cout << std::endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << std::endl; // this is not fatal... only RA-HV values are not available } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... //streaming of a ASCII-file would be more easy TString s; TObjArrayIter summIter(runSummary); TObjString *os(dynamic_cast(summIter.Next())); - TObjArray *oa(0); - TObjString *objTok(0); - while (os != 0) { + TObjArray *oa(nullptr); + TObjString *objTok(nullptr); + while (os != nullptr) { s = os->GetString(); // will put four parallel if's since it may be that more than one RA-values are on one line if (s.Contains("RA-L")) { oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0) { + while (objTok != nullptr) { if (!objTok->GetString().CompareTo("RA-L")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(0, objTok->GetString().Atof()); // fill RA-R value into the runData structure break; @@ -1842,7 +1840,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1850,10 +1848,10 @@ Bool_t PRunDataHandler::ReadRootFile() oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ + while (objTok != nullptr){ if (!objTok->GetString().CompareTo("RA-R")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(1, objTok->GetString().Atof()); // fill RA-R value into the runData structure break; @@ -1864,7 +1862,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1872,10 +1870,10 @@ Bool_t PRunDataHandler::ReadRootFile() oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ + while (objTok != nullptr){ if (!objTok->GetString().CompareTo("RA-T")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(2, objTok->GetString().Atof()); // fill RA-T value into the runData structure break; @@ -1886,7 +1884,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1894,10 +1892,10 @@ Bool_t PRunDataHandler::ReadRootFile() oa = s.Tokenize(" "); TObjArrayIter lineIter(oa); objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ + while (objTok != nullptr){ if (!objTok->GetString().CompareTo("RA-B")) { objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + if ((objTok != nullptr) && !objTok->GetString().CompareTo("=")) { objTok = dynamic_cast(lineIter.Next()); // HV value runData.SetRingAnode(3, objTok->GetString().Atof()); // fill RA-B value into the runData structure break; @@ -1908,7 +1906,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (oa) { delete oa; - oa = 0; + oa = nullptr; } } @@ -1921,7 +1919,7 @@ Bool_t PRunDataHandler::ReadRootFile() // check if histos folder is found f.GetObject("histos", folder); if (!folder) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << std::endl; f.Close(); return false; } @@ -1932,8 +1930,8 @@ Bool_t PRunDataHandler::ReadRootFile() str.Form("hDecay%03d", redGreenOffsets[i]+j+1); TH1F *histo = dynamic_cast(folder->FindObjectAny(str.Data())); if (!histo) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << str; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << str; + std::cerr << std::endl; f.Close(); return false; } @@ -1973,7 +1971,7 @@ Bool_t PRunDataHandler::ReadRootFile() // clean up if (header) { delete header; - header=0; + header=nullptr; } } @@ -2001,26 +1999,26 @@ Bool_t PRunDataHandler::ReadRootFile() Bool_t PRunDataHandler::ReadNexusFile() { #ifdef PNEXUS_ENABLED - cout << endl << ">> PRunDataHandler::ReadNexusFile(): Will read nexus file " << fRunPathName.Data() << " ..."; + std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): Will read nexus file " << fRunPathName.Data() << " ..."; PDoubleVector histoData; PRawRunData runData; PRawRunDataSet dataSet; TString str; - string sstr; + std::string sstr; Double_t dval; bool ok; PNeXus *nxs_file = new PNeXus(fRunPathName.Data()); if (!nxs_file->IsValid()) { - cerr << endl << ">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file."; - cerr << endl << ">> Error Message: " << nxs_file->GetErrorMsg().data() << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file."; + std::cerr << std::endl << ">> Error Message: " << nxs_file->GetErrorMsg().data() << std::endl; return false; } if (nxs_file->GetIdfVersion() == 1) { if (!nxs_file->IsValid()) { - cout << endl << "**ERROR** invalid NeXus IDF 2 version file found." << endl; + std::cout << std::endl << "**ERROR** invalid NeXus IDF 2 version file found." << std::endl; return false; } @@ -2105,12 +2103,12 @@ Bool_t PRunDataHandler::ReadNexusFile() } // get/set t0, firstGoodBin, lastGoodBin - vector *t0 = nxs_file->GetEntryIdf1()->GetData()->GetT0s(); - vector *fgb = nxs_file->GetEntryIdf1()->GetData()->GetFirstGoodBins(); - vector *lgb = nxs_file->GetEntryIdf1()->GetData()->GetLastGoodBins(); + std::vector *t0 = nxs_file->GetEntryIdf1()->GetData()->GetT0s(); + std::vector *fgb = nxs_file->GetEntryIdf1()->GetData()->GetFirstGoodBins(); + std::vector *lgb = nxs_file->GetEntryIdf1()->GetData()->GetLastGoodBins(); // get/set data - vector *pdata; + std::vector *pdata; unsigned int max=0, binMax=0; PDoubleVector data; for (UInt_t i=0; iGetEntryIdf1()->GetData()->GetNoOfHistos(); i++) { @@ -2156,7 +2154,7 @@ Bool_t PRunDataHandler::ReadNexusFile() fData.push_back(runData); } else if (nxs_file->GetIdfVersion() == 2) { if (!nxs_file->IsValid()) { - cout << endl << "**ERROR** invalid NeXus IDF 2 version file found." << endl; + std::cout << std::endl << "**ERROR** invalid NeXus IDF 2 version file found." << std::endl; return false; } // get header information @@ -2218,7 +2216,7 @@ Bool_t PRunDataHandler::ReadNexusFile() runData.SetRingAnode(i, PMUSR_UNDEFINED); // get/set setup take NXsample/temperature_1_env and NXsample/magnetic_field_1_env - sstr = nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentTemp() + string("/"); + sstr = nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentTemp() + std::string("/"); sstr += nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentField(); str = sstr; runData.SetSetup(str); @@ -2341,16 +2339,16 @@ Bool_t PRunDataHandler::ReadNexusFile() // keep the information fData.push_back(runData); } else { - cout << endl << ">> PRunDataHandler::ReadNexusFile(): IDF version " << nxs_file->GetIdfVersion() << ", not implemented." << endl; + std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): IDF version " << nxs_file->GetIdfVersion() << ", not implemented." << std::endl; } // clean up if (nxs_file) { delete nxs_file; - nxs_file = 0; + nxs_file = nullptr; } #else - cout << endl << ">> PRunDataHandler::ReadNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << endl << endl; + std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << std::endl << std::endl; #endif return true; } @@ -2372,13 +2370,13 @@ Bool_t PRunDataHandler::ReadWkmFile() PRawRunData runData; // open file - ifstream f; + std::ifstream f; // open wkm-file - f.open(fRunPathName.Data(), ifstream::in); + f.open(fRunPathName.Data(), std::ifstream::in); if (!f.is_open()) { - cerr << endl << ">> PRunDataHandler::ReadWkmFile: **ERROR** Couldn't open run data (" << fRunPathName.Data() << ") file for reading, sorry ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile: **ERROR** Couldn't open run data (" << fRunPathName.Data() << ") file for reading, sorry ..."; + std::cerr << std::endl; return false; } @@ -2408,19 +2406,19 @@ Bool_t PRunDataHandler::ReadWkmFile() } else { // real stuff, hence filter data if (line.Contains("Title") || line.Contains("Titel")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Title:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Title:' StripWhitespace(line); runData.SetRunTitle(line); } else if (line.Contains("Run:")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Run:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Run:' StripWhitespace(line); ival = ToInt(line, ok); if (ok) runData.SetRunNumber(ival); } else if (line.Contains("Field")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Field:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Field:' StripWhitespace(line); idx = line.Index("G"); // check if unit is given if (idx > 0) // unit is indeed given @@ -2430,13 +2428,13 @@ Bool_t PRunDataHandler::ReadWkmFile() runData.SetField(dval); } else if (line.Contains("Setup")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Setup:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Setup:' StripWhitespace(line); runData.SetSetup(line); } else if (line.Contains("Temp:") || line.Contains("Temp(meas1):")) { linecp = line; idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Temp:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Temp:' StripWhitespace(line); idx = line.Index("+/-"); // remove "+/- ..." part if (idx > 0) @@ -2449,7 +2447,7 @@ Bool_t PRunDataHandler::ReadWkmFile() runData.SetTemperature(0, dval, 0.0); } idx = linecp.Index("+/-"); // get the error - linecp.Replace(0, idx+3, 0, 0); + linecp.Replace(0, idx+3, nullptr, 0); StripWhitespace(linecp); dval = ToDouble(linecp, ok); if (ok) { @@ -2458,7 +2456,7 @@ Bool_t PRunDataHandler::ReadWkmFile() } else if (line.Contains("Temp(meas2):")) { linecp = line; idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Temp(meas2):' + line.Replace(0, idx+1, nullptr, 0); // remove 'Temp(meas2):' StripWhitespace(line); idx = line.Index("+/-"); // remove "+/- ..." part if (idx > 0) @@ -2471,7 +2469,7 @@ Bool_t PRunDataHandler::ReadWkmFile() runData.SetTemperature(1, dval, 0.0); } idx = linecp.Index("+/-"); // get the error - linecp.Replace(0, idx+3, 0, 0); + linecp.Replace(0, idx+3, nullptr, 0); StripWhitespace(linecp); dval = ToDouble(linecp, ok); if (ok) { @@ -2479,21 +2477,21 @@ Bool_t PRunDataHandler::ReadWkmFile() } } else if (line.Contains("Groups")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Groups:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Groups:' StripWhitespace(line); ival = ToInt(line, ok); if (ok) groups = ival; } else if (line.Contains("Channels")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Channels:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Channels:' StripWhitespace(line); ival = ToInt(line, ok); if (ok) channels = ival; } else if (line.Contains("Resolution")) { idx = line.Index(":"); - line.Replace(0, idx+1, 0, 0); // remove 'Resolution:' + line.Replace(0, idx+1, nullptr, 0); // remove 'Resolution:' StripWhitespace(line); dval = ToDouble(line, ok); if (ok) @@ -2506,11 +2504,11 @@ Bool_t PRunDataHandler::ReadWkmFile() } while (headerInfo && !f.eof()); if ((groups == 0) || (channels == 0) || runData.GetTimeResolution() == 0.0) { - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** essential header informations are missing!"; - cerr << endl << ">> groups = " << groups; - cerr << endl << ">> channels = " << channels; - cerr << endl << ">> time resolution = " << runData.GetTimeResolution(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** essential header informations are missing!"; + std::cerr << std::endl << ">> groups = " << groups; + std::cerr << std::endl << ">> channels = " << channels; + std::cerr << std::endl << ">> time resolution = " << runData.GetTimeResolution(); + std::cerr << std::endl; f.close(); return false; } @@ -2556,7 +2554,7 @@ Bool_t PRunDataHandler::ReadWkmFile() tokens = line.Tokenize(" "); if (!tokens) { // no tokens found - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; return false; } for (Int_t i=0; iGetEntries(); i++) { @@ -2566,7 +2564,7 @@ Bool_t PRunDataHandler::ReadWkmFile() if (ok) { histoData.push_back(val); } else { - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; // clean up delete tokens; return false; @@ -2575,7 +2573,7 @@ Bool_t PRunDataHandler::ReadWkmFile() // clean up if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } @@ -2589,7 +2587,7 @@ Bool_t PRunDataHandler::ReadWkmFile() line = TString(instr); tokens = line.Tokenize(" "); if (!tokens) { // no tokens found - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; return false; } for (Int_t i=0; iGetEntries(); i++) { @@ -2599,7 +2597,7 @@ Bool_t PRunDataHandler::ReadWkmFile() if (ok) { histoData.push_back(val); } else { - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; // clean up delete tokens; return false; @@ -2608,7 +2606,7 @@ Bool_t PRunDataHandler::ReadWkmFile() // clean up if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } @@ -2637,17 +2635,17 @@ Bool_t PRunDataHandler::ReadWkmFile() f.close(); // check if all groups are found - if ((Int_t) runData.GetNoOfHistos() != groups) { - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR**"; - cerr << endl << ">> expected " << groups << " histos, but found " << runData.GetNoOfHistos(); + if (static_cast(runData.GetNoOfHistos()) != groups) { + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR**"; + std::cerr << std::endl << ">> expected " << groups << " histos, but found " << runData.GetNoOfHistos(); return false; } // check if all groups have enough channels for (UInt_t i=0; isize() != channels) { - cerr << endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR**"; - cerr << endl << ">> expected " << channels << " bins in histo " << i+1 << ", but found " << runData.GetDataBin(i)->size(); + if (static_cast(runData.GetDataBin(i+1)->size()) != channels) { + std::cerr << std::endl << ">> PRunDataHandler::ReadWkmFile(): **ERROR**"; + std::cerr << std::endl << ">> expected " << channels << " bins in histo " << i+1 << ", but found " << runData.GetDataBin(i)->size(); return false; } } @@ -2685,23 +2683,23 @@ Bool_t PRunDataHandler::ReadPsiBinFile() success = true; break; case 1: // couldn't open file, or failed while reading the header - cerr << endl << ">> **ERROR** couldn't open psi-bin file, or failed while reading the header"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** couldn't open psi-bin file, or failed while reading the header"; + std::cerr << std::endl; success = false; break; case 2: // unsupported version of the data - cerr << endl << ">> **ERROR** psi-bin file: unsupported version of the data"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** psi-bin file: unsupported version of the data"; + std::cerr << std::endl; success = false; break; case 3: // error when allocating data buffer - cerr << endl << ">> **ERROR** psi-bin file: error when allocating data buffer"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** psi-bin file: error when allocating data buffer"; + std::cerr << std::endl; success = false; break; case 4: // number of histograms/record not equals 1 - cerr << endl << ">> **ERROR** psi-bin file: number of histograms/record not equals 1"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** psi-bin file: number of histograms/record not equals 1"; + std::cerr << std::endl; success = false; break; default: // you never should have reached this point @@ -2784,9 +2782,9 @@ Bool_t PRunDataHandler::ReadPsiBinFile() runData.SetTransport(PMUSR_UNDEFINED); // get field Double_t scale = 0.0; - if (psiBin.get_field().rfind("G") != string::npos) + if (psiBin.get_field().rfind("G") != std::string::npos) scale = 1.0; - if (psiBin.get_field().rfind("T") != string::npos) + if (psiBin.get_field().rfind("T") != std::string::npos) scale = 1.0e4; status = sscanf(psiBin.get_field().c_str(), "%lf", &dval); if (status == 1) @@ -2812,15 +2810,15 @@ Bool_t PRunDataHandler::ReadPsiBinFile() runData.SetTimeResolution(psiBin.get_binWidth_ns()); // get start/stop time - vector sDateTime = psiBin.get_timeStart_vector(); + std::vector sDateTime = psiBin.get_timeStart_vector(); if (sDateTime.size() < 2) { - cerr << endl << ">> **WARNING** psi-bin file: couldn't obtain run start date/time" << endl; + std::cerr << std::endl << ">> **WARNING** psi-bin file: couldn't obtain run start date/time" << std::endl; } - string date(""); + std::string date(""); if (DateToISO8601(sDateTime[0], date)) { runData.SetStartDate(date); } else { - cerr << endl << ">> **WARNING** failed to convert start date: " << sDateTime[0] << " into ISO 8601 date." << endl; + std::cerr << std::endl << ">> **WARNING** failed to convert start date: " << sDateTime[0] << " into ISO 8601 date." << std::endl; runData.SetStartDate(sDateTime[0]); } runData.SetStartTime(sDateTime[1]); @@ -2828,13 +2826,13 @@ Bool_t PRunDataHandler::ReadPsiBinFile() sDateTime = psiBin.get_timeStop_vector(); if (sDateTime.size() < 2) { - cerr << endl << ">> **WARNING** psi-bin file: couldn't obtain run stop date/time" << endl; + std::cerr << std::endl << ">> **WARNING** psi-bin file: couldn't obtain run stop date/time" << std::endl; } - date = string(""); + date = std::string(""); if (DateToISO8601(sDateTime[0], date)) { runData.SetStopDate(date); } else { - cerr << endl << ">> **WARNING** failed to convert stop date: " << sDateTime[0] << " into ISO 8601 date." << endl; + std::cerr << std::endl << ">> **WARNING** failed to convert stop date: " << sDateTime[0] << " into ISO 8601 date." << std::endl; runData.SetStopDate(sDateTime[0]); } runData.SetStopTime(sDateTime[1]); @@ -2844,24 +2842,24 @@ Bool_t PRunDataHandler::ReadPsiBinFile() PIntVector t0 = psiBin.get_t0_vector(); if (t0.empty()) { - cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any t0's"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any t0's"; + std::cerr << std::endl; return false; } // get first good bin PIntVector fgb = psiBin.get_firstGood_vector(); if (fgb.empty()) { - cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any fgb's"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any fgb's"; + std::cerr << std::endl; return false; } // get last good bin PIntVector lgb = psiBin.get_lastGood_vector(); if (lgb.empty()) { - cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any lgb's"; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any lgb's"; + std::cerr << std::endl; return false; } @@ -2889,12 +2887,12 @@ Bool_t PRunDataHandler::ReadPsiBinFile() dataSet.Clear(); dataSet.SetName(psiBin.get_nameHisto(i).c_str()); dataSet.SetHistoNo(i+1); // i.e. hist numbering starts at 1 - if (i < (Int_t)t0.size()) + if (i < static_cast(t0.size())) dataSet.SetTimeZeroBin(t0[i]); dataSet.SetTimeZeroBinEstimated(maxBin); - if (i < (Int_t)fgb.size()) + if (i < static_cast(fgb.size())) dataSet.SetFirstGoodBin(fgb[i]); - if (i < (Int_t)lgb.size()) + if (i < static_cast(lgb.size())) dataSet.SetLastGoodBin(lgb[i]); dataSet.SetData(histoData); @@ -2929,10 +2927,10 @@ Bool_t PRunDataHandler::ReadMudFile() PRawRunData runData; - fh = MUD_openRead((Char_t *)fRunPathName.Data(), &type); + fh = MUD_openRead((char*)fRunPathName.Data(), &type); if (fh == -1) { - cerr << endl << ">> **ERROR** Couldn't open mud-file " << fRunPathName.Data() << ", sorry."; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** Couldn't open mud-file " << fRunPathName.Data() << ", sorry."; + std::cerr << std::endl; return false; } @@ -2944,8 +2942,8 @@ Bool_t PRunDataHandler::ReadMudFile() // get/set the lab success = MUD_getLab( fh, str, sizeof(str) ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't obtain the laboratory name of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't obtain the laboratory name of run " << fRunName.Data(); + std::cerr << std::endl; strcpy(str, "n/a"); } runData.SetLaboratory(TString(str)); @@ -2953,8 +2951,8 @@ Bool_t PRunDataHandler::ReadMudFile() // get/set the beamline success = MUD_getArea( fh, str, sizeof(str) ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't obtain the beamline of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't obtain the beamline of run " << fRunName.Data(); + std::cerr << std::endl; strcpy(str, "n/a"); } runData.SetBeamline(TString(str)); @@ -2962,8 +2960,8 @@ Bool_t PRunDataHandler::ReadMudFile() // get/set the instrument success = MUD_getApparatus( fh, str, sizeof(str) ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't obtain the instrument name of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't obtain the instrument name of run " << fRunName.Data(); + std::cerr << std::endl; strcpy(str, "n/a"); } runData.SetInstrument(TString(str)); @@ -2971,15 +2969,15 @@ Bool_t PRunDataHandler::ReadMudFile() // get run title success = MUD_getTitle( fh, str, sizeof(str) ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't obtain the run title of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't obtain the run title of run " << fRunName.Data(); + std::cerr << std::endl; } runData.SetRunTitle(TString(str)); // get run number success = MUD_getRunNumber( fh, &val ); if (success) { - runData.SetRunNumber((Int_t)val); + runData.SetRunNumber(static_cast(val)); } // get start/stop time of the run @@ -2988,7 +2986,7 @@ Bool_t PRunDataHandler::ReadMudFile() TString stime(""); success = MUD_getTimeBegin( fh, (UINT32*)&tval ); if (success) { - runData.SetStartDateTime((const time_t)tval); + runData.SetStartDateTime(static_cast(tval)); dt = localtime((const time_t*)&tval); if (dt) { @@ -3002,7 +3000,7 @@ Bool_t PRunDataHandler::ReadMudFile() stime = str; runData.SetStartTime(stime); } else { - cerr << "PRunDataHandler::ReadMudFile: **WARNING** run start time readback wrong, will set it to 1900-01-01, 00:00:00" << endl; + std::cerr << "PRunDataHandler::ReadMudFile: **WARNING** run start time readback wrong, will set it to 1900-01-01, 00:00:00" << std::endl; stime = "1900-01-01"; runData.SetStartDate(stime); stime = "00:00:00"; @@ -3027,7 +3025,7 @@ Bool_t PRunDataHandler::ReadMudFile() stime = str; runData.SetStopTime(stime); } else { - cerr << "PRunDataHandler::ReadMudFile: **WARNING** run stop time readback wrong, will set it to 1900-01-01, 00:00:00" << endl; + std::cerr << "PRunDataHandler::ReadMudFile: **WARNING** run stop time readback wrong, will set it to 1900-01-01, 00:00:00" << std::endl; stime = "1900-01-01"; runData.SetStopDate(stime); stime = "00:00:00"; @@ -3046,11 +3044,9 @@ Bool_t PRunDataHandler::ReadMudFile() if (success) { setup += TString(str) + TString("/"); if (TString(str) == "BNQR" || TString(str) == "BNMR") { - cerr << "PRunDataHandler::ReadMudFile: **INFORMATION** this run was performed on " << str << endl; - // identified BNMR/BNQR, do not change multiplier. - // Change x label in PMusrCanvas instead. - // I am keeping this here for now for possible future use. - // timeResMultiplier = 1.0e9; + std::cerr << "PRunDataHandler::ReadMudFile: **INFORMATION** this run was performed on " << str << std::endl; + // identified BNMR/BNQR, correct time resolution. + timeResMultiplier = 1.0e15; } } success = MUD_getApparatus( fh, str, sizeof(str) ); @@ -3097,12 +3093,12 @@ Bool_t PRunDataHandler::ReadMudFile() // get number of histogramms success = MUD_getHists(fh, &type, &val); if ( !success ) { - cerr << endl << ">> **ERROR** Couldn't obtain the number of histograms of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **ERROR** Couldn't obtain the number of histograms of run " << fRunName.Data(); + std::cerr << std::endl; MUD_closeRead(fh); return false; } - Int_t noOfHistos = (Int_t)val; + Int_t noOfHistos = static_cast(val); // get time resolution (ns) // check that time resolution is identical for all histograms @@ -3113,9 +3109,9 @@ Bool_t PRunDataHandler::ReadMudFile() for (Int_t i=1; i<=noOfHistos; i++) { success = MUD_getHistSecondsPerBin( fh, i, &lrval ); if (!success) { - cerr << endl << ">> **ERROR** Couldn't obtain the time resolution of run " << fRunName.Data(); - cerr << endl << ">> which is fatal, sorry."; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** Couldn't obtain the time resolution of run " << fRunName.Data(); + std::cerr << std::endl << ">> which is fatal, sorry."; + std::cerr << std::endl; MUD_closeRead(fh); return false; } @@ -3123,16 +3119,16 @@ Bool_t PRunDataHandler::ReadMudFile() timeResolution = lrval; } else { if (lrval != timeResolution) { - cerr << endl << ">> **ERROR** various time resolutions found in run " << fRunName.Data(); - cerr << endl << ">> this is currently not supported, sorry."; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** various time resolutions found in run " << fRunName.Data(); + std::cerr << std::endl << ">> this is currently not supported, sorry."; + std::cerr << std::endl; MUD_closeRead(fh); return false; } } } - runData.SetTimeResolution((Double_t)timeResolution * timeResMultiplier); // s -> ns + runData.SetTimeResolution(static_cast(timeResolution) * timeResMultiplier); // s -> ns // An additional factor of 1e6 needed for bNMR // Check if it is a bNMR run and fix it or check if "timeres" line // was introduced in the msr file @@ -3140,7 +3136,7 @@ Bool_t PRunDataHandler::ReadMudFile() // read histograms UINT32 *pData; // histo memory - pData = NULL; + pData = nullptr; PDoubleVector histoData; PRawRunDataSet dataSet; UInt_t noOfBins; @@ -3153,61 +3149,61 @@ Bool_t PRunDataHandler::ReadMudFile() // get t0's success = MUD_getHistT0_Bin( fh, i, &val ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't get t0 of histo " << i << " of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't get t0 of histo " << i << " of run " << fRunName.Data(); + std::cerr << std::endl; } - dataSet.SetTimeZeroBin((Double_t)val); + dataSet.SetTimeZeroBin(static_cast(val)); // get bkg bins success = MUD_getHistBkgd1( fh, i, &val ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't get bkg bin 1 of histo " << i << " of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't get bkg bin 1 of histo " << i << " of run " << fRunName.Data(); + std::cerr << std::endl; val = 0; } - dataSet.SetFirstBkgBin((Int_t)val); + dataSet.SetFirstBkgBin(static_cast(val)); success = MUD_getHistBkgd2( fh, i, &val ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't get bkg bin 2 of histo " << i << " of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't get bkg bin 2 of histo " << i << " of run " << fRunName.Data(); + std::cerr << std::endl; val = 0; } - dataSet.SetLastBkgBin((Int_t)val); + dataSet.SetLastBkgBin(static_cast(val)); // get good data bins success = MUD_getHistGoodBin1( fh, i, &val ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't get good bin 1 of histo " << i << " of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't get good bin 1 of histo " << i << " of run " << fRunName.Data(); + std::cerr << std::endl; val = 0; } - dataSet.SetFirstGoodBin((Int_t)val); + dataSet.SetFirstGoodBin(static_cast(val)); success = MUD_getHistGoodBin2( fh, i, &val ); if ( !success ) { - cerr << endl << ">> **WARNING** Couldn't get good bin 2 of histo " << i << " of run " << fRunName.Data(); - cerr << endl; + std::cerr << std::endl << ">> **WARNING** Couldn't get good bin 2 of histo " << i << " of run " << fRunName.Data(); + std::cerr << std::endl; val = 0; } - dataSet.SetLastGoodBin((Int_t)val); + dataSet.SetLastGoodBin(static_cast(val)); // get number of bins success = MUD_getHistNumBins( fh, i, &val ); if ( !success ) { - cerr << endl << ">> **ERROR** Couldn't get the number of bins of histo " << i << "."; - cerr << endl << ">> This is fatal, sorry."; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** Couldn't get the number of bins of histo " << i << "."; + std::cerr << std::endl << ">> This is fatal, sorry."; + std::cerr << std::endl; MUD_closeRead( fh ); return false; } - noOfBins = (UInt_t)val; + noOfBins = static_cast(val); pData = (UINT32*)malloc(noOfBins*sizeof(pData)); - if (pData == NULL) { - cerr << endl << ">> **ERROR** Couldn't allocate memory for data."; - cerr << endl << ">> This is fatal, sorry."; - cerr << endl; + if (pData == nullptr) { + std::cerr << std::endl << ">> **ERROR** Couldn't allocate memory for data."; + std::cerr << std::endl << ">> This is fatal, sorry."; + std::cerr << std::endl; MUD_closeRead( fh ); return false; } @@ -3215,9 +3211,9 @@ Bool_t PRunDataHandler::ReadMudFile() // get histogram success = MUD_getHistData( fh, i, pData ); if ( !success ) { - cerr << endl << ">> **ERROR** Couldn't get histo no " << i << "."; - cerr << endl << ">> This is fatal, sorry."; - cerr << endl; + std::cerr << std::endl << ">> **ERROR** Couldn't get histo no " << i << "."; + std::cerr << std::endl << ">> This is fatal, sorry."; + std::cerr << std::endl; MUD_closeRead( fh ); return false; } @@ -3287,13 +3283,13 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() Bool_t success = true; // open file - ifstream f; + std::ifstream f; // open data-file - f.open(fRunPathName.Data(), ifstream::in); + f.open(fRunPathName.Data(), std::ifstream::in); if (!f.is_open()) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ..."; + std::cerr << std::endl; return false; } @@ -3309,12 +3305,12 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() Bool_t dataTag = false; Int_t dataLineCounter = 0; TObjString *ostr; - TObjArray *tokens = 0; + TObjArray *tokens = nullptr; TString str; Int_t groups = 0; Int_t channels = 0; Double_t dval = 0.0, unitScaling = 0.0; - vector data; + std::vector data; while (!f.eof()) { f.getline(instr, sizeof(instr)); @@ -3356,9 +3352,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() tokens = workStr.Tokenize(":("); // field: val (units) // check if expected number of tokens present if (tokens->GetEntries() != 3) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", invalid field entry in header."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", invalid field entry in header."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3367,9 +3363,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() if (ostr->GetString().IsFloat()) { dval = ostr->GetString().Atof(); } else { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", field value is not float/doulbe."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", field value is not float/doulbe."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3380,9 +3376,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() else if (ostr->GetString().Contains("T")) unitScaling = 1.0e4; else { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", unkown field units."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", unkown field units."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3391,15 +3387,15 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } else if (workStr.BeginsWith("temp:", TString::kIgnoreCase)) { tokens = workStr.Tokenize(":("); // temp: val (units) // check if expected number of tokens present if (tokens->GetEntries() != 3) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", invalid temperatue entry in header."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", invalid temperatue entry in header."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3408,9 +3404,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() if (ostr->GetString().IsFloat()) { dval = ostr->GetString().Atof(); } else { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", temperature value is not float/doulbe."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", temperature value is not float/doulbe."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3419,7 +3415,7 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } else if (workStr.BeginsWith("setup:", TString::kIgnoreCase)) { runData.SetSetup(TString(workStr.Data()+workStr.First(":")+2)); @@ -3427,8 +3423,8 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() workStr = TString(workStr.Data()+workStr.First(":")+2); groups = workStr.Atoi(); if (groups == 0) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", groups is not a number or 0."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", groups is not a number or 0."; + std::cerr << std::endl; success = false; break; } @@ -3437,8 +3433,8 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() workStr = TString(workStr.Data()+workStr.First(":")+2); channels = workStr.Atoi(); if (channels == 0) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", channels is not a number or 0."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", channels is not a number or 0."; + std::cerr << std::endl; success = false; break; } @@ -3446,9 +3442,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() tokens = workStr.Tokenize(":("); // resolution: val (units) // check if expected number of tokens present if (tokens->GetEntries() != 3) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", invalid time resolution entry in header."; - cerr << endl << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", invalid time resolution entry in header."; + std::cerr << std::endl << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3457,9 +3453,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() if (ostr->GetString().IsFloat()) { dval = ostr->GetString().Atof(); } else { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", time resolution value is not float/doulbe."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", time resolution value is not float/doulbe."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3474,9 +3470,9 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() else if (ostr->GetString().Contains("us")) unitScaling = 1.0e3; else { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", unkown time resolution units."; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", unkown time resolution units."; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3485,11 +3481,11 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } else { // error - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", illegal header line."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo << ", illegal header line."; + std::cerr << std::endl; success = false; break; } @@ -3498,10 +3494,10 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() tokens = line.Tokenize(" ,\t"); // check if the number of data line entries is correct if (tokens->GetEntries() != groups+1) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** found data line with a wrong data format, cannot be handled (line no " << lineNo << ")"; - cerr << endl << ">> line:"; - cerr << endl << ">> " << line.Data(); - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **ERROR** found data line with a wrong data format, cannot be handled (line no " << lineNo << ")"; + std::cerr << std::endl << ">> line:"; + std::cerr << std::endl << ">> " << line.Data(); + std::cerr << std::endl; success = false; break; } @@ -3514,7 +3510,7 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } } } @@ -3547,8 +3543,8 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() data.clear(); if (dataLineCounter != channels) { - cerr << endl << ">> PRunDataHandler::ReadMduAsciiFile **WARNING** found " << dataLineCounter << " data bins,"; - cerr << endl << ">> expected " << channels << " according to the header." << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadMduAsciiFile **WARNING** found " << dataLineCounter << " data bins,"; + std::cerr << std::endl << ">> expected " << channels << " according to the header." << std::endl; } fData.push_back(runData); @@ -3600,13 +3596,13 @@ Bool_t PRunDataHandler::ReadAsciiFile() Bool_t success = true; // open file - ifstream f; + std::ifstream f; // open data-file - f.open(fRunPathName.Data(), ifstream::in); + f.open(fRunPathName.Data(), std::ifstream::in); if (!f.is_open()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ..."; + std::cerr << std::endl; return false; } @@ -3666,8 +3662,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() } else if (workStr.BeginsWith("field:", TString::kIgnoreCase)) { workStr = TString(workStr.Data()+workStr.First(":")+2); if (!workStr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", field is not a number."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", field is not a number."; + std::cerr << std::endl; success = false; break; } @@ -3679,8 +3675,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() } else if (workStr.BeginsWith("temp:", TString::kIgnoreCase)) { workStr = TString(workStr.Data()+workStr.First(":")+2); if (!workStr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", temperature is not a number."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", temperature is not a number."; + std::cerr << std::endl; success = false; break; } @@ -3688,16 +3684,16 @@ Bool_t PRunDataHandler::ReadAsciiFile() } else if (workStr.BeginsWith("energy:", TString::kIgnoreCase)) { workStr = TString(workStr.Data()+workStr.First(":")+2); if (!workStr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", energy is not a number."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", energy is not a number."; + std::cerr << std::endl; success = false; break; } runData.SetEnergy(workStr.Atof()); runData.SetTransport(PMUSR_UNDEFINED); // just to initialize the variables to some "meaningful" value } else { // error - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", illegal header line."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", illegal header line."; + std::cerr << std::endl; success = false; break; } @@ -3714,8 +3710,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() tokens = line.Tokenize(" ,\t"); // check if the number of data line entries is 2 or 3 if ((tokens->GetEntries() != 2) && (tokens->GetEntries() != 3)) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** found data line with a structure different than \"x, y [, error y]\", cannot be handled (line no " << lineNo << ")"; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** found data line with a structure different than \"x, y [, error y]\", cannot be handled (line no " << lineNo << ")"; + std::cerr << std::endl; success = false; break; } @@ -3723,8 +3719,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() // get x ostr = dynamic_cast(tokens->At(0)); if (!ostr->GetString().IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ": x = " << ostr->GetString().Data() << " is not a number, sorry."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ": x = " << ostr->GetString().Data() << " is not a number, sorry."; + std::cerr << std::endl; success = false; break; } @@ -3733,8 +3729,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() // get y ostr = dynamic_cast(tokens->At(1)); if (!ostr->GetString().IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ": y = " << ostr->GetString().Data() << " is not a number, sorry."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ": y = " << ostr->GetString().Data() << " is not a number, sorry."; + std::cerr << std::endl; success = false; break; } @@ -3744,8 +3740,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() if (tokens->GetEntries() == 3) { ostr = dynamic_cast(tokens->At(2)); if (!ostr->GetString().IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ": error y = " << ostr->GetString().Data() << " is not a number, sorry."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ": error y = " << ostr->GetString().Data() << " is not a number, sorry."; + std::cerr << std::endl; success = false; break; } @@ -3757,7 +3753,7 @@ Bool_t PRunDataHandler::ReadAsciiFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } // keep values @@ -3767,8 +3763,8 @@ Bool_t PRunDataHandler::ReadAsciiFile() eyVec.push_back(ey); } else { - cerr << endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << " neither header nor data line. No idea how to handle it!"; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << " neither header nor data line. No idea how to handle it!"; + std::cerr << std::endl; success = false; break; } @@ -3911,13 +3907,13 @@ Bool_t PRunDataHandler::ReadDBFile() Bool_t success = true; // open file - ifstream f; + std::ifstream f; // open db-file - f.open(fRunPathName.Data(), ifstream::in); + f.open(fRunPathName.Data(), std::ifstream::in); if (!f.is_open()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ..."; + std::cerr << std::endl; return false; } @@ -3938,7 +3934,7 @@ Bool_t PRunDataHandler::ReadDBFile() // variables needed to tokenize strings TString tstr; TObjString *ostr; - TObjArray *tokens = 0; + TObjArray *tokens = nullptr; while (!f.eof()) { // get next line from file @@ -3983,7 +3979,7 @@ Bool_t PRunDataHandler::ReadDBFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } continue; } @@ -4023,7 +4019,7 @@ Bool_t PRunDataHandler::ReadDBFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } // prepare data vector for use @@ -4043,9 +4039,9 @@ Bool_t PRunDataHandler::ReadDBFile() TString run("run"); idx = GetDataTagIndex(run, runData.fDataNonMusr.GetDataTags()); if (idx == -1) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> found potential run data line without run data tag."; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> found potential run data line without run data tag."; return false; } // split string in tokens @@ -4053,10 +4049,10 @@ Bool_t PRunDataHandler::ReadDBFile() ostr = dynamic_cast(tokens->At(0)); tstr = ostr->GetString(); if (!tstr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: runNo,,, runTitle"; - cerr << endl << ">> runNo = " << tstr.Data() << ", seems to be not a number."; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: runNo,,, runTitle"; + std::cerr << std::endl << ">> runNo = " << tstr.Data() << ", seems to be not a number."; delete tokens; return false; } @@ -4069,9 +4065,9 @@ Bool_t PRunDataHandler::ReadDBFile() // split string in tokens tokens = workStr.Tokenize("=,"); // line has structure: tag = val,err1,err2, if (tokens->GetEntries() < 3) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; delete tokens; return false; } @@ -4079,9 +4075,9 @@ Bool_t PRunDataHandler::ReadDBFile() tstr = ostr->GetString(); idx = GetDataTagIndex(tstr, runData.fDataNonMusr.GetDataTags()); if (idx == -1) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> data tag error: " << tstr.Data() << " seems not present in the data tag list"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> data tag error: " << tstr.Data() << " seems not present in the data tag list"; delete tokens; return false; } @@ -4091,10 +4087,10 @@ Bool_t PRunDataHandler::ReadDBFile() ostr = dynamic_cast(tokens->At(1)); tstr = ostr->GetString(); if (!tstr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; - cerr << endl << ">> val = " << tstr.Data() << ", seems to be not a number."; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; + std::cerr << std::endl << ">> val = " << tstr.Data() << ", seems to be not a number."; delete tokens; return false; } @@ -4108,10 +4104,10 @@ Bool_t PRunDataHandler::ReadDBFile() ostr = dynamic_cast(tokens->At(1)); tstr = ostr->GetString(); if (!tstr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; - cerr << endl << ">> val = " << tstr.Data() << ", seems to be not a number."; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; + std::cerr << std::endl << ">> val = " << tstr.Data() << ", seems to be not a number."; delete tokens; return false; } @@ -4121,10 +4117,10 @@ Bool_t PRunDataHandler::ReadDBFile() ostr = dynamic_cast(tokens->At(2)); tstr = ostr->GetString(); if (!tstr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; - cerr << endl << ">> err1 = " << tstr.Data() << ", seems to be not a number."; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; + std::cerr << std::endl << ">> err1 = " << tstr.Data() << ", seems to be not a number."; delete tokens; return false; } @@ -4132,24 +4128,23 @@ Bool_t PRunDataHandler::ReadDBFile() runData.fDataNonMusr.AppendSubErrData(idx, val); break; default: - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: tag = val,err1,err2,\\"; delete tokens; return false; - break; } } } else { // handle row formated data // split string in tokens tokens = workStr.Tokenize(","); // line has structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle - if (tokens->GetEntries() != (Int_t)(3*runData.fDataNonMusr.GetDataTags()->size()+1)) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; - cerr << endl << ">> found = " << tokens->GetEntries() << " tokens, however expected " << 3*runData.fDataNonMusr.GetDataTags()->size()+1; - cerr << endl << ">> Perhaps there are commas without space inbetween, like 12.3,, 3.2,..."; + if (tokens->GetEntries() != static_cast(3*runData.fDataNonMusr.GetDataTags()->size()+1)) { + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; + std::cerr << std::endl << ">> found = " << tokens->GetEntries() << " tokens, however expected " << 3*runData.fDataNonMusr.GetDataTags()->size()+1; + std::cerr << std::endl << ">> Perhaps there are commas without space inbetween, like 12.3,, 3.2,..."; delete tokens; return false; } @@ -4160,10 +4155,10 @@ Bool_t PRunDataHandler::ReadDBFile() ostr = dynamic_cast(tokens->At(i)); tstr = ostr->GetString(); if (!tstr.IsFloat()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; - cerr << endl << ">> value=" << tstr.Data() << " seems not to be a number"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; + std::cerr << std::endl << ">> value=" << tstr.Data() << " seems not to be a number"; delete tokens; return false; } @@ -4177,10 +4172,10 @@ Bool_t PRunDataHandler::ReadDBFile() } else if (tstr.IsFloat()) { runData.fDataNonMusr.AppendSubErrData(j, tstr.Atof()); } else { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; - cerr << endl << ">> " << workStr.Data(); - cerr << endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; - cerr << endl << ">> error1=" << tstr.Data() << " seems not to be a number"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; + std::cerr << std::endl << ">> " << workStr.Data(); + std::cerr << std::endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; + std::cerr << std::endl << ">> error1=" << tstr.Data() << " seems not to be a number"; delete tokens; return false; } @@ -4197,13 +4192,13 @@ Bool_t PRunDataHandler::ReadDBFile() // check that the number of labels == the number of data tags if (runData.fDataNonMusr.GetLabels()->size() != runData.fDataNonMusr.GetDataTags()->size()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR**"; - cerr << endl << ">> number of LABELS found = " << runData.fDataNonMusr.GetLabels()->size(); - cerr << endl << ">> number of Data tags found = " << runData.fDataNonMusr.GetDataTags()->size(); - cerr << endl << ">> They have to be equal!!"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR**"; + std::cerr << std::endl << ">> number of LABELS found = " << runData.fDataNonMusr.GetLabels()->size(); + std::cerr << std::endl << ">> number of Data tags found = " << runData.fDataNonMusr.GetDataTags()->size(); + std::cerr << std::endl << ">> They have to be equal!!"; if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } return false; } @@ -4211,18 +4206,18 @@ Bool_t PRunDataHandler::ReadDBFile() // check if all vectors have the same size for (UInt_t i=1; isize(); i++) { if (runData.fDataNonMusr.GetData()->at(i).size() != runData.fDataNonMusr.GetData()->at(i-1).size()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo; - cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).size(); - cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i).size(); - cerr << endl << ">> They have to be equal!!"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo; + std::cerr << std::endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).size(); + std::cerr << std::endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i).size(); + std::cerr << std::endl << ">> They have to be equal!!"; success = false; break; } if (runData.fDataNonMusr.GetErrData()->at(i).size() != runData.fDataNonMusr.GetErrData()->at(i-1).size()) { - cerr << endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo; - cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).size(); - cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i).Data() << ", number error data elements = " << runData.fDataNonMusr.GetErrData()->at(i).size(); - cerr << endl << ">> They have to be equal!!"; + std::cerr << std::endl << ">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo; + std::cerr << std::endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).size(); + std::cerr << std::endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i).Data() << ", number error data elements = " << runData.fDataNonMusr.GetErrData()->at(i).size(); + std::cerr << std::endl << ">> They have to be equal!!"; success = false; break; } @@ -4231,7 +4226,7 @@ Bool_t PRunDataHandler::ReadDBFile() // clean up tokens if (tokens) { delete tokens; - tokens = 0; + tokens = nullptr; } // keep run name @@ -4262,7 +4257,7 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) return false; if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WriteMusrRootFile(): writing a root data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteMusrRootFile(): writing a root data file (" << fln.Data() << ") ... " << std::endl; // generate data file TFolder *histosFolder; @@ -4327,7 +4322,7 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) dval[0] = fData[0].GetField(); prop.Set("Sample Magnetic Field", dval[0], "G"); header->Set("RunInfo/Sample Magnetic Field", prop); - header->Set("RunInfo/No of Histos", (Int_t)fData[0].GetNoOfHistos()); + header->Set("RunInfo/No of Histos", static_cast(fData[0].GetNoOfHistos())); dval[0] = fData[0].GetTimeResolution(); prop.Set("Time Resolution", dval[0], "ns"); header->Set("RunInfo/Time Resolution", prop); @@ -4339,9 +4334,9 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) UInt_t size = fData[0].GetNoOfHistos(); for (UInt_t i=0; i> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } histoNo = dataSet->GetHistoNo(); @@ -4353,15 +4348,15 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) pathName.Form("DetectorInfo/Detector%03d/Histo Number", histoNo); header->Set(pathName, histoNo); pathName.Form("DetectorInfo/Detector%03d/Histo Length", histoNo); - header->Set(pathName, (Int_t)(dataSet->GetData()->size()/fAny2ManyInfo->rebin)); + header->Set(pathName, static_cast(dataSet->GetData()->size()/fAny2ManyInfo->rebin)); pathName.Form("DetectorInfo/Detector%03d/Time Zero Bin", histoNo); header->Set(pathName, dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); pathName.Form("DetectorInfo/Detector%03d/First Good Bin", histoNo); ival = dataSet->GetFirstGoodBin(); - header->Set(pathName, (Int_t)(ival/fAny2ManyInfo->rebin)); + header->Set(pathName, static_cast(ival/fAny2ManyInfo->rebin)); pathName.Form("DetectorInfo/Detector%03d/Last Good Bin", histoNo); ival = dataSet->GetLastGoodBin(); - header->Set(pathName, (Int_t)(ival/fAny2ManyInfo->rebin)); + header->Set(pathName, static_cast(ival/fAny2ManyInfo->rebin)); } // feed SampleEnvironmentInfo @@ -4377,20 +4372,20 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) header->Set("BeamlineInfo/Name", str); // feed histos - vector histos; - TH1F *histo = 0; + std::vector histos; + TH1F *histo = nullptr; UInt_t length = 0; if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; i> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } str.Form("hDecay%03d", dataSet->GetHistoNo()); length = dataSet->GetData()->size(); - histo = new TH1F(str.Data(), str.Data(), length+1, -0.5, (Double_t)length+0.5); + histo = new TH1F(str.Data(), str.Data(), length+1, -0.5, static_cast(length)+0.5); for (UInt_t j=0; jSetBinContent(j+1, dataSet->GetData()->at(j)); } @@ -4401,14 +4396,14 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) UInt_t dataCount = 0; for (UInt_t i=0; i> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } str.Form("hDecay%03d", dataSet->GetHistoNo()); length = dataSet->GetData()->size(); - histo = new TH1F(str.Data(), str.Data(), (Int_t)(length/fAny2ManyInfo->rebin)+1, -0.5, (Double_t)((Int_t)(length/fAny2ManyInfo->rebin))+0.5); + histo = new TH1F(str.Data(), str.Data(), static_cast(length/fAny2ManyInfo->rebin)+1, -0.5, static_cast(static_cast(length/fAny2ManyInfo->rebin))+0.5); dataCount = 0; for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { @@ -4428,8 +4423,8 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) // write file TFile *fout = new TFile(fln, "RECREATE", fln); - if (fout == 0) { - cerr << endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't create ROOT file '" << fln << "'" << endl; + if (fout == nullptr) { + std::cerr << std::endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't create ROOT file '" << fln << "'" << std::endl; return false; } @@ -4442,24 +4437,24 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) // check if root file shall be streamed to stdout if (fAny2ManyInfo->useStandardOutput && (fAny2ManyInfo->compressionTag == 0)) { // stream file to stdout - ifstream is; + std::ifstream is; int length=1024; char *buffer; - is.open(fln.Data(), ios::binary); + is.open(fln.Data(), std::ios::binary); if (!is.is_open()) { - cerr << endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't open the root-file for streaming." << endl; + std::cerr << std::endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't open the root-file for streaming." << std::endl; remove(fln.Data()); return false; } // get length of file - is.seekg(0, ios::end); + is.seekg(0, std::ios::end); length = is.tellg(); - is.seekg(0, ios::beg); + is.seekg(0, std::ios::beg); if (length == -1) { - cerr << endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't determine the root-file size." << endl; + std::cerr << std::endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't determine the root-file size." << std::endl; remove(fln.Data()); return false; } @@ -4470,7 +4465,7 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) // read data as a block while (!is.eof()) { is.read(buffer, length); - cout.write(buffer, length); + std::cout.write(buffer, length); } is.close(); @@ -4505,7 +4500,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WriteRootFile(): writing a root data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteRootFile(): writing a root data file (" << fln.Data() << ") ... " << std::endl; // generate data file TFolder *histosFolder; @@ -4546,8 +4541,8 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) // feed t0's if possible UInt_t NoT0s = fData[0].GetNoOfHistos(); if (fData[0].GetNoOfHistos() > NHIST) { - cerr << endl << ">> PRunDataHandler::WriteRootFile: **WARNING** found more T0's (" << NoT0s << ") than can be handled (" << NHIST << ")."; - cerr << endl << ">> Will only write the first " << NHIST << " T0s!!" << endl; + std::cerr << std::endl << ">> PRunDataHandler::WriteRootFile: **WARNING** found more T0's (" << NoT0s << ") than can be handled (" << NHIST << ")."; + std::cerr << std::endl << ">> Will only write the first " << NHIST << " T0s!!" << std::endl; NoT0s = NHIST; } Double_t *tt0 = new Double_t[NoT0s]; @@ -4560,20 +4555,20 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) runInfo->Add(header); // add header to RunInfo folder // feed histos - vector histos; - TH1F *histo = 0; + std::vector histos; + TH1F *histo = nullptr; Char_t str[32]; UInt_t size = 0; if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; i> PRunDataHandler::WriteRootFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteRootFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } size = dataSet->GetData()->size(); - sprintf(str, "hDecay%02d", (Int_t)i); + sprintf(str, "hDecay%02d", static_cast(i)); histo = new TH1F(str, str, size+1, -0.5, static_cast(size)+0.5); for (UInt_t j=0; jSetBinContent(j+1, dataSet->GetData()->at(j)); @@ -4585,14 +4580,14 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) UInt_t dataCount = 0; for (UInt_t i=0; i> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } size = dataSet->GetData()->size(); - sprintf(str, "hDecay%02d", (Int_t)i); - histo = new TH1F(str, str, (UInt_t)(size/fAny2ManyInfo->rebin)+1, -0.5, (Double_t)size/(Double_t)fAny2ManyInfo->rebin+0.5); + sprintf(str, "hDecay%02d", static_cast(i)); + histo = new TH1F(str, str, static_cast(size/fAny2ManyInfo->rebin)+1, -0.5, static_cast(size)/static_cast(fAny2ManyInfo->rebin)+0.5); dataCount = 0; for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { @@ -4612,8 +4607,8 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) // write file TFile *fout = new TFile(fln, "RECREATE", fln); - if (fout == 0) { - cerr << endl << "PRunDataHandler::WriteRootFile(): **ERROR** Couldn't create ROOT file '" << fln << "'" << endl; + if (fout == nullptr) { + std::cerr << std::endl << "PRunDataHandler::WriteRootFile(): **ERROR** Couldn't create ROOT file '" << fln << "'" << std::endl; return false; } @@ -4634,24 +4629,24 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) // check if root file shall be streamed to stdout if (fAny2ManyInfo->useStandardOutput && (fAny2ManyInfo->compressionTag == 0)) { // stream file to stdout - ifstream is; + std::ifstream is; int length=1024; char *buffer; - is.open(fln.Data(), ios::binary); + is.open(fln.Data(), std::ios::binary); if (!is.is_open()) { - cerr << endl << "PRunDataHandler::WriteRootFile(): **ERROR** Couldn't open the root-file for streaming." << endl; + std::cerr << std::endl << "PRunDataHandler::WriteRootFile(): **ERROR** Couldn't open the root-file for streaming." << std::endl; remove(fln.Data()); return false; } // get length of file - is.seekg(0, ios::end); + is.seekg(0, std::ios::end); length = is.tellg(); - is.seekg(0, ios::beg); + is.seekg(0, std::ios::beg); if (length == -1) { - cerr << endl << "PRunDataHandler::WriteRootFile(): **ERROR** Couldn't determine the root-file size." << endl; + std::cerr << std::endl << "PRunDataHandler::WriteRootFile(): **ERROR** Couldn't determine the root-file size." << std::endl; remove(fln.Data()); return false; } @@ -4662,7 +4657,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) // read data as a block while (!is.eof()) { is.read(buffer, length); - cout.write(buffer, length); + std::cout.write(buffer, length); } is.close(); @@ -4697,12 +4692,12 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) return false; if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WriteNexusFile(): writing a NeXus data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteNexusFile(): writing a NeXus data file (" << fln.Data() << ") ... " << std::endl; // create NeXus object PNeXus *nxs = new PNeXus(); - if (nxs == 0) { - cerr << endl << ">> PRunDataHandler::WriteNexusFile(): **ERROR** couldn't invoke the NeXus object." << endl; + if (nxs == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::WriteNexusFile(): **ERROR** couldn't invoke the NeXus object." << std::endl; return false; } @@ -4718,10 +4713,10 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) struct tm *tm; time(&now); tm = localtime(&now); - string str(""); + std::string str(""); char cstr[128]; strftime(cstr, sizeof(cstr), "%FT%T", tm); - str = string(cstr); + str = std::string(cstr); nxs->SetFileTime(str); nxs->GetEntryIdf1()->SetProgramName("any2many"); @@ -4734,9 +4729,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf1()->SetLaboratory(fData[0].GetLaboratory()->Data()); if (*fData[0].GetBeamline() != "n/a") nxs->GetEntryIdf1()->SetBeamline(fData[0].GetBeamline()->Data()); - str = string(fData[0].GetStartDate()->Data()) + string("T") + string(fData[0].GetStartTime()->Data()); + str = std::string(fData[0].GetStartDate()->Data()) + std::string("T") + std::string(fData[0].GetStartTime()->Data()); nxs->GetEntryIdf1()->SetStartTime(str); - str = string(fData[0].GetStopDate()->Data()) + string("T") + string(fData[0].GetStopTime()->Data()); + str = std::string(fData[0].GetStopDate()->Data()) + std::string("T") + std::string(fData[0].GetStopTime()->Data()); nxs->GetEntryIdf1()->SetStopTime(str); nxs->GetEntryIdf1()->SetSwitchingState(1); nxs->GetEntryIdf1()->GetUser()->SetName("n/a"); @@ -4753,12 +4748,12 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf1()->GetInstrument()->GetCollimator()->SetType("n/a"); // calculate the total number of counts double total_counts = 0; - PRawRunDataSet *dataSet = 0; + PRawRunDataSet *dataSet = nullptr; for (unsigned int i=0; i> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } for (unsigned int j=0; jGetData()->size(); j++) @@ -4772,9 +4767,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) for (unsigned int i=0; iGetEntryIdf1()->GetData()->SetT0((Int_t)(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin), i); - nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin((Int_t)(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin), i); - nxs->GetEntryIdf1()->GetData()->SetLastGoodBin((Int_t)(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin), i); + nxs->GetEntryIdf1()->GetData()->SetT0(static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin), i); + nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(static_cast(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin), i); + nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(static_cast(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin), i); } // feed histos @@ -4783,9 +4778,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; i> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } size = dataSet->GetData()->size(); @@ -4800,9 +4795,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) UInt_t dataCount = 0; for (UInt_t i=0; i> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } size = dataSet->GetData()->size(); @@ -4828,10 +4823,10 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) struct tm *tm; time(&now); tm = localtime(&now); - string str(""); + std::string str(""); char cstr[128]; strftime(cstr, sizeof(cstr), "%FT%T", tm); - str = string(cstr); + str = std::string(cstr); nxs->SetFileTime(str); // NXroot info @@ -4843,9 +4838,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf2()->SetProgramVersion("$Id$"); nxs->GetEntryIdf2()->SetRunNumber(fData[0].GetRunNumber()); nxs->GetEntryIdf2()->SetTitle(fData[0].GetRunTitle()->Data()); - str = string(fData[0].GetStartDate()->Data()) + string("T") + string(fData[0].GetStartTime()->Data()); + str = std::string(fData[0].GetStartDate()->Data()) + std::string("T") + std::string(fData[0].GetStartTime()->Data()); nxs->GetEntryIdf2()->SetStartTime(str); - str = string(fData[0].GetStopDate()->Data()) + string("T") + string(fData[0].GetStopTime()->Data()); + str = std::string(fData[0].GetStopDate()->Data()) + std::string("T") + std::string(fData[0].GetStopTime()->Data()); nxs->GetEntryIdf2()->SetStopTime(str); nxs->GetEntryIdf2()->SetExperimentIdentifier("n/a"); @@ -4877,23 +4872,23 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfPeriods(0); // currently red/green is not distinguished nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfSpectra(fData[0].GetNoOfHistos()); PRawRunDataSet *dataSet = fData[0].GetDataSet(0, false); // i.e. the false means, that i is the index and NOT the histo number - if (dataSet == 0) { // something is really wrong - cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfBins((unsigned int)(dataSet->GetData()->size() / fAny2ManyInfo->rebin)); nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin, "ns"); - int *histo = 0; + int *histo = nullptr; int idx = 0; if (fAny2ManyInfo->rebin == 1) { histo = new int[fData[0].GetNoOfHistos()*dataSet->GetData()->size()]; idx = 0; for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number - if (dataSet == 0) { // something is really wrong - cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } for (unsigned int j=0; jGetData()->size(); j++) { @@ -4904,7 +4899,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) // clean up if (histo) { delete [] histo; - histo = 0; + histo = nullptr; } } else { // rebin > 1 histo = new int[fData[0].GetNoOfHistos()*(int)(dataSet->GetData()->size()/fAny2ManyInfo->rebin)]; @@ -4912,9 +4907,9 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) idx = 0; for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number - if (dataSet == 0) { // something is really wrong - cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } for (unsigned int j=0; jGetData()->size(); j++) { @@ -4929,7 +4924,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) // clean up if (histo) { delete [] histo; - histo = 0; + histo = nullptr; } } @@ -4941,7 +4936,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin, "ns"); // handle raw time - vector raw_time; + std::vector raw_time; UInt_t size = (unsigned int)(dataSet->GetData()->size() / fAny2ManyInfo->rebin); for (unsigned int i=0; irebin * 1.0e-3); // since time resolution is given in ns, the factor 1.0e-3 is needed to convert to us @@ -4957,14 +4952,14 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) int *fgb = new int[fData[0].GetNoOfHistos()]; int *lgb = new int[fData[0].GetNoOfHistos()]; if ((t0==0) || (fgb==0) || (lgb==0)) { - cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't allocate memory for t0, fgb, lgb" << endl; + std::cerr << std::endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't allocate memory for t0, fgb, lgb" << std::endl; return false; } for (unsigned int i=0; i> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } t0[i] = (int)(dataSet->GetTimeZeroBin() / fAny2ManyInfo->rebin); @@ -4983,7 +4978,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) // clean up if (nxs != 0) { delete nxs; - nxs = 0; + nxs = nullptr; } return false; } @@ -4998,11 +4993,11 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) else if (!fAny2ManyInfo->outFormat.CompareTo("nexus1-xml", TString::kIgnoreCase) || !fAny2ManyInfo->outFormat.CompareTo("nexus2-xml", TString::kIgnoreCase)) strncpy(fileType, "xml", sizeof(fileType)); else { - cerr << endl << ">> PRunDataHandler::WriteNexusFile(): **ERROR** undefined output NeXus format " << fAny2ManyInfo->outFormat.Data() << " found."; - cerr << endl << ">> Allowed are: hdf4, hdf5, xml" << endl; + std::cerr << std::endl << ">> PRunDataHandler::WriteNexusFile(): **ERROR** undefined output NeXus format " << fAny2ManyInfo->outFormat.Data() << " found."; + std::cerr << std::endl << ">> Allowed are: hdf4, hdf5, xml" << std::endl; if (nxs != 0) { delete nxs; - nxs = 0; + nxs = nullptr; } return false; } @@ -5012,10 +5007,10 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) if (nxs != 0) { delete nxs; - nxs = 0; + nxs = nullptr; } #else - cout << endl << ">> PRunDataHandler::WriteNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << endl << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << std::endl << std::endl; #endif return true; @@ -5052,64 +5047,64 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln) TString fileName = fln; if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WriteWkmFile(): writing a wkm data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteWkmFile(): writing a wkm data file (" << fln.Data() << ") ... " << std::endl; // write ascii file - ofstream fout; - streambuf* strm_buffer = 0; + std::ofstream fout; + std::streambuf* strm_buffer = nullptr; if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { // open data-file - fout.open(fln.Data(), ofstream::out); + fout.open(fln.Data(), std::ofstream::out); if (!fout.is_open()) { - cerr << endl << ">> PRunDataHandler::WriteWkmFile **ERROR** Couldn't open data file (" << fln.Data() << ") for writing, sorry ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::WriteWkmFile **ERROR** Couldn't open data file (" << fln.Data() << ") for writing, sorry ..."; + std::cerr << std::endl; return false; } // save output buffer of the stream - strm_buffer = cout.rdbuf(); + strm_buffer = std::cout.rdbuf(); // redirect output into the file - cout.rdbuf(fout.rdbuf()); + std::cout.rdbuf(fout.rdbuf()); } // write header - cout << "- WKM data file converted with any2many"; + std::cout << "- WKM data file converted with any2many"; if (lem_wkm_style) { - cout << endl << "NEMU_Run: " << fData[0].GetRunNumber(); - cout << endl << "nemu_Run: " << fileName.Data(); + std::cout << std::endl << "NEMU_Run: " << fData[0].GetRunNumber(); + std::cout << std::endl << "nemu_Run: " << fileName.Data(); } else { - cout << endl << "Run: " << fData[0].GetRunNumber(); + std::cout << std::endl << "Run: " << fData[0].GetRunNumber(); } - cout << endl << "Date: " << fData[0].GetStartTime()->Data() << " " << fData[0].GetStartDate()->Data() << " / " << fData[0].GetStopTime()->Data() << " " << fData[0].GetStopDate()->Data(); + std::cout << std::endl << "Date: " << fData[0].GetStartTime()->Data() << " " << fData[0].GetStartDate()->Data() << " / " << fData[0].GetStopTime()->Data() << " " << fData[0].GetStopDate()->Data(); if (fData[0].GetRunTitle()->Length() > 0) - cout << endl << "Title: " << fData[0].GetRunTitle()->Data(); + std::cout << std::endl << "Title: " << fData[0].GetRunTitle()->Data(); if (fData[0].GetField() != PMUSR_UNDEFINED) { - cout << endl << "Field: " << fData[0].GetField(); + std::cout << std::endl << "Field: " << fData[0].GetField(); } else { - cout << endl << "Field: ??"; + std::cout << std::endl << "Field: ??"; } - cout << endl << "Setup: " << fData[0].GetSetup()->Data(); + std::cout << std::endl << "Setup: " << fData[0].GetSetup()->Data(); if (fData[0].GetNoOfTemperatures() == 1) { - cout << endl << "Temp: " << fData[0].GetTemperature(0); + std::cout << std::endl << "Temp: " << fData[0].GetTemperature(0); } else if (fData[0].GetNoOfTemperatures() > 1) { - cout << endl << "Temp(meas1): " << fData[0].GetTemperature(0) << " +- " << fData[0].GetTempError(0); - cout << endl << "Temp(meas2): " << fData[0].GetTemperature(1) << " +- " << fData[0].GetTempError(1); + std::cout << std::endl << "Temp(meas1): " << fData[0].GetTemperature(0) << " +- " << fData[0].GetTempError(0); + std::cout << std::endl << "Temp(meas2): " << fData[0].GetTemperature(1) << " +- " << fData[0].GetTempError(1); } else { - cout << endl << "Temp: ??"; + std::cout << std::endl << "Temp: ??"; } if (lem_wkm_style) - cout << endl << "TOF(M3S1): nocut"; - cout << endl << "Groups: " << fData[0].GetNoOfHistos(); + std::cout << std::endl << "TOF(M3S1): nocut"; + std::cout << std::endl << "Groups: " << fData[0].GetNoOfHistos(); UInt_t histo0 = 1; if (fAny2ManyInfo->groupHistoList.size() != 0) { // red/green list found histo0 = fAny2ManyInfo->groupHistoList[0]+1; // take the first available red/green entry } - cout << endl << "Channels: " << static_cast(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin); - cout.precision(10); - cout << endl << "Resolution: " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin/1.0e3; // ns->us - cout.setf(ios::fixed,ios::floatfield); // floatfield set to fixed + std::cout << std::endl << "Channels: " << static_cast(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin); + std::cout.precision(10); + std::cout << std::endl << "Resolution: " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin/1.0e3; // ns->us + std::cout.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed // write data UInt_t no_of_bins_per_line = 16; @@ -5120,35 +5115,35 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln) if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; iGetData()->size(); j++) { if ((j > 0) && (j % no_of_bins_per_line == 0)) - cout << endl; + std::cout << std::endl; if (lem_wkm_style) - cout << setw(8) << static_cast(dataSet->GetData()->at(j)); + std::cout << std::setw(8) << static_cast(dataSet->GetData()->at(j)); else - cout << static_cast(dataSet->GetData()->at(j)) << " "; + std::cout << static_cast(dataSet->GetData()->at(j)) << " "; } } } else { // rebin > 1 Int_t dataRebin = 0; UInt_t count = 0; for (UInt_t i=0; iGetData()->size(); j++) { if ((j > 0) && (j % fAny2ManyInfo->rebin == 0)) { if (lem_wkm_style) - cout << setw(8) << dataRebin; + std::cout << std::setw(8) << dataRebin; else - cout << dataRebin << " "; + std::cout << dataRebin << " "; count++; dataRebin = 0; if ((count > 0) && (count % no_of_bins_per_line == 0) && (j != dataSet->GetData()->size()-1)) - cout << endl; + std::cout << std::endl; } else { dataRebin += static_cast(dataSet->GetData()->at(j)); } @@ -5158,7 +5153,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln) if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { // restore old output buffer - cout.rdbuf(strm_buffer); + std::cout.rdbuf(strm_buffer); fout.close(); } @@ -5186,7 +5181,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) return false; if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WritePsiBinFile(): writing a psi-bin data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WritePsiBinFile(): writing a psi-bin data file (" << fln.Data() << ") ... " << std::endl; MuSR_td_PSI_bin psibin; int status = 0; @@ -5199,9 +5194,9 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) if (fAny2ManyInfo->groupHistoList.size() != 0) { // red/green list found histo0 = fAny2ManyInfo->groupHistoList[0]+1; // take the first available red/green entry } - psibin.put_histoLength_bin((int)(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin)); + psibin.put_histoLength_bin(static_cast(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin)); // number of histograms - psibin.put_numberHisto_int((int)fData[0].GetNoOfHistos()); + psibin.put_numberHisto_int(static_cast(fData[0].GetNoOfHistos())); // run title = sample (10 char) / temp (10 char) / field (10 char) / orientation (10 char) char cstr[11]; // sample @@ -5243,7 +5238,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) // handle PSI-BIN start/stop Time/Date. PSI-BIN requires: Time -> HH:MM:SS, and Date -> DD-MMM-YY // internally given: Time -> HH:MM:SS, and Date -> YYYY-MM-DD // run start date - vector svec; + std::vector svec; TString str, date; TDatime dt; int year, month, day; @@ -5296,7 +5291,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) psibin.put_numberTemperature_int(fData[0].GetNoOfTemperatures()); // mean temperatures - vector dvec; + std::vector dvec; for (UInt_t i=0; i> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } @@ -5334,32 +5329,32 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) str.Form("Detector%3d", i+1); psibin.put_nameHisto(str.Data(), i); // time zero bin - ival = (Int_t)(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); + ival = static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); psibin.put_t0_int(i, ival); // first good bin - ival = (Int_t)(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin); + ival = static_cast(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin); psibin.put_firstGood_int(i, ival); // last good bin - ival = (Int_t)(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin); + ival = static_cast(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin); psibin.put_lastGood_int(i, ival); } // feed histos - vector< vector > histos; + std::vector< std::vector > histos; histos.resize(fData[0].GetNoOfHistos()); UInt_t length = 0; if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; i> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } length = dataSet->GetData()->size(); histos[i].resize(length); for (UInt_t j=0; jGetData()->at(j); + histos[i][j] = static_cast(dataSet->GetData()->at(j)); } } } else { // rebin > 1 @@ -5367,9 +5362,9 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) UInt_t dataCount = 0; for (UInt_t i=0; i> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } length = dataSet->GetData()->size(); @@ -5386,12 +5381,12 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) } status = psibin.put_histo_array_int(histos); if (status != 0) { - cerr << endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << endl; + std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl; return false; } if (!psibin.CheckDataConsistency()) { - cerr << endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << endl; + std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl; return false; } @@ -5399,7 +5394,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) status = psibin.write(fln.Data()); if (status != 0) { - cerr << endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.WriteStatus() << endl; + std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.WriteStatus() << std::endl; return false; } @@ -5426,12 +5421,12 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) return false; if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WriteMudFile(): writing a mud data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteMudFile(): writing a mud data file (" << fln.Data() << ") ... " << std::endl; // generate the mud data file int fd = MUD_openWrite((char*)fln.Data(), MUD_FMT_TRI_TD_ID); if (fd == -1) { - cerr << endl << ">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't open mud data file for write ..." << endl; + std::cerr << std::endl << ">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't open mud data file for write ..." << std::endl; return false; } @@ -5465,8 +5460,8 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) UInt_t *data, dataSize = fData[0].GetDataSet(0, false)->GetData()->size()/fAny2ManyInfo->rebin + 1; data = new UInt_t[dataSize]; - if (data == 0) { - cerr << endl << ">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't allocate memory for the data ..." << endl; + if (data == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't allocate memory for the data ..." << std::endl; MUD_closeWrite(fd); return false; } @@ -5476,9 +5471,9 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) PRawRunDataSet *dataSet; for (UInt_t i=0; i> PRunDataHandler::WriteMudFile: **ERROR** Couldn't get data set (idx=" << i << ")"; - cerr << endl << ">> something is really wrong!" << endl; + if (dataSet == nullptr) { // something is really wrong + std::cerr << std::endl << ">> PRunDataHandler::WriteMudFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + std::cerr << std::endl << ">> something is really wrong!" << std::endl; return false; } @@ -5525,24 +5520,24 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) // check if mud file shall be streamed to stdout if (fAny2ManyInfo->useStandardOutput && (fAny2ManyInfo->compressionTag == 0)) { // stream file to stdout - ifstream is; + std::ifstream is; int length=1024; char *buffer; - is.open(fln.Data(), ios::binary); + is.open(fln.Data(), std::ios::binary); if (!is.is_open()) { - cerr << endl << "PRunDataHandler::WriteMudFile(): **ERROR** Couldn't open the mud-file for streaming." << endl; + std::cerr << std::endl << "PRunDataHandler::WriteMudFile(): **ERROR** Couldn't open the mud-file for streaming." << std::endl; remove(fln.Data()); return false; } // get length of file - is.seekg(0, ios::end); + is.seekg(0, std::ios::end); length = is.tellg(); - is.seekg(0, ios::beg); + is.seekg(0, std::ios::beg); if (length == -1) { - cerr << endl << "PRunDataHandler::WriteMudFile(): **ERROR** Couldn't determine the mud-file size." << endl; + std::cerr << std::endl << "PRunDataHandler::WriteMudFile(): **ERROR** Couldn't determine the mud-file size." << std::endl; remove(fln.Data()); return false; } @@ -5553,7 +5548,7 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) // read data as a block while (!is.eof()) { is.read(buffer, length); - cout.write(buffer, length); + std::cout.write(buffer, length); } is.close(); @@ -5588,79 +5583,79 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln) TString fileName = fln; if (!fAny2ManyInfo->useStandardOutput) - cout << endl << ">> PRunDataHandler::WriteAsciiFile(): writing an ascii data file (" << fln.Data() << ") ... " << endl; + std::cout << std::endl << ">> PRunDataHandler::WriteAsciiFile(): writing an ascii data file (" << fln.Data() << ") ... " << std::endl; // write ascii file - ofstream fout; - streambuf* strm_buffer = 0; + std::ofstream fout; + std::streambuf* strm_buffer = nullptr; if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { // open data-file - fout.open(fln.Data(), ofstream::out); + fout.open(fln.Data(), std::ofstream::out); if (!fout.is_open()) { - cerr << endl << ">> PRunDataHandler::WriteAsciiFile **ERROR** Couldn't open data file (" << fln.Data() << ") for writing, sorry ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunDataHandler::WriteAsciiFile **ERROR** Couldn't open data file (" << fln.Data() << ") for writing, sorry ..."; + std::cerr << std::endl; return false; } // save output buffer of the stream - strm_buffer = cout.rdbuf(); + strm_buffer = std::cout.rdbuf(); // redirect output into the file - cout.rdbuf(fout.rdbuf()); + std::cout.rdbuf(fout.rdbuf()); } // write header - cout << "%*************************************************************************"; - cout << endl << "% file name : " << fileName.Data(); + std::cout << "%*************************************************************************"; + std::cout << std::endl << "% file name : " << fileName.Data(); if (fData[0].GetRunTitle()->Length() > 0) - cout << endl << "% title : " << fData[0].GetRunTitle()->Data(); + std::cout << std::endl << "% title : " << fData[0].GetRunTitle()->Data(); if (fData[0].GetRunNumber() >= 0) - cout << endl << "% run number : " << fData[0].GetRunNumber(); + std::cout << std::endl << "% run number : " << fData[0].GetRunNumber(); if (fData[0].GetSetup()->Length() > 0) - cout << endl << "% setup : " << fData[0].GetSetup()->Data(); - cout << endl << "% field : " << fData[0].GetField() << " (G)"; + std::cout << std::endl << "% setup : " << fData[0].GetSetup()->Data(); + std::cout << std::endl << "% field : " << fData[0].GetField() << " (G)"; if (fData[0].GetStartTime()->Length() > 0) - cout << endl << "% date : " << fData[0].GetStartTime()->Data() << " " << fData[0].GetStartDate()->Data() << " / " << fData[0].GetStopTime()->Data() << " " << fData[0].GetStopDate()->Data(); + std::cout << std::endl << "% date : " << fData[0].GetStartTime()->Data() << " " << fData[0].GetStartDate()->Data() << " / " << fData[0].GetStopTime()->Data() << " " << fData[0].GetStopDate()->Data(); if (fData[0].GetNoOfTemperatures() > 0) { - cout << endl << "% temperature : "; + std::cout << std::endl << "% temperature : "; for (UInt_t i=0; irebin << " (ns)"; - cout.setf(ios::fixed,ios::floatfield); // floatfield set to fixed + std::cout.precision(10); + std::cout << std::endl << "% time resolution : " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin << " (ns)"; + std::cout.setf(std::ios::fixed,std::ios::floatfield); // floatfield set to fixed } PRawRunDataSet *dataSet; - cout << endl << "% t0 : "; + std::cout << std::endl << "% t0 : "; for (UInt_t i=0; i(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin) << ", "; + std::cout << static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin) << ", "; } dataSet = fData[0].GetDataSet(fData[0].GetNoOfHistos()-1, false); // i.e. the false means, that i is the index and NOT the histo number - cout << static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); + std::cout << static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); - cout << endl << "% # histos : " << fData[0].GetNoOfHistos(); + std::cout << std::endl << "% # histos : " << fData[0].GetNoOfHistos(); dataSet = fData[0].GetDataSet(0, false); // i.e. the false means, that i is the index and NOT the histo number - cout << endl << "% # of bins : " << static_cast(dataSet->GetData()->size()/fAny2ManyInfo->rebin); - cout << endl << "%*************************************************************************"; + std::cout << std::endl << "% # of bins : " << static_cast(dataSet->GetData()->size()/fAny2ManyInfo->rebin); + std::cout << std::endl << "%*************************************************************************"; // write data UInt_t length = fData[0].GetDataSet(0,false)->GetData()->size(); if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; i(dataSet->GetData()->at(i)); + std::cout.width(8); + std::cout << static_cast(dataSet->GetData()->at(i)); } } } else { @@ -5674,10 +5669,10 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln) for (UInt_t i=0; i 0) && ((i % fAny2ManyInfo->rebin) == 0)) { - cout << endl; + std::cout << std::endl; for (UInt_t j=0; juseStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { // restore old output buffer - cout.rdbuf(strm_buffer); + std::cout.rdbuf(strm_buffer); fout.close(); } @@ -5721,14 +5716,14 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln) */ Bool_t PRunDataHandler::StripWhitespace(TString &str) { - Char_t *s = 0; - Char_t *subs = 0; + Char_t *s = nullptr; + Char_t *subs = nullptr; Int_t i; Int_t start; Int_t end; Int_t size; - size = (Int_t)str.Length(); + size = static_cast(str.Length()); s = new Char_t[size+1]; if (!s) @@ -5768,11 +5763,11 @@ Bool_t PRunDataHandler::StripWhitespace(TString &str) // clean up if (subs) { delete [] subs; - subs = 0; + subs = nullptr; } if (s) { delete [] s; - s = 0; + s = nullptr; } return true; @@ -5828,7 +5823,7 @@ Double_t PRunDataHandler::ToDouble(TString &str, Bool_t &ok) ok = true; - size = (Int_t)str.Length(); + size = static_cast(str.Length()); s = new Char_t[size+1]; if (!s) { @@ -5851,7 +5846,7 @@ Double_t PRunDataHandler::ToDouble(TString &str, Bool_t &ok) // clean up if (s) { delete [] s; - s = 0; + s = nullptr; } return value; @@ -5878,7 +5873,7 @@ Int_t PRunDataHandler::ToInt(TString &str, Bool_t &ok) ok = true; - size = (Int_t)str.Length(); + size = static_cast(str.Length()); s = new Char_t[size+1]; if (!s) { @@ -5901,7 +5896,7 @@ Int_t PRunDataHandler::ToInt(TString &str, Bool_t &ok) // clean up if (s) { delete [] s; - s = 0; + s = nullptr; } return value; @@ -5978,8 +5973,8 @@ TString PRunDataHandler::GenerateOutputFileName(const TString fileName, const TS newFln = fln; newFln.Insert(newFln.Last('.'), TString::Format(".%d", count++)); } while (!gSystem->AccessPathName(newFln)); - cerr << endl << ">> PRunDataHandler::GenerateOutputFileName **WARNING** needed to modify output filename to " << newFln << ","; - cerr << endl << ">> due to potential conflict with already existing files." << endl << endl; + std::cerr << std::endl << ">> PRunDataHandler::GenerateOutputFileName **WARNING** needed to modify output filename to " << newFln << ","; + std::cerr << std::endl << ">> due to potential conflict with already existing files." << std::endl << std::endl; fln = newFln; } @@ -6013,7 +6008,7 @@ TString PRunDataHandler::GetFileName(const TString extension, Bool_t &ok) Int_t start = fRunPathName.Last('/'); Int_t end = fRunPathName.Last('.'); if (end == -1) { - cerr << endl << ">> PRunDataHandler::GetFileName(): **ERROR** couldn't generate the output file name ..." << endl; + std::cerr << std::endl << ">> PRunDataHandler::GetFileName(): **ERROR** couldn't generate the output file name ..." << std::endl; ok = false; return fileName; } @@ -6060,14 +6055,14 @@ TString PRunDataHandler::FileNameFromTemplate(TString &fileNameTemplate, Int_t r { TString result(""); - TObjArray *tok=0; + TObjArray *tok=nullptr; TObjString *ostr; TString str; // check year string if ((year.Length() != 2) && (year.Length() != 4)) { - cerr << endl << ">> PRunDataHandler::FileNameFromTemplate: **ERROR** year needs to be of the format"; - cerr << endl << ">> 'yy' or 'yyyy', found " << year << endl; + std::cerr << std::endl << ">> PRunDataHandler::FileNameFromTemplate: **ERROR** year needs to be of the format"; + std::cerr << std::endl << ">> 'yy' or 'yyyy', found " << year << std::endl; return result; } @@ -6085,17 +6080,17 @@ TString PRunDataHandler::FileNameFromTemplate(TString &fileNameTemplate, Int_t r // tokenize template string tok = fileNameTemplate.Tokenize("[]"); - if (tok == 0) { - cerr << endl << ">> PRunDataHandler::FileNameFromTemplate: **ERROR** couldn't tokenize template!" << endl; + if (tok == nullptr) { + std::cerr << std::endl << ">> PRunDataHandler::FileNameFromTemplate: **ERROR** couldn't tokenize template!" << std::endl; return result; } if (tok->GetEntries()==1) { - cerr << endl << ">> PRunDataHandler::FileNameFromTemplate: **WARNING** template without tags." << endl; + std::cerr << std::endl << ">> PRunDataHandler::FileNameFromTemplate: **WARNING** template without tags." << std::endl; } // go through the tokens and generate the result string for (Int_t i=0; iGetEntries(); i++) { - ostr = (TObjString*)tok->At(i); + ostr = dynamic_cast(tok->At(i)); str = ostr->GetString(); // check tokens @@ -6145,9 +6140,9 @@ TString PRunDataHandler::FileNameFromTemplate(TString &fileNameTemplate, Int_t r * \param inDate input date which should be converted to an ISO 8601 date. * \param iso8601Date on success the converted iso8601Date, otherwise an empty string */ -bool PRunDataHandler::DateToISO8601(string inDate, string &iso8601Date) +bool PRunDataHandler::DateToISO8601(std::string inDate, std::string &iso8601Date) { - iso8601Date = string(""); + iso8601Date = std::string(""); struct tm tm; diff --git a/src/classes/PRunMuMinus.cpp b/src/classes/PRunMuMinus.cpp index 66a7990a..83101a8e 100644 --- a/src/classes/PRunMuMinus.cpp +++ b/src/classes/PRunMuMinus.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -36,7 +36,6 @@ #endif #include -using namespace std; #include #include @@ -86,9 +85,9 @@ PRunMuMinus::PRunMuMinus(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t fPacking = fMsrInfo->GetMsrGlobal()->GetPacking(); } if (fPacking == -1) { // this should NOT happen, somethin is severely wrong - cerr << endl << ">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't find any packing information!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't find any packing information!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; return; } @@ -102,9 +101,9 @@ PRunMuMinus::PRunMuMinus(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t fEndTimeBin = -1; if (!PrepareData()) { - cerr << endl << ">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't prepare data for fitting!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't prepare data for fitting!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; } } @@ -159,7 +158,7 @@ Double_t PRunMuMinus::CalcChiSquare(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i < fEndTimeBin; ++i) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); diff = fData.GetValue()->at(i) - fTheory->Func(time, par, fFuncValues); chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i)); } @@ -207,7 +206,7 @@ Double_t PRunMuMinus::CalcChiSquareExpected(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i < fEndTimeBin; ++i) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); theo = fTheory->Func(time, par, fFuncValues); diff = fData.GetValue()->at(i) - theo; chisq += diff*diff / theo; @@ -256,14 +255,14 @@ Double_t PRunMuMinus::CalcMaxLikelihood(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh) #endif for (i=fStartTimeBin; i < fEndTimeBin; ++i) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); // calculate theory for the given parameter set theo = fTheory->Func(time, par, fFuncValues); data = fData.GetValue()->at(i); if (theo <= 0.0) { - cerr << ">> PRunMuMinus::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << endl; + std::cerr << ">> PRunMuMinus::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; continue; } @@ -308,8 +307,8 @@ UInt_t PRunMuMinus::GetNoOfFitBins() */ void PRunMuMinus::SetFitRangeBin(const TString fitRange) { - TObjArray *tok = 0; - TObjString *ostr = 0; + TObjArray *tok = nullptr; + TObjString *ostr = nullptr; TString str; Ssiz_t idx = -1; Int_t offset = 0; @@ -318,7 +317,7 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange) if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 // handle fgb+n0 entry - ostr = (TObjString*) tok->At(1); + ostr = dynamic_cast(tok->At(1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -330,7 +329,7 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(2); + ostr = dynamic_cast(tok->At(2)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -344,11 +343,11 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange) Int_t pos = 2*(fRunNo+1)-1; if (pos + 1 >= tok->GetEntries()) { - cerr << endl << ">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } else { // handle fgb+n0 entry - ostr = (TObjString*) tok->At(pos); + ostr = dynamic_cast(tok->At(pos)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -360,7 +359,7 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(pos+1); + ostr = dynamic_cast(tok->At(pos+1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -372,8 +371,8 @@ void PRunMuMinus::SetFitRangeBin(const TString fitRange) fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; } } else { // error - cerr << endl << ">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } // clean up @@ -429,7 +428,7 @@ void PRunMuMinus::CalcTheory() Double_t resolution = fData.GetDataTimeStep(); Double_t time; for (UInt_t i=0; i(i)*resolution; fData.AppendTheoryValue(fTheory->Func(time, par, fFuncValues)); } @@ -463,8 +462,8 @@ Bool_t PRunMuMinus::PrepareData() // get the proper run PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName()); if (!runData) { // couldn't get run - cerr << endl << ">> PRunMuMinus::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + std::cerr << std::endl; return false; } @@ -474,10 +473,10 @@ Bool_t PRunMuMinus::PrepareData() histoNo.push_back(fRunInfo->GetForwardHistoNo(i)); if (!runData->IsPresent(histoNo[i])) { - cerr << endl << ">> PRunMuMinus::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; histoNo.clear(); return false; } @@ -485,8 +484,8 @@ Bool_t PRunMuMinus::PrepareData() // keep the time resolution in (us) fTimeResolution = runData->GetTimeResolution()/1.0e3; - cout.precision(10); - cout << endl << ">> PRunMuMinus::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl; + std::cout.precision(10); + std::cout << std::endl << ">> PRunMuMinus::PrepareData(): time resolution=" << std::fixed << runData->GetTimeResolution() << "(ns)" << std::endl; // get all the proper t0's and addt0's for the current RUN block if (!GetProperT0(runData, globalBlock, histoNo)) { @@ -494,7 +493,7 @@ Bool_t PRunMuMinus::PrepareData() } // keep the histo of each group at this point (addruns handled below) - vector forward; + std::vector forward; forward.resize(histoNo.size()); // resize to number of groups for (UInt_t i=0; iGetDataBin(histoNo[i])->size()); @@ -508,9 +507,9 @@ Bool_t PRunMuMinus::PrepareData() // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunMuMinus::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunMuMinus::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -520,8 +519,9 @@ Bool_t PRunMuMinus::PrepareData() addRunSize = addRunData->GetDataBin(histoNo[k])->size(); for (UInt_t j=0; jGetDataBin(histoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if (((Int_t)j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] < addRunSize)) { - forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k]); + if ((static_cast(j)+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k]) >= 0) && + (j+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k]) < addRunSize)) { + forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k])); } } } @@ -538,8 +538,8 @@ Bool_t PRunMuMinus::PrepareData() for (UInt_t i=1; iGetDataBin(histoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range - if (((Int_t)j+fT0s[i]-fT0s[0] >= 0) && (j+fT0s[i]-fT0s[0] < runData->GetDataBin(histoNo[i])->size())) { - fForward[j] += forward[i][j+(Int_t)fT0s[i]-(Int_t)fT0s[0]]; + if ((static_cast(j)+fT0s[i]-fT0s[0] >= 0) && (j+fT0s[i]-fT0s[0] < runData->GetDataBin(histoNo[i])->size())) { + fForward[j] += forward[i][j+static_cast(fT0s[i])-static_cast(fT0s[0])]; } } } @@ -589,11 +589,11 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo) // for the single histo fit, just the rebinned raw data are copied // fill data set - Int_t t0 = (Int_t)fT0s[0]; + Int_t t0 = static_cast(fT0s[0]); Double_t value = 0.0; // data start at data_start-t0 // time shifted so that packing is included correctly, i.e. t0 == t0 after packing - fData.SetDataTimeStart(fTimeResolution*((Double_t)fGoodBins[0]-(Double_t)t0+(Double_t)(fPacking-1)/2.0)); + fData.SetDataTimeStart(fTimeResolution*(static_cast(fGoodBins[0])-static_cast(t0)+static_cast(fPacking-1)/2.0)); fData.SetDataTimeStep(fTimeResolution*fPacking); for (Int_t i=fGoodBins[0]; iGetMsrPlotList()->at(0).fViewPacking > 0) { - theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking; + theoryNorm = static_cast(fMsrInfo->GetMsrPlotList()->at(0).fViewPacking)/static_cast(fPacking); } // raw data, since PMusrCanvas is doing ranging etc. @@ -662,12 +662,12 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN Int_t end = start + ((fForward.size()-start)/packing)*packing; // check if data range has been provided, and if not try to estimate them if (start < 0) { - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); - start = ((Int_t)fT0s[0]+offset) - (((Int_t)fT0s[0]+offset)/packing)*packing; + Int_t offset = static_cast(10.0e-3/fTimeResolution); + start = (static_cast(fT0s[0])+offset) - ((static_cast(fT0s[0])+offset)/packing)*packing; end = start + ((fForward.size()-start)/packing)*packing; - cerr << endl << ">> PRunMuMinus::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start, end, and t0 make any sense // 1st check if start and end are in proper order @@ -677,15 +677,15 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)fForward.size())) { - cerr << endl << ">> PRunMuMinus::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start < 0) || (start > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunMuMinus::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)fForward.size())) { - cerr << endl << ">> PRunMuMinus::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; - cerr << endl; + if ((end < 0) || (end > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunMuMinus::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } @@ -696,11 +696,11 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN } // everything looks fine, hence fill data set - Int_t t0 = (Int_t)fT0s[0]; + Int_t t0 = static_cast(fT0s[0]); Double_t value = 0.0; // data start at data_start-t0 // time shifted so that packing is included correctly, i.e. t0 == t0 after packing - fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(packing-1)/2.0)); + fData.SetDataTimeStart(fTimeResolution*(static_cast(start)-static_cast(t0)+static_cast(packing-1)/2.0)); fData.SetDataTimeStep(fTimeResolution*packing); for (Int_t i=start; isize() * 10 > fForward.size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)fForward.size() / (Double_t)size; + factor = static_cast(fForward.size()) / static_cast(size); } Double_t time; Double_t theoryValue; @@ -791,7 +791,7 @@ Bool_t PRunMuMinus::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlo // fill in the T0's from the GLOBAL block section (if present) for (UInt_t i=0; iGetT0BinSize(); i++) { - if (fT0s[i] == -1) { // i.e. not given in the RUN block section + if (fT0s[i] == -1.0) { // i.e. not given in the RUN block section fT0s[i] = globalBlock->GetT0Bin(i); } } @@ -812,19 +812,19 @@ Bool_t PRunMuMinus::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlo fT0s[i] = runData->GetT0BinEstimated(histoNo[i]); fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file - cerr << endl << ">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunMuMinus::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; - cerr << endl; + if ((fT0s[i] < 0) || (fT0s[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunMuMinus::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -837,9 +837,9 @@ Bool_t PRunMuMinus::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlo // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunMuMinus::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunMuMinus::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -870,19 +870,19 @@ Bool_t PRunMuMinus::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlo fAddT0s[i-1][j] = addRunData->GetT0BinEstimated(histoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file - cerr << endl << ">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) { - cerr << endl << ">> PRunMuMinus::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!"; - cerr << endl; + if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > static_cast(addRunData->GetDataBin(histoNo[j])->size()))) { + std::cerr << std::endl << ">> PRunMuMinus::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -923,19 +923,19 @@ Bool_t PRunMuMinus::GetProperDataRange() // check if data range has been provided, and if not try to estimate them if (start < 0) { - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); - start = (Int_t)fT0s[0]+offset; + Int_t offset = static_cast(10.0e-3/fTimeResolution); + start = static_cast(fT0s[0])+offset; fRunInfo->SetDataRange(start, 0); - cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end < 0) { end = fForward.size(); fRunInfo->SetDataRange(end, 1); - cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start and end make any sense @@ -946,15 +946,15 @@ Bool_t PRunMuMinus::GetProperDataRange() start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)fForward.size())) { - cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!"; - cerr << endl; + if ((start < 0) || (start > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunMuMinus::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)fForward.size())) { - cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; - cerr << endl; + if ((end < 0) || (end > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunMuMinus::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } @@ -1008,7 +1008,7 @@ void PRunMuMinus::GetProperFitRange(PMsrGlobalBlock *globalBlock) if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) { fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt - cerr << ">> PRunMuMinus::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl; - cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl; + std::cerr << ">> PRunMuMinus::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl; + std::cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << std::endl; } } diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index c3aa50b8..4931703f 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -38,7 +38,6 @@ #include #include #include -using namespace std; #include #include @@ -91,9 +90,9 @@ PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, fPacking = fMsrInfo->GetMsrGlobal()->GetPacking(); } if (fPacking == -1) { // this should NOT happen, somethin is severely wrong - cerr << endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't find any packing information!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't find any packing information!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; return; } @@ -107,9 +106,9 @@ PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, fEndTimeBin = -1; if (!PrepareData()) { - cerr << endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't prepare data for fitting!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't prepare data for fitting!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; } } @@ -174,7 +173,7 @@ Double_t PRunSingleHisto::CalcChiSquare(const std::vector& par) // calculate functions for (Int_t i=0; iGetNoOfFuncs(); i++) { - Int_t funcNo = fMsrInfo->GetFuncNo(i); + UInt_t funcNo = fMsrInfo->GetFuncNo(i); fFuncValues[i] = fMsrInfo->EvalFunc(funcNo, *fRunInfo->GetMap(), par); } @@ -195,7 +194,7 @@ Double_t PRunSingleHisto::CalcChiSquare(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); diff = fData.GetValue()->at(i) - (N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg); chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i)); @@ -280,7 +279,7 @@ Double_t PRunSingleHisto::CalcChiSquareExpected(const std::vector& par #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i < fEndTimeBin; ++i) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); theo = N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg; diff = fData.GetValue()->at(i) - theo; chisq += diff*diff / theo; @@ -316,7 +315,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) N0 = par[fRunInfo->GetNormParamNo()-1]; } else { // norm is a function // get function number - UInt_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET; + Int_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET; // evaluate function N0 = fMsrInfo->EvalFunc(funNo, *fRunInfo->GetMap(), par); } @@ -342,7 +341,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) // calculate functions for (Int_t i=0; iGetNoOfFuncs(); i++) { - Int_t funcNo = fMsrInfo->GetFuncNo(i); + UInt_t funcNo = fMsrInfo->GetFuncNo(i); fFuncValues[i] = fMsrInfo->EvalFunc(funcNo, *fRunInfo->GetMap(), par); } @@ -371,7 +370,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); // calculate theory for the given parameter set theo = N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg; theo *= normalizer; @@ -379,7 +378,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) data = normalizer*fData.GetValue()->at(i); if (theo <= 0.0) { - cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << endl; + std::cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; continue; } @@ -415,7 +414,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& N0 = par[fRunInfo->GetNormParamNo()-1]; } else { // norm is a function // get function number - UInt_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET; + Int_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET; // evaluate function N0 = fMsrInfo->EvalFunc(funNo, *fRunInfo->GetMap(), par); } @@ -441,7 +440,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& // calculate functions for (Int_t i=0; iGetNoOfFuncs(); i++) { - Int_t funcNo = fMsrInfo->GetFuncNo(i); + UInt_t funcNo = fMsrInfo->GetFuncNo(i); fFuncValues[i] = fMsrInfo->EvalFunc(funcNo, *fRunInfo->GetMap(), par); } @@ -470,7 +469,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); // calculate theory for the given parameter set theo = N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg; theo *= normalizer; @@ -478,7 +477,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& data = normalizer*fData.GetValue()->at(i); if (theo <= 0.0) { - cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << endl; + std::cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; continue; } @@ -511,7 +510,7 @@ void PRunSingleHisto::CalcTheory() N0 = par[fRunInfo->GetNormParamNo()-1]; } else { // norm is a function // get function number - UInt_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET; + Int_t funNo = fRunInfo->GetNormParamNo()-MSR_PARAM_FUN_OFFSET; // evaluate function N0 = fMsrInfo->EvalFunc(funNo, *fRunInfo->GetMap(), par); } @@ -546,7 +545,7 @@ void PRunSingleHisto::CalcTheory() Double_t resolution = fData.GetDataTimeStep(); Double_t time; for (UInt_t i=0; i(i)*resolution; fData.AppendTheoryValue(N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg); } @@ -585,8 +584,8 @@ UInt_t PRunSingleHisto::GetNoOfFitBins() */ void PRunSingleHisto::SetFitRangeBin(const TString fitRange) { - TObjArray *tok = 0; - TObjString *ostr = 0; + TObjArray *tok = nullptr; + TObjString *ostr = nullptr; TString str; Ssiz_t idx = -1; Int_t offset = 0; @@ -595,7 +594,7 @@ void PRunSingleHisto::SetFitRangeBin(const TString fitRange) if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 // handle fgb+n0 entry - ostr = (TObjString*) tok->At(1); + ostr = dynamic_cast(tok->At(1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -607,7 +606,7 @@ void PRunSingleHisto::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(2); + ostr = dynamic_cast(tok->At(2)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -621,11 +620,11 @@ void PRunSingleHisto::SetFitRangeBin(const TString fitRange) Int_t pos = 2*(fRunNo+1)-1; if (pos + 1 >= tok->GetEntries()) { - cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } else { // handle fgb+n0 entry - ostr = (TObjString*) tok->At(pos); + ostr = dynamic_cast(tok->At(pos)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -637,7 +636,7 @@ void PRunSingleHisto::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(pos+1); + ostr = dynamic_cast(tok->At(pos+1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -649,8 +648,8 @@ void PRunSingleHisto::SetFitRangeBin(const TString fitRange) fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; } } else { // error - cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } // clean up @@ -707,8 +706,8 @@ Bool_t PRunSingleHisto::PrepareData() // get the proper run PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName()); if (!runData) { // couldn't get run - cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + std::cerr << std::endl; return false; } @@ -718,10 +717,10 @@ Bool_t PRunSingleHisto::PrepareData() histoNo.push_back(fRunInfo->GetForwardHistoNo(i)); if (!runData->IsPresent(histoNo[i])) { - cerr << endl << ">> PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; histoNo.clear(); return false; } @@ -729,8 +728,8 @@ Bool_t PRunSingleHisto::PrepareData() // keep the time resolution in (us) fTimeResolution = runData->GetTimeResolution()/1.0e3; - cout.precision(10); - cout << endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl; + std::cout.precision(10); + std::cout << std::endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << std::fixed << runData->GetTimeResolution() << "(ns)" << std::endl; // get all the proper t0's and addt0's for the current RUN block if (!GetProperT0(runData, globalBlock, histoNo)) { @@ -738,7 +737,7 @@ Bool_t PRunSingleHisto::PrepareData() } // keep the histo of each group at this point (addruns handled below) - vector forward; + std::vector forward; forward.resize(histoNo.size()); // resize to number of groups for (UInt_t i=0; iGetDataBin(histoNo[i])->size()); @@ -752,9 +751,9 @@ Bool_t PRunSingleHisto::PrepareData() // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunSingleHisto::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -764,8 +763,9 @@ Bool_t PRunSingleHisto::PrepareData() addRunSize = addRunData->GetDataBin(histoNo[k])->size(); for (UInt_t j=0; jGetDataBin(histoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if (((Int_t)j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] < addRunSize)) { - forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k]); + if ((static_cast(j)+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k]) >= 0) && + (j+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k]) < addRunSize)) { + forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k])); } } } @@ -782,8 +782,8 @@ Bool_t PRunSingleHisto::PrepareData() for (UInt_t i=1; iGetDataBin(histoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range - if (((Int_t)j+fT0s[i]-fT0s[0] >= 0) && (j+fT0s[i]-fT0s[0] < runData->GetDataBin(histoNo[i])->size())) { - fForward[j] += forward[i][j+(Int_t)fT0s[i]-(Int_t)fT0s[0]]; + if ((static_cast(j)+fT0s[i]-fT0s[0] >= 0) && (j+fT0s[i]-fT0s[0] < runData->GetDataBin(histoNo[i])->size())) { + fForward[j] += forward[i][j+static_cast(fT0s[i])-static_cast(fT0s[0])]; } } } @@ -854,10 +854,10 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN } else { // no background given to do the job, try estimate fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << ">> NO GUARANTEE THAT THIS MAKES ANY SENSE! Better check ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!"; + std::cerr << std::endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + std::cerr << std::endl; if (!EstimateBkg(histoNo)) return false; } @@ -869,7 +869,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN } // everything looks fine, hence fill data set - Int_t t0 = (Int_t)fT0s[0]; + Int_t t0 = static_cast(fT0s[0]); Double_t value = 0.0; Double_t normalizer = 1.0; // in order that after rebinning the fit does not need to be redone (important for plots) @@ -878,7 +878,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN normalizer = fPacking * (fTimeResolution * 1.0e3); // fTimeResolution us->ns // data start at data_start-t0 // time shifted so that packing is included correctly, i.e. t0 == t0 after packing - fData.SetDataTimeStart(fTimeResolution*((Double_t)fGoodBins[0]-(Double_t)t0+(Double_t)(fPacking-1)/2.0)); + fData.SetDataTimeStart(fTimeResolution*(static_cast(fGoodBins[0])-static_cast(t0)+static_cast(fPacking-1)/2.0)); fData.SetDataTimeStep(fTimeResolution*fPacking); for (Int_t i=fGoodBins[0]; ins } else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) { - theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking; + theoryNorm = static_cast(fMsrInfo->GetMsrPlotList()->at(0).fViewPacking)/static_cast(fPacking); } // raw data, since PMusrCanvas is doing ranging etc. // start = the first bin which is a multiple of packing backward from first good data bin Int_t start = fGoodBins[0] - (fGoodBins[0]/packing)*packing; - // end = last bin starting from start which is a multipl of packing and still within the data + // end = last bin starting from start which is a multiple of packing and still within the data Int_t end = start + ((fForward.size()-start)/packing)*packing; // check if data range has been provided, and if not try to estimate them if (start < 0) { - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); - start = ((Int_t)fT0s[0]+offset) - (((Int_t)fT0s[0]+offset)/packing)*packing; + Int_t offset = static_cast(10.0e-3/fTimeResolution); + start = (static_cast(fT0s[0])+offset) - ((static_cast(fT0s[0])+offset)/packing)*packing; end = start + ((fForward.size()-start)/packing)*packing; - cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **WARNING** data range was not provided, will try data range start = " << start << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareRawViewData(): **WARNING** data range was not provided, will try data range start = " << start << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start, end, and t0 make any sense // 1st check if start and end are in proper order @@ -966,24 +966,24 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)fForward.size())) { - cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start < 0) || (start > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)fForward.size())) { - cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; - cerr << endl; + if ((end < 0) || (end > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // everything looks fine, hence fill data set - Int_t t0 = (Int_t)fT0s[0]; + Int_t t0 = static_cast(fT0s[0]); Double_t value = 0.0; // data start at data_start-t0 // time shifted so that packing is included correctly, i.e. t0 == t0 after packing - fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(packing-1)/2.0)); + fData.SetDataTimeStart(fTimeResolution*(static_cast(start)-static_cast(t0)+static_cast(packing-1)/2.0)); fData.SetDataTimeStep(fTimeResolution*packing); for (Int_t i=start; iSetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << ">> NO GUARANTEE THAT THIS MAKES ANY SENSE! Better check ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareRawViewData(): **WARNING** Neither fix background nor background bins are given!"; + std::cerr << std::endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + std::cerr << std::endl; if (!EstimateBkg(histoNo)) return false; } @@ -1065,7 +1065,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi Double_t factor = 1.0; if (fData.GetValue()->size() * 10 > fForward.size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)fForward.size() / (Double_t)size; + factor = static_cast(fForward.size()) / static_cast(size); } Double_t time; Double_t theoryValue; @@ -1132,13 +1132,13 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo if (fScaleN0AndBkg) { dataNorm = 1.0/ (packing * (fTimeResolution * 1.0e3)); // fTimeResolution us->ns } else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) { - theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking; + theoryNorm = static_cast(fMsrInfo->GetMsrPlotList()->at(0).fViewPacking)/static_cast(fPacking); } // transform raw histo data. This is done the following way (for details see the manual): // for the single histo fit, just the rebinned raw data are copied // first get start data, end data, and t0 - Int_t t0 = (Int_t)fT0s[0]; + Int_t t0 = static_cast(fT0s[0]); // start = the first bin which is a multiple of packing backward from first good data bin Int_t start = fGoodBins[0] - (fGoodBins[0]/packing)*packing; @@ -1147,12 +1147,12 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo // check if data range has been provided, and if not try to estimate them if (start < 0) { - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); - start = ((Int_t)fT0s[0]+offset) - (((Int_t)fT0s[0]+offset)/packing)*packing; + Int_t offset = static_cast(10.0e-3/fTimeResolution); + start = (static_cast(fT0s[0])+offset) - ((static_cast(fT0s[0])+offset)/packing)*packing; end = start + ((fForward.size()-start)/packing)*packing; - cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **WARNING** data range was not provided, will try data range start = " << start << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareViewData(): **WARNING** data range was not provided, will try data range start = " << start << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start, end, and t0 make any sense @@ -1163,15 +1163,15 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)fForward.size())) { - cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; - cerr << endl; + if ((start < 0) || (start > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)fForward.size())) { - cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; - cerr << endl; + if ((end < 0) || (end > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; + std::cerr << std::endl; return false; } @@ -1213,10 +1213,10 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo } else { // no background given to do the job, try estimate fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << ">> NO GUARANTEE THAT THIS MAKES ANY SENSE! Better check ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::PrepareViewData(): **WARNING** Neither fix background nor background bins are given!"; + std::cerr << std::endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + std::cerr << std::endl; if (!EstimateBkg(histoNo)) return false; } @@ -1235,7 +1235,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo Double_t time = 0.0; // data start at data_start-t0 shifted by (pack-1)/2 - fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(packing-1)/2.0)); + fData.SetDataTimeStart(fTimeResolution*(static_cast(start)-static_cast(t0)+static_cast(packing-1)/2.0)); fData.SetDataTimeStep(fTimeResolution*packing); // data is always normalized to (per nsec!!) @@ -1244,7 +1244,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo for (Int_t i=start; i(i)-static_cast(packing-1)/2.0)-t0)*fTimeResolution; expval = TMath::Exp(+time/tau)/N0; fData.AppendValue(-1.0+expval*(value-bkg)); fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm)); @@ -1285,7 +1285,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo value = 0.0; error = 0.0; } - time = ((Double_t)i-t0)*fTimeResolution; + time = (static_cast(i)-t0)*fTimeResolution; expval = TMath::Exp(+time/tau)/N0; rrf_val = (-1.0+expval*(fForward[i]/(fTimeResolution*1.0e3)-bkg))*TMath::Cos(wRRF * time + phaseRRF); value += rrf_val; @@ -1310,7 +1310,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo // check if a finer binning for the theory is needed if (fData.GetValue()->size() * 10 > fForward.size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)fForward.size() / (Double_t)size; + factor = static_cast(fForward.size()) / static_cast(size); } fData.SetTheoryTimeStart(fData.GetDataTimeStart()); fData.SetTheoryTimeStep(fTimeResolution*factor); @@ -1321,7 +1321,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo } for (UInt_t i=0; i(i)*fData.GetTheoryTimeStep(); theoryValue = fTheory->Func(time, par, fFuncValues); if (wRRF != 0.0) { theoryValue *= 2.0*TMath::Cos(wRRF * time + phaseRRF); @@ -1399,7 +1399,7 @@ Bool_t PRunSingleHisto::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globa // fill in the T0's from the GLOBAL block section (if present) for (UInt_t i=0; iGetT0BinSize(); i++) { - if (fT0s[i] == -1) { // i.e. not given in the RUN block section + if (fT0s[i] == -1.0) { // i.e. not given in the RUN block section fT0s[i] = globalBlock->GetT0Bin(i); } } @@ -1420,19 +1420,19 @@ Bool_t PRunSingleHisto::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globa fT0s[i] = runData->GetT0BinEstimated(histoNo[i]); fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file - cerr << endl << ">> PRunSingleHisto::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; - cerr << endl; + if ((fT0s[i] < 0.0) || (fT0s[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1445,9 +1445,9 @@ Bool_t PRunSingleHisto::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globa // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -1478,19 +1478,19 @@ Bool_t PRunSingleHisto::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globa fAddT0s[i-1][j] = addRunData->GetT0BinEstimated(histoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file - cerr << endl << ">> PRunSingleHisto::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) { - cerr << endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!"; - cerr << endl; + if ((fAddT0s[i-1][j] < 0.0) || (fAddT0s[i-1][j] > static_cast(addRunData->GetDataBin(histoNo[j])->size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -1531,19 +1531,19 @@ Bool_t PRunSingleHisto::GetProperDataRange() // check if data range has been provided, and if not try to estimate them if (start < 0) { - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); - start = (Int_t)fT0s[0]+offset; + Int_t offset = static_cast(10.0e-3/fTimeResolution); + start = static_cast(fT0s[0])+offset; fRunInfo->SetDataRange(start, 0); - cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end < 0) { end = fForward.size(); fRunInfo->SetDataRange(end, 1); - cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start and end make any sense @@ -1554,22 +1554,22 @@ Bool_t PRunSingleHisto::GetProperDataRange() start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)fForward.size())) { - cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!"; - cerr << endl; + if ((start < 0) || (start > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds if (end < 0) { - cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } - if (end > (Int_t)fForward.size()) { - cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** end data bin (" << end << ") > histo length (" << (Int_t)fForward.size() << ")."; - cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; - cerr << endl; - end = (Int_t)fForward.size()-1; + if (end > static_cast(fForward.size())) { + std::cerr << std::endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** end data bin (" << end << ") > histo length (" << fForward.size() << ")."; + std::cerr << std::endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << std::endl; + std::cerr << std::endl; + end = static_cast(fForward.size())-1; } // keep good bins for potential later use @@ -1622,8 +1622,8 @@ void PRunSingleHisto::GetProperFitRange(PMsrGlobalBlock *globalBlock) if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) { fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt - cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl; - cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl; + std::cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl; + std::cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << std::endl; } } @@ -1646,7 +1646,7 @@ void PRunSingleHisto::EstimateN0() assert(param); if (paramNo > param->size()) { - cerr << endl << ">> PRunSingleHisto::EstimateN0: **ERROR** found parameter number " << paramNo << ", which is larger than the number of parameters = " << param->size() << endl; + std::cerr << std::endl << ">> PRunSingleHisto::EstimateN0: **ERROR** found parameter number " << paramNo << ", which is larger than the number of parameters = " << param->size() << std::endl; return; } @@ -1663,7 +1663,7 @@ void PRunSingleHisto::EstimateN0() if ((paramNoBkg > 10000) || (paramNoBkg == -1)) { // i.e. fun or map scaleBkg = false; } else { - if (paramNoBkg-1 < (Int_t)param->size()) { + if (paramNoBkg-1 < static_cast(param->size())) { bkg = param->at(paramNoBkg-1).fValue; errBkg = param->at(paramNoBkg-1).fStep; } @@ -1673,7 +1673,7 @@ void PRunSingleHisto::EstimateN0() Double_t dt = fTimeResolution; Double_t tau = PMUON_LIFETIME; - UInt_t t0 = (UInt_t)round(fT0s[0]); + UInt_t t0 = static_cast(round(fT0s[0])); Double_t dval = 0.0; Double_t nom = 0.0; Double_t denom = 0.0; @@ -1681,13 +1681,13 @@ void PRunSingleHisto::EstimateN0() // calc nominator for (UInt_t i=t0; i(i-t0)/tau); nom += xx; } // calc denominator for (UInt_t i=t0; i(i-t0)/tau); dval = fForward[i]; if (dval > 0) denom += xx*xx/dval; @@ -1707,9 +1707,9 @@ void PRunSingleHisto::EstimateN0() errBkg *= rescale; } - cout << ">> PRunSingleHisto::EstimateN0: found N0=" << param->at(paramNo-1).fValue << ", will set it to N0=" << N0 << endl; + std::cout << ">> PRunSingleHisto::EstimateN0: found N0=" << param->at(paramNo-1).fValue << ", will set it to N0=" << N0 << std::endl; if (scaleBkg) - cout << ">> PRunSingleHisto::EstimateN0: found Bkg=" << param->at(paramNoBkg-1).fValue << ", will set it to Bkg=" << bkg << endl; + std::cout << ">> PRunSingleHisto::EstimateN0: found Bkg=" << param->at(paramNoBkg-1).fValue << ", will set it to Bkg=" << bkg << std::endl; fMsrInfo->SetMsrParamValue(paramNo-1, N0); fMsrInfo->SetMsrParamStep(paramNo-1, sqrt(fabs(N0))); if (scaleBkg) { @@ -1745,41 +1745,41 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo) beamPeriod = 0.0; // check if start and end are in proper order - UInt_t start = fRunInfo->GetBkgRange(0); - UInt_t end = fRunInfo->GetBkgRange(1); + Int_t start = fRunInfo->GetBkgRange(0); + Int_t end = fRunInfo->GetBkgRange(1); if (end < start) { - cout << endl << "PRunSingleHisto::EstimatBkg(): end = " << end << " > start = " << start << "! Will swap them!"; - UInt_t keep = end; + std::cout << std::endl << "PRunSingleHisto::EstimatBkg(): end = " << end << " > start = " << start << "! Will swap them!"; + Int_t keep = end; end = start; start = keep; } // calculate proper background range if (beamPeriod != 0.0) { - Double_t timeBkg = (Double_t)(end-start)*(fTimeResolution*fPacking); // length of the background intervall in time - UInt_t fullCycles = (UInt_t)(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall + Double_t timeBkg = static_cast(end-start)*(fTimeResolution*fPacking); // length of the background intervall in time + UInt_t fullCycles = static_cast(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall // correct the end of the background intervall such that the background is as close as possible to a multiple of the proton cylce - end = start + (UInt_t) ((fullCycles*beamPeriod)/(fTimeResolution*fPacking)); - cout << endl << "PRunSingleHisto::EstimatBkg(): Background " << start << ", " << end; + end = start + static_cast((fullCycles*beamPeriod)/(fTimeResolution*fPacking)); + std::cout << std::endl << "PRunSingleHisto::EstimatBkg(): Background " << start << ", " << end; if (end == start) end = fRunInfo->GetBkgRange(1); } // check if start is within histogram bounds if (start >= fForward.size()) { - cerr << endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths = " << fForward.size(); - cerr << endl << ">> background start = " << start; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths = " << fForward.size(); + std::cerr << std::endl << ">> background start = " << start; + std::cerr << std::endl; return false; } // check if end is within histogram bounds if (end >= fForward.size()) { - cerr << endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths = " << fForward.size(); - cerr << endl << ">> background end = " << end; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths = " << fForward.size(); + std::cerr << std::endl << ">> background end = " << end; + std::cerr << std::endl; return false; } @@ -1821,13 +1821,13 @@ Bool_t PRunSingleHisto::IsScaleN0AndBkg() PMsrLines *cmd = fMsrInfo->GetMsrCommands(); for (UInt_t i=0; isize(); i++) { if (cmd->at(i).fLine.Contains("SCALE_N0_BKG", TString::kIgnoreCase)) { - TObjArray *tokens = 0; - TObjString *ostr = 0; + TObjArray *tokens = nullptr; + TObjString *ostr = nullptr; TString str; tokens = cmd->at(i).fLine.Tokenize(" \t"); if (tokens->GetEntries() != 2) { - cerr << endl << ">> PRunSingleHisto::IsScaleN0AndBkg(): **WARNING** Found uncorrect 'SCALE_N0_BKG' command, will ignore it."; - cerr << endl << ">> Allowed commands: SCALE_N0_BKG TRUE | FALSE" << endl; + std::cerr << std::endl << ">> PRunSingleHisto::IsScaleN0AndBkg(): **WARNING** Found uncorrect 'SCALE_N0_BKG' command, will ignore it."; + std::cerr << std::endl << ">> Allowed commands: SCALE_N0_BKG TRUE | FALSE" << std::endl; return willScale; } ostr = dynamic_cast(tokens->At(1)); diff --git a/src/classes/PRunSingleHistoRRF.cpp b/src/classes/PRunSingleHistoRRF.cpp index a42575bd..ec9ab895 100644 --- a/src/classes/PRunSingleHistoRRF.cpp +++ b/src/classes/PRunSingleHistoRRF.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -38,7 +38,6 @@ #include #include #include -using namespace std; #include #include @@ -88,24 +87,24 @@ PRunSingleHistoRRF::PRunSingleHistoRRF(PMsrHandler *msrInfo, PRunDataHandler *ra PMsrGlobalBlock *global = msrInfo->GetMsrGlobal(); if (!global->IsPresent()) { - cerr << endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no GLOBAL-block present!"; - cerr << endl << ">> For Single Histo RRF the GLOBAL-block is mandatory! Please fix this first."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no GLOBAL-block present!"; + std::cerr << std::endl << ">> For Single Histo RRF the GLOBAL-block is mandatory! Please fix this first."; + std::cerr << std::endl; fValid = false; return; } if (!global->GetRRFUnit().CompareTo("??")) { - cerr << endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no RRF-Frequency found!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no RRF-Frequency found!"; + std::cerr << std::endl; fValid = false; return; } fRRFPacking = global->GetRRFPacking(); if (fRRFPacking == -1) { - cerr << endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no RRF-Packing found!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: no RRF-Packing found!"; + std::cerr << std::endl; fValid = false; return; } @@ -118,9 +117,9 @@ PRunSingleHistoRRF::PRunSingleHistoRRF(PMsrHandler *msrInfo, PRunDataHandler *ra fN0EstimateEndTime = 1.0; // end time in (us) over which N0 is estimated. if (!PrepareData()) { - cerr << endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: Couldn't prepare data for fitting!"; - cerr << endl << ">> This is very bad :-(, will quit ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PRunSingleHistoRRF(): **SEVERE ERROR**: Couldn't prepare data for fitting!"; + std::cerr << std::endl << ">> This is very bad :-(, will quit ..."; + std::cerr << std::endl; fValid = false; } } @@ -154,7 +153,7 @@ Double_t PRunSingleHistoRRF::CalcChiSquare(const std::vector& par) // calculate functions for (Int_t i=0; iGetNoOfFuncs(); i++) { - Int_t funcNo = fMsrInfo->GetFuncNo(i); + UInt_t funcNo = fMsrInfo->GetFuncNo(i); fFuncValues[i] = fMsrInfo->EvalFunc(funcNo, *fRunInfo->GetMap(), par); } @@ -175,7 +174,7 @@ Double_t PRunSingleHistoRRF::CalcChiSquare(const std::vector& par) #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); diff = fData.GetValue()->at(i) - fTheory->Func(time, par, fFuncValues); chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i)); } @@ -202,7 +201,7 @@ Double_t PRunSingleHistoRRF::CalcChiSquareExpected(const std::vector& // calculate functions for (Int_t i=0; iGetNoOfFuncs(); i++) { - Int_t funcNo = fMsrInfo->GetFuncNo(i); + UInt_t funcNo = fMsrInfo->GetFuncNo(i); fFuncValues[i] = fMsrInfo->EvalFunc(funcNo, *fRunInfo->GetMap(), par); } @@ -223,7 +222,7 @@ Double_t PRunSingleHistoRRF::CalcChiSquareExpected(const std::vector& #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) #endif for (i=fStartTimeBin; i < fEndTimeBin; ++i) { - time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep(); + time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); theo = fTheory->Func(time, par, fFuncValues); diff = fData.GetValue()->at(i) - theo; chisq += diff*diff / theo; @@ -275,7 +274,7 @@ void PRunSingleHistoRRF::CalcTheory() Double_t resolution = fData.GetDataTimeStep(); Double_t time; for (UInt_t i=0; i(i)*resolution; fData.AppendTheoryValue(fTheory->Func(time, par, fFuncValues)); } @@ -314,8 +313,8 @@ UInt_t PRunSingleHistoRRF::GetNoOfFitBins() */ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange) { - TObjArray *tok = 0; - TObjString *ostr = 0; + TObjArray *tok = nullptr; + TObjString *ostr = nullptr; TString str; Ssiz_t idx = -1; Int_t offset = 0; @@ -324,7 +323,7 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange) if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 // handle fgb+n0 entry - ostr = (TObjString*) tok->At(1); + ostr = dynamic_cast(tok->At(1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -336,7 +335,7 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(2); + ostr = dynamic_cast(tok->At(2)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -350,11 +349,11 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange) Int_t pos = 2*(fRunNo+1)-1; if (pos + 1 >= tok->GetEntries()) { - cerr << endl << ">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } else { // handle fgb+n0 entry - ostr = (TObjString*) tok->At(pos); + ostr = dynamic_cast(tok->At(pos)); str = ostr->GetString(); // check if there is an offset present idx = str.First("+"); @@ -366,7 +365,7 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange) fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; // handle lgb-n1 entry - ostr = (TObjString*) tok->At(pos+1); + ostr = dynamic_cast(tok->At(pos+1)); str = ostr->GetString(); // check if there is an offset present idx = str.First("-"); @@ -378,8 +377,8 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange) fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; } } else { // error - cerr << endl << ">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; - cerr << endl << ">> will ignore it. Sorry ..." << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + std::cerr << std::endl << ">> will ignore it. Sorry ..." << std::endl; } // clean up @@ -436,8 +435,8 @@ Bool_t PRunSingleHistoRRF::PrepareData() // get the proper run PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName()); if (!runData) { // couldn't get run - cerr << endl << ">> PRunSingleHistoRRF::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + std::cerr << std::endl; return false; } @@ -447,10 +446,10 @@ Bool_t PRunSingleHistoRRF::PrepareData() histoNo.push_back(fRunInfo->GetForwardHistoNo(i)); if (!runData->IsPresent(histoNo[i])) { - cerr << endl << ">> PRunSingleHistoRRF::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; - cerr << endl << ">> Will quit :-("; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PrepareData(): **PANIC ERROR**:"; + std::cerr << std::endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; + std::cerr << std::endl << ">> Will quit :-("; + std::cerr << std::endl; histoNo.clear(); return false; } @@ -458,8 +457,8 @@ Bool_t PRunSingleHistoRRF::PrepareData() // keep the time resolution in (us) fTimeResolution = runData->GetTimeResolution()/1.0e3; - cout.precision(10); - cout << endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl; + std::cout.precision(10); + std::cout << std::endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << std::fixed << runData->GetTimeResolution() << "(ns)" << std::endl; // get all the proper t0's and addt0's for the current RUN block if (!GetProperT0(runData, globalBlock, histoNo)) { @@ -467,7 +466,7 @@ Bool_t PRunSingleHistoRRF::PrepareData() } // keep the histo of each group at this point (addruns handled below) - vector forward; + std::vector forward; forward.resize(histoNo.size()); // resize to number of groups for (UInt_t i=0; iGetDataBin(histoNo[i])->size()); @@ -481,9 +480,9 @@ Bool_t PRunSingleHistoRRF::PrepareData() // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunSingleHistoRRF::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunSingleHistoRRF::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -493,8 +492,9 @@ Bool_t PRunSingleHistoRRF::PrepareData() addRunSize = addRunData->GetDataBin(histoNo[k])->size(); for (UInt_t j=0; jGetDataBin(histoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if (((Int_t)j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] < addRunSize)) { - forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k]); + if ((static_cast(j)+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k]) >= 0) && + (j+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k]) < addRunSize)) { + forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+static_cast(fAddT0s[i-1][k])-static_cast(fT0s[k])); } } } @@ -511,8 +511,9 @@ Bool_t PRunSingleHistoRRF::PrepareData() for (UInt_t i=1; iGetDataBin(histoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range - if (((Int_t)j+fT0s[i]-fT0s[0] >= 0) && (j+fT0s[i]-fT0s[0] < runData->GetDataBin(histoNo[i])->size())) { - fForward[j] += forward[i][j+(Int_t)fT0s[i]-(Int_t)fT0s[0]]; + if ((static_cast(j)+static_cast(fT0s[i])-static_cast(fT0s[0]) >= 0) && + (j+static_cast(fT0s[i])-static_cast(fT0s[0]) < runData->GetDataBin(histoNo[i])->size())) { + fForward[j] += forward[i][j+static_cast(fT0s[i])-static_cast(fT0s[0])]; } } } @@ -567,13 +568,13 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his rawNt.push_back(fForward[i]); // N(t) without any corrections } Double_t freqMax = GetMainFrequency(rawNt); - cout << "info> freqMax=" << freqMax << " (MHz)" << endl; + std::cout << "info> freqMax=" << freqMax << " (MHz)" << std::endl; // "optimal packing" Double_t optNoPoints = 8; if (freqMax < 271.0) // < 271 MHz, i.e ~ 2T optNoPoints = 5; - cout << "info> optimal packing: " << (Int_t)(1.0 / (fTimeResolution*(freqMax - fMsrInfo->GetMsrGlobal()->GetRRFFreq("MHz"))) / optNoPoints); + std::cout << "info> optimal packing: " << static_cast(1.0 / (fTimeResolution*(freqMax - fMsrInfo->GetMsrGlobal()->GetRRFFreq("MHz"))) / optNoPoints); // initially fForward is the "raw data set" (i.e. grouped histo and raw runs already added) to be fitted. This means fForward = N(t) at this point. @@ -586,10 +587,10 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his } else { // no background given to do the job, try estimate fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << ">> PRunSingleHistoRRF::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << ">> NO GUARANTEE THAT THIS MAKES ANY SENSE! Better check ..."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!"; + std::cerr << std::endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + std::cerr << std::endl; if (!EstimateBkg(histoNo)) return false; } @@ -604,10 +605,10 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his } // here fForward = N(t) - Nbkg - Int_t t0 = (Int_t)fT0s[0]; + Int_t t0 = static_cast(fT0s[0]); // 2) N(t) - Nbkg -> exp(+t/tau) [N(t)-Nbkg] - Double_t startTime = fTimeResolution * ((Double_t)fGoodBins[0] - (Double_t)t0); + Double_t startTime = fTimeResolution * (static_cast(fGoodBins[0]) - static_cast(t0)); Double_t time_tau=0.0; Double_t exp_t_tau=0.0; @@ -650,7 +651,7 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his Double_t phaseRRF = globalBlock->GetRRFPhase()*TMath::TwoPi()/180.0; Double_t time = 0.0; for (Int_t i=fGoodBins[0]; i<=fGoodBins[1]; i++) { - time = startTime + fTimeResolution * ((Double_t)i - (Double_t)fGoodBins[0]); + time = startTime + fTimeResolution * (static_cast(i) - static_cast(fGoodBins[0])); fForward[i] *= 2.0*cos(wRRF * time + phaseRRF); } @@ -683,7 +684,7 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his } // set start time and time step - fData.SetDataTimeStart(fTimeResolution*((Double_t)fGoodBins[0]-(Double_t)t0+(Double_t)(fRRFPacking-1)/2.0)); + fData.SetDataTimeStart(fTimeResolution*(static_cast(fGoodBins[0])-static_cast(t0)+static_cast(fRRFPacking-1)/2.0)); fData.SetDataTimeStep(fTimeResolution*fRRFPacking); CalcNoOfFitBins(); @@ -723,8 +724,8 @@ Bool_t PRunSingleHistoRRF::PrepareViewData(PRawRunData* runData, const UInt_t hi Int_t viewPacking = fMsrInfo->GetMsrPlotList()->at(0).fViewPacking; if (viewPacking > 0) { if (viewPacking < fRRFPacking) { - cerr << ">> PRunSingleHistoRRF::PrepareViewData(): **WARNING** Found View Packing (" << viewPacking << ") < RRF Packing (" << fRRFPacking << ")."; - cerr << ">> Will ignore View Packing." << endl; + std::cerr << ">> PRunSingleHistoRRF::PrepareViewData(): **WARNING** Found View Packing (" << viewPacking << ") < RRF Packing (" << fRRFPacking << ")."; + std::cerr << ">> Will ignore View Packing." << std::endl; } else { // STILL MISSING } @@ -753,14 +754,14 @@ Bool_t PRunSingleHistoRRF::PrepareViewData(PRawRunData* runData, const UInt_t hi if (fData.GetValue()->size() * 10 > fForward.size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)fForward.size() / (Double_t)size; + factor = static_cast(fForward.size()) / static_cast(size); } fData.SetTheoryTimeStart(fData.GetDataTimeStart()); fData.SetTheoryTimeStep(fTimeResolution*factor); // calculate theory for (UInt_t i=0; i(i)*fData.GetTheoryTimeStep(); theoryValue = fTheory->Func(time, par, fFuncValues); if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!! theoryValue = 0.0; @@ -808,7 +809,7 @@ Bool_t PRunSingleHistoRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *gl // fill in the T0's from the GLOBAL block section (if present) for (UInt_t i=0; iGetT0BinSize(); i++) { - if (fT0s[i] == -1) { // i.e. not given in the RUN block section + if (fT0s[i] == -1.0) { // i.e. not given in the RUN block section fT0s[i] = globalBlock->GetT0Bin(i); } } @@ -829,19 +830,19 @@ Bool_t PRunSingleHistoRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *gl fT0s[i] = runData->GetT0BinEstimated(histoNo[i]); fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file - cerr << endl << ">> PRunSingleHistoRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName()->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunSingleHistoRRF::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; - cerr << endl; + if ((fT0s[i] < 0.0) || (fT0s[i] > static_cast(runData->GetDataBin(histoNo[i])->size()))) { + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -854,9 +855,9 @@ Bool_t PRunSingleHistoRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *gl // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); - if (addRunData == 0) { // couldn't get run - cerr << endl << ">> PRunSingleHistoRRF::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; - cerr << endl; + if (addRunData == nullptr) { // couldn't get run + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + std::cerr << std::endl; return false; } @@ -887,19 +888,19 @@ Bool_t PRunSingleHistoRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *gl fAddT0s[i-1][j] = addRunData->GetT0BinEstimated(histoNo[j]); fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file - cerr << endl << ">> PRunSingleHistoRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); - cerr << endl << ">> NO GUARANTEE THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + std::cerr << std::endl << ">> run: " << fRunInfo->GetRunName(i)->Data(); + std::cerr << std::endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); + std::cerr << std::endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + std::cerr << std::endl; } } // check if t0 is within proper bounds for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) { - cerr << endl << ">> PRunSingleHistoRRF::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!"; - cerr << endl; + if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > static_cast(addRunData->GetDataBin(histoNo[j])->size()))) { + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } } @@ -940,19 +941,19 @@ Bool_t PRunSingleHistoRRF::GetProperDataRange() // check if data range has been provided, and if not try to estimate them if (start < 0) { - Int_t offset = (Int_t)(10.0e-3/fTimeResolution); - start = (Int_t)fT0s[0]+offset; + Int_t offset = static_cast(10.0e-3/fTimeResolution); + start = static_cast(fT0s[0])+offset; fRunInfo->SetDataRange(start, 0); - cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } if (end < 0) { end = fForward.size(); fRunInfo->SetDataRange(end, 1); - cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << "."; - cerr << endl << ">> NO GUARANTEE THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << "."; + std::cerr << std::endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + std::cerr << std::endl; } // check if start and end make any sense @@ -963,22 +964,22 @@ Bool_t PRunSingleHistoRRF::GetProperDataRange() start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)fForward.size())) { - cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!"; - cerr << endl; + if ((start < 0) || (start > static_cast(fForward.size()))) { + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } // 3rd check if end is within proper bounds if (end < 0) { - cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!"; + std::cerr << std::endl; return false; } - if (end > (Int_t)fForward.size()) { - cerr << endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** end data bin (" << end << ") > histo length (" << (Int_t)fForward.size() << ")."; - cerr << endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << endl; - cerr << endl; - end = (Int_t)fForward.size()-1; + if (end > static_cast(fForward.size())) { + std::cerr << std::endl << ">> PRunSingleHistoRRF::GetProperDataRange(): **WARNING** end data bin (" << end << ") > histo length (" << fForward.size() << ")."; + std::cerr << std::endl << ">> Will set end = (histo length - 1). Consider to change it in the msr-file." << std::endl; + std::cerr << std::endl; + end = static_cast(fForward.size()-1); } // keep good bins for potential later use @@ -1031,8 +1032,8 @@ void PRunSingleHistoRRF::GetProperFitRange(PMsrGlobalBlock *globalBlock) if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) { fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt - cerr << ">> PRunSingleHistoRRF::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl; - cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl; + std::cerr << ">> PRunSingleHistoRRF::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl; + std::cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << std::endl; } } @@ -1102,7 +1103,7 @@ Double_t PRunSingleHistoRRF::EstimateN0(Double_t &errN0, Double_t freqMax) { // endBin is estimated such that the number of full cycles (according to the maximum frequency of the data) // is approximately the time fN0EstimateEndTime. - Int_t endBin = (Int_t)round(ceil(fN0EstimateEndTime*freqMax/TMath::TwoPi()) * (TMath::TwoPi()/freqMax) / fTimeResolution); + Int_t endBin = static_cast(round(ceil(fN0EstimateEndTime*freqMax/TMath::TwoPi()) * (TMath::TwoPi()/freqMax) / fTimeResolution)); Double_t n0 = 0.0; Double_t wN = 0.0; @@ -1120,7 +1121,7 @@ Double_t PRunSingleHistoRRF::EstimateN0(Double_t &errN0, Double_t freqMax) } errN0 = sqrt(errN0)/wN; - cout << "info> PRunSingleHistoRRF::EstimateN0(): N0=" << n0 << "(" << errN0 << ")" << endl; + std::cout << "info> PRunSingleHistoRRF::EstimateN0(): N0=" << n0 << "(" << errN0 << ")" << std::endl; return n0; } @@ -1155,7 +1156,7 @@ Bool_t PRunSingleHistoRRF::EstimateBkg(UInt_t histoNo) UInt_t start = fRunInfo->GetBkgRange(0); UInt_t end = fRunInfo->GetBkgRange(1); if (end < start) { - cout << endl << "PRunSingleHistoRRF::EstimatBkg(): end = " << end << " > start = " << start << "! Will swap them!"; + std::cout << std::endl << "PRunSingleHistoRRF::EstimatBkg(): end = " << end << " > start = " << start << "! Will swap them!"; UInt_t keep = end; end = start; start = keep; @@ -1163,30 +1164,30 @@ Bool_t PRunSingleHistoRRF::EstimateBkg(UInt_t histoNo) // calculate proper background range if (beamPeriod != 0.0) { - Double_t timeBkg = (Double_t)(end-start)*fTimeResolution; // length of the background intervall in time - UInt_t fullCycles = (UInt_t)(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall + Double_t timeBkg = static_cast(end-start)*fTimeResolution; // length of the background intervall in time + UInt_t fullCycles = static_cast(timeBkg/beamPeriod); // how many proton beam cylces can be placed within the proposed background intervall // correct the end of the background intervall such that the background is as close as possible to a multiple of the proton cylce - end = start + (UInt_t) ((fullCycles*beamPeriod)/fTimeResolution); - cout << endl << "PRunSingleHistoRRF::EstimatBkg(): Background " << start << ", " << end; + end = start + static_cast((fullCycles*beamPeriod)/fTimeResolution); + std::cout << std::endl << "PRunSingleHistoRRF::EstimatBkg(): Background " << start << ", " << end; if (end == start) end = fRunInfo->GetBkgRange(1); } // check if start is within histogram bounds if (start >= fForward.size()) { - cerr << endl << ">> PRunSingleHistoRRF::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths = " << fForward.size(); - cerr << endl << ">> background start = " << start; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::EstimatBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths = " << fForward.size(); + std::cerr << std::endl << ">> background start = " << start; + std::cerr << std::endl; return false; } // check if end is within histogram bounds if (end >= fForward.size()) { - cerr << endl << ">> PRunSingleHistoRRF::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths = " << fForward.size(); - cerr << endl << ">> background end = " << end; - cerr << endl; + std::cerr << std::endl << ">> PRunSingleHistoRRF::EstimatBkg(): **ERROR** background bin values out of bound!"; + std::cerr << std::endl << ">> histo lengths = " << fForward.size(); + std::cerr << std::endl << ">> background end = " << end; + std::cerr << std::endl; return false; } @@ -1205,7 +1206,7 @@ Bool_t PRunSingleHistoRRF::EstimateBkg(UInt_t histoNo) bkg += pow(fForward[i]-fBackground, 2.0); fBkgErr = sqrt(bkg/(static_cast(end - start))); - cout << endl << "info> fBackground=" << fBackground << "(" << fBkgErr << ")" << endl; + std::cout << std::endl << "info> fBackground=" << fBackground << "(" << fBkgErr << ")" << std::endl; fRunInfo->SetBkgEstimated(fBackground, 0);