]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
tool for checking rising and trailing edges
authorhadaq <M.Traxler@gsi.de>
Mon, 28 Aug 2017 15:54:52 +0000 (17:54 +0200)
committerhadaq <M.Traxler@gsi.de>
Mon, 28 Aug 2017 15:54:52 +0000 (17:54 +0200)
users/gsi_dirc/check_tot.cc [new file with mode: 0644]

diff --git a/users/gsi_dirc/check_tot.cc b/users/gsi_dirc/check_tot.cc
new file mode 100644 (file)
index 0000000..32b1f9e
--- /dev/null
@@ -0,0 +1,110 @@
+#include <cstdlib>
+#include <string>
+using std::string;
+
+
+#include <iostream>
+using std::cout;
+using std::cerr;
+using std::cin;
+using std::endl;
+#include <iomanip>
+using std::hex;
+using std::dec;
+using std::oct;
+
+#include <fstream>
+using std::fstream;
+
+#include <cmath>
+
+#include <sstream>
+using std::stringstream;
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+
+int main(int argc, char* argv[]) 
+{
+
+
+  
+  fstream infile;
+  infile.open("check_tot.dat",std::ios::in);
+
+  int good=0,bad=0,good_sum=0,bad_sum=0;
+  for (int i=0; i<30; i++)
+    {
+
+      if (i<=15 || i>=20)
+        {
+          infile>>bad;
+          infile>>good;
+          
+          bad_sum+=bad;
+          good_sum+=good;
+          //cout<<bad<<" "<<good<<endl;
+          if (bad+good!=0)
+            {
+             cout<<" TDC "<<hex<<i+8192<<"  bad: ";
+             if(float(bad)/(bad+good)*100>=2.0)
+               {
+
+                 cout<<"\033[1;31m";
+                 cout.precision(1);
+                 cout.fill (' ');
+                 cout.width(5);
+                 cout<<dec<<std::fixed<<std::right
+                     <<float(bad)/(bad+good)*100<<" % "<<endl;
+                 cout<<"\033[0m";
+               }
+             else
+               {
+                 cout<<"\033[1;32m";
+                 cout.precision(1);
+                 cout.fill (' ');
+                 cout.width(5);
+                 cout<<dec<<std::fixed<<std::right
+                     <<float(bad)/(bad+good)*100<<" % "<<endl;
+                 cout<<"\033[0m";
+               }
+            }
+          else
+            {
+              cout<<" TDC "<<hex<<i+8192<<"  no edges in TDC"
+                  <<endl;
+            }
+        }
+
+    }
+  cout<<endl<<endl<<endl;
+  
+  if (bad_sum+good_sum!=0)
+    {
+      cout<<" ALL   bad: ";
+      if (float(bad_sum)/(bad_sum+good_sum)*100>=2.0)
+        {
+          cout<<"\033[1;31m";
+        }
+      else
+        {
+          cout<<"\033[1;32m";
+        }
+        
+      cout.precision(1);
+      cout.fill (' ');
+      cout.width(5);
+      cout<<std::fixed<<std::right
+          <<float(bad_sum)/(bad_sum+good_sum)*100<<" % "<<endl;
+                 cout<<"\033[0m";
+    }
+  else
+    {
+          cout<<" ALL "<<"  no edges in TDCs"<<endl;
+      
+    }
+      infile.close();
+      exit(0);
+}