All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
TJjetsPFOAnalysisProcessor.cpp
Go to the documentation of this file.
2 
4 
5 
7  Processor("TJjetsPFOAnalysisProcessor"),
8  // Parameters for PFOAnalysis
9  m_nRun(0),
10  m_nEvt(0),
11  m_nRunSum(0),
12  m_nEvtSum(0),
13  m_printing(0),
14  m_lookForQuarksWithMotherZ(0),
15  m_mcPfoSelectionRadius(500.f),
16  m_mcPfoSelectionMomentum(0.01f),
17  m_mcPfoSelectionLowEnergyNPCutOff(1.2f),
18  m_nPfosTotal(0),
19  m_nPfosNeutralHadrons(0),
20  m_nPfosPhotons(0),
21  m_nPfosTracks(0),
22  m_pfoEnergyTotal(0.f),
23  m_pfoEnergyNeutralHadrons(0.f),
24  m_pfoEnergyPhotons(0.f),
25  m_pfoEnergyTracks(0.f),
26  m_pfoECalToEmEnergy(0.f),
27  m_pfoECalToHadEnergy(0.f),
28  m_pfoHCalToEmEnergy(0.f),
29  m_pfoHCalToHadEnergy(0.f),
30  m_pfoMuonToEnergy(0.f),
31  m_pfoOtherEnergy(0.f),
32  m_pfoMassTotal(0.f),
33  m_nPfoTargetsTotal(0),
34  m_nPfoTargetsNeutralHadrons(0),
35  m_nPfoTargetsPhotons(0),
36  m_nPfoTargetsTracks(0),
37  m_pfoTargetsEnergyTotal(0.f),
38  m_pfoTargetsEnergyNeutralHadrons(0.f),
39  m_pfoTargetsEnergyPhotons(0.f),
40  m_pfoTargetsEnergyTracks(0.f),
41  m_mcEnergyENu(0.f),
42  m_mcEnergyFwd(0.f),
43  m_eQQ(-99.f),
44  m_eQ1(-99.f),
45  m_eQ2(-99.f),
46  m_costQQ(-99.f),
47  m_costQ1(-99.f),
48  m_costQ2(-99.f),
49  m_mQQ(-99.f),
50  m_thrust(-99.f),
51  m_qPdg(-99.f),
52  m_pTFile(NULL),
53  m_pTTree(NULL),
54  m_hPfoEnergySum(NULL),
55  m_hPfoEnergySumL7A(NULL)
56 {
57  _description = "TJjetsPFOAnalysisProcessor: Basically a copy-pasted version of the PFOAnalysis processor working on individual TrueJet jets" ;
58 
59 
60 
61 
62  // Standard input collections
63  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
64  "InputAllPFOsCollection",
65  "Name of the PFOs collection",
67  std::string("PandoraPFOs")
68  );
69 
70  registerInputCollection( LCIO::MCPARTICLE,
71  "MCParticleCollection",
72  "Name of the MC particle collection",
73  _colMC,
74  std::string("MCParticle")
75  );
76 
77 
78  // Collection for TrueJet
79 
80  registerInputCollection( LCIO::LCRELATION,
81  "RecoMCTruthLink",
82  "Name of the RecoMCTruthLink input collection" ,
84  std::string("RecoMCTruthLink") ) ;
85 
86  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
87  "TrueJets" ,
88  "Name of the TrueJetCollection output collection" ,
89  _trueJetCollectionName ,
90  std::string("TrueJets") ) ;
91 
92  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
93  "FinalColourNeutrals" ,
94  "Name of the FinalColourNeutralCollection output collection" ,
95  _finalColourNeutralCollectionName ,
96  std::string("FinalColourNeutrals") ) ;
97 
98  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
99  "InitialColourNeutrals" ,
100  "Name of the InitialColourNeutralCollection output collection" ,
101  _initialColourNeutralCollectionName ,
102  std::string("InitialColourNeutrals") ) ;
103 
104  registerInputCollection( LCIO::LCRELATION,
105  "TrueJetPFOLink" ,
106  "Name of the TrueJetPFOLink output collection" ,
107  _trueJetPFOLink,
108  std::string("TrueJetPFOLink") ) ;
109 
110  registerInputCollection( LCIO::LCRELATION,
111  "TrueJetMCParticleLink" ,
112  "Name of the TrueJetMCParticleLink output collection" ,
113  _trueJetMCParticleLink,
114  std::string("TrueJetMCParticleLink") ) ;
115 
116  registerInputCollection( LCIO::LCRELATION,
117  "FinalElementonLink" ,
118  "Name of the FinalElementonLink output collection" ,
119  _finalElementonLink,
120  std::string("FinalElementonLink") ) ;
121 
122  registerInputCollection( LCIO::LCRELATION,
123  "InitialElementonLink" ,
124  "Name of the InitialElementonLink output collection" ,
125  _initialElementonLink,
126  std::string("InitialElementonLink") ) ;
127 
128  registerInputCollection( LCIO::LCRELATION,
129  "FinalColourNeutralLink" ,
130  "Name of the FinalColourNeutralLink output collection" ,
131  _finalColourNeutralLink,
132  std::string("FinalColourNeutralLink") ) ;
133 
134  registerInputCollection( LCIO::LCRELATION,
135  "InitialColourNeutralLink" ,
136  "Name of the InitialColourNeutralLink output collection" ,
137  _initialColourNeutralLink,
138  std::string("InitialColourNeutralLink") ) ;
139 
140 
141 
142  // Collections for PFOAnalysis
143 
144  registerProcessorParameter(
145  "LookForQuarksWithMotherZ",
146  "Flag to look for quarks with mother Z",
148  int(0));
149 
150  registerProcessorParameter(
151  "MCPfoSelectionRadius",
152  "MC pfo selection radius",
154  float(500.f));
155 
156  registerProcessorParameter(
157  "MCPfoSelectionMomentum",
158  "MC pfo selection momentum",
160  float(0.01f));
161 
162  registerProcessorParameter(
163  "MCPfoSelectionLowEnergyNPCutOff",
164  "MC pfo selection neutron and proton low energy cut-off",
166  float(1.0f));
167 
168  registerProcessorParameter(
169  "RootFile",
170  "Name of the output root file",
171  m_rootFile,
172  std::string("PFOAnalysis.root"));
173 
174 }
175 
176 
177 
179  streamlog_out(DEBUG) << " init called " << std::endl ;
180 
181  // usually a good idea to
182  printParameters() ;
183 
184  m_nRun = 0;
185  m_nEvt = 0;
186  m_nRunSum = 0;
187  m_nEvtSum = 0;
188  this->Clear();
189 
190  m_pTFile = new TFile(m_rootFile.c_str(), "recreate");
191  makeNTuple() ;
192 }
193 
194 
196  m_pTTree = new TTree("PfoAnalysisTree", "PfoAnalysisTree");
197  m_pTTree->SetDirectory(m_pTFile);
198  m_pTTree->Branch("run", &m_nRun, "run/I");
199  m_pTTree->Branch("event", &m_nEvt, "event/I");
200  m_pTTree->Branch("jet", &m_nJet, "jet/I");
201 
202  m_pTTree->Branch("jetInitElPDG", &m_jetInitElPDG, "jetInitElPDG/I");
203  m_pTTree->Branch("jetFinElPDG", &m_jetInitElPDG, "jetFinElPDG/I");
204 
205  m_pTTree->Branch("nPfosTotal", &m_nPfosTotal, "nPfosTotal/I");
206  m_pTTree->Branch("nPfosNeutralHadrons", &m_nPfosNeutralHadrons, "nPfosNeutralHadrons/I");
207  m_pTTree->Branch("nPfosPhotons", &m_nPfosPhotons, "nPfosPhotons/I");
208  m_pTTree->Branch("nPfosTracks", &m_nPfosTracks, "nPfosTracks/I");
209  m_pTTree->Branch("pfoEnergyTotal", &m_pfoEnergyTotal, "pfoEnergyTotal/F");
210  m_pTTree->Branch("pfoEnergyNeutralHadrons", &m_pfoEnergyNeutralHadrons, "pfoEnergyNeutralHadrons/F");
211  m_pTTree->Branch("pfoEnergyPhotons", &m_pfoEnergyPhotons, "pfoEnergyPhotons/F");
212  m_pTTree->Branch("pfoEnergyTracks", &m_pfoEnergyTracks, "pfoEnergyTracks/F");
213  m_pTTree->Branch("pfoECalToEmEnergy", &m_pfoECalToEmEnergy, "pfoECalToEmEnergy/F");
214  m_pTTree->Branch("pfoECalToHadEnergy", &m_pfoECalToHadEnergy, "pfoECalToHadEnergy/F");
215  m_pTTree->Branch("pfoHCalToEmEnergy", &m_pfoHCalToEmEnergy, "pfoHCalToEmEnergy/F");
216  m_pTTree->Branch("pfoHCalToHadEnergy", &m_pfoHCalToHadEnergy, "pfoHCalToHadEnergy/F");
217  m_pTTree->Branch("pfoOtherEnergy", &m_pfoOtherEnergy, "pfoOtherEnergy/F");
218  m_pTTree->Branch("pfoMuonToEnergy", &m_pfoMuonToEnergy, "pfoMuonToEnergy/F");
219  m_pTTree->Branch("pfoMassTotal", &m_pfoMassTotal, "pfoMassTotal/F");
220  m_pTTree->Branch("pfoEnergies", &m_pfoEnergies);
221  m_pTTree->Branch("pfoPx", &m_pfoPx);
222  m_pTTree->Branch("pfoPy", &m_pfoPy);
223  m_pTTree->Branch("pfoPz", &m_pfoPz);
224  m_pTTree->Branch("pfoCosTheta", &m_pfoCosTheta);
225  m_pTTree->Branch("pfoTargetEnergies", &m_pfoTargetEnergies);
226  m_pTTree->Branch("pfoTargetPx", &m_pfoTargetPx);
227  m_pTTree->Branch("pfoTargetPy", &m_pfoTargetPy);
228  m_pTTree->Branch("pfoTargetPz", &m_pfoTargetPz);
229  m_pTTree->Branch("pfoTargetCosTheta", &m_pfoTargetCosTheta);
230  m_pTTree->Branch("pfoPdgCodes", &m_pfoPdgCodes);
231  m_pTTree->Branch("pfoTargetPdgCodes", &m_pfoTargetPdgCodes);
232  m_pTTree->Branch("nPfoTargetsTotal", &m_nPfoTargetsTotal, "nPfoTargetsTotal/I");
233  m_pTTree->Branch("nPfoTargetsNeutralHadrons", &m_nPfoTargetsNeutralHadrons, "nPfoTargetsNeutralHadrons/I");
234  m_pTTree->Branch("nPfoTargetsPhotons", &m_nPfoTargetsPhotons, "nPfoTargetsPhotons/I");
235  m_pTTree->Branch("nPfoTargetsTracks", &m_nPfoTargetsTracks, "nPfoTargetsTracks/I");
236  m_pTTree->Branch("pfoTargetsEnergyTotal", &m_pfoTargetsEnergyTotal, "pfoTargetsEnergyTotal/F");
237  m_pTTree->Branch("pfoTargetsEnergyNeutralHadrons", &m_pfoTargetsEnergyNeutralHadrons, "pfoTargetsEnergyNeutralHadrons/F");
238  m_pTTree->Branch("pfoTargetsEnergyPhotons", &m_pfoTargetsEnergyPhotons, "pfoTargetsEnergyPhotons/F");
239  m_pTTree->Branch("pfoTargetsEnergyTracks", &m_pfoTargetsEnergyTracks, "pfoTargetsEnergyTracks/F");
240  m_pTTree->Branch("mcEnergyENu", &m_mcEnergyENu, "mcEnergyENu/F");
241  m_pTTree->Branch("mcEnergyFwd", &m_mcEnergyFwd, "mcEnergyFwd/F");
242  m_pTTree->Branch("eQQ", &m_eQQ, "eQQ/F");
243  m_pTTree->Branch("eQ1", &m_eQ1, "eQ1/F");
244  m_pTTree->Branch("eQ2", &m_eQ2, "eQ2/F");
245  m_pTTree->Branch("costQQ", &m_costQQ, "costQQ/F");
246  m_pTTree->Branch("costQ1", &m_costQ1, "costQ1/F");
247  m_pTTree->Branch("costQ2", &m_costQ2, "costQ2/F");
248  m_pTTree->Branch("mQQ", &m_mQQ, "mQQ/F");
249  m_pTTree->Branch("thrust", &m_thrust, "thrust/F");
250  m_pTTree->Branch("qPdg", &m_qPdg, "qPdg/I");
251 
252  m_hPfoEnergySum = new TH1F("fPFA", "total pfo energy", 10000, 0., 5000.);
253  m_hPfoEnergySumL7A = new TH1F("fPFA_L7A", "total pfo energy < 0.7 A", 10000, 0., 5000.);
254  m_hPfoEnergySum->SetDirectory(m_pTFile);
255  m_hPfoEnergySumL7A->SetDirectory(m_pTFile);
256 }
257 
258 
259 
260 void TJjetsPFOAnalysisProcessor::processRunHeader( LCRunHeader* /*run*/) {
261  m_nRun = 0;
262  m_nEvt = 0;
263  ++m_nRunSum;
264 }
265 
266 
267 
268 
269 
271 
272  // tj is a pointer to a Trujet_Parser, with the data of this processor object:
273  TrueJet_Parser* tj= this ;
274  // this method gets all the collections needed + initialises a few convienent variables.
275  tj->getall(event);
276 
277 
278  m_nRun = event->getRunNumber();
279  m_nEvt = event->getEventNumber();
280  ++m_nEvtSum;
281 
282  if ((m_nEvtSum % 100) == 0)
283  std::cout << " processed events: " << m_nEvtSum << std::endl;
284 
285  m_jets.clear();
286  this->findTrueJetParticles(event);
287 
288  for (int i_jet=0; i_jet<njets(); i_jet++) {
289  m_nJet = i_jet;
290  this->Clear();
291 
292  if( initial_elementon(i_jet) != NULL) {
293  m_jetInitElPDG = initial_elementon(i_jet)->getPDG();
294  } else {
295  m_jetInitElPDG = 0;
296  }
297  if( final_elementon(i_jet) != NULL) {
298  m_jetFinElPDG = final_elementon(i_jet)->getPDG();
299  } else {
300  m_jetFinElPDG = 0;
301  }
302 
303 
304  this->ExtractCollections(m_jets[i_jet]);
305  this->MakeQuarkVariables(m_jets[i_jet]);
306  this->PerformPfoAnalysis();
307 
308  m_pTTree->Fill();
309 
310  delete m_jets[i_jet];
311  }
312 }
313 
314 
315 
316 void TJjetsPFOAnalysisProcessor::check( LCEvent * /*event*/ ) {
317  // nothing to check here - could be used to fill checkplots in reconstruction processor
318 }
319 
320 
322  if (m_printing > -1)
323  {
324  std::cout << "PfoAnalysis::end() " << this->name() << " processed " << m_nEvtSum << " events in " << m_nRunSum << " runs " << std::endl
325  << "Rootfile: " << m_rootFile.c_str() << std::endl;
326  }
327 
328  m_pTFile->cd();
329  m_pTTree->Write();
330  m_hPfoEnergySum->Write();
331  m_hPfoEnergySumL7A->Write();
332 
333  m_pTFile->Close();
334  delete m_pTFile;
335 }
TJjetsPFOAnalysisProcessor aTJjetsPFOAnalysisProcessor
void MakeQuarkVariables(JetContentPair *jet_content)
Make quark variables.
void end()
Called after data processing for clean up.
std::string _colAllPFOs
Input collection name.
void init()
Called at the begin of the job before anything is read.
void processRunHeader(LCRunHeader *run)
Called for every run.
void findTrueJetParticles(LCEvent *event)
void PerformPfoAnalysis()
Perform pfo analysis.
void ExtractCollections(JetContentPair *jet_content)
Extract lcio collections.
void Clear()
PFOAnalysis stuff.
void processEvent(LCEvent *event)
Called for every event - the working horse.