FACT++  1.0
void FitsDumper::DumpStats ( ostream &  fout,
const vector< MyColumn > &  cols,
const string &  ,
size_t  first,
size_t  limit 
)
private

Definition at line 849 of file fitsdump.cc.

References counter, data, GetDouble(), zfits::GetNumRows(), fits::GetRow(), and i.

Referenced by displayStats(), and Exec().

851 {
852 #ifdef HAVE_ROOT
853  TFormula select;
854  if (!filter.empty() && select.Compile(filter.c_str()))
855  throw runtime_error("Syntax Error: TFormula::Compile failed for '"+filter+"'");
856 #endif
857 
858  // Loop over all columns in our list of requested columns
859  vector<vector<char>> statData;
860 
861  const size_t rows = limit==0 || GetNumRows()<limit ? GetNumRows() : limit;
862 
863  for (auto it=cols.begin(); it!=cols.end(); it++)
864  statData.emplace_back(vector<char>(it->col.size*rows*(it->last-it->first+1)));
865 
866 #ifdef HAVE_ROOT
867  size_t num = 0;
868  for (auto it=cols.begin(); it!=cols.end(); it++)
869  num += it->last-it->first+1;
870 
871  vector<Double_t> data(num+1);
872 #endif
873 
874  // Loop over all columns in our list of requested columns
875  const size_t last = limit ? first + limit : size_t(-1);
876 
877  uint64_t counter = 0;
878 
879  while (GetRow(first++))
880  {
881  const size_t row = GetRow();
882  if (row==GetNumRows() || row==last)
883  break;
884 
885 #ifdef HAVE_ROOT
886  if (!filter.empty())
887  {
888  size_t p = 0;
889 
890  data[p++] = first-1;
891 
892  for (auto it=cols.begin(); it!=cols.end(); it++)
893  for (uint32_t i=it->first; i<=it->last; i++, p++)
894  data[p] = GetDouble(*it, i);
895 
896  if (select.EvalPar(0, data.data())<0.5)
897  continue;
898  }
899 #endif
900 
901  auto statsIt = statData.begin();
902  for (auto it=cols.begin(); it!=cols.end(); it++, statsIt++)
903  {
904  const char *src = reinterpret_cast<const char*>(it->ptr);
905  const size_t sz = (it->last-it->first+1)*it->col.size;
906  memcpy(statsIt->data()+counter*sz, src+it->first*it->col.size, sz);
907  }
908 
909  counter++;
910  }
911 
912  auto statsIt = statData.begin();
913  for (auto it=cols.begin(); it!=cols.end(); it++, statsIt++)
914  {
915  fout << "\n[" << it->name << ':' << it->first;
916  if (it->last!=it->first)
917  fout << ':' << it->last;
918  fout << "]\n";
919 
920  const size_t sz = (it->last-it->first+1)*it->col.size;
921  statsIt->resize(counter*sz);
922 
923  switch (it->col.type)
924  {
925  case 'L':
926  displayStats<bool>(*statsIt, fout);
927  break;
928  case 'B':
929  displayStats<char>(*statsIt, fout);
930  break;
931  case 'I':
932  displayStats<int16_t>(*statsIt, fout);
933  break;
934  case 'J':
935  displayStats<int32_t>(*statsIt, fout);
936  break;
937  case 'K':
938  displayStats<int64_t>(*statsIt, fout);
939  break;
940  case 'E':
941  displayStats<float>(*statsIt, fout);
942  break;
943  case 'D':
944  displayStats<double>(*statsIt, fout);
945  break;
946  default:
947  ;
948  }
949  }
950 }
int i
Definition: db_dim_client.c:21
size_t GetNumRows() const
Definition: zfits.h:57
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
size_t GetRow() const
Definition: fits.h:1019
float data[4 *1440]
int counter
Definition: db_dim_client.c:19
double GetDouble(const MyColumn &, size_t) const
Definition: fitsdump.cc:275

+ Here is the call graph for this function:

+ Here is the caller graph for this function: