262   using namespace KM3NETDAQ;
 
  264   gStyle->SetLegendBorderSize(0);
 
  265   struct timeval startTimeTv;
 
  266   gettimeofday(&startTimeTv, NULL);
 
  267   time_t startTime = (time_t)startTimeTv.tv_sec;
 
  268   tm* startGmTime = gmtime(&startTime);
 
  269   const string startUTCTime = asctime(startGmTime);
 
  271   JMultipleFileScanner<JDAQTimesliceTypes_t> vInputFiles; 
 
  273   std::string detectorFile;
 
  274   std::string outXMLFile;
 
  277   std::string mycookies;
 
  278   std::string testType;
 
  279   std::string location;
 
  282   std::string hvDefault;
 
  292     zap[
'T'] = 
make_field(testType) = 
"HV-TUNING-V2";
 
  293     zap[
'w'] = 
make_field(location) = 
"A00070004";
 
  299   catch(
const exception& error) {
 
  300     FATAL(error.what() << endl);
 
  305     load(detectorFile, detector);
 
  307   catch(
const JException& error) {
 
  310   const JModuleRouter moduleRouter(detector);
 
  313   for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
 
  314     const int curId = module->getString();
 
  315     if (lineIds.size() == 0) {
 
  316       lineIds.push_back(curId);
 
  319       for (
unsigned int l = 0; l < lineIds.size(); ++l) {
 
  320         if (curId == lineIds[l]) {
 
  324       if (newLine == 
true) {
 
  325         lineIds.push_back(curId);
 
  329   const unsigned int lineNb = lineIds.size();
 
  331   const int AllDomNb = detector.size();
 
  332   const int runNb = vInputFiles.size();
 
  334   const int domNb = AllDomNb/lineNb;
 
  335   const double diffHVMax = 250;
 
  344   string cookiesContent;
 
  345   ifstream incookies(mycookies.c_str(), ofstream::in);
 
  346   getline(incookies, cookiesContent);
 
  358   stringstream detectorIdSStr;
 
  359   int detectorId = detector.getID();
 
  360   detectorIdSStr << detectorId;
 
  361   string detectorIdStr = detectorIdSStr.str();
 
  363   string streamName = 
"pmt_hv_settings";
 
  365   AccessDB(vvvupi, vvvupiExt, vvvHv, cookiesContent, username, streamName, detectorIdStr, -1, hvDefault, lineIds);
 
  371   vhToTReducedChi2.resize(runNb);
 
  372   for (
int run = 0; run < runNb; ++run) {
 
  373     ostringstream plotname;
 
  374     plotname << 
"hToTReducedChi2-run" << run + 1;
 
  375     vhToTReducedChi2[run] = 
new TH1D(plotname.str().c_str(), plotname.str().c_str(), 101, -0.05, 10.05);
 
  376     for (
unsigned int line = 0; line < lineNb; ++line) {
 
  377       for (
int dom = 0; dom < domNb; ++dom) {
 
  378         for (
int pmt = 0; pmt < pmtNb; ++pmt) {
 
  381           plotname << 
"hToT-run" << run + 1 << 
"-line" << line + 1 << 
"-dom" << dom + 1 << 
"-pmt" << pmt;
 
  382           vhToT[run][line][dom][pmt] = 
new TH1D(plotname.str().c_str(), plotname.str().c_str(), 301, -0.5, 300.5);
 
  392   JROOTClassSelector selector(
"JDAQTimesliceL1");
 
  395   for ( ; in.hasNext() && counter != vInputFiles.getLimit(); ++counter) {
 
  398     if (newRun != oldRun) {
 
  399       streamName = 
"pmt_hv_run_settings";
 
  401       AccessDB(vvvupi, vvvupiExt, vvvRunHv[runCounter], cookiesContent, username, streamName, detectorIdStr, newRun, hvDefault, lineIds);
 
  403       runList.push_back(newRun);
 
  406     for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
 
  407       const int domId = super_frame->getModuleID();
 
  408       const JModule module = moduleRouter.getModule(domId);
 
  409       const int lineIndex = module.getString() - 1; 
 
  410       const int domIndex = module.getFloor() - 1;
 
  412         const double hitToT = hit->getToT();
 
  413         const int pmtIndex = hit->getPMT();
 
  414         const int pmtId = module.getPMT(pmtIndex).getID();
 
  415         if (pmtId != vvvupi[lineIndex][domIndex][pmtIndex]) {
 
  416           DEBUG(
"mismatch between pmt id of detector file " << pmtId << 
" and the xml file " 
  417                 << vvvupi[lineIndex][domIndex][pmtIndex] << endl);
 
  420         vhToT[runCounter - 1][lineIndex][domIndex][pmtIndex]->Fill(hitToT);
 
  427   for (
unsigned int line = 0; line < lineNb; ++line) {
 
  428     for (
int dom = 0; dom < domNb; ++dom) {
 
  430       for (
int pmt = 0; pmt < pmtNb; ++pmt) {
 
  431         vgToTvsHV[line][dom][pmt] = 
new TGraphErrors();
 
  432         int localCounter = 0;
 
  433         for (
int run = 0; run < runNb; ++run) {
 
  434           if (vvvRunHv[run][line][dom][pmt] == 0) 
continue;
 
  435           FillGraph(vgToTvsHV[line][dom][pmt], vhToTReducedChi2[run], vhToT[run][line][dom][pmt], vvvRunHv[run][line][dom][pmt] - vvvHv[line][dom][pmt], localCounter);
 
  437         if ((localCounter < runNb) && (localCounter > 0))
 
  438           DEBUG(
"only " << localCounter << 
" runs out of " << runNb << 
" have ToT data for line " << line + 1 << 
" - dom " << dom + 1 << 
" - pmt " << pmt << endl);
 
  439         if (localCounter == 0) ++fullDom;
 
  442         DEBUG(fullDom << 
" pmt do not have data in dom " << dom + 1 << 
" of line " << line + 1 << endl);
 
  447   fstream outCalibXml(outXMLFile.c_str(), ofstream::out);
 
  448   struct timeval endTimeTv;
 
  449   gettimeofday(&endTimeTv, NULL);
 
  450   time_t endTime = (time_t)endTimeTv.tv_sec;
 
  451   tm* endGmTime = gmtime(&endTime);
 
  452   const string endUTCTime = asctime(endGmTime);
 
  454   ostringstream endTimeStr;
 
  455   endTimeStr << 1900 + endGmTime->tm_year << 
"-" << std::setw(2) << std::setfill(
'0') 
 
  456              << endGmTime->tm_mon + 1 << 
"-" << std::setw(2) << std::setfill(
'0')  
 
  457              << endGmTime->tm_mday << 
"T" << std::setw(2) << std::setfill(
'0') 
 
  458              << endGmTime->tm_hour << 
":" << std::setw(2) << std::setfill(
'0') 
 
  459              << endGmTime->tm_min << 
":" << std::setw(2) << std::setfill(
'0') 
 
  460              << endGmTime->tm_sec << 
"." << std::setw(6) << std::setfill(
'0') 
 
  461              << endTimeTv.tv_usec << 
"+01:00";
 
  462   ostringstream startTimeStr; 
 
  463   startTimeStr << 1900 + startGmTime->tm_year << 
"-" << std::setw(2) << std::setfill(
'0')
 
  464                << startGmTime->tm_mon + 1 << 
"-" << std::setw(2) << std::setfill(
'0')
 
  465                << startGmTime->tm_mday << 
"T" << std::setw(2) << std::setfill(
'0')
 
  466                << startGmTime->tm_hour << 
":" << std::setw(2) << std::setfill(
'0')
 
  467                << startGmTime->tm_min << 
":" << std::setw(2) << std::setfill(
'0')
 
  468                << startGmTime->tm_sec << 
"." << std::setw(6) << std::setfill(
'0')
 
  469                << startTimeTv.tv_usec << 
"+01:00";
 
  470   outCalibXml << 
"<ProductTestSession>\r\n";
 
  472   outCalibXml << 
"\t<User>" << username << 
"</User>\r\n";
 
  473   outCalibXml << 
"\t<Location>" << location << 
"</Location>\r\n";
 
  474   outCalibXml << 
"\t<StartTime>" << startTimeStr.str() << 
"</StartTime>\r\n";
 
  475   outCalibXml << 
"\t<EndTime>" << endTimeStr.str() << 
"</EndTime>\r\n";
 
  476   outCalibXml << 
"\t<TestType>" << testType << 
"</TestType>\r\n";
 
  477   outCalibXml << 
"\t<Tests>\r\n";
 
  478   TCanvas* cToTvsHV = 
new TCanvas(
"cToTvsHV", 
"cToTvsHV", 800, 600);
 
  479   TH1D* hToTvsHVReducedChi2 = 
new TH1D(
"hToTvsHVReducedChi2", 
"hToTvsHVReducedChi2", 101, -0.05, 10.05);
 
  480   TH1D* hToTExpected = 
new TH1D(
"hToTExpected", 
"hToTExpected", 100001, -0.0005, 100.0005);
 
  481   bool firstEvent = 
true;
 
  487   int counterLinear = 0;
 
  488   int counter2Order = 0;
 
  489   int counter2OrderPos = 0;
 
  490   int counter2OrderNeg = 0;
 
  492   double aveLinearSlope = 0;
 
  493   for (
unsigned int line = 0; line < lineNb; ++line) {
 
  494     for (
int dom = 0; dom < domNb; ++dom) {
 
  495       for (
int pmt = 0; pmt < pmtNb; ++pmt) {
 
  496         stringstream filename;
 
  499         filename << 
"ToTvsHV-line" << line + 1 << 
"-dom" << dom + 1 << 
"-pmt" << pmt;
 
  500         vgToTvsHV[line][dom][pmt]->SetName(filename.str().c_str());
 
  501         const int pointNb = vgToTvsHV[line][dom][pmt]->GetN();
 
  504           vgToTvsHV[line][dom][pmt]->SetLineColor(line*18 + dom*31 + pmt);
 
  505           vgToTvsHV[line][dom][pmt]->SetMarkerColor(line*18 + dom*31 + pmt);
 
  506           vgToTvsHV[line][dom][pmt]->SetMarkerStyle(2);
 
  507           vgToTvsHV[line][dom][pmt]->SetMarkerSize(1);
 
  508           if (firstEvent == 
true) {
 
  510             vgToTvsHV[line][dom][pmt]->SetTitle(
"");
 
  511             vgToTvsHV[line][dom][pmt]->GetXaxis()->SetTitle(
"HV_{offset}  [V]");
 
  512             vgToTvsHV[line][dom][pmt]->GetXaxis()->CenterTitle();
 
  513             vgToTvsHV[line][dom][pmt]->GetXaxis()->SetTitleOffset(1.2);
 
  514             vgToTvsHV[line][dom][pmt]->GetXaxis()->SetRangeUser(-200, +200);
 
  515             vgToTvsHV[line][dom][pmt]->GetYaxis()->SetTitle(
"ToT values  [ns]");
 
  516             vgToTvsHV[line][dom][pmt]->GetYaxis()->CenterTitle();
 
  517             vgToTvsHV[line][dom][pmt]->GetYaxis()->SetTitleOffset(1.2);
 
  518             vgToTvsHV[line][dom][pmt]->GetYaxis()->SetRangeUser(0, 80);
 
  519             vgToTvsHV[line][dom][pmt]->Draw(
"APL");
 
  521             vgToTvsHV[line][dom][pmt]->GetXaxis()->SetRangeUser(-200, +200);
 
  522             vgToTvsHV[line][dom][pmt]->Draw(
"samePL");
 
  526         string functionFormula = 
"";
 
  529           const string pol2Name = 
"pol2";
 
  532           const string pol1Name = 
"pol1";
 
  535           const string sqrtName = 
"[0] + sqrt([1] - [2]*x)";
 
  538           const double testChi2 = min({fabs(vParameterPol1[0] - 1), fabs(vParameterPol2[0] - 1), fabs(vParameterSqrt[0] - 1)});
 
  539           if (testChi2 == fabs(vParameterPol1[0] - 1)) {
 
  540             vParameter = vParameterPol1;
 
  541             functionFormula = pol1Name;
 
  542             aveLinearSlope += vParameterPol1[2];
 
  544           } 
else if (testChi2 == fabs(vParameterPol2[0] - 1)) {
 
  545             vParameter = vParameterPol2;
 
  546             functionFormula = pol2Name;
 
  548             if (vParameterPol2[3] > 0) ++counter2OrderPos;
 
  549             else ++counter2OrderNeg;
 
  550           } 
else if (testChi2 == fabs(vParameterSqrt[0] - 1)) {
 
  551             vParameter = vParameterSqrt;
 
  552             functionFormula = sqrtName;
 
  555             DEBUG(
"problem in the function definition, check the code at about line 500");
 
  557           vgToTvsHV[line][dom][pmt]->Fit(functionFormula.c_str(), 
"RQ");
 
  558           hToTvsHVReducedChi2->Fill(vParameter[0]);
 
  559           if (vParameter[0] > redChi2Max) 
DEBUG(
"ToTvsHV fit may be bad for pmt " << pmt << 
" of dom " << dom + 1 << 
" of line " << line + 1 << 
", the reduced chi square is " << vParameter[0] << endl);
 
  560           hvAndToTOpt = 
Solve(vParameter, functionFormula, tot);
 
  561           if ((hvAndToTOpt.first == -1) && (hvAndToTOpt.second == -1))
 
  562             DEBUG(
"function used for fitting " << functionFormula << 
" is not handled by the code. Change the code or use a predefined function such as pol1 or pol2" << endl);
 
  563           if ((fabs(vParameter[2]) > slopeMax) && ((functionFormula == 
"pol1") || (functionFormula == 
"pol2")))
 
  564             DEBUG(
"ToTvsHV fit may be bad for pmt " << pmt << 
" of dom " << dom + 1 << 
" of line " << line + 1 << 
", the slope at 0 is " << vParameter[2] << endl);
 
  565           hToTExpected->Fill(hvAndToTOpt.second);
 
  567         if (fabs(hvAndToTOpt.first) > diffHVMax) hvAndToTOpt.first = 0;
 
  568         vvvHvOpt[line][dom][pmt] = hvAndToTOpt.first;
 
  569         outCalibXml << 
"\t\t<ProductTest>\r\n";
 
  570         outCalibXml << 
"\t\t\t<UPI>3.4.2.3/HAMA-R12199/" << vvvupiExt[line][dom][pmt] << 
"." << vvvupi[line][dom][pmt] << 
"</UPI>\r\n";
 
  571         outCalibXml << 
"\t\t\t<TestResult>OK</TestResult>\r\n";
 
  572         outCalibXml << 
"\t\t\t<TestParameters>\r\n";
 
  573         outCalibXml << 
"\t\t\t\t<ProductTestParameter>\r\n";
 
  574         outCalibXml << 
"\t\t\t\t\t<Name>PMT_Supply_Voltage</Name>\r\n";
 
  575         outCalibXml << 
"\t\t\t\t\t<Values>\r\n";
 
  576         outCalibXml << 
"\t\t\t\t\t\t<string>" << hvAndToTOpt.first + vvvHv[line][dom][pmt] << 
"</string>\r\n";
 
  577         outCalibXml << 
"\t\t\t\t\t</Values>\r\n";
 
  578         outCalibXml << 
"\t\t\t\t</ProductTestParameter>\r\n";
 
  579         outCalibXml << 
"\t\t\t\t<ProductTestParameter>\r\n";
 
  580         outCalibXml << 
"\t\t\t\t\t<Name>RUN_NUMBER</Name>\r\n";
 
  581         outCalibXml << 
"\t\t\t\t\t<Values>\r\n";
 
  582         for (
int run = 0; run < runNb; ++run) {
 
  583           outCalibXml << 
"\t\t\t\t\t\t<string>" << runList[run] << 
"</string>\r\n";
 
  585         outCalibXml << 
"\t\t\t\t\t</Values>\r\n";
 
  586         outCalibXml << 
"\t\t\t\t</ProductTestParameter>\r\n";
 
  587         outCalibXml << 
"\t\t\t\t<ProductTestParameter>\r\n";
 
  588         outCalibXml << 
"\t\t\t\t\t<Name>PMT_Time_over_Threshold</Name>\r\n";
 
  589         outCalibXml << 
"\t\t\t\t\t<Values>\r\n";
 
  590         outCalibXml << 
"\t\t\t\t\t\t<string>" << tot*1e-9 << 
"</string>\r\n";
 
  591         outCalibXml << 
"\t\t\t\t\t</Values>\r\n";
 
  592         outCalibXml << 
"\t\t\t\t</ProductTestParameter>\r\n";
 
  593         outCalibXml << 
"\t\t\t</TestParameters>\r\n";
 
  594         outCalibXml << 
"\t\t</ProductTest>\r\n";
 
  598   cout << 
"linear:" << counterLinear << 
" - 2nd order (pos, neg):" << counter2Order 
 
  599        << 
"(" << counter2OrderPos << 
"," << counter2OrderNeg << 
")" 
  600        << 
" - sqrt:" << counterSqrt << 
" - linear slope average: "  
  601        << aveLinearSlope/counterLinear << endl;
 
  602   outCalibXml << 
"\t</Tests>\r\n";
 
  603   outCalibXml << 
"</ProductTestSession>\r\n";
 
  605   cToTvsHV->SaveAs(
"figs/cToTvsHV.png");
 
  606   cToTvsHV->SaveAs(
"figs/cToTvsHV.root");
 
  608   ostringstream osstxt;
 
  611   osstxt << 
"HVTuning-det" << detectorId << 
".txt";
 
  613   ofstream outHv(osstxt.str().c_str(), ofstream::out);
 
  614   for (
unsigned int line = 0; line < lineNb; ++line) {
 
  615     for (
int dom = 0; dom < domNb; ++dom) {
 
  616       for (
int pmt = 0; pmt < pmtNb; ++pmt) {
 
  617         outHv << line + 1 << 
' ' << dom + 1 << 
' ' << pmt << 
' ' << vvvupiExt[line][dom][pmt] << 
' ' << vvvupi[line][dom][pmt] << 
' ' << vvvHv[line][dom][pmt] << 
' ' << vvvHvOpt[line][dom][pmt] + vvvHv[line][dom][pmt] << endl;
 
  623   TCanvas* cToTs[lineNb][domNb];
 
  624   for (
unsigned int line = 0; line < lineNb; ++line) {
 
  625     for (
int dom = 0; dom < domNb; ++dom) {
 
  629       iss << 
"cToTs-line" << line + 1 << 
"-dom" << dom + 1; 
 
  630       cToTs[line][dom] = 
new TCanvas(iss.str().c_str(), iss.str().c_str(), 800, 600);
 
  631       cToTs[line][dom]->Divide(8,4);
 
  632       for (
int pmt = 0; pmt < pmtNb; ++pmt) {
 
  633         cToTs[line][dom]->cd(pmt + 1);
 
  635         for (
int run = 0; run < runNb; ++run) { 
 
  636           vhToT[run][line][dom][pmt]->SetLineColor(run + 1);
 
  637           if (vhToT[run][line][dom][pmt]->GetMaximum() > localMax) localMax = vhToT[run][line][dom][pmt]->GetMaximum();
 
  639             vhToT[run][line][dom][pmt]->SetTitle(
"");
 
  640             vhToT[run][line][dom][pmt]->SetStats(0);
 
  641             vhToT[run][line][dom][pmt]->GetXaxis()->SetTitle(
"ToT values  [ns]");
 
  642             vhToT[run][line][dom][pmt]->GetXaxis()->CenterTitle();
 
  643             vhToT[run][line][dom][pmt]->GetXaxis()->SetTitleOffset(1.2);
 
  644             vhToT[run][line][dom][pmt]->GetXaxis()->SetRange(0, 100);
 
  645             vhToT[run][line][dom][pmt]->Draw();
 
  647             vhToT[run][line][dom][pmt]->Draw(
"same");      
 
  651         vhToT[0][line][dom][pmt]->GetYaxis()->SetRangeUser(0.1, 2*localMax);
 
  655       iss << 
"figs/cToTs-line" << line + 1 << 
"-dom" << dom + 1 << 
".png"; 
 
  656       cToTs[line][dom]->SaveAs(iss.str().c_str());
 
  659       iss << 
"figs/cToTs-line" << line + 1 << 
"-dom" << dom + 1 << 
".root";  
 
  660       cToTs[line][dom]->SaveAs(iss.str().c_str());
 
  664   TCanvas* cToTReducedChi2 = 
new TCanvas(
"cToTReducedChi2", 
"cToTReducedChi2", 800, 600);
 
  665   for (
int run = 0; run < runNb; ++run) {
 
  667       vhToTReducedChi2[run]->SetTitle(
"");
 
  668       vhToTReducedChi2[run]->SetStats(0);
 
  669       vhToTReducedChi2[run]->GetXaxis()->SetTitle(
"reduced #chi^{2}");
 
  670       vhToTReducedChi2[run]->GetXaxis()->CenterTitle();
 
  671       vhToTReducedChi2[run]->GetXaxis()->SetTitleOffset(1.2);
 
  672       vhToTReducedChi2[run]->Draw();
 
  674       vhToTReducedChi2[run]->Draw(
"same");
 
  676     vhToTReducedChi2[run]->SetLineColor(run + 1);
 
  678   cToTReducedChi2->SetLogy();
 
  679   cToTReducedChi2->SaveAs(
"figs/cToT-ReducedChi2.png");
 
  680   cToTReducedChi2->SaveAs(
"figs/cToT-ReducedChi2.root");
 
  682   TCanvas* cToTvsHVReducedChi2 = 
new TCanvas(
"cToTvsHVReducedChi2", 
"cToTvsHVReducedChi2", 800, 600);
 
  683   hToTvsHVReducedChi2->SetTitle(
"");
 
  684   hToTvsHVReducedChi2->SetStats(0);
 
  685   hToTvsHVReducedChi2->GetXaxis()->SetTitle(
"reduced #chi^{2}");
 
  686   hToTvsHVReducedChi2->GetXaxis()->CenterTitle();
 
  687   hToTvsHVReducedChi2->GetXaxis()->SetTitleOffset(1.2);
 
  688   hToTvsHVReducedChi2->Draw();
 
  689   cToTvsHVReducedChi2->SetLogy();
 
  690   cToTvsHVReducedChi2->SaveAs(
"figs/cToTvsHV-ReducedChi2.png");
 
  691   cToTvsHVReducedChi2->SaveAs(
"figs/cToTvsHV-ReducedChi2.root");
 
  693   TCanvas* cToTExpected = 
new TCanvas(
"cToTExpected", 
"cToTExpected", 800, 600);
 
  694   hToTExpected->SetTitle(
"");
 
  695   hToTExpected->SetStats(0);
 
  696   hToTExpected->GetXaxis()->SetTitle(
"Expected ToT value  [ns]");
 
  697   hToTExpected->GetXaxis()->CenterTitle();
 
  698   hToTExpected->GetXaxis()->SetTitleOffset(1.2);
 
  699   hToTExpected->Draw();
 
  701   cToTExpected->SaveAs(
"figs/cToTExpected.png");
 
  702   cToTExpected->SaveAs(
"figs/cToTExpected.root");
 
  704   const int lineId1 = 0;
 
  705   const int domId1 = 2;
 
  706   const int pmtId1 = 5;
 
  707   const int lineId2 = 0;
 
  708   const int domId2 = 5;
 
  709   const int pmtId2 = 7;
 
  710   ostringstream issTemp;
 
  711   issTemp << 
"cToTsdom" << domId1 + 1 << 
"pmt" << pmtId1;
 
  712   TCanvas* cToTsdomxpmtx = 
new TCanvas(issTemp.str().c_str(), issTemp.str().c_str(), 800, 600);
 
  714   TLegend* leg1 = 
new TLegend(0.70,0.55,0.90,0.90);
 
  715   leg1->SetFillStyle(0);
 
  716   double localMaxTemp = 0;
 
  717   if ((lineId1 > lineNb - 1) || (domId1 > domNb - 1) || (pmtId1 > pmtNb - 1))
 
  719   if (pmtTest == 
false) {
 
  720     DEBUG(
"wrong PMT1 identification for sample plot");
 
  722     ostringstream plotname0;
 
  723     for (
int run = 0; run < runNb; ++run) {
 
  724       vhToT[run][lineId1][domId1][pmtId1]->SetLineColor(run + 1);
 
  725       if (vhToT[run][lineId1][domId1][pmtId1]->GetMaximum() > localMaxTemp) localMaxTemp = vhToT[run][lineId1][domId1][pmtId1]->GetMaximum();
 
  727         vhToT[run][lineId1][domId1][pmtId1]->SetTitle(
"");
 
  728         vhToT[run][lineId1][domId1][pmtId1]->SetStats(0);
 
  729         vhToT[run][lineId1][domId1][pmtId1]->GetXaxis()->SetTitle(
"ToT values  [ns]");
 
  730         vhToT[run][lineId1][domId1][pmtId1]->GetXaxis()->CenterTitle();
 
  731         vhToT[run][lineId1][domId1][pmtId1]->GetXaxis()->SetTitleOffset(1.2);
 
  732         vhToT[run][lineId1][domId1][pmtId1]->GetXaxis()->SetRange(0, 100);
 
  733         vhToT[run][lineId1][domId1][pmtId1]->Draw();
 
  735         vhToT[run][lineId1][domId1][pmtId1]->Draw(
"same");
 
  739       plotname0 << 
"HV: " << setprecision(2) << fixed
 
  740                 << vvvRunHv[run][lineId1][domId1][pmtId1] << 
"V";
 
  741       leg1->AddEntry(vhToT[run][lineId1][domId1][pmtId1], plotname0.str().c_str(), 
"l");
 
  744     vhToT[0][lineId1][domId1][pmtId1]->GetYaxis()->SetRangeUser(0.1, 2*localMaxTemp);
 
  748     issTemp << 
"figs/cToTs-line" << lineId1 + 1 << 
"-dom" << domId1 + 1 << 
"-pmt" << pmtId1 << 
".png";
 
  749     cToTsdomxpmtx->SaveAs(issTemp.str().c_str());
 
  752     issTemp << 
"figs/cToTs-line" << lineId1 + 1 << 
"-dom" << domId1 + 1 << 
"-pmt" << pmtId1 << 
".root";
 
  753     cToTsdomxpmtx->SaveAs(issTemp.str().c_str());
 
  758   issTemp << 
"cToTsdom" << domId2 + 1 << 
"pmt" << pmtId2;
 
  759   TCanvas* cToTsdomxpmty = 
new TCanvas(issTemp.str().c_str(), issTemp.str().c_str(), 800, 600);
 
  761   TLegend* leg2 = 
new TLegend(0.70,0.55,0.90,0.90);
 
  762   if ((lineId2 > lineNb - 1) || (domId2 > domNb - 1) || (pmtId2 > pmtNb - 1))
 
  764   if (pmtTest == 
false) {
 
  765     DEBUG(
"wrong PMT2 identification for sample plot");
 
  767     ostringstream plotname0;
 
  768     for (
int run = 0; run < runNb; ++run) {
 
  769       vhToT[run][lineId2][domId2][pmtId2]->SetLineColor(run + 1);
 
  770       if (vhToT[run][lineId2][domId2][pmtId2]->GetMaximum() > localMaxTemp) localMaxTemp = vhToT[run][lineId2][domId2][pmtId2]->GetMaximum();
 
  772         vhToT[run][lineId2][domId2][pmtId2]->SetTitle(
"");
 
  773         vhToT[run][lineId2][domId2][pmtId2]->SetStats(0);
 
  774         vhToT[run][lineId2][domId2][pmtId2]->GetXaxis()->SetTitle(
"ToT values  [ns]");
 
  775         vhToT[run][lineId2][domId2][pmtId2]->GetXaxis()->CenterTitle();
 
  776         vhToT[run][lineId2][domId2][pmtId2]->GetXaxis()->SetTitleOffset(1.2);
 
  777         vhToT[run][lineId2][domId2][pmtId2]->GetXaxis()->SetRange(0, 100);
 
  778         vhToT[run][lineId2][domId2][pmtId2]->Draw();
 
  780         vhToT[run][lineId2][domId2][pmtId2]->Draw(
"same");
 
  784       plotname0 << 
"HV: " << setprecision(2) << fixed
 
  785                 << vvvRunHv[run][lineId2][domId2][pmtId2] << 
"V";
 
  786       leg2->AddEntry(vhToT[run][lineId2][domId2][pmtId2], plotname0.str().c_str(), 
"l");
 
  789     vhToT[0][lineId2][domId2][pmtId2]->GetYaxis()->SetRangeUser(0.1, 2*localMaxTemp);
 
  793     issTemp << 
"figs/cToTs-line" << lineId2 + 1 << 
"-dom" << domId2 + 1 << 
"-pmt" << pmtId2 << 
".png";
 
  794     cToTsdomxpmty->SaveAs(issTemp.str().c_str());
 
  797     issTemp << 
"figs/cToTs-line" << lineId2 + 1 << 
"-dom" << domId2 + 1 << 
"-pmt" << pmtId2 << 
".root";
 
  798     cToTsdomxpmty->SaveAs(issTemp.str().c_str());
 
  801   DEBUG(
"analysis duration: " << difftime(endTime, startTime) << endl);
 
void AccessDB(std::vector< std::vector< std::vector< int > > > &vvvupi, std::vector< std::vector< std::vector< int > > > &vvvupiExt, std::vector< std::vector< std::vector< double > > > &vvvHv, std::string &cookie, std::string &username, std::string &streamName, std::string &detectorId, const int runId, const std::string &hvDefault, std::vector< int > &lineIds)
 
Utility class to parse command line options. 
 
void FillParameterFitFunction(std::vector< double > &vParameter, TGraphErrors *&localGraph, const std::string &curFunction, const std::string &curOptions, const std::pair< double, double > range)
 
void FindHVRange(std::vector< std::vector< std::vector< std::pair< double, double > > > > &vvvHvRange, std::vector< std::vector< std::vector< std::vector< double > > > > &vvvRunHv, std::vector< std::vector< std::vector< double > > > &vvvHv)
 
Long64_t counter_type
Type definition for counter. 
 
Auxiliary class for multiplexing object iterators. 
 
int getRunNumber() const 
Get run number. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line. 
 
void load(const JString &file_name, JDetector &detector)
Load detector from input file. 
 
std::pair< double, double > Solve(std::vector< double > &vParameter, const std::string &curFunction, const double tot)
 
void FillGraph(TGraphErrors *&graph, TH1D *&hChi2, TH1D *&histo, const double hv, int &localCounter)
 
static const int NUMBER_OF_PMTS
Total number of PMTs in module. 
 
#define DEBUG(A)
Message macros.