Namespaces | Classes | Typedefs | Functions | Variables
lem Namespace Reference

$ \nu_e $ PID More...

Namespaces

 dec
 Decision tree PID.
 

Classes

class  AlignLibToVtx
 Rewrite a library file with events aligned according to vertex. More...
 
class  ApplyFilter
 Filter according to FilterList status of largest slice. More...
 
class  BackgroundEnricher
 Filter to remove non-pizero interactions. More...
 
class  DistanceMap
 Calculate and cache electrostatic potential between cells. More...
 
class  EventSummary
 Simple representation of event for LEM use. More...
 
class  FindLEMMatches
 Module to find best LEM matches. More...
 
class  FindMatchesAlg
 
class  FindMatchesTranspose
 
struct  FlippedPotentials
 Collection of Potential objects with odd and/or even view flipped. More...
 
class  GenFromLib
 Reconstitute ART events from a LEM library. More...
 
struct  GetWorkArgs
 
class  Heads
 Mapping from a subset of the library to their best matches. More...
 
class  HeadsTranspose
 
class  LEM
 Module to find best LEM matches. More...
 
class  LEMAssociator
 
class  LEMClient
 Fetch LEM PID result from remote server. More...
 
class  LEMInput
 
class  LEMLibrary
 Provide access to the LEM library to all modules. More...
 
class  LEMMixer
 
class  LEMSummarizer
 Transform slices into the minimal description LEM needs to PID them. More...
 
struct  LEMWebSettings
 
class  LEMWorker
 This runs on a high-mem node and reconstitutes LEMSummary events. More...
 
class  LEMWorkerOutput
 Runs after LEM on the high-mem node, returns results to the server. More...
 
class  Library
 Collection of events for matching. More...
 
class  LibrarySummary
 Details of the library LEM matches were made against. More...
 
class  LiteHit
 Compressed hit info, basic component of LEM events. More...
 
class  MakeLibrary
 Summarize ART events into LEM libary format. More...
 
class  MakeMatches
 Calculate final PID variables from match details. More...
 
class  MakePID
 Calculate final PID variables from match details. More...
 
class  Match
 Information about a LEM match. More...
 
class  MatchableEvent
 Attach some information used in matching to an EventSummary. More...
 
class  MatchIndices
 List of indices of matched events. More...
 
class  MatchList
 Collection of MatchSummary objects. More...
 
struct  MatchSummary
 Simplified Match information, suitable for serialization. More...
 
class  MergeMatches
 Merge LEM match lists from split running. More...
 
class  PIDDetails
 Attach LEM-specific info to the base PID object. More...
 
class  PIDExtraVars
 Outputs of the MakePID module. More...
 
class  PIDInput
 Attach MatchList and other useful stuff. More...
 
class  Potential
 Map of electrostatic potential at each cell. More...
 
class  Preselection
 
struct  ReturnResultsArgs
 
class  SortedMatchList
 
class  UnTranspose
 

Typedefs

typedef art::Source< GenFromLibGenFromLibSource
 

Functions

double SimpleSurvivalProb (const EventSummary &evt)
 
float CalcEnergy (const Potential &Va, const MatchableEvent &a, const MatchableEvent &b)
 
double FracChargeMatched (const EventSummary &a, const EventSummary &b, bool flipEven, bool flipOdd)
 
void FillPotential (const EventSummary &trial, Potential &V, bool flipEven, bool flipOdd)
 
void FillPotential (const EventSummary &trial, FlippedPotentials &Vs)
 
std::vector< MatchFindMatches (const MatchableEvent &trial, unsigned int libSize, const MatchableEvent *lib, const MatchableEvent *libDownsample, int factor, const std::multiset< float > &alreadyInput, unsigned int numMatches, int enrich, const Heads *heads, int headIdx, bool flipHeadEven, bool flipHeadOdd, bool useDownsample)
 
std::ostream & operator<< (std::ostream &os, const lem::Heads &hs)
 
std::ostream & operator<< (std::ostream &os, const lem::HeadsTranspose &hs)
 
std::ostream & operator<< (std::ostream &os, const lem::LibrarySummary &ls)
 
bool compareByCell (const LiteHit &a, const LiteHit &b)
 
bool compareByPlane (const LiteHit &a, const LiteHit &b)
 
std::ostream & operator<< (std::ostream &os, const lem::LiteHit &h)
 
void SetOnDemandMemoryLimit (long limit_mb)
 
void CreateOnDemandMapping (const std::string &fname, const char *base)
 
long MMapFileAtAddress (const std::string &fname, void *addr, bool touchAll, const std::string &lockName)
 
voidGetWorkThreadFunc (void *x)
 
voidReturnResultsThreadFunc (void *x)
 
int Clamp (int x)
 
int MeanCell (geo::View_t view, const rb::Cluster &slice)
 
void DefaultVertex (const rb::Cluster &slice, int &plane, int &cell, int &cellOtherView, bool reverse)
 
geo::CellUniqueId FindCellRobust (double x, double y, double z)
 Steps around a bit. Can still return zero for total failure. More...
 
void VertexToPlaneAndCell (const TVector3 vtx, const rb::Cluster &slice, int &plane, int &cell, int &cellOtherView, bool reverse)
 
size_t writeMemoryCallback (void *contents, size_t size, size_t nmemb, void *userp)
 
std::string get_http_response_internal (const std::string &host, const std::string &query, const std::string &postdata, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
 
std::string get_query (const std::string &host, const std::string &query, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
 Make an HTTP GET query. More...
 
std::string post_query (const std::string &host, const std::string &query, const std::string &postdata, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
 Make an HTTP POST query. More...
 
std::string get_release ()
 Figure out the current release. TODO: does this belong somewhere else? More...
 

Variables

const int kNumPlanes = 256
 
const int kNumCells = 256
 
const int kVertexPlane = 64
 
const int kVertexCell = 128
 
const unsigned int kMaxNumMatches = 1001
 

Detailed Description

$ \nu_e $ PID

Provide access to the LEM library to all modules.

Author
Christopher Backhouse - bckho.nosp@m.use@.nosp@m.calte.nosp@m.ch.e.nosp@m.du

Typedef Documentation

Definition at line 216 of file GenFromLib_source.cc.

Function Documentation

float lem::CalcEnergy ( const Potential Va,
const MatchableEvent a,
const MatchableEvent b 
)

Definition at line 21 of file FindMatches.cxx.

References lem::LiteHit::cellIdx, energy, lem::EventSummary::hits, MECModelEnuComparisons::i, Nb, lem::EventSummary::nhits, lem::LiteHit::pecorr, lem::MatchableEvent::selfEnergy, and lem::Potential::V.

Referenced by lem::FindMatchesAlg::BestHeadFor(), lem::FindMatchesTranspose::endRun(), FindMatches(), lem::FindMatchesAlg::FindMatchesHeads(), lem::FindMatchesAlg::FindMatchesNoHeads(), and lem::LEM::produce().

22  {
23  float energy = a.selfEnergy + b.selfEnergy;
24 
25  const LiteHit* hb = b.hits;
26  const unsigned int Nb = b.nhits;
27 
28  for(unsigned int i = 0; i < Nb; ++i){
29  energy -= hb->pecorr*Va.V[hb->cellIdx];
30  ++hb;
31  }
32 
33  return energy;
34  }
const double a
double energy
Definition: plottest35.C:25
const hit & b
Definition: hits.cxx:21
const int Nb
int lem::Clamp ( int  x)

Definition at line 154 of file MakeLibrary_module.cc.

References cet::sqlite::max(), and min().

Referenced by lem::MakeLibrary::produce(), ana::FitSinSq2Theta13::SetValue(), ana::FitSinSqTheta23::SetValue(), FitSinSqTheta23UO::SetValue(), ana::FitSinSqTheta23UpperOctant::SetValue(), FitSinSqTheta23LO::SetValue(), ana::FitTheta13Sterile::SetValue(), ana::FitSinSqTheta23LowerOctant::SetValue(), ana::FitSinSqTheta13Sterile::SetValue(), ana::FitSinSq2Theta23::SetValue(), ana::FitSinSq2Theta13Sterile::SetValue(), ana::FitDmSq32::SetValue(), ana::FitTheta23Sterile::SetValue(), ana::FitDmSq32Scaled::SetValue(), ana::FitSinSqTheta23Sterile::SetValue(), ana::FitDmSq32NormalHierarchy::SetValue(), ana::FitTheta14Sterile::SetValue(), ana::FitDmSq32ScaledNH::SetValue(), ana::FitSinSqTheta14Sterile::SetValue(), ana::FitDmSq32ScaledIH::SetValue(), ana::FitTheta24Sterile::SetValue(), ana::FitDmSq32InvertedHierarchy::SetValue(), FitSinSqTheta23MaxMix::SetValue(), ana::FitSinSqTheta24Sterile::SetValue(), ana::FitTanSqTheta12::SetValue(), ana::FitSinSq2Theta12::SetValue(), ana::FitTheta34Sterile::SetValue(), ana::FitDmSq21::SetValue(), ana::FitSinSqTheta34Sterile::SetValue(), ana::FitTheta13InDegreesSterile::SetValue(), ana::FitTheta23InDegreesSterile::SetValue(), ana::FitTheta14InDegreesSterile::SetValue(), ana::FitTheta24InDegreesSterile::SetValue(), and ana::FitTheta34InDegreesSterile::SetValue().

155  {
156  return std::min(std::max(0, x), 255);
157  }
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
bool lem::compareByCell ( const LiteHit a,
const LiteHit b 
)

Definition at line 11 of file LiteHit.cxx.

References lem::LiteHit::Cell().

Referenced by lem::LiteHit::operator<().

12  {
13  return a.Cell() < b.Cell();
14  }
const double a
const hit & b
Definition: hits.cxx:21
bool lem::compareByPlane ( const LiteHit a,
const LiteHit b 
)

Definition at line 16 of file LiteHit.cxx.

References lem::LiteHit::Plane().

Referenced by lem::LiteHit::operator<().

17  {
18  return a.Plane() < b.Plane();
19  }
const double a
const hit & b
Definition: hits.cxx:21
void lem::CreateOnDemandMapping ( const std::string &  fname,
const char *  base 
)

Definition at line 123 of file OnDemand.cxx.

References ana::assert(), fclose(), and fileno.

Referenced by lem::Heads::FromMMapOnDemand(), lem::Library::FromMMapOnDemand(), and lem::HeadsTranspose::FromMMapOnDemand().

124  {
125  // Must be aligned on OS pages
126  assert(long(base)%(4*1024) == 0);
127 
128  // Open the file to check it exists and find out its length
129  FILE* f = fopen(fname.c_str(), "r");
130  assert(f);
131 
132  struct stat st;
133  fstat(fileno(f), &st);
134  const long fsize = st.st_size;
135  fclose(f);
136 
137 
138  gMappings.push_back(Mapping(fname, base, fsize));
139 
140  // Set up signal handler to fault this file (and others) in on demand. It
141  // should be OK to do this multiple times.
142  struct sigaction sa;
143  memset(&sa, 0, sizeof(sa));
144  sigemptyset(&sa.sa_mask);
145 
146  sa.sa_sigaction = segfault_sigaction;
147  sa.sa_flags = SA_SIGINFO;
148 
149  sigaction(SIGSEGV, &sa, NULL);
150  }
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
fclose(fg1)
assert(nhit_max >=nhit_nbins)
unsigned int fileno
Definition: runWimpSim.h:102
void lem::DefaultVertex ( const rb::Cluster slice,
int plane,
int cell,
int cellOtherView,
bool  reverse 
)

Definition at line 20 of file Util.cxx.

References geom(), rb::Cluster::MaxPlane(), MeanCell(), rb::Cluster::MinPlane(), geo::GeometryBase::NPlanes(), geo::GeometryBase::Plane(), POTSpillRate::view, and geo::PlaneGeo::View().

Referenced by lem::LEMSummarizer::produce(), lem::AlignLibToVtx::produce(), and VertexToPlaneAndCell().

23  {
25 
26  // Fallback when everything goes wrong.
27 
28  // Just put the vertex at the top of the slice in the middle
29 
30  plane = reverse ? slice.MaxPlane() : slice.MinPlane();
31  if(plane < 0 || plane >= int(geom->NPlanes())) plane = 0; // arghhh
32  const geo::View_t view = geom->Plane(plane)->View();
33  cell = MeanCell(view, slice);
34  cellOtherView = MeanCell(geo::View_t(1-view), slice);
35  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const PlaneGeo * Plane(unsigned int i) const
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:53
int MeanCell(geo::View_t view, const rb::Cluster &slice)
Definition: Util.cxx:14
unsigned int MinPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.cxx:462
void geom(int which=0)
Definition: geom.C:163
unsigned int MaxPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.cxx:508
unsigned int NPlanes() const
void lem::FillPotential ( const EventSummary trial,
Potential V,
bool  flipEven,
bool  flipOdd 
)

Definition at line 76 of file FindMatches.cxx.

References abs(), getBrightness::cell, lem::LiteHit::Cell(), make_syst_table_plots::h, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::DistanceMap::Instance(), lem::DistanceMap::InvDist(), kVertexCell, lem::EventSummary::nhits, lem::LiteHit::pecorr, lem::LiteHit::Plane(), NDAPDHVSetting::plane, lem::Potential::V, and POTSpillRate::view.

Referenced by lem::FindLEMMatches::AddHists(), lem::LEM::AddHists(), FindMatches(), lem::FindMatchesAlg::FindMatchesHeads(), lem::FindMatchesAlg::FindMatchesNoHeads(), lem::FindMatchesTranspose::produce(), lem::LEM::produce(), and show_potential().

78  {
79  const DistanceMap& dm = DistanceMap::Instance();
80 
81  const unsigned int N = trial.nhits;
82 
83  for(unsigned int i = 0; i < N; ++i){
84  const LiteHit& h = trial.hits[i];
85 
86  // Doesn't matter? Has to match in qfrac definition
87  const int view = abs(h.Plane())%2;
88 
89  int hc = h.Cell();
90  if((flipEven && view == 0) || (flipOdd && view == 1))
91  hc = 2*lem::kVertexCell-hc;
92 
93  for(int plane = 0; plane < 256; ++plane){
94  // Only in the same view
95  if(abs(plane-h.Plane())%2) continue;
96  for(int cell = 0; cell < 256; ++cell){
97 
98  const double contrib = h.pecorr*dm.InvDist(plane, h.Plane(),
99  cell, hc);
100 
101  V.V[256*plane+cell] += contrib;
102  }
103  }
104  }
105  }
void abs(TH1 *hist)
const int kVertexCell
Definition: EventSummary.h:23
void lem::FillPotential ( const EventSummary trial,
FlippedPotentials Vs 
)

Definition at line 108 of file FindMatches.cxx.

References abs(), getBrightness::cell, lem::LiteHit::Cell(), make_associated_cosmic_defs::fc, make_syst_table_plots::h, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::DistanceMap::Instance(), lem::DistanceMap::InvDist(), kVertexCell, lem::EventSummary::nhits, lem::LiteHit::pecorr, lem::LiteHit::Plane(), NDAPDHVSetting::plane, lem::Potential::V, lem::FlippedPotentials::V, and POTSpillRate::view.

109  {
110  // We could just call FillPotential 4 times with each flip variant like so
111  /*
112  for(bool flipEven: {false, true}){
113  for(bool flipOdd: {false, true}){
114  FillPotential(trial, Vs.V[flipEven][flipOdd], flipEven, flipOdd);
115  }
116  }
117  */
118 
119  // But this function actually takes noticeable runtime, so instead just
120  // fill it once, and then copy into the over three flips.
121  const DistanceMap& dm = DistanceMap::Instance();
122 
123  const unsigned int N = trial.nhits;
124 
125  // There's a complication because 256 is odd there isn't a perfect
126  // centreline to flip round. The way things are defined, we end up needing
127  // to know what cell 256 in the original map would have been, which we
128  // don't have. Make a place to store it here.
129  float overflow[256] = {0,};
130 
131  for(unsigned int i = 0; i < N; ++i){
132  const LiteHit& h = trial.hits[i];
133 
134  for(int plane = 0; plane < 256; ++plane){
135  // Only in the same view
136  if(abs(plane-h.Plane())%2) continue;
137  for(int cell = 0; cell < 256; ++cell){
138 
139  const double contrib = h.pecorr*dm.InvDist(plane, h.Plane(),
140  cell, h.Cell());
141 
142  Vs.V[false][false].V[256*plane+cell] += contrib;
143  }
144  // And one for cell 256, stored seperately
145  overflow[plane] += h.pecorr*dm.InvDist(plane, h.Plane(),
146  256, h.Cell());
147  }
148  }
149 
150  // Now copy over into the flipped variants
151 
152  for(bool flipEven: {false, true}){
153  for(bool flipOdd: {false, true}){
154  if(!flipEven && !flipOdd) continue;
155 
156  for(int plane = 0; plane < 256; ++plane){
157  const int view = plane%2;
158 
159  for(int cell = 0; cell < 256; ++cell){
160 
161  int fc = cell; // flipped cell
162  if((flipEven && view == 0) || (flipOdd && view == 1))
163  fc = 2*lem::kVertexCell-fc;
164 
165  if(fc >= 0 && fc < 256)
166  Vs.V[flipEven][flipOdd].V[plane*256+cell] = Vs.V[false][false].V[plane*256+fc];
167  if(fc == 256) Vs.V[flipEven][flipOdd].V[plane*256+cell] = overflow[plane];
168  }
169  }
170  }
171  }
172  }
void abs(TH1 *hist)
const int kVertexCell
Definition: EventSummary.h:23
geo::CellUniqueId lem::FindCellRobust ( double  x,
double  y,
double  z 
)

Steps around a bit. Can still return zero for total failure.

Definition at line 38 of file Util.cxx.

References geo::GeometryBase::CellId(), and geom().

Referenced by VertexToPlaneAndCell().

39  {
41 
42  for(int trial = 0; trial < 4; ++trial){
43  // Figure out what cell the vertex was in. Step 3cm in z in case of
44  // failure. If that didn't work, it must be in plastic between cells,
45  // move laterally in x or y.
46  double offsetX = 0, offsetY = 0;
47  if(trial == 1) offsetX = -2;
48  if(trial == 2) offsetY = -2;
49  if(trial == 3) offsetX = offsetY = -2;
50 
51  const geo::CellUniqueId id = geom->CellId(x+offsetX, y+offsetY, z,
52  0, 0, 1, 3);
53  // We found one that works
54  if(id) return id;
55  }
56  return 0;
57  }
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
const CellUniqueId CellId(const double &x, const double &y, const double &z, double dxds=0., double dyds=0., double dzds=1., double step=0.01) const
z
Definition: test.py:28
unsigned long long int CellUniqueId
Definition: CellUniqueId.h:15
void geom(int which=0)
Definition: geom.C:163
std::vector< Match > lem::FindMatches ( const MatchableEvent trial,
unsigned int  libSize,
const MatchableEvent lib,
const MatchableEvent libDownsample,
int  factor,
const std::multiset< float > &  alreadyInput,
unsigned int  numMatches,
int  enrich,
const Heads heads,
int  headIdx,
bool  flipHeadEven,
bool  flipHeadOdd,
bool  useDownsample 
)

Definition at line 175 of file FindMatches.cxx.

References a, ana::assert(), CalcEnergy(), lem::Heads::ChildIdxFor(), lem::Potential::Downsampled(), E, FillPotential(), lem::Heads::FlipEvenFor(), lem::Heads::FlipOddFor(), FracChargeMatched(), lem::Heads::HeadSeqsLen(), MECModelEnuComparisons::i, calib::j, m, runNovaSAM::ret, lem::MatchableEvent::selfEnergy, lem::FlippedPotentials::V, lem::MatchableEvent::weight, and weight.

Referenced by lem::LEM::produce().

188  {
189  // assert(libsize >= kMaxNumMatches);
190 
191  assert(!heads || headIdx >= 0);
192 
193  float target = FLT_MAX; // infinity
194 
195  // "De-normalize" values back into the range most of this function deals
196  // with. Need to copy to a new container, since set iterators are const
197  std::multiset<float> already;
198  for(auto a: alreadyInput) already.insert(a*trial.selfEnergy);
199 
200  // Truncate to the right length. Update target if possible.
201  while(already.size() > numMatches){
202  auto itLargest = already.end();
203  --itLargest;
204  already.erase(itLargest);
205  target = *already.rbegin();
206  }
207 
208  // Precalculate potential
209  // Try it with either/both of x&y flipped. Effectively gain factor of 4 library stats.
210  // TODO: This isn't entirely right because of attenuation. It /would/
211  // actually be possible to introduce this properly during library building
212  // when truth information is available.
213 
214  FlippedPotentials Vs;
215  FillPotential(trial, Vs);
216 
217  // Make downsampled versions of the four potential cases
218  FlippedPotentials Vs_down;
219  if(useDownsample){
220  for(int flipEven = 0; flipEven <= 1; ++flipEven){
221  for(int flipOdd = 0; flipOdd <= 1; ++flipOdd){
222  Vs_down.V[flipEven][flipOdd] = Vs.V[flipEven][flipOdd].Downsampled(factor);
223  }
224  }
225  }
226 
227  // Candidates for return, remains sorted
228  std::multiset<Match> Elist;
229 
230  // This is the quickest ordering of the loops (locality into lib?)
231  for(unsigned int j = 0; j < libSize; ++j){
232  int i = j;
233  if(heads){
234  if(int(j) >= heads->HeadSeqsLen()) break;
235  i = heads->ChildIdxFor(headIdx, j);
236  }
237 
238  if(enrich != 2){
239  if(lib[i].enrich != bool(enrich)) continue;
240  }
241 
242  const MatchableEvent& downEvt = libDownsample[i];
243 
244  // There's beam nue in the library, but we don't want to match to it
245  if( useDownsample && downEvt.weight == 0) continue;
246  if(!useDownsample && lib[i].weight == 0) continue;
247 
248  for(int flipEven = 0; flipEven <= 1; ++flipEven){
249  if(heads && (heads->FlipEvenFor(headIdx, j) ^ flipHeadEven) != flipEven) continue;
250  for(int flipOdd = 0; flipOdd <= 1; ++flipOdd){
251  if(heads && (heads->FlipOddFor(headIdx, j) ^ flipHeadOdd) != flipOdd) continue;
252 
253  // Compare the downsampled event to the downsampled potential. The
254  // resulting energy is a lower-bound on what the real match would
255  // have done.
256  float E = useDownsample ? CalcEnergy(Vs_down.V[flipEven][flipOdd], trial, downEvt) : 0;
257 
258  if(E < target){
259  // Calculate the energy fully
260  E = CalcEnergy(Vs.V[flipEven][flipOdd], trial, lib[i]);
261 
262  // If it's still good, use it
263  if(E < target){
264  Elist.insert(Match(E, &lib[i], flipEven, flipOdd, j));
265  already.insert(E);
266 
267  if(Elist.size() > numMatches){
268  // Always drop the last one, to keep list correct size
269  auto itLargest = Elist.end();
270  --itLargest;
271  Elist.erase(itLargest);
272  // In case "already" isn't long enough
273  target = Elist.rbegin()->energy;
274  }
275  if(already.size() > numMatches){
276  // Always drop the last one, to keep list correct size
277  auto itLargest = already.end();
278  --itLargest;
279  already.erase(itLargest);
280  target = *already.rbegin();
281  }
282  }
283  }
284  } // end for flipOdd
285  } // end for flipEven
286  } // end for i
287 
288  // Convert back to a vector, and calculate the qfrac variable for surviving
289  // matches.
290  std::vector<Match> ret;
291  ret.reserve(numMatches);
292  for(const auto& m: Elist){
293  ret.push_back(m);
294  ret.back().qfrac = FracChargeMatched(trial, *m.evt, m.flipEven, m.flipOdd);
295  ret.back().energy /= trial.selfEnergy; // Normalize to approx 0-1
296  }
297  return ret;
298  }
float CalcEnergy(const Potential &Va, const MatchableEvent &a, const MatchableEvent &b)
Definition: FindMatches.cxx:21
const XML_Char * target
Definition: expat.h:268
Definition: __init__.py:1
Float_t E
Definition: plot.C:20
const double a
double FracChargeMatched(const EventSummary &a, const EventSummary &b, bool flipEven, bool flipOdd)
Definition: FindMatches.cxx:37
const double j
Definition: BetheBloch.cxx:29
void FillPotential(const EventSummary &trial, FlippedPotentials &Vs)
assert(nhit_max >=nhit_nbins)
const Var weight
Definition: exporter_fd.C:34
double lem::FracChargeMatched ( const EventSummary a,
const EventSummary b,
bool  flipEven,
bool  flipOdd 
)

Definition at line 37 of file FindMatches.cxx.

References abs(), lem::LiteHit::Cell(), lem::LiteHit::cellIdx, lem::EventSummary::hits, kVertexCell, min(), Na, Nb, lem::EventSummary::nhits, lem::LiteHit::pecorr, lem::LiteHit::Plane(), lem::EventSummary::totalPE, and registry_explorer::v.

Referenced by lem::FindMatchesTranspose::endRun(), FindMatches(), and lem::FindMatchesAlg::PackageMatches().

39  {
40  // TODO: Duplicate hits definitely screw this up
41 
42  float qmatched = 0;
43 
44  // Quicker to spend this (not much) memory than the more obvious
45  // nested-loops implementation.
46  float acharge[256*256] = {0,};
47 
48  const unsigned int Na = a.nhits;
49  const unsigned int Nb = b.nhits;
50  for(unsigned int ia = 0; ia < Na; ++ia){
51  const LiteHit& ha = a.hits[ia];
52  acharge[ha.cellIdx] += ha.pecorr;
53  } // end for ia
54 
55  for(unsigned int ib = 0; ib < Nb; ++ib){
56  const LiteHit& hb = b.hits[ib];
57 
58  int hbc = hb.Cell();
59 
60  const int v = abs(hb.Plane())%2; // Matches definition in FillPotential
61  if((v == 0 && flipEven) ||
62  (v == 1 && flipOdd)) hbc = 2*lem::kVertexCell-hbc;
63 
64  const int bidx = 256*hb.Plane()+hbc;
65 
66  // This is the MINOS definition
67  // if(acharge[bidx]) qmatched += acharge[bidx]+hb.pecorr;
68 
69  qmatched += 2*std::min(acharge[bidx], hb.pecorr);
70  } // end for ib
71 
72  return qmatched/(a.totalPE+b.totalPE);
73  }
const int Na
void abs(TH1 *hist)
const double a
const int kVertexCell
Definition: EventSummary.h:23
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
const hit & b
Definition: hits.cxx:21
const int Nb
std::string lem::get_http_response_internal ( const std::string &  host,
const std::string &  query,
const std::string &  postdata,
int  minPort,
int  maxPort,
int  queryTimeout,
int  retryTimeout,
bool &  ok 
)

Definition at line 31 of file WebUtils.cxx.

References ana::assert(), om::cerr, om::cout, allTimeWatchdog::endl, genie::utils::style::Format(), central_limit::rand, sw, getGoodRuns4SAM::t0, getGoodRuns4SAM::t1, recentWatchdog::url, and writeMemoryCallback().

Referenced by get_query(), and post_query().

39  {
40  ok = false;
41 
42  const time_t t0 = time(0);
43 
44  // No, this is explicitly not thread-safe. Caller should call this themselves
45  // curl_global_init(CURL_GLOBAL_ALL);
46  CURL* curl_handle = curl_easy_init();
47  assert(curl_handle);
48 
49  // Don't send "Expect: 100-continue" for long queries, just forge
50  // ahead. The chances of being rejected are pretty low and the server
51  // doesn't send a continue anyway.
52  curl_slist* slist = 0;
53  slist = curl_slist_append(slist, "Expect:");
54  curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist);
55 
56  // Configure callback function
57  std::string response;
58  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
59  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &response);
60 
61  // Timeout for the HTTP connection. Will try again with a new connection up
62  // to retryTimeout.
63  curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, queryTimeout);
64 
65  // Work around this crash
66  // http://stackoverflow.com/questions/9191668/error-longjmp-causes-uninitialized-stack-frame
67  curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
68 
69  // Allow redirection
70  curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
71 
72  if(!postdata.empty()){
73  curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
74  curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, postdata.c_str());
75  }
76 
77  double realTime = -1;
78 
79  int k = 0;
80  while(true){
81  const TString url = TString::Format("%s:%d/%s",
82  host.c_str(),
83  minPort+rand()%(maxPort-minPort+1),
84  query.c_str());
85  curl_easy_setopt(curl_handle, CURLOPT_URL, url.Data());
86 
87  std::cout << "Making query " << url;
88  if(!postdata.empty()) std::cout << " with " << postdata.size() << " bytes of postdata";
90 
91  response.clear();
92  TStopwatch sw;
93  CURLcode code = curl_easy_perform(curl_handle);
94  sw.Stop();
95  realTime = sw.RealTime();
96 
97  if(code != CURLE_OK){
98  std::cerr << "Connection failed: " << curl_easy_strerror(code)
99  << std::endl;
100  }
101  else {
102  long http_code;
103  curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_code);
104  if(http_code == 200 && code != CURLE_ABORTED_BY_CALLBACK){
105  //Succeeded
106  ok = true;
107  break;
108  }
109  else{
110  std::cerr << "Connection failed with HTTP " << http_code
111  << ": " << response << std::endl;
112  }
113  }
114 
115  // For subsequent iterations round the loop let's have a lot of debugging
116  // output.
117  curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
118 
119  const int delay = 1 + ((double)random()/(double)RAND_MAX) * (1 << k++);
120  const time_t t1 = time(0);
121  if(t1+delay > t0+retryTimeout) break;
122 
123  std::cerr << "Iteration " << k
124  << ": will wait for " << delay << " sec and try again. "
125  << t1-t0 << " sec since we started. Will retry until "
126  << retryTimeout << " sec." << std::endl;
127  sleep(delay);
128  } // end while
129 
130  curl_easy_cleanup(curl_handle);
131  // No, this is explicitly not thread-safe. Caller should call this themselves
132  // curl_global_cleanup();
133 
134  curl_slist_free_all(slist);
135 
136  if(!response.empty() && response.size() < 20){
137  std::cout << "Response: " << response << " in " << realTime << " sec" << std::endl;
138  }
139  else{
140  std::cout << "Response: " << response.size() << " bytes in " << realTime << " sec" << std::endl;
141  }
142 
143  return response;
144  }
size_t writeMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
Definition: WebUtils.cxx:17
OStream cerr
Definition: OStream.cxx:7
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
OStream cout
Definition: OStream.cxx:6
Definition: inftrees.h:24
Float_t sw
Definition: plot.C:20
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
std::string lem::get_query ( const std::string &  host,
const std::string &  query,
int  minPort,
int  maxPort,
int  queryTimeout,
int  retryTimeout,
bool &  ok 
)

Make an HTTP GET query.

Definition at line 147 of file WebUtils.cxx.

References get_http_response_internal().

Referenced by GetWorkThreadFunc().

154  {
156  minPort, maxPort,
157  queryTimeout, retryTimeout,
158  ok);
159  }
std::string get_http_response_internal(const std::string &host, const std::string &query, const std::string &postdata, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
Definition: WebUtils.cxx:31
std::string lem::get_release ( )

Figure out the current release. TODO: does this belong somewhere else?

Definition at line 178 of file WebUtils.cxx.

References om::cerr, e, allTimeWatchdog::endl, and cet::getenv().

Referenced by lem::LEMWorker::GetWork(), and lem::LEMClient::produce().

179  {
180  char* e = getenv("NOVA_RELEASE");
181  if(e) return e;
182  e = getenv("SRT_BASE_RELEASE");
183  if(e) return e;
184  std::cerr << "Unable to determine current release. Aborting." << std::endl;
185  abort();
186  }
OStream cerr
Definition: OStream.cxx:7
std::string getenv(std::string const &name)
Float_t e
Definition: plot.C:35
void* lem::GetWorkThreadFunc ( void x)

Definition at line 101 of file LEMWorker_module.cc.

References runNovaSAM::args, om::cerr, allTimeWatchdog::endl, get_query(), lem::LEMWebSettings::host, lem::LEMWebSettings::maxPort, lem::LEMWebSettings::minPort, lem::GetWorkArgs::params, lem::LEMWebSettings::queryTimeout, lem::LEMWebSettings::retryTimeout, and lem::GetWorkArgs::web.

Referenced by lem::LEMWorker::GetWork().

102  {
103  const GetWorkArgs* args = (GetWorkArgs*)x;
104 
105  bool ok;
106  const std::string work = get_query(args->web.host(),
107  args->params,
108  args->web.minPort(),
109  args->web.maxPort(),
110  args->web.queryTimeout(),
111  args->web.retryTimeout(),
112  ok);
113  if(!ok){
114  std::cerr << "No response from server after many retries. "
115  << "Maybe there's no work for us. Aborting"
116  << std::endl;
117  abort();
118  }
119 
120  delete args;
121  return new std::string(work);
122  }
OStream cerr
Definition: OStream.cxx:7
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string get_query(const std::string &host, const std::string &query, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
Make an HTTP GET query.
Definition: WebUtils.cxx:147
int lem::MeanCell ( geo::View_t  view,
const rb::Cluster slice 
)

Definition at line 14 of file Util.cxx.

References rb::Cluster::MaxCell(), and rb::Cluster::MinCell().

Referenced by DefaultVertex().

15  {
16  return (slice.MinCell(view)+slice.MaxCell(view))/2;
17  }
unsigned int MaxCell(geo::View_t view) const
Definition: Cluster.cxx:518
unsigned int MinCell(geo::View_t view) const
Definition: Cluster.cxx:472
long lem::MMapFileAtAddress ( const std::string &  fname,
void addr,
bool  touchAll,
const std::string &  lockName = "" 
)
Parameters
fnameFile to map in
addrWhere to map it
touchAllRead from every page to make sure it's cached
lockNameIf touchAll, coordinate using lock here
Returns
Size of mapping in bytes

Definition at line 18 of file Util.cxx.

References ana::assert(), om::cout, allTimeWatchdog::endl, MakeMiniprodValidationCuts::f, fclose(), fileno, MECModelEnuComparisons::i, makeTrainCVSamples::int, runNovaSAM::ret, and PandAna.Demos.pi0_spectra::tot.

Referenced by lem::Heads::FromMMap(), lem::Library::FromMMap(), and lem::HeadsTranspose::FromMMap().

20  {
21  // Touching all the memory ("preloading") means we can be sure that it's
22  // all quickly available to us later. The first process to do this has to
23  // fetch the whole file from disk. We don't want more than one process
24  // doing that, it's counter-productive. But once that's happened once, it's
25  // in disk cache, and all other processes should feel free to preload in
26  // parallel. This locking scheme ensures that.
27 
28  FILE* lockMain = 0;
29  FILE* lockDone = 0;
30  if(touchAll && !lockName.empty()){
31  // No two processes should be preloading from disk at once
32 
33  // Make sure not to block out other users from this lock
34  chmod(lockName.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
35  chmod((lockName+".done").c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
36 
37  lockMain = fopen(lockName.c_str(), "w");
38  int ret = flock(fileno(lockMain), LOCK_EX);
39  assert(ret == 0); // Blocking flock call, must have got it
40 
41  // We're now holding the loading lock. Either it's our responsibility to
42  // do the preload, or someone else beat us to it but is now done, so we
43  // can go ahead freely. Check the ".done" lock to see which.
44 
45  lockDone = fopen((lockName+".done").c_str(), "w");
46  ret = flock(fileno(lockDone), LOCK_EX | LOCK_NB);
47  // If we succesfully get this lock, that means that no running processes
48  // have preloaded the file for us.
49  if(ret == 0){
50  // Drop it again, we were just testing
51  fclose(lockDone);
52  lockDone = 0;
53  }
54  else{
55  // Otherwise, someone else has already done the preload. Don't hold the
56  // rest of the processes up.
57  fclose(lockMain);
58  lockMain = 0;
59  }
60  }
61 
62 
63  FILE* f = fopen(fname.c_str(), "r");
64  assert(f);
65 
66  struct stat st;
67  fstat(fileno(f), &st);
68  const long fsize = st.st_size;
69 
70  void* ret = mmap(addr, fsize, PROT_READ, MAP_SHARED | MAP_FIXED, fileno(f), 0);
71  fclose(f);
72  assert(ret != (void*)-1);
73 
74 
75  if(touchAll){
76  // Touch all the memory, one byte on each page
77  char tot = 0;
78  for(long i = 0; i < fsize; i += 4096){
79  if((i/4096)%(fsize/409600) == 0) std::cout << (100*i)/fsize << "%" << std::endl;
80  tot += ((char*)addr)[i];
81  }
82  // Printing forces it not to get optimized out
83  std::cout << "Fully loaded: " << int(tot) << std::endl;
84 
85  if(!lockName.empty()){
86  lockDone = fopen((lockName+".done").c_str(), "w");
87  // Mark that we succesfully preloaded the file. This indication lasts
88  // until the end of this process.
89  flock(fileno(lockDone), LOCK_SH);
90 
91  // Release the main lock if we still have it
92  if(lockMain) fclose(lockMain);
93  }
94  }
95 
96  return fsize;
97  }
fclose(fg1)
OStream cout
Definition: OStream.cxx:6
assert(nhit_max >=nhit_nbins)
unsigned int fileno
Definition: runWimpSim.h:102
std::ostream & lem::operator<< ( std::ostream &  os,
const lem::LiteHit h 
)

Definition at line 21 of file LiteHit.cxx.

References lem::LiteHit::Cell(), lem::LiteHit::pecorr, and lem::LiteHit::Plane().

22  {
23  os << h.pecorr << " PECorr on plane " << h.Plane() << ", cell " << h.Cell();
24  return os;
25  }
float pecorr
Definition: LiteHit.h:24
int Cell() const
Definition: LiteHit.h:39
int Plane() const
Definition: LiteHit.h:38
std::ostream & lem::operator<< ( std::ostream &  os,
const lem::LibrarySummary ls 
)

Definition at line 32 of file LibrarySummary.cxx.

References lem::LibrarySummary::N, lem::LibrarySummary::totBkg, lem::LibrarySummary::totEnrich, and lem::LibrarySummary::totSig.

33  {
34  os << ls.N << " events, weighted to "
35  << ls.totSig << " signal, "
36  << ls.totBkg << " background and "
37  << ls.totEnrich << " enriched background";
38 
39  return os;
40  }
std::ostream & lem::operator<< ( std::ostream &  os,
const lem::Heads hs 
)

Definition at line 140 of file Heads.cxx.

References lem::Heads::fHeadSeqsLen, and lem::Heads::fNHeads.

Referenced by lem::LiteHit::operator<().

141  {
142  os << hs.fNHeads << " heads, with " << hs.fHeadSeqsLen << " events each.";
143  return os;
144  }
int fHeadSeqsLen
Definition: Heads.h:40
int fNHeads
Definition: Heads.h:38
std::ostream & lem::operator<< ( std::ostream &  os,
const lem::HeadsTranspose hs 
)

Definition at line 147 of file Heads.cxx.

References lem::HeadsTranspose::fLibSize, and lem::HeadsTranspose::fNHeads.

148  {
149  os << hs.fNHeads << " heads, for a librar of " << hs.fLibSize << " events.";
150  return os;
151  }
std::string lem::post_query ( const std::string &  host,
const std::string &  query,
const std::string &  postdata,
int  minPort,
int  maxPort,
int  queryTimeout,
int  retryTimeout,
bool &  ok 
)

Make an HTTP POST query.

Definition at line 162 of file WebUtils.cxx.

References get_http_response_internal().

Referenced by lem::LEMClient::produce(), and ReturnResultsThreadFunc().

170  {
171  return get_http_response_internal(host, query, postdata,
172  minPort, maxPort,
173  queryTimeout, retryTimeout,
174  ok);
175  }
std::string get_http_response_internal(const std::string &host, const std::string &query, const std::string &postdata, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
Definition: WebUtils.cxx:31
void* lem::ReturnResultsThreadFunc ( void x)

Definition at line 100 of file LEMWorkerOutput_module.cc.

References runNovaSAM::args, om::cerr, allTimeWatchdog::endl, lem::LEMWebSettings::host, lem::LEMWebSettings::maxPort, lem::LEMWebSettings::minPort, lem::ReturnResultsArgs::params, post_query(), lem::ReturnResultsArgs::postdata, lem::LEMWebSettings::queryTimeout, lem::LEMWebSettings::retryTimeout, and lem::ReturnResultsArgs::web.

Referenced by lem::LEMWorkerOutput::ReturnResults().

101  {
102  const ReturnResultsArgs* args = (ReturnResultsArgs*)x;
103 
104  bool ok;
105  post_query(args->web.host(),
106  args->params, args->postdata,
107  args->web.minPort(), args->web.maxPort(),
108  args->web.queryTimeout(), args->web.retryTimeout(),
109  ok);
110 
111  if(!ok){
112  std::cerr << "No response from server after many retries. Aborting"
113  << std::endl;
114  abort();
115  }
116 
117  delete args;
118 
119  return 0;
120  }
OStream cerr
Definition: OStream.cxx:7
std::string post_query(const std::string &host, const std::string &query, const std::string &postdata, int minPort, int maxPort, int queryTimeout, int retryTimeout, bool &ok)
Make an HTTP POST query.
Definition: WebUtils.cxx:162
void lem::SetOnDemandMemoryLimit ( long  limit_mb)

Definition at line 117 of file OnDemand.cxx.

Referenced by lem::LEMLibrary::reconfigure(), lem::FindMatchesTranspose::reconfigure(), and lem::LEM::reconfigure().

118  {
119  // Convert to bytes
120  gMemoryLimit = limit_mb<<20;
121  }
double lem::SimpleSurvivalProb ( const EventSummary evt)

Definition at line 159 of file FindMatchesTranspose_module.cc.

References abs(), lem::EventSummary::ccnc, e, lem::EventSummary::IsSig(), lem::EventSummary::origPdg, lem::EventSummary::pdg, std::sin(), util::sqr(), and lem::EventSummary::trueEVis.

160  {
161  if(evt.IsSig()){
162  // Scale up to keep as much signal as possible in sample, weighted
163  // correctly internally. The missing prefactor is (ss2th13*ssth23)
164  return util::sqr(sin(1.267*2.35e-3*810/evt.trueEVis));
165  }
166  if(evt.ccnc == 0 && abs(evt.pdg) == 14 && abs(evt.origPdg) == 14){
167  // CC mu
168  return 1-util::sqr(sin(1.267*2.35e-3*810/evt.trueEVis));
169  }
170  if(evt.ccnc == 0 && abs(evt.pdg) == 12 && abs(evt.origPdg) == 12){
171  // Beam nue
172  // return 1-.1*util::sqr(sin(1.267*2.35e-3*810/evt.trueEVis));
173  // Want library matching to ignore nues
174  return 0;
175  }
176  if(evt.ccnc == 1 && evt.pdg == evt.origPdg){
177  // NC
178  return 1;
179  }
180  if(evt.ccnc == 1 && evt.pdg != evt.origPdg){
181  // Swapped NC. We play clever reweighting games so this is OK
182  return 1;
183  }
184  if(evt.ccnc == 0 && abs(evt.pdg) == 14 && abs(evt.origPdg) == 12){
185  // CC mu appearance, take ss2th13=0.1, maximal th23
186  return .1*.5*util::sqr(sin(1.267*2.35e-3*810/evt.trueEVis));
187  }
188  // Don't know what this is
189  return 0;
190  }
void abs(TH1 *hist)
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
T sin(T number)
Definition: d0nt_math.hpp:132
Float_t e
Definition: plot.C:35
void lem::VertexToPlaneAndCell ( const TVector3  vtx,
const rb::Cluster slice,
int plane,
int cell,
int cellOtherView,
bool  reverse 
)

Definition at line 60 of file Util.cxx.

References geo::PlaneGeo::Cell(), DefaultVertex(), FindCellRobust(), geom(), geo::CellGeo::GetCenter(), geo::GeometryBase::IdToCell(), geo::kPLANE_NOT_FOUND, geo::PlaneGeo::Ncells(), ncells, geo::GeometryBase::NextPlaneOtherView(), and geo::GeometryBase::Plane().

Referenced by lem::LEMSummarizer::produce(), lem::AlignLibToVtx::produce(), and lem::MakeLibrary::produce().

63  {
64  // Picked up by failure cases below
65  DefaultVertex(slice, plane, cell, cellOtherView, reverse);
66 
68 
69  const geo::CellUniqueId id = FindCellRobust(vtx.X(),
70  vtx.Y(),
71  vtx.Z());
72 
73  // Take defaults
74  if(!id) return;
75 
76  geom->IdToCell(id, &plane, &cell);
77 
78  const int nextPlane = geom->NextPlaneOtherView(plane);
79  // Take default in other view
80 
81  if(nextPlane == geo::kPLANE_NOT_FOUND) return;
82 
83  double xyz[3];
84  int ncells = geom->Plane(nextPlane)->Ncells();
85  if(cellOtherView >= ncells)
86  cellOtherView = ncells-1;
87 
88  geom->Plane(nextPlane)->Cell(cellOtherView)->GetCenter(xyz);
89 
90  // z position of plane in other view
91  double zOther = xyz[2];
92 
93  // Sometimes this goes wrong and we have to iterate a bit
94  while(true){
95  const geo::CellUniqueId idOther = FindCellRobust(vtx.X(),
96  vtx.Y(),
97  zOther);
98  // Take default in other view
99  if(!idOther) return;
100 
101  // The cell we found must be in the plane we wanted
102  int checkPlane;
103  geom->IdToCell(idOther, &checkPlane, &cellOtherView);
104  // If so, we're good and return the answer
105  if(checkPlane == nextPlane) return;
106  // Otherwise, walk 1cm at a time in the right direction
107  if(checkPlane < nextPlane) zOther += 1;
108  if(checkPlane > nextPlane) zOther -= 1;
109  }
110  }
void GetCenter(double *xyz, double localz=0.0) const
Definition: CellGeo.cxx:159
const CellGeo * Cell(int icell) const
Definition: PlaneGeo.h:48
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const PlaneGeo * Plane(unsigned int i) const
void DefaultVertex(const rb::Cluster &slice, int &plane, int &cell, int &cellOtherView, bool reverse)
Definition: Util.cxx:20
geo::CellUniqueId FindCellRobust(double x, double y, double z)
Steps around a bit. Can still return zero for total failure.
Definition: Util.cxx:38
unsigned long long int CellUniqueId
Definition: CellUniqueId.h:15
void geom(int which=0)
Definition: geom.C:163
int ncells
Definition: geom.C:124
const CellGeo * IdToCell(const CellUniqueId &id, int *iplane, int *icell) const
const unsigned int NextPlaneOtherView(unsigned int p, int d=+1) const
size_t lem::writeMemoryCallback ( void contents,
size_t  size,
size_t  nmemb,
void userp 
)

Definition at line 17 of file WebUtils.cxx.

References ana::assert(), and runNovaSAM::str.

Referenced by get_http_response_internal().

19  {
20  assert(userp);
21  std::string* str = (std::string*)userp;
22 
23  const size_t recvdSize = size*nmemb;
24  const size_t prevSize = str->size();
25  str->resize(prevSize+recvdSize);
26  memcpy((char*)str->c_str()+prevSize, contents, recvdSize);
27  return recvdSize;
28  }
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
assert(nhit_max >=nhit_nbins)

Variable Documentation

const unsigned int lem::kMaxNumMatches = 1001
const int lem::kNumCells = 256
const int lem::kNumPlanes = 256
const int lem::kVertexCell = 128
const int lem::kVertexPlane = 64