create account

Particle physics - exercise 1c solution (CORRECTED) by irelandscape

View this thread on: hive.blogpeakd.comecency.com
· @irelandscape ·
$20.26
Particle physics - exercise 1c solution (CORRECTED)
# 
#### Repository

https://github.com/BFuks/mad5-utopian-exercises

The files described in this post are saved as:
```console
ex1c-irelandscape/test_cms.cpp
ex1c-irelandscape/saf_reader.py
ex1c-irelandscape/pldoc.py
ex1c-irelandscape/ex1c.py
ex1c-irelandscape/xml_as_dict/
```

#### Introduction
	
This is my second post for providing a solution to @lemouth [third exercise](https://steemit.com/utopian-io/@lemouth/particle-physics-utopian-io-objects-isolation-histogramming-and-a-first-task-request) in his series about open-source implementation of LHC particle analysis.

It contains corrections to were kindly provided by @lemouth and I hope that the new results are correct.

My original answer to the exercise can be found at [here](https://steemit.com/utopian-io/@irelandscape/particle-physics-exercise-1c-solution)

https://s22.postimg.cc/ye61kq2xt/brush-1356383_640.jpg
[Image credits - [Pixabay](https://pixabay.com/en/brush-particles-wave-line-colorful-1356383)]

## Corrections

In my previous post I wrote:
> This new isolation procedure is applied to photons in the exercise and consists in calculating the sum of all transverse momenta of charged hadrons (Iπ), neutral hadrons (Iη) and photons (Iγ) within an angular distance  _dR_  of the subject photon.

>These sums are compared to the transverse momentum of the subject photon and if these are small enough the photon is tagged as a signal photon.

**Correction:** The photon that matches the above criteria is not yet selected as a signal photon. 
Instead it means that the photon has been isolated. 
That is, it is a photon with little activity from other particles within a certain angular distance.
This photon can then be further assessed to see if it should be considered as a signal photon for the analysis.

---

In my original C++ code, I attempted to clean the jets from the electrons as follows:
```cpp
// Remove jets electrons overlap auto cleaned_jets = PHYSICS->Isol->JetCleaning(jets, electrons, 0.2);
```

**Correction:**: This is only partly correct and @lemouth will explain the full procedure in a future post.
As a result, that code is now removed.

---

In my original C++ code, I tried to isolate photons using the sum of transverse momenta using the following code:
```cpp
    if (Igam >= (0.7 + (0.005 * photon_pt)) &&
        In >= (1.0  + (0.04 * photon_pt)) &&
        iPi >= 1.5 &&
        photon.HEoverEE() < 0.05 &&
        photon.abseta() < 1.44)
    {
	    ...
```
**Correction:** The above check is incorrect. Firstly, the transverse momenta should be lower than the expression on the right of each condition.
Secondly the photon itself contributes to the gamma transverse momentum so its transverse momentum should be substracted from the Igamma element.

The corrected code is thus:
```cpp
    if ((Igam - photon_pt) < (0.7 + (0.005 * photon_pt)) &&
        In < (1.0  + (0.04 * photon_pt)) &&
        iPi < 1.5 &&
        photon.HEoverEE() < 0.05 &&
        photon.abseta() < 1.44)
	{
		...
```

---

In my original code I added every signal jet and photon to the histograms.
@lemouth asked to only add the first of each element since Madanalysis5 already provide jets and photons sorted by descending transverse momentum.

The corrected code is thus:
```cpp
  // Extract jets (pt > 30GeV, |n| < 5)
  bool found = false;
  std::vector<RecJetFormat> signal_jets;
  for (auto &jet : event.rec()->jets())
  {
    if (jet.pt() > 30 && jet.abseta() < 5)
    {
      if (!found)
      {
        Manager()->FillHisto("pt_jets", jet.pt());
        Manager()->FillHisto("n_jets", jet.eta());
        found = true;
      }
      signal_jets.push_back(jet);
      cout << "Adding jet - Pt = " << jet.pt() << ", |n| = " << jet.eta() << endl;
    }
  }
...
    auto photon_pt = photon.pt();
    if ((Igam - photon_pt) < (0.7 + (0.005 * photon_pt)) &&
        In < (1.0  + (0.04 * photon_pt)) &&
        iPi < 1.5 &&
        photon.HEoverEE() < 0.05 &&
        photon.abseta() < 1.44)
    {
      cout << "Adding  photon: Pt = " << photon_pt << ", |n| = " << photon.eta() << endl;
      if (!found)
      {
        Manager()->FillHisto("pt_photons", photon_pt);
        Manager()->FillHisto("n_photons", photon.eta());
        found = true;
      }
    }
  }

```

## New Result

After applying the above corrections and executing the python script, the following diagrams are generated:
https://s22.postimg.cc/qokux6m81/histos.png

## Conclusions

I hope I have understood my mistakes and that the result is now correct.

## Resources
* [# Particle physics @ utopian-io - Objects isolation, histogramming and a first task request](https://steemit.com/utopian-io/@lemouth/particle-physics-utopian-io-objects-isolation-histogramming-and-a-first-task-request) by @lemouth
* [Search for new physics in the monophoton final state in proton-proton collisions at √ s = 13 TeV](https://arxiv.org/pdf/1706.03794.pdf)
* [Performance of photon reconstruction and identification with the CMS detector in proton-proton collisions at √ s = 8 TeV](https://arxiv.org/pdf/1502.02702.pdf)
* [Matplotlib](https://matplotlib.org).
* [XML AS DICTIONARY (PYTHON RECIPE)](https://code.activestate.com/recipes/410469-xml-as-dictionary/) by Duncan McGreggor
* [MadAnalysis5 Download](https://launchpad.net/madanalysis5/+download)

#### Series Backlinks

- [Particle Physics - @lemouth exercise 1a](https://steemit.com/utopian-io/@irelandscape/particle-physics-lemouth-exercise-1a)
- [Particle physics - exercise 1b solution](https://steemit.com/utopian-io/@mactro/particle-physics-exercise-1b-solution)
-  [Particle physics - exercise 1c solution](https://steemit.com/utopian-io/@irelandscape/particle-physics-exercise-1c-solution)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 191 others
properties (23)
authorirelandscape
permlinkparticle-physics-exercise-1c-solution-corrected
categoryutopian-io
json_metadata{"tags":["utopian-io","blog","steemstem","programming","physics"],"users":["lemouth"],"image":["https://s22.postimg.cc/ye61kq2xt/brush-1356383_640.jpg","https://s22.postimg.cc/qokux6m81/histos.png"],"links":["https://github.com/BFuks/mad5-utopian-exercises","https://steemit.com/utopian-io/@lemouth/particle-physics-utopian-io-objects-isolation-histogramming-and-a-first-task-request","https://steemit.com/utopian-io/@irelandscape/particle-physics-exercise-1c-solution","https://pixabay.com/en/brush-particles-wave-line-colorful-1356383","https://arxiv.org/pdf/1706.03794.pdf","https://arxiv.org/pdf/1502.02702.pdf","https://matplotlib.org","https://code.activestate.com/recipes/410469-xml-as-dictionary/","https://launchpad.net/madanalysis5/+download","https://steemit.com/utopian-io/@irelandscape/particle-physics-lemouth-exercise-1a","https://steemit.com/utopian-io/@mactro/particle-physics-exercise-1b-solution"],"app":"steemit/0.1","format":"markdown"}
created2018-06-27 13:27:27
last_update2018-06-27 13:27:27
depth0
children7
last_payout2018-07-04 13:27:27
cashout_time1969-12-31 23:59:59
total_payout_value15.553 HBD
curator_payout_value4.711 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,699
author_reputation15,380,678,988,494
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,485,402
net_rshares8,137,961,616,593
author_curate_reward""
vote details (255)
@kit.andres · (edited)
Hi. Thank you for the contribution.

You've created your own repository to solve the exercises proposed by lemouth, but is clear that your post is promoting the [MadAnalysis 5 framework](https://github.com/BFuks/madanalysis-utopian). For this reason, I think that you should add the MadAnalysis 5 framework repository in the first sections of your posts, instead the [https://github.com/BFuks/mad5-utopian-exercises](https://github.com/BFuks/mad5-utopian-exercises) repository, and, obviously, add the links to your own repository with the exercises solution in the sections that you consider it necessary.

It's great to find this kind of contributions here and see the way that lemouth is supporting the contributors and participants in the project, this is an open learning process that allows many things to be clear to the readers.

This post can be considered an extension of your previous post, [Particle physics - exercise 1c solution](https://steemit.com/utopian-io/@irelandscape/particle-physics-exercise-1c-solution), so considering that it's about corrections of your previous proposal, and that the volume of work in this post is minor, the score for this post will be a bit lower.

Thank you for your efforts and keep up the good work.

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/1/33431324).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
properties (22)
authorkit.andres
permlinkre-irelandscape-particle-physics-exercise-1c-solution-corrected-20180628t194308239z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://github.com/BFuks/madanalysis-utopian","https://github.com/BFuks/mad5-utopian-exercises","https://steemit.com/utopian-io/@irelandscape/particle-physics-exercise-1c-solution","https://join.utopian.io/guidelines","https://review.utopian.io/result/1/33431324","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-06-28 19:43:09
last_update2018-06-28 19:43:51
depth1
children0
last_payout2018-07-05 19:43:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,741
author_reputation31,454,326,251,184
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,655,746
net_rshares0
@lemouth ·
Thanks for implementing he corrections.

Strangely enough, the plotter is still not working. The error this time is still related to the format of the file (only svg seem to be allowed). Moreover, I have just noticed that `exo1c.py --help` returns a crash. Could you please update this? Thanks in advance!

I also think you forgot to commit the new  code ;)
properties (22)
authorlemouth
permlinkre-irelandscape-particle-physics-exercise-1c-solution-corrected-20180628t215212998z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-06-28 21:52:15
last_update2018-06-28 21:52:15
depth1
children2
last_payout2018-07-05 21:52:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length357
author_reputation338,011,164,701,274
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,665,795
net_rshares0
@irelandscape ·
Indeed I did forget to commit the changes.
Everything should be committed now.
properties (22)
authorirelandscape
permlinkre-lemouth-re-irelandscape-particle-physics-exercise-1c-solution-corrected-20180629t083441751z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-06-29 08:34:42
last_update2018-06-29 08:34:42
depth2
children1
last_payout2018-07-06 08:34:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length78
author_reputation15,380,678,988,494
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,715,269
net_rshares0
@lemouth · (edited)
Excellent! I now agree with your code :)
properties (22)
authorlemouth
permlinkre-irelandscape-re-lemouth-re-irelandscape-particle-physics-exercise-1c-solution-corrected-20180702t083736454z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-07-02 08:37:36
last_update2018-07-02 08:37:45
depth3
children0
last_payout2018-07-09 08:37:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length40
author_reputation338,011,164,701,274
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id63,103,722
net_rshares0
@steemitboard ·
Congratulations @irelandscape! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/comments.png)](http://steemitboard.com/@irelandscape) Award for the number of comments

<sub>_Click on the badge to view your Board of Honor._</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>


To support your work, I also upvoted your post!


**Do not miss the [last post](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-results-of-day-14) from @steemitboard!**

---
**Participate in the [SteemitBoard World Cup Contest](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-collect-badges-and-win-free-sbd)!**
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: [@good-karma](https://v2.steemconnect.com/sign/account-witness-vote?witness=good-karma&approve=1) and [@lukestokes](https://v2.steemconnect.com/sign/account-witness-vote?witness=lukestokes.mhth&approve=1)

---

> Do you like [SteemitBoard's project](https://steemit.com/@steemitboard)? Then **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-irelandscape-20180628t131920000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-06-28 13:19:18
last_update2018-06-28 13:19:18
depth1
children0
last_payout2018-07-05 13:19:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,339
author_reputation38,975,615,169,260
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,616,034
net_rshares0
@steemitboard ·
Congratulations @irelandscape! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png)](http://steemitboard.com/@irelandscape) Award for the number of upvotes

<sub>_Click on the badge to view your Board of Honor._</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the [last post](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-croatia-vs-denmark) from @steemitboard!**

---
**Participate in the [SteemitBoard World Cup Contest](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-collect-badges-and-win-free-sbd)!**
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: [@good-karma](https://v2.steemconnect.com/sign/account-witness-vote?witness=good-karma&approve=1) and [@lukestokes](https://v2.steemconnect.com/sign/account-witness-vote?witness=lukestokes.mhth&approve=1)

---

> Do you like [SteemitBoard's project](https://steemit.com/@steemitboard)? Then **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-irelandscape-20180701t051014000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-07-01 05:10:12
last_update2018-07-01 05:10:12
depth1
children0
last_payout2018-07-08 05:10:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,287
author_reputation38,975,615,169,260
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,951,630
net_rshares0
@utopian-io ·
Hey @irelandscape
**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-particle-physics-exercise-1c-solution-corrected-20180701t033509z
categoryutopian-io
json_metadata"{"app": "beem/0.19.29"}"
created2018-07-01 03:35:09
last_update2018-07-01 03:35:09
depth1
children0
last_payout2018-07-08 03:35:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length304
author_reputation152,955,367,999,756
root_title"Particle physics - exercise 1c solution (CORRECTED)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id62,944,244
net_rshares0