Skip to content

Commit fa2da2d

Browse files
Complete instructions
1 parent 44f307d commit fa2da2d

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

README.md

+29-4
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ scram b -j 8
3333
<li> <strong>plugins/</strong>: which contains the plugins (EDAnalyzer's) where the analyzers are defined in .cc files. These are the main code.</li>
3434
<li> <strong>python/</strong>: which contains cfi files to setup the sequences that run with the plugins contained in plugins/. A sequence is an specific configuration of the parameters that run with one of the plugins defined in plugins. One single plugin may have different sequences defined in the same or multiple files.</li>
3535
<li> <strong>test/</strong>: which contains cfg files to run the sequences defined in the python/ folder.</li>
36+
<li> <strong>macros/</strong> (optional): which contains .py files to read the produced ntuples and create the plots if we don't have an external analyzer.</li>
3637
</ul>
3738

3839
### EDAnalyzer plugin
3940

40-
(to be completed)
41+
EDAnalyzer is a class that is designed to loop over the events of one or several ROOT files. It has several actions that are executed before the event loop in the ```beginJob()``` function, actions that are executed per event in the ```analyze()``` function and actions that are executed once the loop has finished in the ```endJob()``` function.
42+
43+
Each EDAnalyzer instance is associated with a module (don't forget to include this line):
44+
https://github.com/CeliaFernandez/standard-Ntuplizer/blob/5e3b77f976d88d9c812b7a5cff1a32b70b0cfe25/plugins/ntuplizer.cc#L265
45+
46+
In the case of the ntuplizer we would like to initialize the output file in the ```beginJob()``` function, fill the information per event in the ```analyze()``` function and finally close and save the file in the ```analyze()``` once all the information is saved.
47+
4148

4249
### Configuration cfi files and parameters
4350

@@ -66,6 +73,8 @@ https://github.com/CeliaFernandez/standard-Ntuplizer/blob/5e3b77f976d88d9c812b7a
6673

6774
### Configuration cfg files
6875

76+
The configurarion cfg file serves to run the plugins as described in Section "How to run".
77+
6978
## How to run
7079

7180
This example runs with a file of the 2023 NoBPTX dataset that may need to be accessed throught xrootd. Make sure that you have a valid proxy before running and do at least once:
@@ -85,9 +94,6 @@ cmsRun test/runNtuplizer_cfg.py
8594

8695
In this section (to be completed) there are several examples of how modify the existing analyzer.
8796

88-
### How to add a parameter
89-
90-
9197
### How to add new variables of an existing collection
9298

9399
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):
@@ -111,3 +117,22 @@ https://github.com/CeliaFernandez/standard-Ntuplizer/blob/df839c1226bc0d8acb6d3d
111117

112118
### How to read a new collection
113119

120+
To read collections we need to know the class of the objects we want to access and the label of the collection itself. If you don't know this information this command is useful:
121+
```
122+
edmDumpEventContent sample.root > eventcontent.txt
123+
```
124+
125+
For example, to access displaced muons in MiniAOD we need to know that the name of the collection is ```slimmedDisplacedMuons``` and that these are saved as ```pat::Muon``` objects.
126+
127+
Then, we need to define a Token and a Handler in the EDAnalyzer declaration as private variables:
128+
https://github.com/CeliaFernandez/standard-Ntuplizer/blob/5e3b77f976d88d9c812b7a5cff1a32b70b0cfe25/plugins/ntuplizer.cc#L66-L67
129+
130+
The Token is initialized in the constructor with the label of the collection and the type with the ```consumes``` method:
131+
https://github.com/CeliaFernandez/standard-Ntuplizer/blob/5e3b77f976d88d9c812b7a5cff1a32b70b0cfe25/plugins/ntuplizer.cc#L126
132+
(in this case the name of the collection is given as a parameter in the cfi file).
133+
134+
Then, we use the Token to load the collection (per event) in the Handler:
135+
https://github.com/CeliaFernandez/standard-Ntuplizer/blob/5e3b77f976d88d9c812b7a5cff1a32b70b0cfe25/plugins/ntuplizer.cc#L205
136+
137+
And this collection can be accesses inside ```analyze()``` as an ```std::vector``` of ```pat::Muon```.
138+

0 commit comments

Comments
 (0)