Skip to content

Commit

Permalink
Add parameters description
Browse files Browse the repository at this point in the history
  • Loading branch information
CeliaFernandez committed Jan 9, 2023
1 parent e4cb98a commit 5e3b77f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ scram b -j 8
<li> <strong>test/</strong>: which contains cfg files to run the sequences defined in the python/ folder.</li>
</ul>

### EDAnalyzer plugin

(to be completed)

### Configuration cfi files and parameters

Parameters are values that are defined "per sequence" and serve to configure how the code should run. For example, if we want to run the same EDAnalyzer for both data and Monte Carlo we may need to know if the generation variables can be accesed or not as if we try to access them in data we may likely get an error. This could be done via parameters.

Each parameter as a variable that is declared in the EDAnalyzer constructor as a private variable that can be used when the code is running. For example, to indicate if we are running on data samples we have can define a bool variable ```isData```:



### Configuration cfg files

## How to run

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:
Expand All @@ -54,6 +68,9 @@ cmsRun test/runNtuplizer_cfg.py

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

### How to add a parameter


### 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):
Expand Down
21 changes: 19 additions & 2 deletions plugins/ntuplizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class ntuplizer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
// --- Variables
//

bool isData = false;

// Event
Int_t event = 0;
Int_t lumiBlock = 0;
Expand Down Expand Up @@ -97,6 +99,7 @@ class ntuplizer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
Int_t dmu_isDSA[200] = {0};
Int_t dmu_isDGL[200] = {0};
Int_t dmu_isDTK[200] = {0};
Float_t dmu_dsa_pt[200] = {0.};

//
// --- Output
Expand All @@ -117,6 +120,7 @@ ntuplizer::ntuplizer(const edm::ParameterSet& iConfig) {

counts = new TH1F("counts", "", 1, 0, 1);

isData = consumes<edm::View<reco::Track> > (parameters.getParameter<edm::InputTag>("displacedGlobalCollection"));
dglToken = consumes<edm::View<reco::Track> > (parameters.getParameter<edm::InputTag>("displacedGlobalCollection"));
dsaToken = consumes<edm::View<reco::Track> > (parameters.getParameter<edm::InputTag>("displacedStandAloneCollection"));
dmuToken = consumes<edm::View<pat::Muon> > (parameters.getParameter<edm::InputTag>("displacedMuonCollection"));
Expand All @@ -134,12 +138,15 @@ void ntuplizer::beginJob() {

std::cout << "Begin Job" << std::endl;

// Init the file and the TTree
output_filename = parameters.getParameter<std::string>("nameOfOutput");
file_out = new TFile(output_filename.c_str(), "RECREATE");

tree_out = new TTree("Events", "Events");

// Tree branches
// Analyzer parameters
isData = parameters.getParameter<bool>("isData");

// TTree branches
tree_out->Branch("event", &event, "event/I");
tree_out->Branch("lumiBlock", &lumiBlock, "lumiBlock/I");
tree_out->Branch("run", &run, "run/I");
Expand All @@ -163,6 +170,7 @@ void ntuplizer::beginJob() {
tree_out->Branch("dmu_isDSA", dmu_isDSA, "dmu_isDSA[ndmu]/I");
tree_out->Branch("dmu_isDGL", dmu_isDGL, "dmu_isDGL[ndmu]/I");
tree_out->Branch("dmu_isDTK", dmu_isDTK, "dmu_isDTK[ndmu]/I");
tree_out->Branch("dmu_dsa_pt", dmu_dsa_pt, "dmu_dsa_pt[ndmu]/F");


}
Expand Down Expand Up @@ -213,6 +221,7 @@ void ntuplizer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
dgl_pt[ndgl] = dgl.pt();
dgl_eta[ndgl] = dgl.eta();
dgl_phi[ndgl] = dgl.phi();
dgl_nhits[ndgl] = dgl.hitPattern().numberOfValidHits();
ndgl++;
}

Expand All @@ -223,6 +232,7 @@ void ntuplizer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
dsa_pt[ndsa] = dsa.pt();
dsa_eta[ndsa] = dsa.eta();
dsa_phi[ndsa] = dsa.phi();
dsa_nhits[ndsa] = dsa.hitPattern().numberOfValidHits();
ndsa++;
}

Expand All @@ -236,6 +246,13 @@ void ntuplizer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
dmu_isDGL[ndmu] = dmuon.isGlobalMuon();
dmu_isDSA[ndmu] = dmuon.isStandAloneMuon();
dmu_isDTK[ndmu] = dmuon.isTrackerMuon();

// Access the DSA track associated to the displacedMuon
if ( dmuon.isStandAloneMuon() ) {
const reco::Track* outerTrack = (dmuon.standAloneMuon()).get();
dmu_dsa_pt[ndmu] = outerTrack->pt();
}

ndmu++;
}

Expand Down

0 comments on commit 5e3b77f

Please sign in to comment.