001
002
003
004
005
006
007
008
009
010
011
012
013 #include "GaudiKernel/ITHistSvc.h"
014
015
016
017
018
019 #include <TMath.h>
020 #include <TTree.h>
021
022 #include "CLHEP/Vector/LorentzVector.h"
023 #include "CLHEP/Matrix/Vector.h"
024 #include "CLHEP/Vector/ThreeVector.h"
025
026 #include "JetTagTools/JetFitterNtupleWriter.h"
027
028 #include "JetTagInfo/JetFitterTagInfo.h"
029
030 #include "JetEvent/Jet.h"
031
032 namespace Analysis {
033
034
035 JetFitterNtupleWriter::JetFitterNtupleWriter(const std::string& name,
036 const std::string& n, const IInterface* p):
037 AthAlgTool(name, n,p)
038 {
039 declareInterface<JetFitterNtupleWriter>(this);
040 }
041
042 JetFitterNtupleWriter::~JetFitterNtupleWriter() {
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060 std::vector<std::pair<std::string,JetFitterVariables*> >::iterator beginvar=m_variables.begin();
061 std::vector<std::pair<std::string,JetFitterVariables*> >::iterator endvar=m_variables.end();
062
063 for ( std::vector<std::pair<std::string,JetFitterVariables*> >::iterator iter=beginvar;iter!=endvar;
064 ++iter ) {
065 if ((*iter).second!=0) {
066 delete (*iter).second;
067 (*iter).second=0;
068 }
069 }
070
071 }
072
073
074 StatusCode JetFitterNtupleWriter::initialize() {
075
076 StatusCode sc=service( "THistSvc", m_histoSvc );
077 if( sc.isSuccess() ) {
078 ATH_MSG_INFO(name() << ": HistoSvc loaded successfully.");
079 } else {
080 ATH_MSG_ERROR(name() << ": HistoSvc could NOT bo loaded.");
081 return sc;
082 }
083
084 ATH_MSG_INFO(" Initialization of JetFitterNtupleWriter succesfull");
085 return StatusCode::SUCCESS;
086 }
087
088 StatusCode JetFitterNtupleWriter::finalize() {
089 ATH_MSG_INFO(" Finalization of JetFitterNtupleWriter succesfull");
090 return StatusCode::SUCCESS;
091 }
092
093
094
095 StatusCode JetFitterNtupleWriter::bookNtuple(const std::string & jetAuthor) {
096
097 ATH_MSG_DEBUG(" Trying to register ntuple for jetAuthor " << jetAuthor);
098
099
100 std::vector<std::pair<std::string,TTree*> >::iterator begin=m_tree.begin();
101 std::vector<std::pair<std::string,TTree*> >::iterator end=m_tree.end();
102
103
104 TTree* newTree(0);
105 for ( std::vector<std::pair<std::string,TTree*> >::iterator iter=begin;iter!=end;
106 ++iter ) {
107
108 if (jetAuthor==(*iter).first) {
109 ATH_MSG_DEBUG(" Tree with key " << jetAuthor << " is already there. Using the same tree");
110 newTree=(*iter).second;
111 if (newTree==0) {
112 ATH_MSG_WARNING(" The ntuple is an empty pointer ");
113 }
114 }
115 }
116
117 ATH_MSG_DEBUG("Already registered with pointer " << newTree);
118
119 if (newTree==0) {
120 newTree=new TTree(("JetFitterTag"+jetAuthor).c_str(),"Calibration variables for JetFitter");
121 m_tree.push_back(std::pair<std::string,TTree*>(jetAuthor,newTree));
122 JetFitterVariables* newVariables=new JetFitterVariables();
123
124 newTree->Branch("nVTX",&newVariables->nVTX,"nVTX/I");
125 newTree->Branch("nTracksAtVtx",&newVariables->nTracksAtVtx,"nTracksAtVtx/I");
126 newTree->Branch("nSingleTracks",&newVariables->nSingleTracks,"nSingleTracks/I");
127 newTree->Branch("energyFraction",&newVariables->energyFraction,"energyFraction/D");
128 newTree->Branch("mass",&newVariables->mass,"mass/D");
129 newTree->Branch("significance3d",&newVariables->significance3d,"significance3d/D");
130 newTree->Branch("flavour",&newVariables->flavour,"flavour/I");
131 newTree->Branch("deltaphi",&newVariables->deltaphi,"deltaphi/D");
132 newTree->Branch("deltaeta",&newVariables->deltaeta,"deltaeta/D");
133 newTree->Branch("jetpt",&newVariables->jetpt,"jetpt/D");
134 newTree->Branch("jeteta",&newVariables->jeteta,"jeteta/D");
135
136 m_variables.push_back(std::pair<std::string,JetFitterVariables*>(jetAuthor,newVariables));
137 }
138
139 ATH_MSG_DEBUG("Now registered with pointer " << newTree);
140
141
142 StatusCode sc = m_histoSvc->regTree("/RefFileJetFitter"+jetAuthor+"/JetFitterTag",newTree);
143 if(!sc)
144 {
145 ATH_MSG_ERROR("initialize() Could not register the tree");
146 return sc;
147 }
148
149 return StatusCode::SUCCESS;
150
151 }
152
153 StatusCode JetFitterNtupleWriter::fillNtuple(const std::string & hypothesis,
154 const std::string & jetAuthor,
155 const JetFitterTagInfo & jetFitterTagInfo,
156 const Jet & myJet) {
157
158 if (hypothesis!="") {
159
160 TTree* myTTree(0);
161
162 std::vector<std::pair<std::string,TTree*> >::iterator begin=m_tree.begin();
163 std::vector<std::pair<std::string,TTree*> >::iterator end=m_tree.end();
164
165 for ( std::vector<std::pair<std::string,TTree*> >::iterator iter=begin;iter!=end;
166 ++iter ) {
167 if ((*iter).first==jetAuthor) {
168 myTTree=(*iter).second;
169 }
170 }
171
172 JetFitterVariables* myVariables(0);
173 std::vector<std::pair<std::string,JetFitterVariables*> >::iterator beginvar=m_variables.begin();
174 std::vector<std::pair<std::string,JetFitterVariables*> >::iterator endvar=m_variables.end();
175
176 for ( std::vector<std::pair<std::string,JetFitterVariables*> >::iterator iter=beginvar;iter!=endvar;
177 ++iter ) {
178 if ((*iter).first==jetAuthor) {
179 myVariables=(*iter).second;
180 }
181 }
182
183 if (myVariables==0||myTTree==0) {
184 ATH_MSG_WARNING(" No Tree for the jetAuthor " << jetAuthor << ". Cannot fill ntuple; skipping this jet... ");
185 return StatusCode::FAILURE;
186 }
187
188 myVariables->nVTX=jetFitterTagInfo.nVTX();
189 myVariables->nTracksAtVtx=jetFitterTagInfo.nTracksAtVtx();
190 myVariables->nSingleTracks=jetFitterTagInfo.nSingleTracks();
191 myVariables->energyFraction=jetFitterTagInfo.energyFraction();
192 myVariables->mass=jetFitterTagInfo.mass();
193 myVariables->significance3d=jetFitterTagInfo.significance3d();
194 myVariables->deltaphi=jetFitterTagInfo.deltaphi();
195 myVariables->deltaeta=jetFitterTagInfo.deltaeta();
196 myVariables->flavour=0;
197 myVariables->jetpt=myJet.hlv().perp();
198 myVariables->jeteta=myJet.hlv().pseudoRapidity();
199
200 ATH_MSG_DEBUG(" nvtx " << myVariables->nVTX <<
201 " ntracksatvtx " << myVariables->nTracksAtVtx << " nsingletracks " << myVariables->nSingleTracks <<
202 " energyfraction " << myVariables->energyFraction << " myVariables->mass " << myVariables->mass <<
203 " myVariables->significance3d " << myVariables->significance3d << " myVariables->deltaphi " <<
204 myVariables->deltaphi << " myVariables->deltaeta " << myVariables->deltaeta);
205
206 if (hypothesis=="bottom") {
207 myVariables->flavour=5;
208 } else if (hypothesis=="charm") {
209 myVariables->flavour=4;
210 } else if (hypothesis=="light") {
211 myVariables->flavour=1;
212 } else {
213 myVariables->flavour=-1;
214 }
215
216
217 ATH_MSG_DEBUG(" the number of entries is: " << myTTree->GetEntries());
218
219 myTTree->Fill();
220
221 }
222
223 return StatusCode::SUCCESS;
224
225 }
226
227 }
228
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|