<div dir="ltr"><div><div>Thank you very much! I read that in useJetArea() but was not sure how to get around it. Your line "
fj.useJetArea(new fastjet::AreaDefinition(fastje<wbr>t::VoronoiAreaSpec()));" works perfectly. Passing it by value was a typo! <br><br></div>Cheers,<br></div>Alan<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 17, 2016 at 4:47 PM, Andy Buckley <span dir="ltr"><<a href="mailto:andy.buckley@cern.ch" target="_blank">andy.buckley@cern.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 17/10/16 15:29, Alan Kaptanoglu wrote:<br>
</span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I am trying to declare jets with area in the initialization section of<br>
my Rivet Analysis. I originally tried:<br>
<br>
fastjet::GhostedAreaSpec areaspec(2.5,1,0.01);<br>
fastjet::AreaDefinition<br>
area_def(fastjet::active_area_<wbr>explicit_ghosts,areaspec);<br>
FastJets jets(vfs, FastJets::ANTIKT, Rsmall);<br>
jets.useJetArea(area_def);<br>
jets.useInvisibles(JetAlg::ALL<wbr>_INVISIBLES);<br>
jets.useMuons(JetAlg::DECAY_MU<wbr>ONS);<br>
declare(jets, "jets");<br>
<br>
but this definition goes out of scope so when I ask for jet areas in my<br>
"analysis" section of my code, it complains the jets have no valid jet<br>
area associated with them. I next tried several versions of:<br>
<br>
areaspec = new fastjet::GhostedAreaSpec(2.5,1<wbr>,0.01);<br>
area_def = new<br>
fastjet::AreaDefinition(fastje<wbr>t::active_area_explicit_ghosts<wbr>,*areaspec);<br>
FastJets jets(vfs, FastJets::ANTIKT, Rsmall);<br>
jets.useJetArea(area_def);<br>
jets.useInvisibles(JetAlg::ALL<wbr>_INVISIBLES);<br>
jets.useMuons(JetAlg::DECAY_MU<wbr>ONS);<br>
declare(jets, "jets");<br>
<br>
where areaspec and area_def are private members of my Analysis class. I<br>
also tried initializing these variables in my constructor using<br>
initialization lists, as well as declaring them global variables (and<br>
yes, to my knowledge, I am also deleting them correctly if I use "new").<br>
In all these cases, the code runs correctly but complains at the end of<br>
a memory error, which is attached in a text file. Any idea why this is<br>
happening or how to fix?<br>
</blockquote>
<br></div></div>
Hi Alan,<br>
<br>
The AreaDefinition provided to FastJets must be a heap-allocated pointer whose ownership is then taken over by the FastJets object: it will delete the pointer at the end of the run so you shouldn't try to do that yourself. (This is documented on the useJetArea() function)<br>
<br>
To this end I usually make sure that I don't have a variable of my own pointing at that area def objects, e.g.<br>
fj.useJetArea(new fastjet::AreaDefinition(fastje<wbr>t::VoronoiAreaSpec()));<br>
<br>
As you noticed, if you pass in a locally allocated object, it goes out of scope and you get a crash. Although I'm not sure how you're able to pass it in by value rather than by pointer!<br>
<br>
I would like, if possible, to avoid this pointer ownership stuff in the FastJets interface... I'm sure it's possible, just needs a bit of care and thought about backward compatibility. Pointers were used historically because we need the option of a null AreaDefinition, and there's no such thing as a null reference in C++.<br>
<br>
Hope that helps,<br>
Andy<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Dr Andy Buckley, Lecturer / Royal Society University Research Fellow<br>
Particle Physics Expt Group, University of Glasgow<br>
</font></span></blockquote></div><br></div>