CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTHeavyIon.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <string>
7 #include <cmath>
8 #include <functional>
9 #include <stdlib.h>
10 #include <string.h>
11 
14 
15 // L1 related
17 
19 using namespace std;
20 
22  //set parameter defaults
23  _Monte = false;
24  _Debug = false;
25  _OR_BXes=false;
27  centralityBin_Label = edm::InputTag("centralityBin");
28  centralityBin_Token = iC.consumes<int>( centralityBin_Label);
29 }
30 
31 void
34  edm::ParameterSetDescription hltParameterSet;
35  desc.add<edm::ParameterSetDescription>("RunParameters",hltParameterSet);
36  desc.add<bool>("Debug",false);
37  desc.add<bool>("Monte",false);
38  descriptions.add("hltHeavyIon", desc);
39 }
40 
41 
43 
44  bool changed(true);
45  if (hltConfig_.init(run,c,processName_,changed)) {
46  // if init returns TRUE, initialisation has succeeded!
47  if (changed) {
48  // The HLT config has actually changed wrt the previous Run, hence rebook your
49  // histograms or do anything else dependent on the revised HLT config
50  cout << "Initalizing HLTConfigProvider" << endl;
51  }
52  } else {
53  // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
54  // with the file and/or code and needs to be investigated!
55  cout << " HLT config extraction failure with process name " << processName_ << endl;
56  // In this case, all access methods will return empty values!
57  }
58 
59 }
60 
61 /* Setup the analysis to put the branch-variables into the tree. */
62 void HLTHeavyIon::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
63 
64 
65  processName_ = pSet.getParameter<std::string>("HLTProcessName") ;
66 
67  edm::ParameterSet myHltParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
68  vector<std::string> parameterNames = myHltParams.getParameterNames() ;
69 
70  for ( vector<std::string>::iterator iParam = parameterNames.begin();
71  iParam != parameterNames.end(); iParam++ ){
72  if ( (*iParam) == "Debug" ) _Debug = myHltParams.getParameter<bool>( *iParam );
73  if ( (*iParam) == "Monte" ) _Monte = myHltParams.getParameter<bool>( *iParam );
74 
75  }
76 
77  HltEvtCnt = 0;
78  const int kMaxEvtPlanes = 1000;
79 
80  fNpart = -1;
81  fNcoll = -1;
82  fNhard = -1;
83  fPhi0 = -1;
84  fb = -1;
85  fNcharged = -1;
86  fNchargedMR = -1;
87  fMeanPt = -1;
88  fMeanPtMR = -1;
89 
90  fEtMR = -1;
91  fNchargedPtCut = -1;
92  fNchargedPtCutMR = -1;
93 
94  nEvtPlanes = 0;
95  hiBin = -1;
96  hiEvtPlane = new float[kMaxEvtPlanes];
97 
98  HltTree->Branch("Npart",&fNpart,"Npart/F");
99  HltTree->Branch("Ncoll",&fNcoll,"Ncoll/F");
100  HltTree->Branch("Nhard",&fNhard,"Nhard/F");
101  HltTree->Branch("phi0",&fPhi0,"NPhi0/F");
102  HltTree->Branch("b",&fb,"b/F");
103  HltTree->Branch("Ncharged",&fNcharged,"Ncharged/I");
104  HltTree->Branch("NchargedMR",&fNchargedMR,"NchargedMR/I");
105  HltTree->Branch("MeanPt",&fMeanPt,"MeanPt/F");
106  HltTree->Branch("MeanPtMR",&fMeanPtMR,"MeanPtMR/F");
107  HltTree->Branch("EtMR",&fEtMR,"EtMR/F");
108  HltTree->Branch("NchargedPtCut",&fNchargedPtCut,"NchargedPtCut/I");
109  HltTree->Branch("NchargedPtCutMR",&fNchargedPtCutMR,"NchargedPtCutMR/I");
110  HltTree->Branch("hiBin",&hiBin,"hiBin/I");
111  HltTree->Branch("hiHF",&hiHF,"hiHF/F");
112  HltTree->Branch("hiHFplus",&hiHFplus,"hiHFplus/F");
113  HltTree->Branch("hiHFminus",&hiHFminus,"hiHFminus/F");
114  HltTree->Branch("hiZDC",&hiZDC,"hiZDC/F");
115  HltTree->Branch("hiZDCplus",&hiZDCplus,"hiZDCplus/F");
116  HltTree->Branch("hiZDCminus",&hiZDCminus,"hiZDCminus/F");
117 
118  HltTree->Branch("hiHFhit",&hiHFhit,"hiHFhit/F");
119  HltTree->Branch("hiHFhitPlus",&hiHFhitPlus,"hiHFhitPlus/F");
120  HltTree->Branch("hiHFhitMinus",&hiHFhitMinus,"hiHFhitMinus/F");
121 
122  HltTree->Branch("hiET",&hiET,"hiET/F");
123  HltTree->Branch("hiEE",&hiEE,"hiEE/F");
124  HltTree->Branch("hiEB",&hiEB,"hiEB/F");
125  HltTree->Branch("hiEEplus",&hiEEplus,"hiEEplus/F");
126  HltTree->Branch("hiEEminus",&hiEEminus,"hiEEminus/F");
127  HltTree->Branch("hiNpix",&hiNpix,"hiNpix/I");
128  HltTree->Branch("hiNpixelTracks",&hiNpixelTracks,"hiNpixelTracks/I");
129  HltTree->Branch("hiNtracks",&hiNtracks,"hiNtracks/I");
130  HltTree->Branch("hiNevtPlane",&nEvtPlanes,"hiNevtPlane/I");
131  HltTree->Branch("hiEvtPlanes",hiEvtPlane,"hiEvtPlanes/F");
132  HltTree->Branch("hiNtracksPtCut",&hiNtracksPtCut,"hiNtracksPtCut/I");
133  HltTree->Branch("hiNtracksEtaCut",&hiNtracksEtaCut,"hiNtracksEtaCut/I");
134  HltTree->Branch("hiNtracksEtaPtCut",&hiNtracksEtaPtCut,"hiNtracksEtaPtCut/I");
135 
136 }
137 
138 /* **Analyze the event** */
140  const edm::Handle<reco::Centrality> & centrality,
141  const edm::Handle<reco::EvtPlaneCollection> & evtPlanes,
142  const edm::Handle<edm::GenHIEvent> & mc,
143  edm::EventSetup const& eventSetup,
144  edm::Event const& iEvent,
145  TTree* HltTree) {
146 
147  std::cout << " Beginning HLTHeavyIon " << std::endl;
148 
149  if(_Monte){
150  fb = mc->b();
151  fNpart = mc->Npart();
152  fNcoll = mc->Ncoll();
153  fNhard = mc->Nhard();
154  fPhi0 = mc->evtPlane();
155  fNcharged = mc->Ncharged();
156  fNchargedMR = mc->NchargedMR();
157  fMeanPt = mc->MeanPt();
158  fMeanPtMR = mc->MeanPtMR();
159  fEtMR = mc->EtMR();
160  fNchargedPtCut = mc->NchargedPtCut();
161  fNchargedPtCutMR = mc->NchargedPtCutMR();
162  }
163 
164  edm::Handle<int> binHandle;
165  iEvent.getByToken(centralityBin_Token,binHandle);
166  hiBin = *binHandle;
167 
168  hiNpix = centrality->multiplicityPixel();
169  hiNpixelTracks = centrality->NpixelTracks();
170  hiNtracks = centrality->Ntracks();
171  hiNtracksPtCut = centrality->NtracksPtCut();
172  hiNtracksEtaCut = centrality->NtracksEtaCut();
173  hiNtracksEtaPtCut = centrality->NtracksEtaPtCut();
174 
175  hiHF = centrality->EtHFtowerSum();
176  hiHFplus = centrality->EtHFtowerSumPlus();
177  hiHFminus = centrality->EtHFtowerSumMinus();
178  hiHFhit = centrality->EtHFhitSum();
179  hiHFhitPlus = centrality->EtHFhitSumPlus();
180  hiHFhitMinus = centrality->EtHFhitSumMinus();
181 
182  hiZDC = centrality->zdcSum();
183  hiZDCplus = centrality->zdcSumPlus();
184  hiZDCminus = centrality->zdcSumMinus();
185 
186  hiEEplus = centrality->EtEESumPlus();
187  hiEEminus = centrality->EtEESumMinus();
188  hiEE = centrality->EtEESum();
189  hiEB = centrality->EtEBSum();
190  hiET = centrality->EtMidRapiditySum();
191 
192 
193  if(evtPlanes.isValid()){
194  nEvtPlanes = evtPlanes->size();
195  for(unsigned int i = 0; i < evtPlanes->size(); ++i){
196  hiEvtPlane[i] = (*evtPlanes)[i].angle();
197  }
198  }
199 
200 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void analyze(const edm::Handle< edm::TriggerResults > &hltresults, const edm::Handle< reco::Centrality > &centrality, const edm::Handle< reco::EvtPlaneCollection > &evtPlanes, const edm::Handle< edm::GenHIEvent > &hiMC, edm::EventSetup const &eventSetup, edm::Event const &iEvent, TTree *tree)
Definition: HLTHeavyIon.cc:139
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: HLTHeavyIon.cc:42
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > getParameterNames() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTHeavyIon.cc:32
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
HLTHeavyIon(edm::ConsumesCollector &&iC)
Definition: HLTHeavyIon.cc:21
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTHeavyIon.cc:62
void add(std::string const &label, ParameterSetDescription const &psetDescription)
tuple cout
Definition: gather_cfg.py:121
Definition: Run.h:43