27    for (
int i = 0; i < 2; i++) {
 
   42    for (
int i = 0; i < 2; i++) {
 
   75    Int_t status = crdcpedestals.ReadFile(pedfile, kEnvLocal);
 
   77       Warning(__FUNCTION__, 
"Could not read CrdcPedFile %s", pedfile);
 
   79       Info(__FUNCTION__, 
"Reading CrdcPedFile %s", pedfile);
 
   83    status = crdccal.ReadFile(filename, kEnvLocal);
 
   85       Warning(__FUNCTION__, 
"Could not read CrdcCalFile %s", filename);
 
   87       Info(__FUNCTION__, 
"Reading CrdcCalFile %s", filename);
 
   90    for (
int c = 0; 
c < 2; 
c++) {
 
   92          fped[
c][p] = crdcpedestals.GetValue(Form(
"Crdc.%d.Ped.%03d", 
c, p), 0.0);
 
   93          fslope[
c][p] = crdccal.GetValue(Form(
"Crdc.%d.Slope.%03d", 
c, p), 1.0);
 
   94          foffset[
c][p] = crdccal.GetValue(Form(
"Crdc.%d.Offset.%03d", 
c, p), 0.0);
 
  107    Int_t status = bad.ReadFile(filename, kEnvLocal);
 
  109       Warning(__FUNCTION__, 
"Could not read bad pad file %s", filename);
 
  111       Info(__FUNCTION__, 
"Reading bad pad file %s", filename);
 
  114    for (UShort_t i = 0; i < 2; i++) {
 
  115       fbad[i].resize(bad.GetValue(Form(
"Crdc.%d.Nofbadpads", i), 0));
 
  116       for (UShort_t k = 0; k < fbad[i].size(); k++) {
 
  117          fbad[i][k] = bad.GetValue(Form(
"Crdc.%d.badpad.%d", i, k), 0);
 
  127    std::vector<Float_t> sum;
 
  128    std::vector<Short_t> samples;
 
  135    if (channel.size() != data.size()) {
 
  136       std::cerr << 
" channel (" << channel.size() << 
") and data (" << data.size() << 
") have different sizes " 
  141    for (UShort_t 
f = 0; 
f < channel.size(); 
f++) {
 
  143       sum[index] += data[
f] - fped[id][index];
 
  147       if (samples[ch] > 0) {
 
  148          fcrdccal[ch] = sum[ch]; 
 
  149          fcrdccal[ch] *= fslope[id][ch];
 
  150          fcrdccal[ch] += foffset[id][ch];
 
  152          fcrdccal[ch] = sqrt(-1.0);
 
  162                                                             Int_t 
id, vector<Float_t> &PedSubtractedPads)
 
  171    std::vector<Float_t> samples;
 
  176    std::vector<Float_t> calibratedPadValues;
 
  180    if (channels.size() != data.size()) {
 
  182       std::cerr << 
" channel (" << channels.size() << 
") and data (" << data.size() << 
") have different sizes " 
  189    for (UShort_t 
f = 0; 
f < channels.size(); 
f++) {
 
  192       calibratedPadValues[index] += (data[
f] - fped[id][index]);
 
  193       PedSubtractedPads[index] += (data[
f] - fped[id][index]);
 
  201       if (samples[ch] > 0) {
 
  205          calibratedPadValues[ch] *= fslope[id][ch];
 
  206          calibratedPadValues[ch] += foffset[id][ch];
 
  208          calibratedPadValues[ch] = sqrt(-1.0);
 
  212    return calibratedPadValues;
 
  221    this->
CrdcCal(channel, data, 
id);
 
  247    Bool_t flg_clstr = kFALSE;
 
  251    Int_t clstr[maxclstr][3]; 
 
  252    Float_t maxchg[maxclstr]; 
 
  253    Float_t maxpad[maxclstr];
 
  254    const Float_t qmax = 25.; 
 
  256    const Float_t qthr = 8.;  
 
  257    Float_t tmp_qmax = 0.0;
 
  263       if ((flg_clstr == kFALSE) && (!std::isnan(fcrdccal[i]))) {
 
  266          clstr[iclstr][0] = i;  
 
  267          clstr[iclstr][1] = -1; 
 
  268          maxchg[iclstr] = fcrdccal[i];
 
  270       } 
else if ((flg_clstr == kTRUE) && (!std::isnan(fcrdccal[i]))) {
 
  271          if (fcrdccal[i] > maxchg[iclstr]) {
 
  272             maxchg[iclstr] = fcrdccal[i];
 
  275       } 
else if ((flg_clstr == kTRUE) && (std::isnan(fcrdccal[i]))) {
 
  277          clstr[iclstr][1] = i - 1;
 
  278          clstr[iclstr][2] = i - clstr[iclstr][0];
 
  280          if (maxchg[iclstr] < qmax) { 
 
  287    if (flg_clstr == kTRUE) {
 
  295    } 
else if (iclstr > 0) {
 
  304       tmp_qmax = maxchg[0];
 
  307       for (Int_t i = 0; i < iclstr + 1; i++) {
 
  308          if (maxchg[i] > tmp_qmax) {
 
  309             tmp_qmax = maxchg[i];
 
  318    fcrdc.
SetMaxChg((Float_t)maxchg[gclstr]);
 
  319    fcrdc.
SetMaxPad((Float_t)maxpad[gclstr]);
 
  325    Float_t sum_q = 0.0, sum_qx = 0.0, sum_qxx = 0.0;
 
  327    for (UShort_t i = clstr[gclstr][0]; i <= clstr[gclstr][1]; i++) {
 
  330       if (fcrdccal[i] < qthr)
 
  332       sum_q += fcrdccal[i];
 
  333       sum_qx += fcrdccal[i] * i;
 
  334       sum_qxx += fcrdccal[i] * i * i;
 
  336       xpad[j] = (Double_t)i;
 
  337       qcal[j] = (Double_t)fcrdccal[i];
 
  346    Double_t xcog = (Double_t)sum_qx / sum_q;
 
  347    auto sigma = (Double_t)TMath::Sqrt(sum_qxx / sum_q - (sum_qx / sum_q) * (sum_qx / sum_q));
 
  350       std::cout << 
"Something strange happens with the CRDC data." << std::endl;
 
  367       par[0] = (Double_t)maxchg[gclstr];
 
  374       } 
else if (fSett->
XFitFunc() == 2) {
 
  385       return (Float_t)xfit;
 
  389    return (Float_t)xcog;
 
  397    vector<Float_t> theCalibratedPads = theCRDC->
GetCal();
 
  400    Bool_t flg_clstr = kFALSE;
 
  404    Int_t clstr[maxclstr][3]; 
 
  405    Float_t maxchg[maxclstr]; 
 
  406    Float_t maxpad[maxclstr]; 
 
  407    const Float_t qmax = 25.; 
 
  409    const Float_t qthr = 8.; 
 
  417       if ((flg_clstr == kFALSE) && (!std::isnan(theCalibratedPads[i]))) {
 
  420          clstr[iclstr][0] = i;  
 
  421          clstr[iclstr][1] = -1; 
 
  422          maxchg[iclstr] = theCalibratedPads[i];
 
  424       } 
else if ((flg_clstr == kTRUE) && (!std::isnan(theCalibratedPads[i]))) {
 
  425          if (theCalibratedPads[i] > maxchg[iclstr]) {
 
  426             maxchg[iclstr] = theCalibratedPads[i];
 
  429       } 
else if ((flg_clstr == kTRUE) && (std::isnan(theCalibratedPads[i]))) {
 
  432          clstr[iclstr][1] = i - 1;                
 
  433          clstr[iclstr][2] = i - clstr[iclstr][0]; 
 
  435          if (maxchg[iclstr] < qmax) { 
 
  445    if (flg_clstr == kTRUE) {
 
  456    } 
else if (iclstr > 0) {
 
  458       Float_t tmp_qmax = 0.0;
 
  466       tmp_qmax = maxchg[0];
 
  469       for (Int_t i = 0; i < iclstr + 1; i++) {
 
  470          if (maxchg[i] > tmp_qmax) {
 
  471             tmp_qmax = maxchg[i];
 
  480    theCRDC->
SetMaxChg((Float_t)maxchg[gclstr]);
 
  481    theCRDC->
SetMaxPad((Float_t)maxpad[gclstr]);
 
  487    Float_t sum_q = 0.0, sum_qx = 0.0, sum_qxx = 0.0;
 
  490    for (UShort_t i = clstr[gclstr][0]; i <= clstr[gclstr][1]; i++) {
 
  493       if (theCalibratedPads[i] < qthr)
 
  496       sum_q += theCalibratedPads[i];
 
  497       sum_qx += theCalibratedPads[i] * i;
 
  498       sum_qxx += theCalibratedPads[i] * i * i;
 
  500       xpad[j] = (Double_t)i;
 
  501       qcal[j] = (Double_t)theCalibratedPads[i];
 
  510    Double_t xcog = (Double_t)sum_qx / sum_q;
 
  511    auto sigma = (Double_t)TMath::Sqrt(sum_qxx / sum_q - (sum_qx / sum_q) * (sum_qx / sum_q));
 
  514       std::cout << 
"Something strange happens with the CRDC data." << std::endl;
 
  517    theCRDC->
SetXcog((Float_t)xcog);
 
  532       par[0] = (Double_t)maxchg[gclstr];
 
  541       } 
else if (fSett->
XFitFunc() == 2) {
 
  547       theCRDC->
SetXfit((Float_t)xfit);
 
  552       return (Float_t)xfit;
 
  556    return (Float_t)xcog;
 
  561    return time1 - time2;
 
  566    return time - fts800;
 
  577    auto iccal = std::make_unique<TEnv>(filename);
 
  579       fICoffset[i] = iccal->GetValue(Form(
"IonChamber.Offset.%d", i), 0.0);
 
  580       fICslope[i] = iccal->GetValue(Form(
"IonChamber.Slope.%d", i), 1.0);
 
  582    fde_slope = iccal->GetValue(
"IonChamber.Slope.DE", 1.0);
 
  583    fde_offset = iccal->GetValue(
"IonChamber.Offset.DE", 0.0);
 
  588    std::vector<Float_t> cal;
 
  590    if (chan.size() != raw.size()) {
 
  591       std::cerr << 
" channel (" << chan.size() << 
") and data (" << raw.size() << 
" have different sizes " << std::endl;
 
  594    for (
unsigned int f = 0; 
f < chan.size(); 
f++) {
 
  596          cal[chan[
f]] = raw[
f] * fICslope[chan[
f]] + fICoffset[chan[
f]];
 
  598          std::cerr << 
" channel " << chan[
f] << 
" not found!" << std::endl;
 
  607    for (
float j : cal) {
 
  636                                          Float_t tac, Float_t anode, Int_t 
id)
 
  641    vector<Float_t> PedSubtractedPads;
 
  645    theCRDC->
SetCal(calibratedPads);
 
  704    for (UShort_t k = 0; k < 2; k++) {
 
  710    for (UShort_t s = 0; s < 3; s++) {
 
  718    for (UShort_t s = 0; s < 32; s++) {
 
  719       hodoscope[s].
Clear();
 
  735    for (UShort_t s = 0; s < 3; s++) {
 
  738    for (UShort_t s = 0; s < 32; s++) {