9 #include "boost/program_options/options_description.hpp"    10 #include "boost/program_options/variables_map.hpp"    11 #include "boost/program_options/parsers.hpp"    14 #include "leveldb/db.h"    18 #pragma GCC diagnostic push    19 #pragma GCC diagnostic ignored "-Wsign-compare"    21 #pragma GCC diagnostic pop    29 namespace po = boost::program_options;
    35   po::options_description 
desc(
"Allowed options");
    37   (
"help", 
"produce help message")
    38   (
"dir,d", po::value<std::string>(&dir)->required(),
    44     po::store(po::parse_command_line(argc, argv, desc), vm);
    50     std::cout  << 
"ERROR: " << e.what() << 
std::endl;
    55   if (vm.count(
"help")) {
    56     std::cout << desc << 
"\n";
    69   po::variables_map vm = 
getOptions(argc, argv, directory);
    73   leveldb::Status 
status = leveldb::DB::Open(options, directory, &db);
    75   if (!status.ok()) 
return 1;
    79   TH1D* hLabels = 
new TH1D(
"hLabels", 
";Event Type", 15, 0, 15);
    80   TH1D* hPE = 
new TH1D(
"hPE", 
"Scaled PE", 256, 0, 256);
    88   leveldb::Iterator* itCount = db->NewIterator(leveldb::ReadOptions());
    89   for (itCount->SeekToFirst(); itCount->Valid(); itCount->Next())
    93   std::cout << 
"total: " << total << 
std::endl;
    96   leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
    97   for (it->SeekToFirst(); it->Valid(); it->Next())
   101       datum.ParseFromString( it->value().ToString() );
   103       int height   = datum.height();
   104       int width    = datum.width();
   105       int label    = datum.label();
   112       const char* 
pixels = datum.data().data();
   113       for (
int iX = 0; iX < channels*height*width; ++iX)
   115         hPE->Fill( (uint8_t)pixels[iX] );
   116         hLabels->Fill(label);
   120         outFile << 
"key " << it->key().ToString() << 
endl;
   121         outFile << 
"count " << count << 
endl;
   122         outFile << 
"label " << label << 
endl;
   124         TString hName = 
"PixelMap_";
   129         TH2D* xMap = 
new TH2D(hName + TString(
"_X"), 
";Wire;TDC",
   130          height, 0, height, width, 0, width);
   131         XVec.push_back(xMap);
   132         TH2D* yMap = 
new TH2D(hName + TString(
"_Y"), 
";Wire;TDC",
   133          height, 0, height, width, 0, width);
   134         YVec.push_back(yMap);
   135         TH2D* zMap = 
new TH2D(hName + TString(
"_Z"), 
";Wire;TDC",
   136          height, 0, height, width, 0, width);
   137         ZVec.push_back(zMap);
   139         for (
int iPix = 0; iPix < channels*height*width; ++iPix)
   141           int iCell = iPix%width;
   142           int iPlane = (iPix/width)%height;
   143           int iChan =  (iPix/width)/height;
   144           int pixVal = (uint8_t)pixels[iPix];
   147               xMap->SetBinContent(iPlane+1, iCell+1, pixVal);
   151               yMap->SetBinContent(iPlane+1, iCell+1, pixVal);
   155               zMap->SetBinContent(iPlane+1, iCell+1, pixVal);
   162               outFile << 
"X " << iCell << 
"  " << iPlane << 
endl;
   166                   outFile << 
"Y " << iCell << 
"  " << iPlane << 
endl;
   170                   outFile << 
"Z " << iCell << 
"  " << iPlane << 
endl;
   172             outFile << 
"[" << pixVal << 
"]" << 
endl;
   184   TFile* 
fOut = 
new TFile(
"test.root", 
"recreate");
   185   fOut->WriteTObject(hPE);
   186   fOut->WriteTObject(hLabels);
   188   for (
size_t i = 0; i < XVec.size(); ++i)
   190     TString cName = 
"cPixelMap_";
   192     TCanvas* canv = 
new TCanvas(cName, cName);
   195     std::cout<<XVec[i]->Integral()<<
std::endl;
   196     XVec[i]->Draw(
"colz");
   198     std::cout<<YVec[i]->Integral()<<
std::endl;
   199     YVec[i]->Draw(
"colz");
   201     std::cout<<ZVec[i]->Integral()<<
std::endl;
   202     ZVec[i]->Draw(
"colz");
   203     fOut->WriteTObject(canv);
 
int main(int argc, char *argv[])
 
po::variables_map getOptions(int argc, char *argv[], std::string &dir)
 
QTextStream & endl(QTextStream &s)