From df839c1226bc0d8acb6d3d5408cd9dad6daa94a6 Mon Sep 17 00:00:00 2001 From: CeliaFernandez Date: Mon, 9 Jan 2023 16:23:06 +0100 Subject: [PATCH] Add description of how to add a variable --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b7c9783..7cadb86 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ scram b -j 8

The analyzer consists of three folders:

## How to run @@ -54,7 +54,19 @@ cmsRun test/runNtuplizer_cfg.py In this section (to be completed) there are several examples of how modify the existing analyzer. -### How to add new variables +### How to add new variables of an existing collection + +1) We first need to declare a new variable that will act as a container for the value we want to store e.g. the number of displacedGlobalMuon tracks ```ndgl```. It is defined in the constructor of the EDAnalyzer as a private variable (although it could be also a global variable): +https://github.com/CeliaFernandez/standard-Ntuplizer/blob/8656711d7fa7d640a9ec160daa955738d283720e/plugins/ntuplizer.cc#L79 + +2) We then need to link this variable's address ```&ndlg``` to the TTree branch. This is done at the beginning, where the TTree is created in ```beginJob()```: +https://github.com/CeliaFernandez/standard-Ntuplizer/blob/8656711d7fa7d640a9ec160daa955738d283720e/plugins/ntuplizer.cc#L147 + +3) This variable will be saved inside the TTree once the Fill() command is executed: +https://github.com/CeliaFernandez/standard-Ntuplizer/blob/8656711d7fa7d640a9ec160daa955738d283720e/plugins/ntuplizer.cc#L244 +So the value of this variable should be assigned before that like: +https://github.com/CeliaFernandez/standard-Ntuplizer/blob/8656711d7fa7d640a9ec160daa955738d283720e/plugins/ntuplizer.cc#L210 +https://github.com/CeliaFernandez/standard-Ntuplizer/blob/8656711d7fa7d640a9ec160daa955738d283720e/plugins/ntuplizer.cc#L216 ### How to read a new collection