DAS  3.0
Das Analysis System
DAS::Unfolding::InclusiveJet1D Namespace Reference

Classes

struct  PtVariation
 

Functions

void getUnfHistPt (const vector< fs::path > &inputs, const fs::path &output, const int steering, const DT::Slice slice={1, 0})
 

Variables

static const std::vector< double > recBins {74,84,97,114,133,153,174,196,220,245,272,300,330,362,395,430,468,507,548,592,638,686,737,790,846,905,967,1032,1101,1172,1248,1327,1410,1497,1588,1684,1784,1890,2000,2116,2238,2366,2500,2640,2787,2941,3103,3273,3450,3637,3832}
 
static const std::vector< double > genBins {74 ,97 ,133 ,174 ,220 ,272 ,330 ,395 ,468 ,548 ,638 ,737 ,846 ,967 ,1101 ,1248 ,1410 ,1588 ,1784 ,2000 ,2238 ,2500 ,2787 ,3103 ,3450, 3832}
 
static const int nRecBins = recBins.size()-1
 
static const int nGenBins = genBins.size()-1
 
static const double minpt = recBins.front()
 
static const double maxpt = recBins.back()
 
static const double maxy = 2.0
 

Function Documentation

◆ getUnfHistPt()

void DAS::Unfolding::InclusiveJet1D::getUnfHistPt ( const vector< fs::path > &  inputs,
const fs::path &  output,
const int  steering,
const DT::Slice  slice = {1,0} 
)

Get histograms for unfolding only for pt (in d=1), without using TUnfoldBinning.

Then the output can be unfolded using unfold.

Todo:
try to use the underflow and overflow for matching out of the phase space...
Parameters
inputsinput ROOT files (n-tuple)
outputoutput ROOT file (n-tuple)
steeringparameters obtained from explicit options
slicenumber and index of slice
107  {1,0}
108  )
109 {
110  cout << __func__ << ' ' << slice << " start" << endl;
111 
112  DT::Flow flow(steering, inputs);
113  auto tIn = flow.GetInputTree(slice);
114  auto [fOut, tOut] = flow.GetOutput(output);
115 
116  DT::MetaInfo metainfo(tOut);
117  auto isMC = metainfo.Get<bool>("flags", "isMC");
118  int R = metainfo.Get<int>("flags", "R");
119 
120  auto gEv = isMC ? flow.GetBranchReadOnly<GenEvent>("genEvent") : nullptr;
121  auto rEv = flow.GetBranchReadOnly<RecEvent>("recEvent");
122  auto genJets = isMC ? flow.GetBranchReadOnly <vector<GenJet>>("genJets") : nullptr;
123  auto recJets = flow.GetBranchReadWrite<vector<RecJet>>("recJets");
124 
125  JMEmatching<>::maxDR = R/10./2.;
126  cout << "Radius for matching: " << JMEmatching<>::maxDR << endl;
127 
128  cout << "Setting variations" << endl;
129 
131  vector<PtVariation> variations { PtVariation("nominal") };
132  if (steering & DT::syst) {
133 
134  auto push = [&variations](auto... args) {
135  variations.emplace_back(args...);
136  };
137 
138  auto getvars = [&push,&metainfo](const char * category, auto indices) {
139  TList * ev_wgts = metainfo.List("variations", category);
140  for (TObject * obj: *ev_wgts) {
141  auto param = dynamic_cast<TParameter<int>*>(obj);
142  const int val = param->GetVal();
143  static int i = 0;
144  // in case of several members (e.g. NNPDF replicas)
145  for (int j = 0; j < val; ++j, ++i) {
146  TString varname = param->GetName();
147  if (val > 1) varname += j;
148  apply(push, indices(varname, i));
149  }
150  }
151  };
152  // JEC GJW RJW GEW REW
153  getvars(GenEvent::WeightVar, [](const char * v, int i) { return make_tuple(v, 0 , 0 , 0 , i , 0); });
154  getvars(RecEvent::WeightVar, [](const char * v, int i) { return make_tuple(v, 0 , 0 , 0 , 0 , i); });
155  getvars(RecJet :: ScaleVar, [](const char * v, int i) { return make_tuple(v, i , 0 , 0 , 0 , 0); });
156  }
157 
158  for (DT::Looper looper(tIn); looper(); ++looper) {
159  [[ maybe_unused ]]
160  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
161 
162  for (const PtVariation& v: variations) {
163 
164  v.tmp->Reset();
165 
166  auto evWgt = rEv->weights.at(v.iRecEvtWgt);
167  if (isMC) evWgt *= gEv->weights.at(v.iGenEvtWgt);
168 
169  vector<int> binIDs; // we save the indices of the filled bins to avoid trivial operations
170  for (const RecJet& recjet: *recJets) {
171  auto y = recjet.AbsRap();
172  if (y >= maxy) continue;
173  auto pt = recjet.CorrPt(v.iJEC);
174  if (pt < minpt || pt >= maxpt) continue;
175 
176  auto irecbin = v.rec->FindBin(pt);
177  if (find(binIDs.begin(), binIDs.end(), irecbin) == binIDs.end()) binIDs.push_back(irecbin);
178 
179  auto jWgt = recjet.weights.at(v.iRecJetWgt);
180 
181  v.rec->Fill(pt, evWgt * jWgt);
182  v.tmp->Fill(pt, evWgt * jWgt); // for cov
183  }
184 
185  for (auto x: binIDs) for (auto y: binIDs) {
186  double cCov = v.cov->GetBinContent(x,y),
187  cTmp = v.tmp->GetBinContent(x)*v.tmp->GetBinContent(y);
188  v.cov->SetBinContent(x,y,cCov+cTmp);
189  }
190  }
191 
192  if (!isMC) continue;
193 
194  JMEmatching matching(*recJets, *genJets);
195  for (const auto& [rec_it,gen_it]: matching.match_its) {
196 
197  auto genpt = gen_it->p4.Pt(),
198  geny = gen_it->AbsRap();
199 
200  bool LowGenPt = genpt < minpt,
201  HighGenPt = genpt >= maxpt,
202  HighGenY = geny >= maxy;
203  bool goodGen = (!LowGenPt) && (!HighGenPt) && (!HighGenY);
204 
205  for (const PtVariation& v: variations) {
206  auto gEvW = gEv->weights.at(v.iGenEvtWgt),
207  gJetW = gen_it->weights.at(v.iGenJetWgt);
208 
209  if (goodGen) v.gen->Fill(genpt, gEvW * gJetW);
210 
211  auto rEvW = rEv->weights.at(v.iRecEvtWgt),
212  rJetW = rec_it->weights.at(v.iRecJetWgt);
213 
214  auto recpt = rec_it->CorrPt(v.iJEC),
215  recy = abs(rec_it->Rapidity());
216 
217  bool LowRecPt = recpt < minpt,
218  HighRecPt = recpt >= maxpt,
219  HighRecY = recy >= maxy;
220  bool goodRec = (!LowRecPt) && (!HighRecPt) && (!HighRecY);
221 
222  if ( goodRec && goodGen) { v.RM->Fill(genpt, recpt, gEvW * gJetW * rEvW * rJetW );
223  v.missNoMatch->Fill(genpt, gEvW * gJetW * (1 - rEvW * rJetW) ); }
224  else if (!goodRec && goodGen) v.missOut->Fill(genpt, gEvW * gJetW );
225  else if ( goodRec && !goodGen) v.fakeOut->Fill( recpt, gEvW * gJetW * rEvW * rJetW );
226  }
228  } // end of loop on matched jets
229 
230  for (const auto& gen_it: matching.miss_its) {
231  for (const PtVariation& v: variations) {
232 
233  double y = gen_it->AbsRap();
234  if (y >= maxy) continue;
235  double pt = gen_it->p4.Pt();
236  if (pt < minpt || pt > maxpt) continue;
237 
238  auto evWgt = gEv->weights.at(v.iGenEvtWgt);
239  auto jWgt = gen_it->weights.at(v.iGenJetWgt);
240 
241  v.gen ->Fill(pt, evWgt * jWgt);
242  v.missNoMatch->Fill(pt, evWgt * jWgt);
243  }
244  } // end of loop on missed jets
245 
246  for (const auto& rec_it: matching.fake_its) {
247  for (const auto& v: variations) {
248 
249  double y = rec_it->AbsRap();
250  if (y >= maxy) continue;
251  double pt = rec_it->CorrPt(v.iJEC);
252  if (pt < minpt || pt > maxpt) continue;
253 
254  auto evWgt = rEv->weights.at(v.iRecEvtWgt) * gEv->weights.at(v.iGenEvtWgt);
255  auto jWgt = rec_it->weights.at(v.iRecJetWgt);
256 
257  v.fakeNoMatch->Fill(pt, evWgt * jWgt);
258  }
259  } // end of loop on fake jets
260  }
261 
262  fOut->cd();
263  for (PtVariation& v: variations)
264  v.Write(fOut);
265 
266  cout << __func__ << ' ' << slice << " stop" << endl;
267 }

Variable Documentation

◆ genBins

const std::vector<double> genBins {74 ,97 ,133 ,174 ,220 ,272 ,330 ,395 ,468 ,548 ,638 ,737 ,846 ,967 ,1101 ,1248 ,1410 ,1588 ,1784 ,2000 ,2238 ,2500 ,2787 ,3103 ,3450, 3832}
static

◆ maxpt

const double maxpt = recBins.back()
static

◆ maxy

const double maxy = 2.0
static

◆ minpt

const double minpt = recBins.front()
static

◆ nGenBins

const int nGenBins = genBins.size()-1
static

◆ nRecBins

const int nRecBins = recBins.size()-1
static

◆ recBins

const std::vector<double> recBins {74,84,97,114,133,153,174,196,220,245,272,300,330,362,395,430,468,507,548,592,638,686,737,790,846,905,967,1032,1101,1172,1248,1327,1410,1497,1588,1684,1784,1890,2000,2116,2238,2366,2500,2640,2787,2941,3103,3273,3450,3637,3832}
static
jmarExample.pt
pt
Definition: jmarExample.py:19
Darwin::Tools::Flow
User-friendly handling of input and output n-tuples.
Definition: Flow.h:80
Step::verbose
static bool verbose
Definition: Step.h:40
Ntupliser_cfg.args
args
Definition: Ntupliser_cfg.py:11
DAS::Unfolding::InclusiveJet1D::maxpt
static const double maxpt
Definition: getUnfHistPt.cc:41
Darwin::Tools::Looper
Facility to loop over a n-tuple, including parallelisation and printing.
Definition: Looper.h:22
Darwin::Tools::syst
@ syst
activate -s to systematic uncertainties
Definition: Options.h:34
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:68
DAS::Unfolding::InclusiveJet1D::minpt
static const double minpt
Definition: getUnfHistPt.cc:41
DAS::PhysicsObject::AbsRap
float AbsRap(const Uncertainties::Variation &=Uncertainties::nominal) const final
absolute rapidity
Definition: PhysicsObject.h:58
recjet
DAS::RecJet recjet
Definition: classes.h:15
DAS::PhysicsObject::CorrPt
float CorrPt(size_t i) const
corrected transverse momentum
Definition: PhysicsObject.h:55
Ntupliser_cfg.isMC
dictionary isMC
Definition: Ntupliser_cfg.py:62
DAS::PhysicsObject::weights
Weights weights
object weights
Definition: PhysicsObject.h:52
jercExample.inputs
def inputs
Definition: jercExample.py:118
Darwin::Tools::dev_null
static std::ostream dev_null(nullptr)
to redirect output stream to nowhere
DAS::Unfolding::InclusiveJet1D::maxy
static const double maxy
Definition: getUnfHistPt.cc:41