All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  InfoTransfer
 
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  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
 
class  SimulationDrawer
 
class  SimulationDrawingOptions
 
class  Style
 
class  TQPad
 
class  TWireProjPad
 A drawing pad for time vs wire. More...
 
class  ZoomOptionsMultiTPC
 
class  TWQMultiTPCProjectionView
 
struct  ZoomOptions
 
class  TWQProjectionView
 
class  InputSeeker
 This is obviously a hack, but it's modeled on what EventDisplayBase does. More...
 
class  JSONFormatter
 
class  PNGArena
 
class  PNGView
 
class  ThreadsafeGalleryEvent
 
class  WebEVD
 
class  ILazy
 
class  LazyDigits
 
class  LazyWires
 
struct  Result
 
class  WebEVDServer
 

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 geo::Point_t &pt)
 
JSONFormatteroperator<< (JSONFormatter &json, const sim::SimEnergyDeposit &edep)
 
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 793 of file WebEVDServer.cxx.

794 {
795  if(doc == "/") doc = "/index.html";
796 
797  if(endswith(doc, ".png")){
798  _HandleGetPNG(doc, sock, digs, wires);
799  return;
800  }
801 
802  if(endswith(doc, ".json")){
803  _HandleGetJSON(doc, sock, evt, geom, detprop, digs, wires);
804  return;
805  }
806 
807  // TODO - more sophisticated MIME type handling
808  std::string mime = "text/html";
809  if(endswith(doc, ".js" )) mime = "application/javascript";
810  if(endswith(doc, ".css")) mime = "text/css";
811  if(endswith(doc, ".ico")) mime = "image/vnd.microsoft.icon";
812 
813  // Otherwise it must be a physical file
814 
815  // Don't accidentally serve any file we shouldn't
816  const std::set<std::string> whitelist = {"/evd.css", "/evd.js", "/traces.js", "/favicon.ico", "/index.html", "/traces.html"};
817 
818  if(whitelist.count(doc)){
819  write_ok200(sock, mime, true);
820  write_compressed_file(FindWebDir()+doc, sock, Z_DEFAULT_COMPRESSION);
821  }
822  else{
823  write_notfound404(sock);
824  }
825 
826  close(sock);
827 }
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
std::string FindWebDir()
void write_compressed_file(const std::string &loc, int fd_out, int level)
bool endswith(const std::string &s, const std::string &suffix)
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)
TCEvent evt
Definition: DataStructs.cxx:8
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
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 759 of file WebEVDServer.cxx.

760 {
761  const std::string mime = "application/json";
762 
763  std::stringstream ss;
764  JSONFormatter json(ss);
765 
766  /***/if(doc == "/evtid.json") SerializeEventID(*evt, json);
767  else if(doc == "/tracks.json") SerializeProduct<recob::Track>(*evt, json);
768  else if(doc == "/spacepoints.json") SerializeProduct<recob::SpacePoint>(*evt, json);
769  else if(doc == "/vtxs.json") SerializeProduct<recob::Vertex>(*evt, json);
770  else if(doc == "/trajs.json") SerializeProductByLabel<simb::MCParticle>(*evt, "largeant", json);
771  else if(doc == "/mctruth.json") SerializeProduct<simb::MCTruth>(*evt, json);
772  else if(doc == "/simedep.json") SerializeProduct<sim::SimEnergyDeposit>(*evt, json);
773  else if(doc == "/opflashes.json") SerializeProduct<recob::OpFlash>(*evt, json);
774  else if(doc == "/hits.json") SerializeHits(*evt, geom, json);
775  else if(doc == "/geom.json") SerializeGeometry(geom, *detprop, json);
776  else if(doc == "/digs.json") digs->Serialize(json);
777  else if(doc == "/wires.json") wires->Serialize(json);
778  else if(doc == "/dig_traces.json") SerializeDigitTraces(*evt, geom, json);
779  else if(doc == "/wire_traces.json") SerializeWireTraces(*evt, geom, json);
780  else{
781  write_notfound404(sock);
782  close(sock);
783  return;
784  }
785 
786  std::string response = ss.str();
787  write_ok200(sock, mime, true);
788  write_compressed_buffer((unsigned char*)response.data(), response.size(), sock, Z_DEFAULT_COMPRESSION, doc);
789  close(sock);
790 }
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 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 SerializeEventID(const T &evt, JSONFormatter &json)
void write_notfound404(int sock)
void SerializeWireTraces(const T &evt, const geo::GeometryCore *geom, JSONFormatter &json)
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
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 221 of file WebEVDServer.cxx.

222 {
223  const std::string mime = "image/png";
224 
225  // Parse the filename
226  char* ctx;
227 
228  const char* pName = strtok_r(&doc.front(), "_", &ctx);
229  const char* pIdx = strtok_r(0, "_", &ctx);
230  const char* pDim = strtok_r(0, ".", &ctx);
231 
232  if(!pName || !pIdx || !pDim){
233  write_notfound404(sock);
234  close(sock);
235  return;
236  }
237 
238  const std::string name(pName);
239  const int idx = atoi(pIdx);
240  const int dim = atoi(pDim);
241 
242  PNGArena* arena = 0;
243  if(name == "/dig") arena = &digs->GetArena();
244  if(name == "/wire") arena = &wires->GetArena();
245 
246  if(!arena || idx >= int(arena->data.size()) || dim > PNGArena::kArenaSize){
247  write_notfound404(sock);
248  close(sock);
249  return;
250  }
251 
252  write_ok200(sock, mime, false);
253  FILE* f = fdopen(sock, "wb");
254  arena->WritePNGBytes(f, idx, dim);
255  fclose(f);
256 }
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
void write_notfound404(int sock)
then echo fcl name
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
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  }
process_name opflash particleana ie x
process_name opflash particleana ie ie y
byte bytes
Alias for common language habits.
Definition: datasize.h:101
BEGIN_PROLOG could also be cout
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  }
process_name opflash particleana ie x
bool evd::endswith ( const std::string &  s,
const std::string &  suffix 
)

Definition at line 323 of file WebEVDServer.cxx.

324 {
325  return s.rfind(suffix)+suffix.size() == s.size();
326 }
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
EResult evd::err ( const char *  call)

Definition at line 140 of file WebEVDServer.cxx.

141 {
142  std::cout << call << "() error " << errno << " = " << strerror(errno) << std::endl;
143  return kERROR;
144  // return errno;
145 }
BEGIN_PROLOG could also be cout
std::string evd::FindWebDir ( )

Definition at line 194 of file WebEVDServer.cxx.

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

Definition at line 259 of file WebEVDServer.cxx.

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

Definition at line 147 of file WebEVDServer.cxx.

148 {
149  EResult code = kERROR;
150  int run = -1, subrun = -1, evt = -1;
151  bool traces = false;
152 
153  if(cmd == "/QUIT") code = kQUIT;
154  if(cmd == "/NEXT") code = kNEXT;
155  if(cmd == "/PREV") code = kPREV;
156  if(cmd == "/NEXT_TRACES"){ code = kNEXT; traces = true;}
157  if(cmd == "/PREV_TRACES"){ code = kPREV; traces = true;}
158 
159  if(cmd.find("/seek/") == 0 ||
160  cmd.find("/seek_traces/") == 0){
161  if(cmd.find("/seek_traces/") == 0) traces = true;
162 
163  code = kSEEK;
164  char* ctx;
165  strtok_r(cmd.data(), "/", &ctx); // consumes the "seek" text
166  run = atoi(strtok_r(0, "/", &ctx));
167  subrun = atoi(strtok_r(0, "/", &ctx));
168  evt = atoi(strtok_r(0, "/", &ctx));
169  // if this goes wrong we get zeros, which seems a reasonable fallback
170  }
171 
172  write_ok200(sock, "text/html", false);
173 
174  const int delay = (code == kQUIT) ? 2000 : 0;
175  const std::string txt = (code == kQUIT) ? "Goodbye!" : "Please wait...";
176  const std::string next = traces ? "/traces.html" : "/";
177 
178  // The script tag to set the style is a pretty egregious layering violation,
179  // but doing more seems overkill for a simple interstitial page.
180  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();
181 
182  write(sock, msg.c_str(), msg.size());
183  close(sock);
184 
185  if(code == kSEEK){
186  return Result(kSEEK, run, subrun, evt);
187  }
188  else{
189  return code;
190  }
191 }
void write_ok200(int sock, const std::string content="text/html", bool gzip=false)
def write
Definition: util.py:23
TCEvent evt
Definition: DataStructs.cxx:8
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
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
pdgs nucl
Definition: selectors.fcl:22
std::string to_string(WindowPattern const &pattern)
std::string sup(const std::string &a, const std::string &b)
Definition: TruthText.cxx:94
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  {
252  std::string origin;
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 
284  const std::string suffix = ShortInteractionSuffix(truth.GetNeutrino().InteractionType());
285  return origin+incoming+" &rarr; "+outgoing+suffix;
286  }
pdgs p
Definition: selectors.fcl:22
std::string HTMLName(int pdgcode)
HTML entities style.
Definition: TruthText.cxx:121
const Cut kCosmicRay
std::string ShortInteractionSuffix(int iType)
Definition: TruthText.cxx:202
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
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  }
float A
Definition: dedx.py:137
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const art::InputTag &  t 
)

Definition at line 329 of file WebEVDServer.cxx.

330 {
331  json << "\"" << t.label();
332  if(!t.instance().empty()) json << ":" << t.instance();
333  if(!t.process().empty()) json << ":" << t.process();
334  json << "\"";
335  return json;
336 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const geo::OpDetID id 
)

Definition at line 339 of file WebEVDServer.cxx.

340 {
341  json << "\"" << std::string(id) << "\"";
342  return json;
343 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const geo::PlaneID plane 
)

Definition at line 347 of file WebEVDServer.cxx.

348 {
349  return json << "\"" << std::string(plane) << "\"";
350 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const recob::Hit hit 
)

Definition at line 353 of file WebEVDServer.cxx.

354 {
355  return json << "{\"wire\": " << geo::WireID(hit.WireID()).Wire
356  << ", \"tick\": " << hit.PeakTime()
357  << ", \"rms\": " << hit.RMS()
358  << ", \"peakamp\": " << hit.PeakAmplitude() << "}";
359 }
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
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const recob::Vertex vtx 
)

Definition at line 362 of file WebEVDServer.cxx.

363 {
364  return json << TVector3(vtx.position().x(),
365  vtx.position().y(),
366  vtx.position().z());
367 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
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 370 of file WebEVDServer.cxx.

371 {
372  // Don't show MCTruth for cosmic rays, which can be extremely
373  // lengthy. Ideally we should exclude them from the list entirely, but this
374  // requires less change to the structure of the code.
375  if(mct.Origin() == simb::kCosmicRay) return json << "\"\"";
376 
377  return json << "\"" << MCTruthShortText(mct) << "\"";
378 }
const Cut kCosmicRay
std::string MCTruthShortText(const simb::MCTruth &truth)
Definition: TruthText.cxx:250
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const geo::Point_t pt 
)

Definition at line 381 of file WebEVDServer.cxx.

382 {
383  return json << TVector3(pt.X(), pt.Y(), pt.Z());
384 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const sim::SimEnergyDeposit edep 
)

Definition at line 387 of file WebEVDServer.cxx.

388 {
389  return json << "{\"pdg\": " << edep.PdgCode() << ", "
390  << "\"start\": " << edep.Start() << ", "
391  << "\"end\": " << edep.End() << ", "
392  << "\"edep\": " << edep.Energy()
393  << "}";
394 }
geo::Point_t Start() const
geo::Point_t End() const
basic_json<> json
default JSON class
Definition: json.hpp:2445
double Energy() const
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const recob::SpacePoint sp 
)

Definition at line 397 of file WebEVDServer.cxx.

398 {
399  return json << TVector3(sp.XYZ());
400 }
const Double32_t * XYZ() const
Definition: SpacePoint.h:76
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const recob::Track track 
)

Definition at line 403 of file WebEVDServer.cxx.

404 {
405  std::vector<TVector3> pts;
406 
407  const recob::TrackTrajectory& traj = track.Trajectory();
408  for(unsigned int j = traj.FirstValidPoint(); j <= traj.LastValidPoint(); ++j){
409  if(!traj.HasValidPoint(j)) continue;
410  const geo::Point_t pt = traj.LocationAtPoint(j);
411  pts.emplace_back(pt.X(), pt.Y(), pt.Z());
412  }
413 
414  return json << "{ \"positions\": " << pts << " }";
415 }
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
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.
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
basic_json<> json
default JSON class
Definition: json.hpp:2445
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
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const simb::MCParticle &  part 
)

Definition at line 418 of file WebEVDServer.cxx.

419 {
420  const int apdg = abs(part.PdgCode());
421  if(apdg == 12 || apdg == 14 || apdg == 16) return json << "{ \"pdg\": " << apdg << ", \"positions\": [] }"; // decay neutrinos
422  std::vector<TVector3> pts;
423  for(unsigned int j = 0; j < part.NumberTrajectoryPoints(); ++j){
424  pts.emplace_back(part.Vx(j), part.Vy(j), part.Vz(j));
425  }
426 
427  return json << "{ \"pdg\": " << apdg << ", \"positions\": " << pts << " }";
428 }
T abs(T value)
basic_json<> json
default JSON class
Definition: json.hpp:2445
JSONFormatter& evd::operator<< ( JSONFormatter &  json,
const recob::OpFlash flash 
)

Definition at line 431 of file WebEVDServer.cxx.

432 {
433  json << std::map<std::string, double>{
434  {"tcenter", flash.Time()},
435  {"twidth", flash.TimeWidth()},
436  {"ycenter", flash.YCenter()},
437  {"ywidth", flash.YWidth()},
438  {"zcenter", flash.ZCenter()},
439  {"zwidth", flash.ZWidth()},
440  {"totpe", flash.TotalPE()}
441  };
442 
443  return json;
444 }
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
basic_json<> json
default JSON class
Definition: json.hpp:2445
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 447 of file WebEVDServer.cxx.

448 {
449  const TVector3 r0(cryo.MinX(), cryo.MinY(), cryo.MinZ());
450  const TVector3 r1(cryo.MaxX(), cryo.MaxY(), cryo.MaxZ());
451  return json << "{ \"min\": " << r0 << ", \"max\": " << r1 << " }";
452 }
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.
basic_json<> json
default JSON class
Definition: json.hpp:2445
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 455 of file WebEVDServer.cxx.

456 {
457  return json << "{ \"name\": " << opdet.ID() << ", "
458  << "\"center\": " << TVector3(opdet.GetCenter().X(),
459  opdet.GetCenter().Y(),
460  opdet.GetCenter().Z()) << ", "
461  << "\"length\": " << opdet.Length() << ", "
462  << "\"width\": " << opdet.Width() << ", "
463  << "\"height\": " << opdet.Height() << " }";
464 }
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
basic_json<> json
default JSON class
Definition: json.hpp:2445
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 467 of file WebEVDServer.cxx.

468 {
469  bool first = true;
470  os << "{\"blocks\": [\n";
471  for(unsigned int ix = 0; ix < v.blocks.size(); ++ix){
472  for(unsigned int iy = 0; iy < v.blocks[ix].size(); ++iy){
473  const png_byte* b = v.blocks[ix][iy];
474  if(!b) continue;
475 
476  if(!first) os << ",\n";
477  first = false;
478 
479  int dataidx = 0;
480  for(unsigned int d = 0; d < v.arena.data.size(); ++d){
481  if(b >= &v.arena.data[d]->front() &&
482  b < &v.arena.data[d]->front() + 4*PNGArena::kArenaSize*PNGArena::kArenaSize){
483  dataidx = d;
484  break;
485  }
486  }
487 
488  const int texdx = ((b-&v.arena.data[dataidx]->front())/4)%PNGArena::kArenaSize;
489  const int texdy = ((b-&v.arena.data[dataidx]->front())/4)/PNGArena::kArenaSize;
490 
491  os << "{"
492  << "\"x\": " << ix*PNGArena::kBlockSize << ", "
493  << "\"y\": " << iy*PNGArena::kBlockSize << ", "
494  << "\"dx\": " << PNGArena::kBlockSize << ", "
495  << "\"dy\": " << PNGArena::kBlockSize << ", "
496  << "\"fname\": \"" << v.arena.name << "_" << dataidx << "\", "
497  << "\"texdim\": " << PNGArena::kArenaSize << ", "
498  << "\"u\": " << texdx << ", "
499  << "\"v\": " << texdy << ", "
500  << "\"du\": " << PNGArena::kBlockSize << ", "
501  << "\"dv\": " << PNGArena::kBlockSize
502  << "}";
503  }
504  }
505  os << "\n]}";
506  return os;
507 }
unsigned char png_byte
Definition: PNGArena.h:10
std::string evd::read_all ( int  sock)

Definition at line 125 of file WebEVDServer.cxx.

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

Definition at line 705 of file WebEVDServer.cxx.

708 {
709  // [tag][plane][wire index][t0]
710  std::map<art::InputTag, std::map<geo::PlaneID, std::map<int, std::map<int, std::vector<short>>>>> traces;
711 
712  for(art::InputTag tag: evt.template getInputTags<std::vector<raw::RawDigit>>()){
713  typename T::template HandleT<std::vector<raw::RawDigit>> digs; // deduce handle type
714  // This can fail in the case of dropped products
715  if(!evt.getByLabel(tag, digs)) continue;
716 
717  for(const raw::RawDigit& dig: *digs){
718  for(geo::WireID wire: geom->ChannelToWire(dig.Channel())){
719  const geo::PlaneID plane(wire);
720 
721  raw::RawDigit::ADCvector_t adcs(dig.Samples());
722  raw::Uncompress(dig.ADCs(), adcs, dig.Compression());
723 
724  traces[tag][plane][wire.Wire] = ToSnippets(adcs, short(dig.GetPedestal()));
725  } // end for wire
726  } // end for dig
727  } // end for tag
728 
729  json << traces;
730 }
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.
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
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 553 of file WebEVDServer.cxx.

554 {
555  typedef std::map<std::string, int> EIdMap;
556  json << EIdMap({{"run", evt.run()}, {"subrun", evt.subRun()}, {"evt", evt.event()}});
557 }
unsigned int event
Definition: DataStructs.h:634
unsigned int run
Definition: DataStructs.h:635
unsigned int subRun
Definition: DataStructs.h:636
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
void evd::SerializeEventID ( const ThreadsafeGalleryEvent &  evt,
JSONFormatter &  json 
)

Definition at line 560 of file WebEVDServer.cxx.

561 {
562  SerializeEventID(evt.eventAuxiliary(), json);
563 }
void SerializeEventID(const T &evt, JSONFormatter &json)
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
void evd::SerializeGeometry ( const geo::GeometryCore geom,
const detinfo::DetectorPropertiesData detprop,
JSONFormatter &  json 
)

Definition at line 617 of file WebEVDServer.cxx.

620 {
621  json << "{\n";
622  SerializePlanes(geom, detprop, json);
623  json << ",\n\n";
624 
625  json << " \"cryos\": [\n";
626  for(unsigned int i = 0; i < geom->Ncryostats(); ++i){
627  json << " " << geom->Cryostat(i);
628  if(i != geom->Ncryostats()-1) json << ",\n"; else json << "\n";
629  }
630  json << " ],\n\n";
631 
632  json << " \"opdets\": [\n";
633  for(unsigned int i = 0; i < geom->NOpDets(); ++i){
634  json << " " << geom->OpDetGeoFromOpDet(i);
635  if(i != geom->NOpDets()-1) json << ",\n"; else json << "\n";
636  }
637  json << " ]\n";
638  json << "}\n";
639 }
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.
basic_json<> json
default JSON class
Definition: json.hpp:2445
template<class T >
void evd::SerializeHits ( const T &  evt,
const geo::GeometryCore geom,
JSONFormatter &  json 
)

Definition at line 643 of file WebEVDServer.cxx.

644 {
645  std::map<art::InputTag, std::map<geo::PlaneID, std::vector<recob::Hit>>> plane_hits;
646 
647  for(art::InputTag tag: evt.template getInputTags<std::vector<recob::Hit>>()){
648  typename T::template HandleT<std::vector<recob::Hit>> hits; // deduce handle type
649  // This can fail in the case of dropped products
650  if(!evt.getByLabel(tag, hits)) continue;
651 
652  for(const recob::Hit& hit: *hits){
653  // Would possibly be right for disambiguated hits?
654  // const geo::WireID wire(hit.WireID());
655 
656  for(geo::WireID wire: geom->ChannelToWire(hit.Channel())){
657  const geo::PlaneID plane(wire);
658 
659  // Correct for disambiguated hits
660  // plane_hits[plane].push_back(hit);
661 
662  // Otherwise we have to update the wire number
663  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);
664  }
665  }
666  } // end for tag
667 
668  json << plane_hits;
669 }
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.
process_name hit
Definition: cheaterreco.fcl:51
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
void evd::SerializePlanes ( const geo::GeometryCore geom,
const detinfo::DetectorPropertiesData detprop,
JSONFormatter &  json 
)

Definition at line 566 of file WebEVDServer.cxx.

569 {
570  bool first = true;
571 
572  json << " \"planes\": {\n";
573  for(geo::PlaneID plane: geom->IteratePlaneIDs()){
574  const geo::PlaneGeo& planegeo = geom->Plane(plane);
575  const int view = planegeo.View();
576  const unsigned int nwires = planegeo.Nwires();
577  const double pitch = planegeo.WirePitch();
578  const TVector3 c = planegeo.GetCenter();
579 
580  const TVector3 d = planegeo.GetIncreasingWireDirection();
581  const TVector3 n = planegeo.GetNormalDirection();
582  const TVector3 wiredir = planegeo.GetWireDirection();
583 
584  const double depth = planegeo.Depth();
585  const double width = planegeo.Width();
586  const TVector3 depthdir = planegeo.DepthDir();
587  const TVector3 widthdir = planegeo.WidthDir();
588 
589  const double tick_origin = detprop.ConvertTicksToX(0, plane);
590  const double tick_pitch = detprop.ConvertTicksToX(1, plane) - tick_origin;
591 
592  const int maxTick = detprop.NumberTimeSamples();
593 
594  if(!first) json << ",\n";
595  first = false;
596 
597  json << " " << plane << ": {"
598  << "\"view\": " << view << ", "
599  << "\"nwires\": " << nwires << ", "
600  << "\"pitch\": " << pitch << ", "
601  << "\"nticks\": " << maxTick << ", "
602  << "\"tick_origin\": " << tick_origin << ", "
603  << "\"tick_pitch\": " << tick_pitch << ", "
604  << "\"center\": " << c << ", "
605  << "\"across\": " << d << ", "
606  << "\"wiredir\": " << wiredir << ", "
607  << "\"depth\": " << depth << ", "
608  << "\"width\": " << width << ", "
609  << "\"depthdir\": " << depthdir << ", "
610  << "\"widthdir\": " << widthdir << ", "
611  << "\"normal\": " << n << "}";
612  }
613  json << "\n }";
614 }
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
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
basic_json<> json
default JSON class
Definition: json.hpp:2445
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 511 of file WebEVDServer.cxx.

512 {
513  json << "{";
514 
515  const std::vector<art::InputTag> tags = evt.template getInputTags<std::vector<TProd>>();
516 
517  for(const art::InputTag& tag: tags){
518  typename TEvt::template HandleT<std::vector<TProd>> prods; // deduce handle type
519  // This can fail in the case of dropped products
520  if(!evt.getByLabel(tag, prods)) continue;
521 
522  json << " " << tag << ": ";
523 
524  json << *prods;
525 
526  if(tag != tags.back()){
527  json << ",";
528  }
529  json << "\n";
530  }
531 
532  json << "}";
533 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
template<class TProd , class TEvt >
void evd::SerializeProductByLabel ( const TEvt &  evt,
const std::string &  in_label,
JSONFormatter &  json 
)

Definition at line 537 of file WebEVDServer.cxx.

540 {
541  typename TEvt::template HandleT<std::vector<TProd>> prods; // deduce handle type
542  evt.getByLabel(in_label, prods);
543 
544  if(prods.isValid()){
545  json << *prods;
546  }
547  else{
548  json << "[]";
549  }
550 }
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
template<class T >
void evd::SerializeWireTraces ( const T &  evt,
const geo::GeometryCore geom,
JSONFormatter &  json 
)

Definition at line 733 of file WebEVDServer.cxx.

736 {
737  // [tag][plane][wire][t0]
738  std::map<art::InputTag, std::map<geo::PlaneID, std::map<int, std::map<int, std::vector<float>>>>> traces;
739 
740  for(art::InputTag tag: evt.template getInputTags<std::vector<recob::Wire>>()){
741  typename T::template HandleT<std::vector<recob::Wire>> wires; // deduce handle type
742  // This can fail in the case of dropped products
743  if(!evt.getByLabel(tag, wires)) continue;
744 
745  for(const recob::Wire& rbwire: *wires){
746  // Place all wire traces on the first wire (== channel) they are found on
747  const geo::WireID wire = geom->ChannelToWire(rbwire.Channel())[0];
748  const geo::PlaneID plane(wire);
749 
750  traces[tag][plane][wire.Wire] = ToSnippets(rbwire.Signal());
751  } // end for rbwire
752  } // end for tag
753 
754  json << traces;
755 }
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
basic_json<> json
default JSON class
Definition: json.hpp:2445
TCEvent evt
Definition: DataStructs.cxx:8
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  }
resonant neutral current, nu p -&gt; nu p pi0
Definition: SREnums.h:91
resonant charged current, nubar p -&gt; nubar p pi0
Definition: SREnums.h:98
resonant charged current, nubar n -&gt; nubar p pi-
Definition: SREnums.h:101
resonant charged current, nu n -&gt; l- n pi+
Definition: SREnums.h:90
resonant charged current, nubar p -&gt; l+ p pi-
Definition: SREnums.h:97
resonant neutral current, nu n -&gt; nu p pi-
Definition: SREnums.h:94
charged current deep inelastic scatter
Definition: SREnums.h:124
resonant neutral current, nu n -&gt; nu n pi0
Definition: SREnums.h:93
resonant charged current, nubar p -&gt; nubar n pi+
Definition: SREnums.h:99
charged current coherent pion
Definition: SREnums.h:129
resonant neutral current, nu p -&gt; nu p pi+
Definition: SREnums.h:92
resonant charged current, nu n -&gt; l- p pi0
Definition: SREnums.h:89
resonant charged current, nubar n -&gt; l+ n pi-
Definition: SREnums.h:95
resonant charged current, nubar p -&gt; l+ n pi0
Definition: SREnums.h:96
resonant charged current, nubar n -&gt; nubar n pi0
Definition: SREnums.h:100
neutral current quasi-elastic
Definition: SREnums.h:87
charged current quasi-elastic
Definition: SREnums.h:86
resonant charged current, nu p -&gt; l- p pi+
Definition: SREnums.h:88
charged current deep inelastic scatter
Definition: SREnums.h:123
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  }
process_name gaushit a
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  }
process_name gaushit a
short evd::swap_byte_order ( short  x)

Definition at line 78 of file WebEVDServer.cxx.

79 {
80  char* cx = (char*)&x;
81  std::swap(cx[0], cx[1]);
82  return x;
83 }
process_name opflash particleana ie x
template<class T >
std::map<int, std::vector<T> > evd::ToSnippets ( const std::vector< T > &  adcs,
pedestal = 0 
)

Definition at line 672 of file WebEVDServer.cxx.

673 {
674  std::vector<T> snip;
675  snip.reserve(adcs.size());
676 
677  std::map<int, std::vector<T>> snips;
678 
679  int t = 0;
680  for(T adc: adcs){
681  if(adc == 0){
682  if(!snip.empty()){
683  snips[t-snip.size()] = snip;
684  snip.clear();
685  }
686  }
687  else{
688  snip.push_back(adc - pedestal);
689  }
690 
691  ++t;
692  } // end for adc
693 
694  // Save last in-progress snippet if necessary
695  if(!snip.empty()) snips[t-snip.size()] = snip;
696 
697  // this is a bit of a hack to teach the viewer how long the full trace
698  // is
699  snips[adcs.size()] = {};
700 
701  return snips;
702 }
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  }
BEGIN_PROLOG could also be cout
void evd::write_compressed_buffer ( unsigned char *  src,
int  length,
int  sock,
int  level,
const std::string &  name 
)

Definition at line 291 of file WebEVDServer.cxx.

296 {
297  std::vector<unsigned char> dest;
298  gzip_buffer(src, length, dest, level);
299 
300  std::cout << "Writing " << length << " bytes (compressed to " << dest.size() << ") for " << name << "\n" << std::endl;
301 
302  write(sock, dest.data(), dest.size());
303 }
def write
Definition: util.py:23
void gzip_buffer(unsigned char *src, int length, std::vector< unsigned char > &dest, int level)
then echo fcl name
BEGIN_PROLOG could also be cout
void evd::write_compressed_file ( const std::string &  loc,
int  fd_out,
int  level 
)

Definition at line 306 of file WebEVDServer.cxx.

307 {
308  int fd_in = open(loc.c_str(), O_RDONLY);
309 
310  // Map in the whole file
311  struct stat st;
312  fstat(fd_in, &st);
313  unsigned char* src = (unsigned char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd_in, 0);
314 
315  write_compressed_buffer(src, st.st_size, fd_out, level, loc);
316 
317  munmap(src, st.st_size);
318 
319  close(fd_in);
320 }
void write_compressed_buffer(unsigned char *src, int length, int sock, int level, const std::string &name)
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
open(RACETRACK) or die("Could not open file $RACETRACK for writing")
void evd::write_notfound404 ( int  sock)

Definition at line 101 of file WebEVDServer.cxx.

102 {
103  const char str[] =
104  "HTTP/1.0 404 Not Found\r\n"
105  "Server: WebEVD/1.0.0\r\n"
106  "Content-Type: text/plain\r\n"
107  "\r\n"
108  "404. Huh?\r\n";
109 
110  write(sock, str, strlen(str));
111 }
def write
Definition: util.py:23
void evd::write_ok200 ( int  sock,
const std::string  content = "text/html",
bool  gzip = false 
)

Definition at line 85 of file WebEVDServer.cxx.

88 {
89  std::string str =
90  "HTTP/1.0 200 OK\r\n"
91  "Server: WebEVD/1.0.0\r\n"
92  "Content-Type: "+content+"\r\n";
93 
94  if(gzip) str += "Content-Encoding: gzip\r\n";
95 
96  str += "\r\n";
97 
98  write(sock, &str.front(), str.size());
99 }
def write
Definition: util.py:23
void evd::write_unimp501 ( int  sock)

Definition at line 113 of file WebEVDServer.cxx.

114 {
115  const char str[] =
116  "HTTP/1.0 501 Not Implemented\r\n"
117  "Server: WebEVD/1.0.0\r\n"
118  "Content-Type: text/plain\r\n"
119  "\r\n"
120  "I don't know how to do that\r\n";
121 
122  write(sock, str, strlen(str));
123 }
def write
Definition: util.py:23

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 30 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 32 of file TQPad.cxx.

const int evd::kRAW = 0
static

Definition at line 29 of file TQPad.cxx.

const int evd::kTQ = 1
static

Definition at line 33 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.