Namespaces | Classes | Enumerations | Functions | Variables
evd Namespace Reference

LArSoft includes. More...

Namespaces

 details
 

Classes

class  AnalysisBaseDrawer
 Aid in the rendering of AnalysisBase objects. More...
 
class  AnalysisDrawingOptions
 
class  CalorPad
 A drawing pad showing calorimetric particle ID information. More...
 
class  CalorView
 View showing calorimetric particle ID information. More...
 
class  ColorDrawingOptions
 
class  Display3DPad
 A drawing pad showing a 3D rendering of the detector. More...
 
class  Display3DView
 View of event shoing the XZ and YZ readout planes. More...
 
class  DrawingPad
 Base class for event display drawing pads. More...
 
class  EVD
 a class for transporting photons in a roughly realistic way More...
 
class  EvdLayoutOptions
 
class  GraphCluster
 
class  GraphClusterAlg
 
class  HeaderDrawer
 
class  HeaderPad
 
class  HitSelector
 
class  ILazy
 
class  InfoTransfer
 
class  InputSeeker
 This is obviously a hack, but it's modeled on what EventDisplayBase does. More...
 
class  JSONFormatter
 
class  LazyDigits
 
class  LazyWires
 
class  MCBriefPad
 
class  Ortho3DPad
 A drawing pad showing an orthographic rendering of 3D objects. More...
 
class  Ortho3DView
 View of event shoing orthographic view of 3D objects. More...
 
class  PNGArena
 
class  PNGView
 
class  RawDataDrawer
 Aid in the rendering of RawData objects. More...
 
class  RawDrawingOptions
 Display parameters for the raw data. More...
 
class  RecoBaseDrawer
 Aid in the rendering of RecoBase objects. More...
 
class  RecoDrawingOptions
 
struct  Result
 
class  SimulationDrawer
 
class  SimulationDrawingOptions
 
class  Style
 
class  ThreadsafeGalleryEvent
 
class  TQPad
 
class  TWireProjPad
 A drawing pad for time vs wire. More...
 
class  TWQMultiTPCProjectionView
 
class  TWQProjectionView
 
class  WebEVD
 
class  WebEVDServer
 
struct  ZoomOptions
 
class  ZoomOptionsMultiTPC
 

Enumerations

enum  OrthoProj_t { kNoProj, kXY, kXZ, kYZ }
 
enum  EResult {
  kNEXT, kPREV, kQUIT, kERROR,
  kSEEK
}
 

Functions

void webevd_png_write_fn (png_struct_def *png_ptr, png_byte *buffer, long unsigned int nbytes)
 
void webevd_png_flush_fn (png_struct_def *png_ptr)
 
void AnalyzeArena (const PNGArena &bytes)
 
static constexpr int MipMapOffset (int dim, int maxdim)
 
std::string LatexName (int pdgcode)
 Convert PDG code to a latex string (root-style) More...
 
std::string sup (const std::string &a, const std::string &b)
 
std::string sub (const std::string &a, const std::string &b)
 
std::string bar (const std::string &x)
 
std::string nucl (const std::string &A, const std::string &elem)
 
std::string HTMLName (int pdgcode)
 HTML entities style. More...
 
std::string ShortInteractionSuffix (int iType)
 
std::string MCTruthShortText (const simb::MCTruth &truth)
 
short swap_byte_order (short x)
 
void write_ok200 (int sock, const std::string content="text/html", bool gzip=false)
 
void write_notfound404 (int sock)
 
void write_unimp501 (int sock)
 
std::string read_all (int sock)
 
EResult err (const char *call)
 
Result HandleCommand (std::string cmd, int sock)
 
std::string FindWebDir ()
 
void _HandleGetPNG (std::string doc, int sock, ILazy *digs, ILazy *wires)
 
void gzip_buffer (unsigned char *src, int length, std::vector< unsigned char > &dest, int level)
 
void write_compressed_buffer (unsigned char *src, int length, int sock, int level, const std::string &name)
 
void write_compressed_file (const std::string &loc, int fd_out, int level)
 
bool endswith (const std::string &s, const std::string &suffix)
 
JSONFormatteroperator<< (JSONFormatter &json, const art::InputTag &t)
 
JSONFormatteroperator<< (JSONFormatter &json, const geo::OpDetID &id)
 
JSONFormatteroperator<< (JSONFormatter &json, const geo::PlaneID &plane)
 
JSONFormatteroperator<< (JSONFormatter &json, const recob::Hit &hit)
 
JSONFormatteroperator<< (JSONFormatter &json, const recob::Vertex &vtx)
 
JSONFormatteroperator<< (JSONFormatter &json, const simb::MCTruth &mct)
 
JSONFormatteroperator<< (JSONFormatter &json, const recob::SpacePoint &sp)
 
JSONFormatteroperator<< (JSONFormatter &json, const recob::Track &track)
 
JSONFormatteroperator<< (JSONFormatter &json, const simb::MCParticle &part)
 
JSONFormatteroperator<< (JSONFormatter &json, const recob::OpFlash &flash)
 
JSONFormatteroperator<< (JSONFormatter &json, const geo::CryostatGeo &cryo)
 
JSONFormatteroperator<< (JSONFormatter &json, const geo::OpDetGeo &opdet)
 
JSONFormatteroperator<< (JSONFormatter &os, const PNGView &v)
 
template<class TProd , class TEvt >
void SerializeProduct (const TEvt &evt, JSONFormatter &json)
 
template<class TProd , class TEvt >
void SerializeProductByLabel (const TEvt &evt, const std::string &in_label, JSONFormatter &json)
 
template<class T >
void SerializeEventID (const T &evt, JSONFormatter &json)
 
void SerializeEventID (const ThreadsafeGalleryEvent &evt, JSONFormatter &json)
 
void SerializePlanes (const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData &detprop, JSONFormatter &json)
 
void SerializeGeometry (const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData &detprop, JSONFormatter &json)
 
template<class T >
void SerializeHits (const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
 
template<class T >
std::map< int, std::vector< T > > ToSnippets (const std::vector< T > &adcs, T pedestal=0)
 
template<class T >
void SerializeDigitTraces (const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
 
template<class T >
void SerializeWireTraces (const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
 
template<class T >
void _HandleGetJSON (std::string doc, int sock, const T *evt, const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData *detprop, ILazy *digs, ILazy *wires)
 
template<class T >
void _HandleGet (std::string doc, int sock, const T *evt, ILazy *digs, ILazy *wires, const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData *detprop)
 

Variables

HitSelectorgTheHitSelector
 
static const int kNCOLS = 14
 
static const int kColor [kNCOLS]
 
static const int kColor2 [kNCOLS]
 
static const int kRAW = 0
 
static const int kCALIB = 1
 
static const int kQ = 0
 
static const int kTQ = 1
 
static unsigned int kPlane
 
static unsigned int kWire
 
static double kDistance
 
static int curr_zooming_plane
 
static const char * zoom_opt = 0
 
static int shift_lock
 
static unsigned int kPlane
 
static unsigned int kWire
 
static double kDistance
 
static int curr_zooming_plane
 
static const char * zoom_opt = 0
 
static int shift_lock
 

Detailed Description

LArSoft includes.

Class to perform operations needed to select hits and pass them to InfoTransfer.

Event display classes.

The Event Display.

Author
messi.nosp@m.er@i.nosp@m.ndian.nosp@m.a.ed.nosp@m.u

Enumeration Type Documentation

Enumerator
kNEXT 
kPREV 
kQUIT 
kERROR 
kSEEK 

Definition at line 17 of file WebEVDServer.h.

Enumerator
kNoProj 
kXY 
kXZ 
kYZ 

Definition at line 12 of file OrthoProj.h.

Function Documentation

template<class T >
void evd::_HandleGet ( std::string  doc,
int  sock,
const T *  evt,
ILazy digs,
ILazy wires,
const geo::GeometryCore geom,
const detinfo::DetectorPropertiesData detprop 
)

Definition at line 774 of file WebEVDServer.cxx.

775 {
776  if(doc == "/") doc = "/index.html";
777 
778  if(endswith(doc, ".png")){
779  _HandleGetPNG(doc, sock, digs, wires);
780  return;
781  }
782 
783  if(endswith(doc, ".json")){
784  _HandleGetJSON(doc, sock, evt, geom, detprop, digs, wires);
785  return;
786  }
787 
788  // TODO - more sophisticated MIME type handling
789  std::string mime = "text/html";
790  if(endswith(doc, ".js" )) mime = "application/javascript";
791  if(endswith(doc, ".css")) mime = "text/css";
792  if(endswith(doc, ".ico")) mime = "image/vnd.microsoft.icon";
793 
794  // Otherwise it must be a physical file
795 
796  // Don't accidentally serve any file we shouldn't
797  const std::set<std::string> whitelist = {"/evd.css", "/evd.js", "/traces.js", "/favicon.ico", "/index.html", "/traces.html"};
798 
799  if(whitelist.count(doc)){
800  write_ok200(sock, mime, true);
801  write_compressed_file(FindWebDir()+doc, sock, Z_DEFAULT_COMPRESSION);
802  }
803  else{
804  write_notfound404(sock);
805  }
806 
807  close(sock);
808 }
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
std::string FindWebDir()
std::string string
Definition: nybbler.cc:12
void write_compressed_file(const std::string &loc, int fd_out, int level)
bool endswith(const std::string &s, const std::string &suffix)
int close(int)
Closes the file descriptor fd.
void _HandleGetPNG(std::string doc, int sock, ILazy *digs, ILazy *wires)
void _HandleGetJSON(std::string doc, int sock, const T *evt, const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData *detprop, ILazy *digs, ILazy *wires)
void write_notfound404(int sock)
QCString doc
TCEvent evt
Definition: DataStructs.cxx:7
template<class T >
void evd::_HandleGetJSON ( std::string  doc,
int  sock,
const T *  evt,
const geo::GeometryCore geom,
const detinfo::DetectorPropertiesData detprop,
ILazy digs,
ILazy wires 
)

Definition at line 741 of file WebEVDServer.cxx.

742 {
743  const std::string mime = "application/json";
744 
745  std::stringstream ss;
746  JSONFormatter json(ss);
747 
748  /***/if(doc == "/evtid.json") SerializeEventID(*evt, json);
749  else if(doc == "/tracks.json") SerializeProduct<recob::Track>(*evt, json);
750  else if(doc == "/spacepoints.json") SerializeProduct<recob::SpacePoint>(*evt, json);
751  else if(doc == "/vtxs.json") SerializeProduct<recob::Vertex>(*evt, json);
752  else if(doc == "/trajs.json") SerializeProductByLabel<simb::MCParticle>(*evt, "largeant", json);
753  else if(doc == "/mctruth.json") SerializeProduct<simb::MCTruth>(*evt, json);
754  else if(doc == "/opflashes.json") SerializeProduct<recob::OpFlash>(*evt, json);
755  else if(doc == "/hits.json") SerializeHits(*evt, geom, json);
756  else if(doc == "/geom.json") SerializeGeometry(geom, *detprop, json);
757  else if(doc == "/digs.json") digs->Serialize(json);
758  else if(doc == "/wires.json") wires->Serialize(json);
759  else if(doc == "/dig_traces.json") SerializeDigitTraces(*evt, geom, json);
760  else if(doc == "/wire_traces.json") SerializeWireTraces(*evt, geom, json);
761  else{
762  write_notfound404(sock);
763  close(sock);
764  return;
765  }
766 
767  std::string response = ss.str();
768  write_ok200(sock, mime, true);
769  write_compressed_buffer((unsigned char*)response.data(), response.size(), sock, Z_DEFAULT_COMPRESSION, doc);
770  close(sock);
771 }
void SerializeDigitTraces(const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
void SerializeEventID(const ThreadsafeGalleryEvent &evt, JSONFormatter &json)
std::string string
Definition: nybbler.cc:12
int close(int)
Closes the file descriptor fd.
void write_compressed_buffer(unsigned char *src, int length, int sock, int level, const std::string &name)
void SerializeGeometry(const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData &detprop, JSONFormatter &json)
void write_notfound404(int sock)
QCString doc
void SerializeWireTraces(const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
TCEvent evt
Definition: DataStructs.cxx:7
void SerializeHits(const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
void evd::_HandleGetPNG ( std::string  doc,
int  sock,
ILazy digs,
ILazy wires 
)

Definition at line 219 of file WebEVDServer.cxx.

220 {
221  const std::string mime = "image/png";
222 
223  // Parse the filename
224  char* ctx;
225 
226  const char* pName = strtok_r(&doc.front(), "_", &ctx);
227  const char* pIdx = strtok_r(0, "_", &ctx);
228  const char* pDim = strtok_r(0, ".", &ctx);
229 
230  if(!pName || !pIdx || !pDim){
231  write_notfound404(sock);
232  close(sock);
233  return;
234  }
235 
236  const std::string name(pName);
237  const int idx = atoi(pIdx);
238  const int dim = atoi(pDim);
239 
240  PNGArena* arena = 0;
241  if(name == "/dig") arena = &digs->GetArena();
242  if(name == "/wire") arena = &wires->GetArena();
243 
244  if(!arena || idx >= int(arena->data.size()) || dim > PNGArena::kArenaSize){
245  write_notfound404(sock);
246  close(sock);
247  return;
248  }
249 
250  write_ok200(sock, mime, false);
251  FILE* f = fdopen(sock, "wb");
252  arena->WritePNGBytes(f, idx, dim);
253  fclose(f);
254 }
static QCString name
Definition: declinfo.cpp:673
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
std::string string
Definition: nybbler.cc:12
int close(int)
Closes the file descriptor fd.
void write_notfound404(int sock)
QCString doc
void evd::AnalyzeArena ( const PNGArena bytes)

Definition at line 169 of file PNGArena.cxx.

170  {
171  for(int blockSize = 1; blockSize <= PNGArena::kArenaSize; blockSize *= 2){
172  long nfilled = 0;
173  for(unsigned int d = 0; d < bytes.data.size(); ++d){
174  for(int iy = 0; iy < PNGArena::kArenaSize/blockSize; ++iy){
175  for(int ix = 0; ix < PNGArena::kArenaSize/blockSize; ++ix){
176  bool filled = false;
177  for(int y = 0; y < blockSize && !filled; ++y){
178  for(int x = 0; x < blockSize; ++x){
179  if(bytes(d, ix*blockSize+x, iy*blockSize+y, 3) > 0){
180  filled = true;
181  break;
182  }
183  }
184  } // end for y
185  if(filled) ++nfilled;
186  }
187  }
188  }
189 
190  std::cout << "With block size = " << blockSize << " " << double(nfilled)/((PNGArena::kArenaSize*PNGArena::kArenaSize)/(blockSize*blockSize)*bytes.data.size()) << " of the blocks are filled" << std::endl;
191  }
192  }
list x
Definition: train.py:276
byte bytes
Alias for common language habits.
Definition: datasize.h:101
QTextStream & endl(QTextStream &s)
std::string evd::bar ( const std::string x)

Definition at line 106 of file TruthText.cxx.

107  {
108  // NB we escape the quote marks in the CSS because we know this is going to
109  // be served as CSS and we don't sanitize it there.
110  return "<span style=\\\"text-decoration:overline\\\">"+x+"</span>";
111  }
list x
Definition: train.py:276
bool evd::endswith ( const std::string s,
const std::string suffix 
)

Definition at line 321 of file WebEVDServer.cxx.

322 {
323  return s.rfind(suffix)+suffix.size() == s.size();
324 }
uint size() const
Definition: qcstring.h:201
static QCString * s
Definition: config.cpp:1042
EResult evd::err ( const char *  call)

Definition at line 138 of file WebEVDServer.cxx.

139 {
140  std::cout << call << "() error " << errno << " = " << strerror(errno) << std::endl;
141  return kERROR;
142  // return errno;
143 }
int errno
Contains the last error code.
Definition: structcmd.h:53
QTextStream & endl(QTextStream &s)
std::string evd::FindWebDir ( )

Definition at line 192 of file WebEVDServer.cxx.

193 {
194  std::string webdir;
195 
196  // For development purposes we prefer to serve the files from the source
197  // directory, which allows them to be live-edited with just a refresh of the
198  // browser window to see them.
199  if(getenv("MRB_SOURCE")) cet::search_path("MRB_SOURCE").find_file("webevd/webevd/WebEVD/web/", webdir);
200  // Otherwise, serve the files from where they get installed
201  if(webdir.empty() && getenv("PRODUCTS") && getenv("WEBEVD_VERSION")) cet::search_path("PRODUCTS").find_file("webevd/"+std::string(getenv("WEBEVD_VERSION"))+"/webevd/", webdir);
202 
203  if(webdir.empty()){
204  std::cout << "Unable to find webevd files under $MRB_SOURCE or $PRODUCTS" << std::endl;
205  abort();
206  }
207 
208  return webdir;
209 }
std::string string
Definition: nybbler.cc:12
std::string getenv(std::string const &name)
Definition: getenv.cc:15
std::string find_file(std::string const &filename) const
Definition: search_path.cc:96
QTextStream & endl(QTextStream &s)
void evd::gzip_buffer ( unsigned char *  src,
int  length,
std::vector< unsigned char > &  dest,
int  level 
)

Definition at line 257 of file WebEVDServer.cxx.

261 {
262  // C++20 will allow to use designated initializers here
263  z_stream strm;
264  strm.zalloc = Z_NULL;
265  strm.zfree = Z_NULL;
266  strm.opaque = Z_NULL;
267 
268  strm.next_in = src;
269  strm.avail_in = length;
270 
271  // The 16 here is the secret sauce to get gzip header and trailer for some
272  // reason...
273  deflateInit2(&strm, level, Z_DEFLATED, 15 | 16, 9, Z_DEFAULT_STRATEGY);
274 
275  // If we allocate a big enough buffer we can deflate in one pass
276  dest.resize(deflateBound(&strm, length));
277 
278  strm.next_out = dest.data();
279  strm.avail_out = dest.size();
280 
281  deflate(&strm, Z_FINISH);
282 
283  dest.resize(dest.size() - strm.avail_out);
284 
285  deflateEnd(&strm);
286 }
Result evd::HandleCommand ( std::string  cmd,
int  sock 
)

Definition at line 145 of file WebEVDServer.cxx.

146 {
147  EResult code = kERROR;
148  int run = -1, subrun = -1, evt = -1;
149  bool traces = false;
150 
151  if(cmd == "/QUIT") code = kQUIT;
152  if(cmd == "/NEXT") code = kNEXT;
153  if(cmd == "/PREV") code = kPREV;
154  if(cmd == "/NEXT_TRACES"){ code = kNEXT; traces = true;}
155  if(cmd == "/PREV_TRACES"){ code = kPREV; traces = true;}
156 
157  if(cmd.find("/seek/") == 0 ||
158  cmd.find("/seek_traces/") == 0){
159  if(cmd.find("/seek_traces/") == 0) traces = true;
160 
161  code = kSEEK;
162  char* ctx;
163  strtok_r(cmd.data(), "/", &ctx); // consumes the "seek" text
164  run = atoi(strtok_r(0, "/", &ctx));
165  subrun = atoi(strtok_r(0, "/", &ctx));
166  evt = atoi(strtok_r(0, "/", &ctx));
167  // if this goes wrong we get zeros, which seems a reasonable fallback
168  }
169 
170  write_ok200(sock, "text/html", false);
171 
172  const int delay = (code == kQUIT) ? 2000 : 0;
173  const std::string txt = (code == kQUIT) ? "Goodbye!" : "Please wait...";
174  const std::string next = traces ? "/traces.html" : "/";
175 
176  // The script tag to set the style is a pretty egregious layering violation,
177  // but doing more seems overkill for a simple interstitial page.
178  const std::string msg = TString::Format("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><script>setTimeout(function(){window.location.replace('%s');}, %d);</script></head><body><script>if(window.sessionStorage.theme != 'lighttheme'){document.body.style.backgroundColor='black';document.body.style.color='white';}</script><h1>%s</h1></body></html>", next.c_str(), delay, txt.c_str()).Data();
179 
180  write(sock, msg.c_str(), msg.size());
181  close(sock);
182 
183  if(code == kSEEK){
184  return Result(kSEEK, run, subrun, evt);
185  }
186  else{
187  return code;
188  }
189 }
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
Format
Definition: utils.h:7
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
int close(int)
Closes the file descriptor fd.
CodeOutputInterface * code
Fw2dFFT::Data Data
list cmd
Definition: getreco.py:22
TCEvent evt
Definition: DataStructs.cxx:7
std::string evd::HTMLName ( int  pdgcode)

HTML entities style.

Definition at line 121 of file TruthText.cxx.

122  {
123  // NB we escape the quote marks in the CSS because we know this is going to
124  // be served as CSS and we don't sanitize it there.
125  switch(pdgcode){
126  case 22: return "&gamma;";
127  case -11: return sup("e", "+");
128  case 11: return sup("e", "-");
129  case 13: return "&mu;";
130  case -15: return bar("&tau;");
131  case 15: return "&tau;";
132  case -13: return bar("&mu;");
133  case 12: return sub("&nu;", "e");
134  case 14: return sub("&nu;", "&mu;");
135  case 16: return sub("&nu;", "&tau;");
136  case -12: return sub(bar("&nu;"), "e");
137  case -14: return sub(bar("&nu;"), "&mu;");
138  case -16: return sub(bar("&nu;"), "&tau;");
139  case 111: return sup("&pi;", "0");
140  case 211: return sup("&pi;", "+");
141  case -211: return sup("&pi;", "-");
142  case 221: return "&eta;";
143  case 331: return "&eta;'";
144  case 130: return sub(sup("K", "0"), "L");
145  case 310: return sub(sup("K", "0"), "L");
146  case 311: return sup("K", "0");
147  case -311: return sup(bar("K"), "0");
148  case 321: return sup("K", "+");
149  case -321: return sup("K", "-");
150  case 2112: return "n";
151  case 2212: return "p";
152  case -2112: return bar("n");
153  case -2212: return bar("p");
154  case 2224: return sup("&Delta;", "++");
155  case 3122: return sup("&Lambda;", "0");
156  case 3222: return sup("&Sigma;", "+");
157  case -3222: return sup("&Sigma;", "-");
158 
159  case 1000010020: return nucl("2", "H");
160  case 1000010030: return nucl("3", "H");
161  case 1000020030: return nucl("3", "He");
162  case 1000020040: return nucl("4", "He");
163  case 1000040070: return nucl("7", "Be");
164  case 1000040080: return nucl("8", "Be");
165  case 1000040100: return nucl("10", "Be");
166  case 1000050090: return nucl("9", "B");
167  case 1000050100: return nucl("10", "B");
168  case 1000050110: return nucl("11", "B");
169  case 1000060100: return nucl("10", "C");
170  case 1000060110: return nucl("11", "C");
171  case 1000060120: return nucl("12", "C");
172  case 1000060130: return nucl("13", "C");
173  case 1000060140: return nucl("14", "C");
174  case 1000070150: return nucl("15", "N");
175  case 1000100220: return nucl("22", "Ne");
176  case 1000140300: return nucl("30", "Si");
177  case 1000150330: return nucl("33", "P");
178  case 1000160340: return nucl("34", "S");
179  case 1000160350: return nucl("35", "S");
180  case 1000160360: return nucl("36", "S");
181  case 1000170350: return nucl("35", "Cl");
182  case 1000170360: return nucl("36", "Cl");
183  case 1000170370: return nucl("37", "Cl");
184  case 1000180380: return nucl("38", "Ar");
185  case 1000180400: return nucl("40", "Ar");
186  case 1000210480: return nucl("48", "Sc");
187  case 1000260560: return nucl("56", "Fe");
188  case 1000220480: return nucl("48", "Ti");
189  case 1000080160: return nucl("16", "O");
190  case 1000070140: return nucl("14", "N");
191  case 1000110230: return nucl("23", "Na");
192  case 1000130270: return nucl("27", "Al");
193  case 1000140280: return nucl("28", "Si");
194  case 1000200400: return nucl("40", "Ca");
195  case 1000561370: return nucl("137", "Ba");
196  default: return sub("X", std::to_string(pdgcode));
197  }
198  return 0;
199  }
std::string bar(const std::string &x)
Definition: TruthText.cxx:106
std::string nucl(const std::string &A, const std::string &elem)
Definition: TruthText.cxx:114
std::string sup(const std::string &a, const std::string &b)
Definition: TruthText.cxx:94
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
std::string sub(const std::string &a, const std::string &b)
Definition: TruthText.cxx:100
std::string evd::LatexName ( int  pdgcode)

Convert PDG code to a latex string (root-style)

Definition at line 12 of file TruthText.cxx.

13  {
14  switch(pdgcode){
15  case 22: return "#gamma";
16  case -11: return "e^{+}";
17  case 11: return "e^{-}";
18  case 13: return "#mu";
19  case -15: return "#bar{#tau}";
20  case 15: return "#tau";
21  case -13: return "#bar{#mu}";
22  case 12: return "#nu_{e}";
23  case 14: return "#nu_{#mu}";
24  case 16: return "#nu_{#tau}";
25  case -12: return "#bar{#nu}_{e}";
26  case -14: return "#bar{#nu}_{#mu}";
27  case -16: return "#bar{#nu}_{#tau}";
28  case 111: return "#pi^{0}";
29  case 211: return "#pi^{+}";
30  case -211: return "#pi^{-}";;
31  case 221: return "#eta";
32  case 331: return "#eta'";
33  case 130: return "K^{0}_{L}";
34  case 310: return "K^{0}_{S}";
35  case 311: return "K^{0}";
36  case -311: return "#bar{K}^{0}";
37  case 321: return "K^{+}";
38  case -321: return "K^{-}";
39  case 2112: return "n";
40  case 2212: return "p";
41  case -2112: return "#bar{n}";
42  case -2212: return "#bar{p}";
43  case 2224: return "#Delta^{++}";
44  case 3122: return "#Lambda^{0}";
45  case 3222: return "#Sigma^{+}";
46  case -3222: return "#Sigma^{-}";
47 
48  case 1000010020: return "^{2}H";
49  case 1000010030: return "^{3}H";
50  case 1000020030: return "^{3}He";
51  case 1000020040: return "^{4}He";
52  case 1000040070: return "^{7}Be";
53  case 1000040080: return "^{8}Be";
54  case 1000040100: return "^{10}Be";
55  case 1000050090: return "^{9}B";
56  case 1000050100: return "^{10}B";
57  case 1000050110: return "^{11}B";
58  case 1000060100: return "^{10}C";
59  case 1000060110: return "^{11}C";
60  case 1000060120: return "^{12}C";
61  case 1000060130: return "^{13}C";
62  case 1000060140: return "^{14}C";
63  case 1000070150: return "^{15}N";
64  case 1000100220: return "^{22}Ne";
65  case 1000140300: return "^{30}Si";
66  case 1000150330: return "^{33}P";
67  case 1000160340: return "^{34}S";
68  case 1000160350: return "^{35}S";
69  case 1000160360: return "^{36}S";
70  case 1000170350: return "^{35}Cl";
71  case 1000170360: return "^{36}Cl";
72  case 1000170370: return "^{37}Cl";
73  case 1000180380: return "^{38}Ar";
74  case 1000180400: return "^{40}Ar";
75  case 1000210480: return "^{48}Sc";
76  case 1000260560: return "^{56}Fe";
77  case 1000220480: return "^{48}Ti";
78  case 1000080160: return "^{16}O";
79  case 1000070140: return "^{14}N";
80  case 1000110230: return "^{23}Na";
81  case 1000130270: return "^{27}Al";
82  case 1000140280: return "^{28}Si";
83  case 1000200400: return "^{40}Ca";
84  case 1000561370: return "^{137}Ba";
85  default:
86  static char buf[256];
87  sprintf(buf,"X_{%d}", pdgcode);
88  return buf;
89  }
90  return 0;
91  }
std::string evd::MCTruthShortText ( const simb::MCTruth truth)

Definition at line 250 of file TruthText.cxx.

251  {
253  std::string incoming;
254  std::string outgoing;
255  // Label cosmic rays -- others are pretty obvious
256  if(truth.Origin() == simb::kCosmicRay) origin = "c-ray: ";
257 
258  for(int j = 0; j < truth.NParticles(); ++j){
259  const simb::MCParticle& p = truth.GetParticle(j);
260 
261  const unsigned int bufsize = 4096;
262  char buf[bufsize];
263 
264  if(p.P() > 0.05){
265  snprintf(buf, bufsize, "%s&nbsp;[%.1f GeV/c]",
266  HTMLName(p.PdgCode()).c_str(), p.P());
267  }
268  else{
269  snprintf(buf, bufsize, "%s",
270  HTMLName(p.PdgCode()).c_str());
271  }
272  if(p.StatusCode() == 0){
273  if(!incoming.empty()) incoming += " + ";
274  incoming += buf;
275  }
276  if(p.StatusCode() == 1){
277  if(!outgoing.empty()) outgoing += " + ";
278  outgoing += buf;
279  }
280  } // loop on j particles
281 
282  if(origin.empty() && incoming.empty()) return outgoing;
283 
285  return origin+incoming+" &rarr; "+outgoing+suffix;
286  }
int PdgCode() const
Definition: MCParticle.h:212
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
std::string string
Definition: nybbler.cc:12
simb::Origin_t Origin() const
Definition: MCTruth.h:74
int StatusCode() const
Definition: MCParticle.h:211
int NParticles() const
Definition: MCTruth.h:75
std::string HTMLName(int pdgcode)
HTML entities style.
Definition: TruthText.cxx:121
int InteractionType() const
Definition: MCNeutrino.h:150
double P(const int i=0) const
Definition: MCParticle.h:234
p
Definition: test.py:223
std::string ShortInteractionSuffix(int iType)
Definition: TruthText.cxx:202
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:76
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
Cosmic rays.
Definition: MCTruth.h:24
static constexpr int evd::MipMapOffset ( int  dim,
int  maxdim 
)
static

Definition at line 16 of file PNGArena.h.

17  {
18  if(dim >= maxdim) return 0;
19  return MipMapOffset(dim*2, maxdim) + (dim*2)*(dim*2)*4;
20  }
static constexpr int MipMapOffset(int dim, int maxdim)
Definition: PNGArena.h:16
std::string evd::nucl ( const std::string A,
const std::string elem 
)

Definition at line 114 of file TruthText.cxx.

115  {
116  return "<sup>"+A+"</sup>"+elem;
117  }
JSONFormatter& evd::operator<< ( JSONFormatter json,
const art::InputTag t 
)

Definition at line 327 of file WebEVDServer.cxx.

328 {
329  json << "\"" << t.label();
330  if(!t.instance().empty()) json << ":" << t.instance();
331  if(!t.process().empty()) json << ":" << t.process();
332  json << "\"";
333  return json;
334 }
std::string const & instance() const noexcept
Definition: InputTag.cc:85
std::string const & process() const noexcept
Definition: InputTag.cc:91
std::string const & label() const noexcept
Definition: InputTag.cc:79
JSONFormatter& evd::operator<< ( JSONFormatter json,
const geo::OpDetID id 
)

Definition at line 337 of file WebEVDServer.cxx.

338 {
339  json << "\"" << std::string(id) << "\"";
340  return json;
341 }
std::string string
Definition: nybbler.cc:12
JSONFormatter& evd::operator<< ( JSONFormatter json,
const geo::PlaneID plane 
)

Definition at line 345 of file WebEVDServer.cxx.

346 {
347  return json << "\"" << std::string(plane) << "\"";
348 }
std::string string
Definition: nybbler.cc:12
JSONFormatter& evd::operator<< ( JSONFormatter json,
const recob::Hit hit 
)

Definition at line 351 of file WebEVDServer.cxx.

352 {
353  return json << "{\"wire\": " << geo::WireID(hit.WireID()).Wire
354  << ", \"tick\": " << hit.PeakTime()
355  << ", \"rms\": " << hit.RMS()
356  << ", \"peakamp\": " << hit.PeakAmplitude() << "}";
357 }
geo::WireID WireID() const
Definition: Hit.h:233
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:220
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
Definition: Hit.h:221
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
JSONFormatter& evd::operator<< ( JSONFormatter json,
const recob::Vertex vtx 
)

Definition at line 360 of file WebEVDServer.cxx.

361 {
362  return json << TVector3(vtx.position().x(),
363  vtx.position().y(),
364  vtx.position().z());
365 }
const Point_t & position() const
Return vertex 3D position.
Definition: Vertex.h:60
JSONFormatter& evd::operator<< ( JSONFormatter json,
const simb::MCTruth mct 
)

Definition at line 368 of file WebEVDServer.cxx.

369 {
370  // Don't show MCTruth for cosmic rays, which can be extremely
371  // lengthy. Ideally we should exclude them from the list entirely, but this
372  // requires less change to the structure of the code.
373  if(mct.Origin() == simb::kCosmicRay) return json << "\"\"";
374 
375  return json << "\"" << MCTruthShortText(mct) << "\"";
376 }
simb::Origin_t Origin() const
Definition: MCTruth.h:74
std::string MCTruthShortText(const simb::MCTruth &truth)
Definition: TruthText.cxx:250
Cosmic rays.
Definition: MCTruth.h:24
JSONFormatter& evd::operator<< ( JSONFormatter json,
const recob::SpacePoint sp 
)

Definition at line 379 of file WebEVDServer.cxx.

380 {
381  return json << TVector3(sp.XYZ());
382 }
const Double32_t * XYZ() const
Definition: SpacePoint.h:76
JSONFormatter& evd::operator<< ( JSONFormatter json,
const recob::Track track 
)

Definition at line 385 of file WebEVDServer.cxx.

386 {
387  std::vector<TVector3> pts;
388 
389  const recob::TrackTrajectory& traj = track.Trajectory();
390  for(unsigned int j = traj.FirstValidPoint(); j <= traj.LastValidPoint(); ++j){
391  if(!traj.HasValidPoint(j)) continue;
392  const geo::Point_t pt = traj.LocationAtPoint(j);
393  pts.emplace_back(pt.X(), pt.Y(), pt.Z());
394  }
395 
396  return json << "{ \"positions\": " << pts << " }";
397 }
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:98
size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
A trajectory in space reconstructed from hits.
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
bool HasValidPoint(size_t i) const
Returns whether the specified point has NoPoint flag unset.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
JSONFormatter& evd::operator<< ( JSONFormatter json,
const simb::MCParticle part 
)

Definition at line 400 of file WebEVDServer.cxx.

401 {
402  const int apdg = abs(part.PdgCode());
403  if(apdg == 12 || apdg == 14 || apdg == 16) return json << "{ \"pdg\": " << apdg << ", \"positions\": [] }"; // decay neutrinos
404  std::vector<TVector3> pts;
405  for(unsigned int j = 0; j < part.NumberTrajectoryPoints(); ++j){
406  pts.emplace_back(part.Vx(j), part.Vy(j), part.Vz(j));
407  }
408 
409  return json << "{ \"pdg\": " << apdg << ", \"positions\": " << pts << " }";
410 }
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:218
int PdgCode() const
Definition: MCParticle.h:212
T abs(T value)
double Vx(const int i=0) const
Definition: MCParticle.h:221
double Vz(const int i=0) const
Definition: MCParticle.h:223
double Vy(const int i=0) const
Definition: MCParticle.h:222
JSONFormatter& evd::operator<< ( JSONFormatter json,
const recob::OpFlash flash 
)

Definition at line 413 of file WebEVDServer.cxx.

414 {
415  json << std::map<std::string, double>{
416  {"tcenter", flash.Time()},
417  {"twidth", flash.TimeWidth()},
418  {"ycenter", flash.YCenter()},
419  {"ywidth", flash.YWidth()},
420  {"zcenter", flash.ZCenter()},
421  {"zwidth", flash.ZWidth()},
422  {"totpe", flash.TotalPE()}
423  };
424 
425  return json;
426 }
double TimeWidth() const
Definition: OpFlash.h:107
double ZCenter() const
Definition: OpFlash.h:117
double Time() const
Definition: OpFlash.h:106
double YWidth() const
Definition: OpFlash.h:116
double TotalPE() const
Definition: OpFlash.cxx:68
double YCenter() const
Definition: OpFlash.h:115
double ZWidth() const
Definition: OpFlash.h:118
JSONFormatter& evd::operator<< ( JSONFormatter json,
const geo::CryostatGeo cryo 
)

Definition at line 429 of file WebEVDServer.cxx.

430 {
431  const TVector3 r0(cryo.MinX(), cryo.MinY(), cryo.MinZ());
432  const TVector3 r1(cryo.MaxX(), cryo.MaxY(), cryo.MaxZ());
433  return json << "{ \"min\": " << r0 << ", \"max\": " << r1 << " }";
434 }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxY() const
Returns the world y coordinate of the end of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
JSONFormatter& evd::operator<< ( JSONFormatter json,
const geo::OpDetGeo opdet 
)

Definition at line 437 of file WebEVDServer.cxx.

438 {
439  return json << "{ \"name\": " << opdet.ID() << ", "
440  << "\"center\": " << TVector3(opdet.GetCenter().X(),
441  opdet.GetCenter().Y(),
442  opdet.GetCenter().Z()) << ", "
443  << "\"length\": " << opdet.Length() << ", "
444  << "\"width\": " << opdet.Width() << ", "
445  << "\"height\": " << opdet.Height() << " }";
446 }
void GetCenter(double *xyz, double localz=0.0) const
Definition: OpDetGeo.cxx:40
double Length() const
Definition: OpDetGeo.h:81
geo::OpDetID const & ID() const
Returns the geometry ID of this optical detector.
Definition: OpDetGeo.h:72
double Width() const
Definition: OpDetGeo.h:82
double Height() const
Definition: OpDetGeo.h:83
JSONFormatter& evd::operator<< ( JSONFormatter os,
const PNGView v 
)

Definition at line 449 of file WebEVDServer.cxx.

450 {
451  bool first = true;
452  os << "{\"blocks\": [\n";
453  for(unsigned int ix = 0; ix < v.blocks.size(); ++ix){
454  for(unsigned int iy = 0; iy < v.blocks[ix].size(); ++iy){
455  const png_byte* b = v.blocks[ix][iy];
456  if(!b) continue;
457 
458  if(!first) os << ",\n";
459  first = false;
460 
461  int dataidx = 0;
462  for(unsigned int d = 0; d < v.arena.data.size(); ++d){
463  if(b >= &v.arena.data[d]->front() &&
464  b < &v.arena.data[d]->front() + 4*PNGArena::kArenaSize*PNGArena::kArenaSize){
465  dataidx = d;
466  break;
467  }
468  }
469 
470  const int texdx = ((b-&v.arena.data[dataidx]->front())/4)%PNGArena::kArenaSize;
471  const int texdy = ((b-&v.arena.data[dataidx]->front())/4)/PNGArena::kArenaSize;
472 
473  os << "{"
474  << "\"x\": " << ix*PNGArena::kBlockSize << ", "
475  << "\"y\": " << iy*PNGArena::kBlockSize << ", "
476  << "\"dx\": " << PNGArena::kBlockSize << ", "
477  << "\"dy\": " << PNGArena::kBlockSize << ", "
478  << "\"fname\": \"" << v.arena.name << "_" << dataidx << "\", "
479  << "\"texdim\": " << PNGArena::kArenaSize << ", "
480  << "\"u\": " << texdx << ", "
481  << "\"v\": " << texdy << ", "
482  << "\"du\": " << PNGArena::kBlockSize << ", "
483  << "\"dv\": " << PNGArena::kBlockSize
484  << "}";
485  }
486  }
487  os << "\n]}";
488  return os;
489 }
unsigned char png_byte
Definition: PNGArena.h:10
static bool * b
Definition: config.cpp:1043
std::string evd::read_all ( int  sock)

Definition at line 123 of file WebEVDServer.cxx.

124 {
125  std::string ret;
126 
127  std::vector<char> buf(1024*1024);
128  while(true){
129  const int nread = read(sock, &buf.front(), buf.size());
130  if(nread == 0) return ret;
131  ret.insert(ret.end(), buf.begin(), buf.begin()+nread);
132  // Only handle GETs, so no need to wait for payload (for which we'd need to
133  // check Content-Length too).
134  if(ret.find("\r\n\r\n") != std::string::npos) return ret;
135  }
136 }
std::string string
Definition: nybbler.cc:12
int read(int, char *, size_t)
Read bytes from a file descriptor.
template<class T >
void evd::SerializeDigitTraces ( const T &  evt,
const geo::GeometryCore geom,
JSONFormatter json 
)

Definition at line 687 of file WebEVDServer.cxx.

690 {
691  // [tag][plane][wire index][t0]
692  std::map<art::InputTag, std::map<geo::PlaneID, std::map<int, std::map<int, std::vector<short>>>>> traces;
693 
694  for(art::InputTag tag: evt.template getInputTags<std::vector<raw::RawDigit>>()){
695  typename T::template HandleT<std::vector<raw::RawDigit>> digs; // deduce handle type
696  // This can fail in the case of dropped products
697  if(!evt.getByLabel(tag, digs)) continue;
698 
699  for(const raw::RawDigit& dig: *digs){
700  for(geo::WireID wire: geom->ChannelToWire(dig.Channel())){
701  const geo::PlaneID plane(wire);
702 
703  raw::RawDigit::ADCvector_t adcs(dig.Samples());
704  raw::Uncompress(dig.ADCs(), adcs, dig.Compression());
705 
706  traces[tag][plane][wire.Wire] = ToSnippets(adcs, short(dig.GetPedestal()));
707  } // end for wire
708  } // end for dig
709  } // end for tag
710 
711  json << traces;
712 }
std::map< int, std::vector< T > > ToSnippets(const std::vector< T > &adcs, T pedestal=0)
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
TCEvent evt
Definition: DataStructs.cxx:7
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
template<class T >
void evd::SerializeEventID ( const T &  evt,
JSONFormatter json 
)

Definition at line 535 of file WebEVDServer.cxx.

536 {
537  typedef std::map<std::string, int> EIdMap;
538  json << EIdMap({{"run", evt.run()}, {"subrun", evt.subRun()}, {"evt", evt.event()}});
539 }
unsigned int event
Definition: DataStructs.h:636
unsigned int run
Definition: DataStructs.h:637
unsigned int subRun
Definition: DataStructs.h:638
TCEvent evt
Definition: DataStructs.cxx:7
void evd::SerializeEventID ( const ThreadsafeGalleryEvent evt,
JSONFormatter json 
)

Definition at line 542 of file WebEVDServer.cxx.

543 {
544  SerializeEventID(evt.eventAuxiliary(), json);
545 }
void SerializeEventID(const ThreadsafeGalleryEvent &evt, JSONFormatter &json)
TCEvent evt
Definition: DataStructs.cxx:7
void evd::SerializeGeometry ( const geo::GeometryCore geom,
const detinfo::DetectorPropertiesData detprop,
JSONFormatter json 
)

Definition at line 599 of file WebEVDServer.cxx.

602 {
603  json << "{\n";
604  SerializePlanes(geom, detprop, json);
605  json << ",\n\n";
606 
607  json << " \"cryos\": [\n";
608  for(unsigned int i = 0; i < geom->Ncryostats(); ++i){
609  json << " " << geom->Cryostat(i);
610  if(i != geom->Ncryostats()-1) json << ",\n"; else json << "\n";
611  }
612  json << " ],\n\n";
613 
614  json << " \"opdets\": [\n";
615  for(unsigned int i = 0; i < geom->NOpDets(); ++i){
616  json << " " << geom->OpDetGeoFromOpDet(i);
617  if(i != geom->NOpDets()-1) json << ",\n"; else json << "\n";
618  }
619  json << " ]\n";
620  json << "}\n";
621 }
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
void SerializePlanes(const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData &detprop, JSONFormatter &json)
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
template<class T >
void evd::SerializeHits ( const T &  evt,
const geo::GeometryCore geom,
JSONFormatter json 
)

Definition at line 625 of file WebEVDServer.cxx.

626 {
627  std::map<art::InputTag, std::map<geo::PlaneID, std::vector<recob::Hit>>> plane_hits;
628 
629  for(art::InputTag tag: evt.template getInputTags<std::vector<recob::Hit>>()){
630  typename T::template HandleT<std::vector<recob::Hit>> hits; // deduce handle type
631  // This can fail in the case of dropped products
632  if(!evt.getByLabel(tag, hits)) continue;
633 
634  for(const recob::Hit& hit: *hits){
635  // Would possibly be right for disambiguated hits?
636  // const geo::WireID wire(hit.WireID());
637 
638  for(geo::WireID wire: geom->ChannelToWire(hit.Channel())){
639  const geo::PlaneID plane(wire);
640 
641  // Correct for disambiguated hits
642  // plane_hits[plane].push_back(hit);
643 
644  // Otherwise we have to update the wire number
645  plane_hits[tag][plane].emplace_back(hit.Channel(), hit.StartTick(), hit.EndTick(), hit.PeakTime(), hit.SigmaPeakTime(), hit.RMS(), hit.PeakAmplitude(), hit.SigmaPeakAmplitude(), hit.SummedADC(), hit.Integral(), hit.SigmaIntegral(), hit.Multiplicity(), hit.LocalIndex(), hit.GoodnessOfFit(), hit.DegreesOfFreedom(), hit.View(), hit.SignalType(), wire);
646  }
647  }
648  } // end for tag
649 
650  json << plane_hits;
651 }
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Detector simulation of raw signals on wires.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TCEvent evt
Definition: DataStructs.cxx:7
void evd::SerializePlanes ( const geo::GeometryCore geom,
const detinfo::DetectorPropertiesData detprop,
JSONFormatter json 
)

Definition at line 548 of file WebEVDServer.cxx.

551 {
552  bool first = true;
553 
554  json << " \"planes\": {\n";
555  for(geo::PlaneID plane: geom->IteratePlaneIDs()){
556  const geo::PlaneGeo& planegeo = geom->Plane(plane);
557  const int view = planegeo.View();
558  const unsigned int nwires = planegeo.Nwires();
559  const double pitch = planegeo.WirePitch();
560  const TVector3 c = planegeo.GetCenter();
561 
562  const TVector3 d = planegeo.GetIncreasingWireDirection();
563  const TVector3 n = planegeo.GetNormalDirection();
564  const TVector3 wiredir = planegeo.GetWireDirection();
565 
566  const double depth = planegeo.Depth();
567  const double width = planegeo.Width();
568  const TVector3 depthdir = planegeo.DepthDir();
569  const TVector3 widthdir = planegeo.WidthDir();
570 
571  const double tick_origin = detprop.ConvertTicksToX(0, plane);
572  const double tick_pitch = detprop.ConvertTicksToX(1, plane) - tick_origin;
573 
574  const int maxTick = detprop.NumberTimeSamples();
575 
576  if(!first) json << ",\n";
577  first = false;
578 
579  json << " " << plane << ": {"
580  << "\"view\": " << view << ", "
581  << "\"nwires\": " << nwires << ", "
582  << "\"pitch\": " << pitch << ", "
583  << "\"nticks\": " << maxTick << ", "
584  << "\"tick_origin\": " << tick_origin << ", "
585  << "\"tick_pitch\": " << tick_pitch << ", "
586  << "\"center\": " << c << ", "
587  << "\"across\": " << d << ", "
588  << "\"wiredir\": " << wiredir << ", "
589  << "\"depth\": " << depth << ", "
590  << "\"width\": " << width << ", "
591  << "\"depthdir\": " << depthdir << ", "
592  << "\"widthdir\": " << widthdir << ", "
593  << "\"normal\": " << n << "}";
594  }
595  json << "\n }";
596 }
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Vector GetNormalDirection() const
Returns the direction normal to the plane.
Definition: PlaneGeo.h:442
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
Definition: PlaneGeo.h:457
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:184
std::void_t< T > n
double Depth() const
Return the depth of the plane.
Definition: PlaneGeo.h:254
Point GetCenter() const
Returns the centre of the wire plane in world coordinates [cm].
Definition: PlaneGeo.h:479
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
double Width() const
Return the width of the plane.
Definition: PlaneGeo.h:246
double ConvertTicksToX(double ticks, int p, int t, int c) const
Vector DepthDir() const
Return the direction of plane depth.
Definition: PlaneGeo.h:236
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:269
Vector WidthDir() const
Return the direction of plane width.
Definition: PlaneGeo.h:221
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
Vector GetWireDirection() const
Returns the direction of the wires.
Definition: PlaneGeo.h:513
template<class TProd , class TEvt >
void evd::SerializeProduct ( const TEvt &  evt,
JSONFormatter json 
)

Definition at line 493 of file WebEVDServer.cxx.

494 {
495  json << "{";
496 
497  const std::vector<art::InputTag> tags = evt.template getInputTags<std::vector<TProd>>();
498 
499  for(const art::InputTag& tag: tags){
500  json << " " << tag << ": ";
501 
502  typename TEvt::template HandleT<std::vector<TProd>> prods; // deduce handle type
503  // This can fail in the case of dropped products
504  if(!evt.getByLabel(tag, prods)) continue;
505 
506  json << *prods;
507 
508  if(tag != tags.back()){
509  json << ",";
510  }
511  json << "\n";
512  }
513 
514  json << "}";
515 }
TCEvent evt
Definition: DataStructs.cxx:7
template<class TProd , class TEvt >
void evd::SerializeProductByLabel ( const TEvt &  evt,
const std::string in_label,
JSONFormatter json 
)

Definition at line 519 of file WebEVDServer.cxx.

522 {
523  typename TEvt::template HandleT<std::vector<TProd>> prods; // deduce handle type
524  evt.getByLabel(in_label, prods);
525 
526  if(prods.isValid()){
527  json << *prods;
528  }
529  else{
530  json << "[]";
531  }
532 }
TCEvent evt
Definition: DataStructs.cxx:7
template<class T >
void evd::SerializeWireTraces ( const T &  evt,
const geo::GeometryCore geom,
JSONFormatter json 
)

Definition at line 715 of file WebEVDServer.cxx.

718 {
719  // [tag][plane][wire][t0]
720  std::map<art::InputTag, std::map<geo::PlaneID, std::map<int, std::map<int, std::vector<float>>>>> traces;
721 
722  for(art::InputTag tag: evt.template getInputTags<std::vector<recob::Wire>>()){
723  typename T::template HandleT<std::vector<recob::Wire>> wires; // deduce handle type
724  // This can fail in the case of dropped products
725  if(!evt.getByLabel(tag, wires)) continue;
726 
727  for(const recob::Wire& rbwire: *wires){
728  // Place all wire traces on the first wire (== channel) they are found on
729  const geo::WireID wire = geom->ChannelToWire(rbwire.Channel())[0];
730  const geo::PlaneID plane(wire);
731 
732  traces[tag][plane][wire.Wire] = ToSnippets(rbwire.Signal());
733  } // end for rbwire
734  } // end for tag
735 
736  json << traces;
737 }
std::map< int, std::vector< T > > ToSnippets(const std::vector< T > &adcs, T pedestal=0)
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
TCEvent evt
Definition: DataStructs.cxx:7
std::string evd::ShortInteractionSuffix ( int  iType)

Definition at line 202 of file TruthText.cxx.

203  {
204  switch(iType){
205  case simb::kQE:
206  case simb::kCCQE:
207  return " (QE)";
208 
209  case simb::kRes:
216  return " (RES)";
217 
218  case simb::kDIS:
219  case simb::kCCDIS:
220  return " (DIS)";
221 
222  case simb::kCoh:
223  case simb::kCCCOH:
224  return " (COH)";
225 
226  case simb::kNCQE:
227  case simb::kNCDIS:
236  return " (NC)";
237 
239  return " (ES)";
240 
242  return " (IBD)";
243 
244  default: // simb::kNuElectronElastic and simb::kInverseMuDecay
245  return "";
246  }
247  }
neutral current quasi-elastic
Definition: MCNeutrino.h:97
resonant charged current, nubar p -> nubar n pi+
Definition: MCNeutrino.h:109
resonant neutral current, nu p -> nu p pi0
Definition: MCNeutrino.h:101
charged current deep inelastic scatter
Definition: MCNeutrino.h:134
resonant charged current, nubar p -> l+ p pi-
Definition: MCNeutrino.h:107
resonant charged current, nubar p -> l+ n pi0
Definition: MCNeutrino.h:106
charged current quasi-elastic
Definition: MCNeutrino.h:96
resonant charged current, nubar p -> nubar p pi0
Definition: MCNeutrino.h:108
resonant charged current, nu n -> l- p pi0
Definition: MCNeutrino.h:99
resonant neutral current, nu n -> nu n pi0
Definition: MCNeutrino.h:103
resonant charged current, nu n -> l- n pi+
Definition: MCNeutrino.h:100
resonant charged current, nubar n -> nubar p pi-
Definition: MCNeutrino.h:111
charged current deep inelastic scatter
Definition: MCNeutrino.h:133
resonant charged current, nu p -> l- p pi+
Definition: MCNeutrino.h:98
charged current coherent pion
Definition: MCNeutrino.h:139
resonant neutral current, nu n -> nu p pi-
Definition: MCNeutrino.h:104
resonant charged current, nubar n -> l+ n pi-
Definition: MCNeutrino.h:105
resonant charged current, nubar n -> nubar n pi0
Definition: MCNeutrino.h:110
resonant neutral current, nu p -> nu p pi+
Definition: MCNeutrino.h:102
std::string evd::sub ( const std::string a,
const std::string b 
)

Definition at line 100 of file TruthText.cxx.

101  {
102  return a+"<sub>"+b+"</sub>";
103  }
const double a
static bool * b
Definition: config.cpp:1043
std::string evd::sup ( const std::string a,
const std::string b 
)

Definition at line 94 of file TruthText.cxx.

95  {
96  return a+"<sup>"+b+"</sup>";
97  }
const double a
static bool * b
Definition: config.cpp:1043
short evd::swap_byte_order ( short  x)

Definition at line 76 of file WebEVDServer.cxx.

77 {
78  char* cx = (char*)&x;
79  std::swap(cx[0], cx[1]);
80  return x;
81 }
void swap(Handle< T > &a, Handle< T > &b)
list x
Definition: train.py:276
template<class T >
std::map<int, std::vector<T> > evd::ToSnippets ( const std::vector< T > &  adcs,
pedestal = 0 
)

Definition at line 654 of file WebEVDServer.cxx.

655 {
656  std::vector<T> snip;
657  snip.reserve(adcs.size());
658 
659  std::map<int, std::vector<T>> snips;
660 
661  int t = 0;
662  for(T adc: adcs){
663  if(adc == 0){
664  if(!snip.empty()){
665  snips[t-snip.size()] = snip;
666  snip.clear();
667  }
668  }
669  else{
670  snip.push_back(adc - pedestal);
671  }
672 
673  ++t;
674  } // end for adc
675 
676  // Save last in-progress snippet if necessary
677  if(!snip.empty()) snips[t-snip.size()] = snip;
678 
679  // this is a bit of a hack to teach the viewer how long the full trace
680  // is
681  snips[adcs.size()] = {};
682 
683  return snips;
684 }
int16_t adc
Definition: CRTFragment.hh:202
void evd::webevd_png_flush_fn ( png_struct_def *  png_ptr)

Definition at line 102 of file PNGArena.cxx.

103  {
104  // Nothing to do here, but libpng requires we provide this
105  }
void evd::webevd_png_write_fn ( png_struct_def *  png_ptr,
png_byte buffer,
long unsigned int  nbytes 
)

Definition at line 88 of file PNGArena.cxx.

91  {
92  FILE* fout = (FILE*)png_get_io_ptr(png_ptr);
93  const size_t ret = fwrite(buffer, 1, nbytes, fout);
94 
95  if(ret != nbytes){
96  std::cout << "Error writing " << nbytes << " bytes of png -- returned " << ret << std::endl;
97  perror(0);
98  std::cout << std::endl;
99  }
100  }
QTextStream & endl(QTextStream &s)
void evd::write_compressed_buffer ( unsigned char *  src,
int  length,
int  sock,
int  level,
const std::string name 
)

Definition at line 289 of file WebEVDServer.cxx.

294 {
295  std::vector<unsigned char> dest;
296  gzip_buffer(src, length, dest, level);
297 
298  std::cout << "Writing " << length << " bytes (compressed to " << dest.size() << ") for " << name << "\n" << std::endl;
299 
300  write(sock, dest.data(), dest.size());
301 }
static QCString name
Definition: declinfo.cpp:673
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
void gzip_buffer(unsigned char *src, int length, std::vector< unsigned char > &dest, int level)
QTextStream & endl(QTextStream &s)
void evd::write_compressed_file ( const std::string loc,
int  fd_out,
int  level 
)

Definition at line 304 of file WebEVDServer.cxx.

305 {
306  int fd_in = open(loc.c_str(), O_RDONLY);
307 
308  // Map in the whole file
309  struct stat st;
310  fstat(fd_in, &st);
311  unsigned char* src = (unsigned char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd_in, 0);
312 
313  write_compressed_buffer(src, st.st_size, fd_out, level, loc);
314 
315  munmap(src, st.st_size);
316 
317  close(fd_in);
318 }
int open(const char *, int)
Opens a file descriptor.
int close(int)
Closes the file descriptor fd.
void write_compressed_buffer(unsigned char *src, int length, int sock, int level, const std::string &name)
void evd::write_notfound404 ( int  sock)

Definition at line 99 of file WebEVDServer.cxx.

100 {
101  const char str[] =
102  "HTTP/1.0 404 Not Found\r\n"
103  "Server: WebEVD/1.0.0\r\n"
104  "Content-Type: text/plain\r\n"
105  "\r\n"
106  "404. Huh?\r\n";
107 
108  write(sock, str, strlen(str));
109 }
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
static QCString str
void evd::write_ok200 ( int  sock,
const std::string  content = "text/html",
bool  gzip = false 
)

Definition at line 83 of file WebEVDServer.cxx.

86 {
88  "HTTP/1.0 200 OK\r\n"
89  "Server: WebEVD/1.0.0\r\n"
90  "Content-Type: "+content+"\r\n";
91 
92  if(gzip) str += "Content-Encoding: gzip\r\n";
93 
94  str += "\r\n";
95 
96  write(sock, &str.front(), str.size());
97 }
std::string string
Definition: nybbler.cc:12
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
static QCString str
void evd::write_unimp501 ( int  sock)

Definition at line 111 of file WebEVDServer.cxx.

112 {
113  const char str[] =
114  "HTTP/1.0 501 Not Implemented\r\n"
115  "Server: WebEVD/1.0.0\r\n"
116  "Content-Type: text/plain\r\n"
117  "\r\n"
118  "I don't know how to do that\r\n";
119 
120  write(sock, str, strlen(str));
121 }
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
static QCString str

Variable Documentation

int evd::curr_zooming_plane
static

Definition at line 47 of file TWQMultiTPCProjection.cxx.

int evd::curr_zooming_plane
static

Definition at line 53 of file TWQProjectionView.cxx.

HitSelector* evd::gTheHitSelector

Definition at line 25 of file DrawingPad.cxx.

const int evd::kCALIB = 1
static

Definition at line 29 of file TQPad.cxx.

const int evd::kColor[kNCOLS]
static
Initial value:
= { kRed+2, kGreen+2, kBlue+2, kYellow+2, kMagenta-9, kCyan-6,
8, 29, 30, 38, 40, 41, 42, 46 }

Definition at line 11 of file eventdisplay.h.

const int evd::kColor2[kNCOLS]
static
Initial value:
= { kRed, kGreen, kBlue, kYellow, kMagenta, kCyan,
8, 29, 30, 38, 40, 41, 42, 46 }

Definition at line 13 of file eventdisplay.h.

double evd::kDistance
static

Definition at line 46 of file TWQMultiTPCProjection.cxx.

double evd::kDistance
static

Definition at line 52 of file TWQProjectionView.cxx.

const int evd::kNCOLS = 14
static

Definition at line 10 of file eventdisplay.h.

unsigned int evd::kPlane
static

Definition at line 44 of file TWQMultiTPCProjection.cxx.

unsigned int evd::kPlane
static

Definition at line 50 of file TWQProjectionView.cxx.

const int evd::kQ = 0
static

Definition at line 31 of file TQPad.cxx.

const int evd::kRAW = 0
static

Definition at line 28 of file TQPad.cxx.

const int evd::kTQ = 1
static

Definition at line 32 of file TQPad.cxx.

unsigned int evd::kWire
static

Definition at line 45 of file TWQMultiTPCProjection.cxx.

unsigned int evd::kWire
static

Definition at line 51 of file TWQProjectionView.cxx.

int evd::shift_lock
static

Definition at line 50 of file TWQMultiTPCProjection.cxx.

int evd::shift_lock
static

Definition at line 56 of file TWQProjectionView.cxx.

const char* evd::zoom_opt = 0
static

Definition at line 48 of file TWQMultiTPCProjection.cxx.

const char* evd::zoom_opt = 0
static

Definition at line 54 of file TWQProjectionView.cxx.