1 |
#include "MyAnalysisTESCO.h"
|
2 |
|
3 |
#include <iostream>
|
4 |
|
5 |
MyAnalysisTESCO::MyAnalysisTESCO(TTree* tree):
|
6 |
CMSAnalysisSelectorTESCO(tree) {
|
7 |
}
|
8 |
|
9 |
void MyAnalysisTESCO::Initialise() {
|
10 |
// Initialise() is called at the start of the query at the worker nodes
|
11 |
// where the analysis is going to run
|
12 |
|
13 |
// Example of Accessing to different kind of Input Parameters
|
14 |
if ( mypar->GetString() ) ss = mypar->GetString();
|
15 |
ii = mypar->TheInt();
|
16 |
dd = mypar->TheDouble();
|
17 |
bb = mypar->TheBool();
|
18 |
if ( mypar->TheNamedString("sel1") ) sss = mypar->TheNamedString("sel1");
|
19 |
mypar->TheNamedInt("i1",iii);
|
20 |
mypar->TheNamedDouble("d1",ddd);
|
21 |
mypar->TheNamedBool("b1",bbb);
|
22 |
|
23 |
// Histograms and counters need to be created here
|
24 |
|
25 |
// Create a TH1F histogram: myhistogram is a pointer to TH1F
|
26 |
myHistogram = CreateH1F("myHistogram", "Number of Events", 21, -10., 10.);
|
27 |
fHmuPT = CreateH1F("fHmuPT", "P_{T}^{#mu}",100, 0., 200.);
|
28 |
// Create a TH1D histogram
|
29 |
// CreateH1D(const char* name, const char* title,
|
30 |
// Int_t nbinsx, Axis_t xlow, Axis_t xup)
|
31 |
// Create a TH2F histogram
|
32 |
// CreateH2F(const char* name, const char* title,
|
33 |
// Int_t nbinsx, Axis_t xlow, Axis_t xup,
|
34 |
// Int_t nbinsy, Axis_t ylow, Axis_t yup)
|
35 |
|
36 |
// Create a counter: nEvents is a TCounterUI
|
37 |
// InitCounterUI(const char* name, const char* title, unsigned int init)
|
38 |
nEvents = InitCounterUI("nEvents","Number of analyzed events",0);
|
39 |
}
|
40 |
|
41 |
void MyAnalysisTESCO::InsideLoop() {
|
42 |
// The InsideLoop() function is called for each entry in the tree to be processed
|
43 |
|
44 |
(*nEvents)++;
|
45 |
myHistogram->Fill(1);
|
46 |
fHmuPT->Fill(MuPt[0]);
|
47 |
}
|
48 |
|
49 |
void MyAnalysisTESCO::SetDataMembersAtTermination() {
|
50 |
// Get Data Members at the client-master (after finishing the analysis at the workers nodes)
|
51 |
// Only data members set here will be accesible at the client-master
|
52 |
|
53 |
// Replace myHistogram with the name of your histo and repeat for each histo
|
54 |
myHistogram = ((TH1F*) FindOutput("myHistogram"));
|
55 |
fHmuPT = ((TH1F*) FindOutput("fHmuPT"));
|
56 |
|
57 |
// Replace nEvents with the name of your counter and repeat for each counter
|
58 |
nEvents = ((TCounterUI*) FindOutput("nEvents"));
|
59 |
}
|
60 |
|
61 |
void MyAnalysisTESCO::Summary() {
|
62 |
|
63 |
// cout << "======" << endl;
|
64 |
// cout << "SUMARY" << endl;
|
65 |
// cout << "======" << endl;
|
66 |
|
67 |
// cout << " My Input Parameters " << endl;
|
68 |
// if (mypar) mypar->DumpParms();
|
69 |
|
70 |
cout << "------------------------------------------" << endl;
|
71 |
cout << *nEvents << " raw Events (no weighted) " << endl;
|
72 |
cout << "------------------------------------------" << endl;
|
73 |
}
|