Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
lem::MatchableEvent Class Reference

Attach some information used in matching to an EventSummary. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-04-15/LEM/func/MatchableEvent.h"

Inheritance diagram for lem::MatchableEvent:
lem::EventSummary

Public Member Functions

 MatchableEvent ()
 
 MatchableEvent (const EventSummary &evt)
 
MatchableEvent Downsampled (int factor) const
 
MatchableEvent Flipped (bool flipEven, bool flipOdd) const
 
bool IsSig () const
 
std::string Description () const
 
void FillHists (TH2 *h1, TH2 *h2, bool flipEven=false, bool flipOdd=false, bool idxs=false) const
 
void SaveImage (TString fname, TString title="") const
 
void ToTree (TTree *tr) const
 
int Length () const
 In planes. More...
 

Static Public Member Functions

static void InitToTree (TTree *tr)
 
static void InitFromTree (TTree *tr)
 
static EventSummary FromTree (TTree *tr, int evtIdx, bool enrich)
 

Public Attributes

double weight
 
float selfEnergy
 
unsigned short nhits
 
LiteHithits
 
double totalPE
 
double trueEVis
 
double y
 
int id
 
int run
 
int subrun
 
int event
 
int ccnc
 
int pdg
 
int origPdg
 
int mode
 
int trueVtxPlane
 
int trueVtxCell
 
int trueVtxCellOther
 
unsigned char nParts
 
intpartPdgs
 
double photL0
 
double photL1
 
double photE0
 
double photE1
 
bool enrich
 Was this event generated in a filtered-for-pi0 job? More...
 

Static Public Attributes

static double fgDecayRate = 0
 
static double fgChargePower = .5
 

Protected Member Functions

void Finalize ()
 

Detailed Description

Attach some information used in matching to an EventSummary.

Definition at line 15 of file MatchableEvent.h.

Constructor & Destructor Documentation

lem::MatchableEvent::MatchableEvent ( )
inline

Definition at line 18 of file MatchableEvent.h.

References Downsampled(), evt, and Flipped().

18 {}
lem::MatchableEvent::MatchableEvent ( const EventSummary evt)
explicit

Definition at line 16 of file MatchableEvent.cxx.

References hi(), lem::EventSummary::hits, MECModelEnuComparisons::i, lem::DistanceMap::Instance(), lem::DistanceMap::InvDist(), calib::j, lem::EventSummary::nhits, lem::LiteHit::pecorr, lem::LiteHit::Plane(), and selfEnergy.

17  : EventSummary(evt), weight(1)
18  {
19  const DistanceMap& dm = DistanceMap::Instance();
20 
21  selfEnergy = 0;
22 
23  for(unsigned int i = 0; i < nhits; ++i){
24  const LiteHit& hi = hits[i];
25 
26  selfEnergy += .5*hi.pecorr*hi.pecorr*dm.InvDist(hi, hi);
27 
28  for(unsigned int j = i+1; j < nhits; ++j){
29  const LiteHit& hj = hits[j];
30 
31  // Only if they're in the same view
32  if(hi.Plane()%2 == hj.Plane()%2)
33  selfEnergy += hi.pecorr*hj.pecorr*dm.InvDist(hi, hj);
34  } // end for j
35  } // end for i
36  }
unsigned short nhits
Definition: EventSummary.h:53
TSpline3 hi("hi", xhi, yhi, 18,"0")
static const DistanceMap & Instance()
Singleton.
Definition: DistanceMap.cxx:26
int evt
const double j
Definition: BetheBloch.cxx:29

Member Function Documentation

std::string lem::EventSummary::Description ( ) const
inherited

Definition at line 144 of file EventSummary.cxx.

References lem::EventSummary::ccnc, genie::utils::style::Format(), lem::EventSummary::origPdg, lem::EventSummary::pdg, lem::EventSummary::totalPE, and lem::EventSummary::y.

Referenced by lem::FindLEMMatches::AddHists(), lem::LEM::AddHists(), lem::EventSummary::IsSig(), and lem::EventSummary::SaveImage().

145  {
146  std::map<int, const char*> partNames;
147  partNames[12] = "#nu_{e}";
148  partNames[14] = "#nu_{#mu}";
149  partNames[16] = "#nu_{#tau}";
150  partNames[-12] = "#bar{#nu}_{e}";
151  partNames[-14] = "#bar{#nu}_{#mu}";
152  partNames[-16] = "#bar{#nu}_{#tau}";
153 
154  return TString::Format("%s %s#rightarrow%s, y=%.2lf, %dPE",
155  ccnc ? "NC" : "CC",
156  partNames[origPdg],
157  partNames[pdg],
158  y,
159  int(totalPE)).Data();
160  }
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
MatchableEvent lem::MatchableEvent::Downsampled ( int  factor) const

Definition at line 39 of file MatchableEvent.cxx.

References plot_validation_datamc::c, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::EventSummary::nhits, runNovaSAM::ret, and tmp.

Referenced by lem::Library::FromTrees(), MatchableEvent(), and lem::FindMatchesTranspose::produce().

40  {
41  std::vector<LiteHit> tmp(hits, hits+nhits);
42 
43  for(unsigned int i = 0; i < nhits; ++i){
44  int p = tmp[i].Plane();
45  int c = tmp[i].Cell();
46  p = ((p>>(factor+1))<<1)+p%2;
47  c = c>>factor;
48  // This encoding screws up Plane() and Cell(), but it collapses all the
49  // possible hits into a small range of indices, so should be better for
50  // looking them up in the Potential map?
51  tmp[i].cellIdx = (p<<(8-factor))+c;
52  } // end for i
53 
54  // Put in order of cellIdx
55  std::sort(tmp.begin(), tmp.end());
56 
57  // Merge identical cellIdxs
58  std::vector<LiteHit> tmp2;
59  for(unsigned int i = 0; i < nhits; ++i){
60  if(tmp2.empty() || tmp2.back().cellIdx != tmp[i].cellIdx)
61  tmp2.push_back(tmp[i]);
62  else
63  tmp2.back().pecorr += tmp[i].pecorr;
64  } // end for i
65 
66  MatchableEvent ret = *this;
67  ret.nhits = tmp2.size();
68  delete[] ret.hits;
69  ret.hits = new LiteHit[ret.nhits];
70  for(int i = 0; i < ret.nhits; ++i) ret.hits[i] = tmp2[i];
71 
72  return ret;
73  }
unsigned short nhits
Definition: EventSummary.h:53
const char * p
Definition: xmltok.h:285
Float_t tmp
Definition: plot.C:36
void lem::EventSummary::FillHists ( TH2 *  h1,
TH2 *  h2,
bool  flipEven = false,
bool  flipOdd = false,
bool  idxs = false 
) const
inherited

Definition at line 122 of file EventSummary.cxx.

References getBrightness::cell, lem::LiteHit::Cell(), make_mec_shifts_plots::GetMaximum(), make_syst_table_plots::h, h1, lem::EventSummary::hits, MECModelEnuComparisons::i, std::max(), lem::EventSummary::nhits, lem::LiteHit::Plane(), NDAPDHVSetting::plane, and registry_explorer::v.

Referenced by lem::FindLEMMatches::AddHists(), lem::LEM::AddHists(), dump_event(), lem::EventSummary::IsSig(), refresh(), and lem::EventSummary::SaveImage().

123  {
124  TH2* h[2] = {h1, h2};
125 
126  for(unsigned int i = 0; i < nhits; ++i){
127  const int plane = hits[i].Plane();
128  int cell = hits[i].Cell();
129  const int v = plane%2;
130  if(v == 0 && flipEven) cell = 255-cell;
131  if(v == 1 && flipOdd) cell = 255-cell;
132  if(idxs){
133  h[plane%2]->Fill(plane, cell, hits[i].partIdx);
134  }
135  else{
136  h[plane%2]->Fill(plane, cell, hits[i].pecorr);
137  }
138  }
139  h[0]->SetMaximum(std::max(h[0]->GetMaximum(), h[1]->GetMaximum()));
140  h[1]->SetMaximum(std::max(h[0]->GetMaximum(), h[1]->GetMaximum()));
141  }
unsigned short nhits
Definition: EventSummary.h:53
T max(const caf::Proxy< T > &a, T b)
int Cell() const
Definition: LiteHit.h:39
int Plane() const
Definition: LiteHit.h:38
TH1F * h2
Definition: plot.C:45
TH1F * h1
void lem::EventSummary::Finalize ( )
protectedinherited

Definition at line 370 of file EventSummary.cxx.

References make_syst_table_plots::h, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::EventSummary::nhits, lem::LiteHit::pecorr, and lem::EventSummary::totalPE.

Referenced by lem::EventSummary::EventSummary().

371  {
372  totalPE = 0;
373 
374  for(unsigned int i = 0; i < nhits; ++i){
375  LiteHit& h = hits[i];
376  totalPE += h.pecorr;
377  } // end for i
378 
379  // Put in order of cellIdx, might improve locality
380  std::sort(hits, hits+nhits);
381  }
unsigned short nhits
Definition: EventSummary.h:53
MatchableEvent lem::MatchableEvent::Flipped ( bool  flipEven,
bool  flipOdd 
) const

Definition at line 76 of file MatchableEvent.cxx.

References lem::LiteHit::Cell(), make_syst_table_plots::h, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::kVertexCell, lem::EventSummary::nhits, lem::LiteHit::Plane(), runNovaSAM::ret, and lem::LiteHit::SetCell().

Referenced by lem::FindMatchesTranspose::endRun(), and MatchableEvent().

77  {
78  MatchableEvent ret = *this;
79 
80  for(int i = 0; i < ret.nhits; ++i){
81  LiteHit& h = ret.hits[i];
82  if((h.Plane()%2 == 0 && flipEven) ||
83  (h.Plane()%2 == 1 && flipOdd)){
84  h.SetCell(2*kVertexCell-h.Cell());
85  }
86  }
87 
88  // TODO: can we try and use move to not have to call another copy
89  // constructor here?
90  return ret;
91  }
const int kVertexCell
Definition: EventSummary.h:23
EventSummary lem::EventSummary::FromTree ( TTree *  tr,
int  evtIdx,
bool  enrich 
)
staticinherited

Definition at line 330 of file EventSummary.cxx.

References lem::EventSummary::ccnc, lem::LiteHit::cellIdx, lem::EventSummary::enrich, gMode, make_syst_table_plots::h, lem::EventSummary::mode, lem::EventSummary::origPdg, lem::EventSummary::pdg, lem::EventSummary::photE0, lem::EventSummary::photE1, lem::EventSummary::photL0, lem::EventSummary::photL1, runNovaSAM::ret, lem::EventSummary::trueEVis, lem::EventSummary::trueVtxCell, lem::EventSummary::trueVtxCellOther, lem::EventSummary::trueVtxPlane, and lem::EventSummary::y.

Referenced by lem::Library::FromTrees(), lem::EventSummary::IsSig(), lem::AlignLibToVtx::produce(), lem::GenFromLib::readNext(), and refresh().

331  {
332  tr->GetEntry(evtIdx);
333 
334  std::vector<LiteHit> hs;
335  hs.reserve(gNHits);
336  for(int n = 0; n < gNHits; ++n){
337  lem::LiteHit h(0, 0, gPECorr[n], gPartIdx[n]);
338  h.cellIdx = gCellIdx[n];
339 
340  hs.push_back(h);
341  } // end for n
342 
343  std::vector<int> pdgs(gNParts);
344  for(int n = 0; n < gNParts; ++n) pdgs[n] = gPartPdgs[n];
345 
346  EventSummary ret(hs, -1, pdgs);
347 
348  ret.ccnc = gCCNC;
349  ret.pdg = gPdg;
350  ret.origPdg = gOrigPdg;
351  ret.mode = gMode;
352  ret.trueEVis = gTrueEVis;
353  ret.y = gY;
354 
355  ret.trueVtxPlane = gTrueVtxPlane;
356  ret.trueVtxCell = gTrueVtxCell;
357  ret.trueVtxCellOther = gTrueVtxCellOther;
358 
359  ret.photL0 = gPhotL0;
360  ret.photL1 = gPhotL1;
361  ret.photE0 = gPhotE0;
362  ret.photE1 = gPhotE1;
363 
364  ret.enrich = enrich;
365 
366  return ret;
367  }
bool enrich
Was this event generated in a filtered-for-pi0 job?
Definition: EventSummary.h:73
std::void_t< T > n
int gMode
Definition: pass1_plots.C:2
Compressed hit info, basic component of LEM events.
Definition: LiteHit.h:18
void lem::EventSummary::InitFromTree ( TTree *  tr)
staticinherited

Definition at line 292 of file EventSummary.cxx.

References gMode.

Referenced by lem::Library::FromTrees(), lem::EventSummary::IsSig(), lem::GenFromLib::readFile(), lem::AlignLibToVtx::respondToOpenInputFile(), and show_event().

293  {
294  // Bookkeeping
295  tr->SetBranchAddress("run", &gRun);
296  tr->SetBranchAddress("subrun", &gSubrun);
297  tr->SetBranchAddress("event", &gEvent);
298 
299  // Truth
300  tr->SetBranchAddress("pdg", &gPdg);
301  tr->SetBranchAddress("origpdg", &gOrigPdg);
302  tr->SetBranchAddress("ccnc", &gCCNC);
303  tr->SetBranchAddress("mode", &gMode);
304  tr->SetBranchAddress("trueEVis", &gTrueEVis);
305  tr->SetBranchAddress("y", &gY);
306 
307  // Hit positions and charges
308  tr->SetBranchAddress("nhits", &gNHits);
309  tr->SetBranchAddress("cellIdx", &gCellIdx);
310  tr->SetBranchAddress("pecorr", &gPECorr);
311  tr->SetBranchAddress("partIdx", &gPartIdx);
312 
313  // Particles
314  tr->SetBranchAddress("nParts", &gNParts);
315  tr->SetBranchAddress("partPdgs", &gPartPdgs);
316 
317  // True vertex
318  tr->SetBranchAddress("trueVtxPlane", &gTrueVtxPlane);
319  tr->SetBranchAddress("trueVtxCell", &gTrueVtxCell);
320  tr->SetBranchAddress("trueVtxCellOther", &gTrueVtxCellOther);
321 
322  // Photons
323  tr->SetBranchAddress("photL0", &gPhotL0);
324  tr->SetBranchAddress("photL1", &gPhotL1);
325  tr->SetBranchAddress("photE0", &gPhotE0);
326  tr->SetBranchAddress("photE1", &gPhotE1);
327  }
int gMode
Definition: pass1_plots.C:2
void lem::EventSummary::InitToTree ( TTree *  tr)
staticinherited

Definition at line 210 of file EventSummary.cxx.

References gMode.

Referenced by lem::AlignLibToVtx::beginJob(), lem::MakeLibrary::beginJob(), and lem::EventSummary::IsSig().

211  {
212  // Bookkeeping
213  tr->Branch("run", &gRun);
214  tr->Branch("subrun", &gSubrun);
215  tr->Branch("event", &gEvent);
216 
217  // Truth information
218  tr->Branch("pdg", &gPdg);
219  tr->Branch("origpdg", &gOrigPdg);
220  tr->Branch("ccnc", &gCCNC);
221  tr->Branch("mode", &gMode);
222  tr->Branch("trueEVis", &gTrueEVis);
223  tr->Branch("y", &gY);
224 
225  // Length of the arrays
226  tr->Branch("nhits", &gNHits);
227 
228  // Hit positions and charges
229  tr->Branch("cellIdx", &gCellIdx, "cellIdx[nhits]/s");
230  tr->Branch("pecorr", &gPECorr, "pecorr[nhits]/F");
231  tr->Branch("partIdx", &gPartIdx, "partIdx[nhits]/b");
232 
233  // True Vertex
234  tr->Branch("trueVtxPlane", &gTrueVtxPlane);
235  tr->Branch("trueVtxCell", &gTrueVtxCell);
236  tr->Branch("trueVtxCellOther", &gTrueVtxCellOther);
237 
238  // Particles
239  tr->Branch("nParts", &gNParts);
240  tr->Branch("partPdgs", &gPartPdgs, "partPdgs[nParts]/I");
241 
242  // Photons
243  tr->Branch("photL0", &gPhotL0);
244  tr->Branch("photL1", &gPhotL1);
245  tr->Branch("photE0", &gPhotE0);
246  tr->Branch("photE1", &gPhotE1);
247  }
int gMode
Definition: pass1_plots.C:2
bool lem::EventSummary::IsSig ( ) const
inlineinherited
int lem::EventSummary::Length ( ) const
inherited

In planes.

Definition at line 384 of file EventSummary.cxx.

References lem::EventSummary::hits, lem::EventSummary::nhits, and lem::LiteHit::Plane().

Referenced by lem::EventSummary::IsSig().

385  {
386  if(nhits < 2) return 0;
387  // Hits are sorted
388  return hits[nhits-1].Plane() - hits[0].Plane();
389  }
unsigned short nhits
Definition: EventSummary.h:53
int Plane() const
Definition: LiteHit.h:38
void lem::EventSummary::SaveImage ( TString  fname,
TString  title = "" 
) const
inherited

Definition at line 163 of file EventSummary.cxx.

References plot_validation_datamc::c, lem::EventSummary::Description(), lem::EventSummary::FillHists(), gMode, make_syst_table_plots::h, and registry_explorer::v.

Referenced by lem::EventSummary::IsSig().

164  {
165  static pthread_mutex_t lock;
166  pthread_mutex_lock(&lock);
167 
168  TCanvas c("a", "b", 1200, 600);
169  c.Divide(2, 1);
170 
171  TH2F h[2] = {TH2F("", ";plane;cell", 128, 32, 160, 128, 64, 192),
172  TH2F("", ";plane;cell", 128, 32, 160, 128, 64, 192)};
173 
174  h[0].SetTitle(Description().c_str());
175 
176  h[1].SetTitle(title);
177 
178  FillHists(&h[0], &h[1]);
179 
180  for(int v = 0; v < 2; ++v){
181  c.cd(v+1);
182  h[v].Draw("colz");
183  }
184 
185  c.cd(0);
186  gPad->Print(fname);
187 
188  pthread_mutex_unlock(&lock);
189  }
std::string Description() const
void FillHists(TH2 *h1, TH2 *h2, bool flipEven=false, bool flipOdd=false, bool idxs=false) const
void lem::EventSummary::ToTree ( TTree *  tr) const
inherited

Definition at line 250 of file EventSummary.cxx.

References ana::assert(), lem::EventSummary::ccnc, lem::LiteHit::cellIdx, lem::EventSummary::event, gMode, lem::EventSummary::hits, lem::EventSummary::mode, lem::EventSummary::nhits, lem::EventSummary::nParts, lem::EventSummary::origPdg, lem::LiteHit::partIdx, lem::EventSummary::partPdgs, lem::EventSummary::pdg, lem::LiteHit::pecorr, lem::EventSummary::photE0, lem::EventSummary::photE1, lem::EventSummary::photL0, lem::EventSummary::photL1, lem::EventSummary::run, lem::EventSummary::subrun, lem::EventSummary::trueEVis, lem::EventSummary::trueVtxCell, lem::EventSummary::trueVtxCellOther, lem::EventSummary::trueVtxPlane, and lem::EventSummary::y.

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

251  {
252  gRun = run;
253  gSubrun = subrun;
254  gEvent = event;
255 
256  gPdg = pdg;
257  gOrigPdg = origPdg;
258  gCCNC = ccnc;
259  gMode = mode;
260 
261  gTrueEVis = trueEVis;
262  gY = y;
263 
264  //comparison of constant 65536 with expression of type 'const unsigned short' is always true
265  // so comment out the assert
266  //assert(nhits < 256*256);
267  gNHits = nhits;
268 
269  for(unsigned int n = 0; n < nhits; ++n){
270  gCellIdx[n] = hits[n].cellIdx;
271  gPECorr[n] = hits[n].pecorr;
272  gPartIdx[n] = hits[n].partIdx;
273  }
274 
275  gNParts = nParts;
276  assert(gNParts <= 255);
277  for(int n = 0; n < gNParts; ++n) gPartPdgs[n] = partPdgs[n];
278 
279  gTrueVtxPlane = trueVtxPlane;
280  gTrueVtxCell = trueVtxCell;
281  gTrueVtxCellOther = trueVtxCellOther;
282 
283  gPhotL0 = photL0;
284  gPhotL1 = photL1;
285  gPhotE0 = photE0;
286  gPhotE1 = photE1;
287 
288  tr->Fill();
289  }
unsigned short nhits
Definition: EventSummary.h:53
unsigned char partIdx
Definition: LiteHit.h:26
float pecorr
Definition: LiteHit.h:24
unsigned short cellIdx
Definition: LiteHit.h:25
std::void_t< T > n
unsigned char nParts
Definition: EventSummary.h:67
assert(nhit_max >=nhit_nbins)
int gMode
Definition: pass1_plots.C:2

Member Data Documentation

int lem::EventSummary::ccnc
inherited
bool lem::EventSummary::enrich
inherited
int lem::EventSummary::event
inherited
double lem::EventSummary::fgChargePower = .5
staticinherited
double lem::EventSummary::fgDecayRate = 0
staticinherited
LiteHit* lem::EventSummary::hits
inherited
int lem::EventSummary::id
inherited

Definition at line 59 of file EventSummary.h.

Referenced by lem::Library::FromTrees(), and lem::EventSummary::operator=().

int lem::EventSummary::mode
inherited
unsigned short lem::EventSummary::nhits
inherited
unsigned char lem::EventSummary::nParts
inherited
int lem::EventSummary::origPdg
inherited
int* lem::EventSummary::partPdgs
inherited
int lem::EventSummary::pdg
inherited
double lem::EventSummary::photE0
inherited
double lem::EventSummary::photE1
inherited
double lem::EventSummary::photL0
inherited
double lem::EventSummary::photL1
inherited
int lem::EventSummary::run
inherited
float lem::MatchableEvent::selfEnergy
int lem::EventSummary::subrun
inherited
double lem::EventSummary::totalPE
inherited
double lem::EventSummary::trueEVis
inherited
int lem::EventSummary::trueVtxCell
inherited
int lem::EventSummary::trueVtxCellOther
inherited
int lem::EventSummary::trueVtxPlane
inherited
double lem::MatchableEvent::weight
double lem::EventSummary::y
inherited

The documentation for this class was generated from the following files: