All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
ErrorFlow.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: ErrorFlow.cc
5  *
6  * Description: This is the implementation of the ErrorFlow Marlin Processor.
7  * See the header file for more information.
8  *
9  * Version: 1.0
10  * Created: 11/02/2016 02:00:30 PM
11  * Revision: none
12  * Compiler: gcc
13  *
14  * Author: Aliakbar Ebrahimi (aliakbar.ebrahimi@desy.de),
15  * Organization: DESY
16  *
17  * =====================================================================================
18  */
19 
20 
21 
22 #include "ErrorFlow.h"
23 #include <iostream>
24 #include <vector>
25 
26 #include <EVENT/LCCollection.h>
27 #include <IMPL/LCCollectionVec.h>
28 #include <IMPL/ReconstructedParticleImpl.h>
29 #include <UTIL/LCRelationNavigator.h>
30 #include <EVENT/MCParticle.h>
31 #include "TVector3.h"
32 
33 // ----- include for verbosity dependend logging ---------
34 #include "marlin/VerbosityLevels.h"
35 
36 using namespace lcio ;
37 using namespace marlin ;
38 
39 
41 
42 
43 /*
44  * === FUNCTION ======================================================================
45  * Name: ErrorFlow::ErrorFlow()
46  * Description: This is the class constructor. The processor parameters are
47  * defined here.
48  * =====================================================================================
49  */
50 ErrorFlow::ErrorFlow() : Processor("ErrorFlow") {
51 
52  // Processor description
53  _description = "ErrorFlow processor computes total error of a jet based on the information from each sub-detector" ;
54 
55  // Register steering parameters: name, description, class-variable, default value
56  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
57  "InputPFOCollection",
58  "Input collection of jets",
60  std::string( "InputJets" )
61  );
62 
63  registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
64  "OutputPFOCollection",
65  "Out collection of jets with calculated covariance matrix",
67  std::string( "OutputJets" )
68  );
69 
70  registerInputCollection( LCIO::LCRELATION,
71  "InputMCTruthLinkCollection" ,
72  "Input collection of MC Truth Links",
74  std::string( "RecoMCTruthLink" )
75  );
76 
77  // Reference of default value: doi:10.1016/j.nima.2009.07.026
78  registerProcessorParameter( "ECALStochastic" ,
79  "Stochastic term coefficient in ECAL resolution",
80  p_aECAL,
81  (double) 0.16 );
82 
83  // Reference of default value: doi:10.1016/j.nima.2009.07.026
84  registerProcessorParameter( "ECALConstant" ,
85  "Constant term coefficient in ECAL resolution",
86  p_cECAL,
87  (double) 0.02 );
88 
89  // Reference of defautl value: 2012 JINST 7 P09017
90  registerProcessorParameter( "HCALStochastic" ,
91  "Stochastic term coefficient in HCAL resolution",
92  p_aHCAL,
93  (double) 0.50 );
94 
95  // Reference of defautl value: 2012 JINST 7 P09017
96  registerProcessorParameter( "HCALConstant" ,
97  "Constant term coefficient in HCAL resolution",
98  p_cHCAL,
99  (double) 0.01 );
100 
101  registerProcessorParameter( "ConfusionScaleFactor" ,
102  "Scale factor for confusion resolution term",
103  p_scaleConf,
104  (double) 1.0 );
105 
106  registerProcessorParameter( "EnableSemiLepCorrection" ,
107  "Enable/disable semi-leptonic correction resolution to be added to covariance matrix",
109  (bool) false );
110 
111  registerProcessorParameter( "EnableConfusionTerm" ,
112  "Enable/disable confusion term to be added to covariance matrix",
114  (bool) true );
115 
116  registerProcessorParameter( "PropagateConfusion2Mom" ,
117  "Enable/disable Propagating uncertainty due to confusion to the Momentum components",
119  (bool) true );
120 
121  registerProcessorParameter( "SemiLepSigmaCorrectionFactor" ,
122  "A correction factor to be multiplied by total lepton energy to get semi-leptonic uncertainty",
124  (double) 0.57 );
125 
126  registerProcessorParameter( "CovMatFactorPhotons" ,
127  "A correction factor to be multiplied to angular uncertainties of photons",
129  (double) 1.0 );
130 
131  registerProcessorParameter( "CovMatFactorNeutralHadrons" ,
132  "A correction factor to be multiplied to angular uncertainties of Neutral Hadrons",
134  (double) 1.0 );
135 
136  registerProcessorParameter( "SotreInTree" ,
137  "Enable/disable storing computed qunatities in a ROOT tree",
138  p_storeTree,
139  (bool) false );
140 
141  registerProcessorParameter( "useFullCovMatforNeutrals" ,
142  "whether use full CovMat for neutral PFOs or use only energy uncertainty",
144  (bool) true );
145 
146 
147 } /* ----- end of function ErrorFlow::ErrorFlow ----- */
148 
149 
150 /*
151  * === FUNCTION ======================================================================
152  * Name: ErrorFlow::init()
153  * Description: The initialisation function for the processor. ROOT tree and
154  * branches are created here.
155  * =====================================================================================
156  */
158 
159  streamlog_out(DEBUG) << " init called " << std::endl ;
160 
161  // usually a good idea to
162  printParameters() ;
163 
164  // Create a ROOT file if enabled in the steering file
165  if ( p_storeTree ) {
166  tree = std::make_shared<TTree>("ErrorFlow", "Number of photons, charged and neutral hadrons in a jet");
167  // PFO count branches
168  tree->Branch( "numPhotons" , &numPhotons, "numPhotons/I");
169  tree->Branch( "numChargedPFOs" , &numChargedPFOs, "numChargedPFOs/I");
170  tree->Branch( "numNeutralPFOs" , &numNeutralPFOs, "numNeutralPFOs/I");
171  tree->Branch( "numPFOsTotal" , &nPFOs, "numPFOsTotal/I");
172  // Energy branches
173  tree->Branch( "ePhotons" , &ePhotons, "ePhotons/D");
174  tree->Branch( "eChargedPFOs" , &eChargedPFOs, "eChargedPFOs/D");
175  tree->Branch( "eNeutralPFOs" , &eNeutralPFOs, "eNeutralPFOs/D");
176  tree->Branch( "ePFOsTotal" , &eJetTotal, "eJetTotal/D");
177  // Jet energy resolution branches
178  tree->Branch( "absDetResSquared" , &absDetResSquared, "absDetResSquared/D");
179  tree->Branch( "relConfCharged" , &relConfCharged, "relConfCharged/D");
180  tree->Branch( "relConfPhotons" , &relConfPhotons, "relConfPhotons/D");
181  tree->Branch( "relConfNeutral" , &relConfNeutral, "relConfNeutral/D");
182  tree->Branch( "relConfSquared" , &relConfSquared, "relConfSquared/D");
183  tree->Branch( "absConfSquared" , &absConfSquared, "absConfSquared/D");
184  tree->Branch( "absSemiLepResSquared" , &absSemiLepResSquared, "absSemiLepResSquared/D");
185  } // end if p_storeTree
186 
187  p_nRun = 0 ;
188  p_nEvt = 0 ;
189 
190 } /* ----- end of function ErrorFlow::init ----- */
191 
192 
193 /*
194  * === FUNCTION ======================================================================
195  * Name: ErrorFlow::processRunHeader( LCRunHeader* run )
196  * Description:
197  * =====================================================================================
198  */
199 void ErrorFlow::processRunHeader( LCRunHeader* /*run*/ ) {
200 
201  p_nRun++ ;
202 
203 } /* ----- end of function ErrorFlow::processRunHeader ----- */
204 
205 
206 /*
207  * === FUNCTION ======================================================================
208  * Name: ErrorFlow::processEvent( LCEvent* evt )
209  * Description: This function loops over all particles of each jet in an events and
210  * 1- Computes error on the energy of each particle by using covariance
211  * matrix of the particle for charged PFOs, ECAL energy resolution for
212  * photons and HCAL energy resolution for neutral particles
213  * 1- Counts number of charged PFOs, photons and neutral PFOs
214  * 2- Summs up energy of charged PFOs, photons and neutral PFOs and
215  * stores them in separate root branches.
216  * This function gets called for every event.
217  * =====================================================================================
218  */
219 void ErrorFlow::processEvent( LCEvent * evt ) {
220 
221  // Debug message
222  streamlog_out(DEBUG) << " processing event: " << evt->getEventNumber()
223  << " in run: " << evt->getRunNumber() << std::endl;
224 
225  // Get input collection (exits if collection is not available)
226  LCCollection *col = evt->getCollection( p_inputJetCollection );
227 
228  // Setup MC relation for semi leptonic correction
229  LCCollection *colMCTL = evt->getCollection( p_inputMCTruth );
230  LCRelationNavigator *navMCTL = new LCRelationNavigator( colMCTL );
231 
232  // Create the output collection
233  LCCollectionVec* outCol= new LCCollectionVec( LCIO::RECONSTRUCTEDPARTICLE );
234  outCol->setSubset( true );
235 
236  // If the collection is available, do the rest of the work
237  if( NULL != col ) {
238 
239  // Get number of jets in the collection
240  size_t nJets = col->getNumberOfElements();
241  streamlog_out(DEBUG) << "Number of jets in the event:" << nJets << std::endl;
242 
243  // Loop over all jets in the event
244  for( size_t iJet=0; iJet < nJets; ++iJet ) {
245 
246  // Reset variables
247  resetVariables();
248 
249  // Set a pointer to the i-th jet in the collection
250  ReconstructedParticleImpl *jetPtr = dynamic_cast<ReconstructedParticleImpl*>( col->getElementAt( iJet ) );
251  TVector3 jet3Momentum( jetPtr->getMomentum()[0] , jetPtr->getMomentum()[1] , jetPtr->getMomentum()[2] );
252  double jetMom = jet3Momentum.Mag();
253  double jetEnergy = jetPtr->getEnergy();
254  float jetTheta = jet3Momentum.Theta();
255  float jetPhi = jet3Momentum.Phi();
256  std::vector< float > jetCovMatrixConf( 10, 0.0 );
257  jetCovMatrixConf[ 0 ] = pow( sin( jetTheta ) , 2 ) * pow( cos( jetPhi ) , 2 );
258  jetCovMatrixConf[ 1 ] = pow( sin( jetTheta ) , 2 ) * sin( jetPhi ) * cos( jetPhi );
259  jetCovMatrixConf[ 2 ] = pow( sin( jetTheta ) , 2 ) * pow( sin( jetPhi ) , 2 );
260  jetCovMatrixConf[ 3 ] = sin( jetTheta ) * cos( jetTheta ) * cos( jetPhi );
261  jetCovMatrixConf[ 4 ] = sin( jetTheta ) * cos( jetTheta ) * sin( jetPhi );
262  jetCovMatrixConf[ 5 ] = pow( cos( jetTheta ) , 2 );
263  jetCovMatrixConf[ 6 ] = ( jetMom / jetEnergy ) * sin( jetTheta ) * cos( jetPhi );
264  jetCovMatrixConf[ 7 ] = ( jetMom / jetEnergy ) * sin( jetTheta ) * sin( jetPhi );
265  jetCovMatrixConf[ 8 ] = ( jetMom / jetEnergy ) * cos( jetTheta );
266  jetCovMatrixConf[ 9 ] = pow( jetMom , 2 ) / pow( jetEnergy , 2 );
267 
268  // Get PFOs in the jet and number of them
269  ReconstructedParticleVec jetPFOs = jetPtr->getParticles();
270  nPFOs = jetPFOs.size();
271  streamlog_out(DEBUG) << "Number of PFOs in the jet:" << nPFOs << std::endl;
272 
273  // Create a vector to hold covariance matrix of the jet
274  std::vector< float > jetCovMatrix( 10, 0.0 );
275 
276  // Loop over all PFOs in the jet
277  for ( size_t iPFO = 0; iPFO < nPFOs; ++iPFO ) {
278  // Set a pointer to the i-th PFO
279  ReconstructedParticle *particlePtr = jetPFOs[ iPFO ];
280  LCObjectVec vecMCTL = navMCTL->getRelatedToObjects( particlePtr );
281  int nTrackspfo = (particlePtr->getTracks()).size();
282 
283  // Add particle energy to the sum
284  eJetTotal += particlePtr->getEnergy();
285  double scaleFactor = 1.0;
286 
287  if ( p_useFullCovMatNeut )
288  {
289  FloatVec particleCovMatrix = particlePtr->getCovMatrix();
290  if ( 0 != nTrackspfo )
291  {
292  ++numChargedPFOs;
293  eChargedPFOs += particlePtr->getEnergy();
294  scaleFactor = 1.0;
295  }
296  // particle is not charged
297  // check whether its a photon
298  else if ( 22 == particlePtr->getType() )
299  {
300  ++numPhotons;
301  ePhotons += particlePtr->getEnergy();
302  scaleFactor = p_CovMatFactorPhotons;
303  }
304  else
305  { // if not a photon, then it's a neutral hadron
306  ++numNeutralPFOs;
307  eNeutralPFOs += particlePtr->getEnergy();
308  scaleFactor = p_CovMatFactorNeutralHadrons;
309  } // end if-else
310  for ( size_t iElement = 0; iElement < 9; ++iElement)
311  { // for all CovMat elements except energy error ( CovMat(9) := sigma_E^2 )
312  if ( iElement < 6 )
313  { // for elements not involving E ( sigma_px^2 , sigma_pxpy , sigma_py^2 , sigma_pxpz , sigma_pypz , sigma_pz^2 )
314  jetCovMatrix[ iElement ] += scaleFactor * scaleFactor * particleCovMatrix [ iElement ];
315  }
316  else
317  { // for elements involving E ( sigma_pxE , sigma_pyE , sigma_pzE )
318  jetCovMatrix[ iElement ] += scaleFactor * particleCovMatrix [ iElement ];
319  }
320  } // end for
321  // for energy error ( CovMat(9) := sigma_E^2 )
322  jetCovMatrix[ 9 ] += particleCovMatrix [ 9 ];
323  }
324  else
325  {
326 
327  // If it is a charged particle, add its covaricance matrix to jet cov matirix
328  if ( 0 != nTrackspfo ) {
329  ++numChargedPFOs;
330  eChargedPFOs += particlePtr->getEnergy();
331  FloatVec particleCovMatrix = particlePtr->getCovMatrix();
332  for ( size_t iElement = 0; iElement < 10; ++iElement) {
333  jetCovMatrix[ iElement ] += particleCovMatrix [ iElement ];
334  } // end for
335  } else { // particle is not charged
336  // check whether its a photon
337  if ( 22 == particlePtr->getType() ) {
338  ++numPhotons;
339  ePhotons += particlePtr->getEnergy();
340  jetCovMatrix[ 9 ] += getPhotonSigmaESqr( particlePtr->getEnergy() );
341  } else { // if not a photon, then it's a neutral hadron
342  ++numNeutralPFOs;
343  eNeutralPFOs += particlePtr->getEnergy();
344  jetCovMatrix[ 9 ] += getNeuHadSigmaESqr( particlePtr->getEnergy() );
345  } // end if-else
346  } // end if-else charged
347  }
348 
349  /* :TODO:03/28/2016 07:09:24 PM:: Double check everything in this procedure here */
350  // Compute error for semi-leptonic decays
351  // If the PFO is a lepton add its energy to Total Lepton energy
352  if( 0 < vecMCTL.size() ) {
353  MCParticle *mcParticle = dynamic_cast<MCParticle*>( vecMCTL[ 0 ] );
354  // Get PDG of the particle
355  int mcpPDG = mcParticle->getPDG();
356 
357  // If it is an electron or a muon add its energy to total lepton energy
358  if ( 11 == abs( mcpPDG ) || 13 == abs( mcpPDG ) ) {
359  /* :TODO:04/03/2016 07:01:21 PM:: Why using mcParticle for the momentum? */
360  double particleMomentum = getTotalMomentum( mcParticle->getMomentum() );
361  if ( particleMomentum > 3.0 ) {
362  eLeptonsTotal += particlePtr->getEnergy();
363  } // end if
364  } // end if an electron or a muon
365  } // end if vecMCTL.size()
366 
367  } //end for loop over all PFOs of a jet
368 
369  // Compute confusion terms of the current jet
370  double relConfTerms[ 3 ] = { 0.0 }; /* Confusion terms: 0: charged, 1: photons, 2: neutral */
372  // Assign each confusion term to its own variable, just to work around a problem with ROOT
373  absDetResSquared = jetCovMatrix [ 9 ];
374  relConfCharged = relConfTerms[ 0 ];
375  relConfPhotons = relConfTerms[ 1 ];
376  relConfNeutral = relConfTerms[ 2 ];
377 
378  // Compute absolute confusion resolution squared
379  relConfSquared = pow( relConfCharged, 2.0 ) +
380  pow( relConfPhotons, 2.0 ) + pow( relConfNeutral, 2.0 );
382 
383  // Compute absolute semi-leptonic resolution squared
386 
387  // Sum up all uncertainties to get total jet energy uncertainty
389  {
390  for ( int iElement = 0 ; iElement < 10 ; ++iElement )
391  {
392  jetCovMatrix[ iElement ] = jetCovMatrix[ iElement ]
393  + ( pow( jetEnergy , 2 ) * absConfSquared * p_scaleConf * p_scaleConf / pow( jetMom , 2 ) ) * jetCovMatrixConf[ iElement ];
394  }
395  }
396  else
397  {
398  jetCovMatrix[ 9 ] = jetCovMatrix[ 9 ]
401  }
402 
403  // Fill the ROOT tree if enabled in the steering file
404  if ( p_storeTree ) {
405  tree->Fill();
406  } // end if p_storeTree
407 
408  // Update the convariance matrix of the jet object
409  jetPtr->setCovMatrix( jetCovMatrix );
410  outCol->addElement( jetPtr );
411 
412  } // end for loop over all jets
413 
414  // Update output collection with new collection of jets which has convariance matrix
415  evt->addCollection( outCol, p_outputJetCollection );
416 
417  } else {
418  streamlog_out(DEBUG) << "Error: collection does not exist!" << std::endl;
419  } //end if-else collection exists
420 
421  // Collect the garbage
422  delete navMCTL;
423 
424  ++p_nEvt;
425 
426 } /* ----- end of function ErrorFlow::processEvent ----- */
427 
428 
429 
430 /*
431  * === FUNCTION ======================================================================
432  * Name: ErrorFlow::resetVariables
433  * Description: This function resets all variables used in processEvent()
434  * function to zero.
435  * =====================================================================================
436  */
438 {
439  // Reset PFO counters and energies
440  numChargedPFOs = 0;
441  numPhotons = 0;
442  numNeutralPFOs = 0;
443  nPFOs = 0;
444  ePhotons = 0.0;
445  eChargedPFOs = 0.0;
446  eNeutralPFOs = 0.0;
447  eJetTotal = 0.0;
448  relConfCharged = 0.0;
449  relConfPhotons = 0.0;
450  relConfNeutral = 0.0;
451  relConfSquared = 0.0;
452  absConfSquared = 0.0;
453  absDetResSquared = 0.0;
454  eLeptonsTotal = 0.0;
455  absSemiLepResSquared = 0.0;
456 
457 } /* ----- end of function ErrorFlow::resetVariables ----- */
458 
459 
460 
461 /*
462  * === FUNCTION ======================================================================
463  * Name: getConfusion
464  * Description: This fucntion computes RELATIVE confusion terms for 3 groups of particles
465  * in each jet based on its particle content. Then total confusion of the
466  * would be these 3 terms added in quadrature.
467  * The assumption for computation is that confusion terms given in
468  * table 4 of DOI:10.1016/j.nima.2009.09.009 are for a jet which has
469  * 0.62 of its energy in charged particles, 0.28 in photons and 0.10 in
470  * neutral hadrons. Then fracton of energy of each of these three categories
471  * is computed for each jet and confusion terms are scaled accordingly.
472  * =====================================================================================
473  */
474 double *ErrorFlow::getRelativeConfusion ( double t_jetEnergy, double t_chargedHadronsEnergy,
475  double t_photonsEnergy, double t_neutralHadronsEnergy, double t_confusion[] )
476 {
477  // Define and initialise variables
478  // Average jet energy carried by: Ref. DOI:10.1016/j.nima.2009.09.009
479  const double muEnCharged = 0.62; /* charged particles */
480  /* :TODO:01/24/2016 06:29:03 PM:: What to do with the neutrinos? */
481  const double muEnPhotons = 0.28; /* Photons +1% for neutrinos*/
482  const double muEnNeutral = 0.10; /* neutral particles */
483 
484  // Average confusion term for {charged, photons, neutral} for various energies
485  // Ref. DOI:10.1016/j.nima.2009.09.009, values are from table 5 multipied by 1.1
486  // to get gaussian values, as suggested in section 5 of the same paper.
487  // /* :TODO:01/24/2016 07:02:23 PM:: Is the multiplication actually correct? */
488  const double conf45[ 3 ] = { 1.32, 0.88, 0.99 }; /* Jet energy 45 GeV */
489  const double conf100[ 3 ] = { 0.77, 1.10, 1.43 }; /* Jet energy 100 GeV */
490  const double conf180[ 3 ] = { 0.55, 1.21, 1.87 }; /* Jet energy 180 GeV */
491  const double conf250[ 3 ] = { 0.22, 1.43, 1.98 }; /* Jet energy 250 GeV */
492 
493  double gammaChargedHadrons = ( t_chargedHadronsEnergy / t_jetEnergy ) / muEnCharged;
494  double gammaPhotons = ( t_photonsEnergy / t_jetEnergy ) / muEnPhotons;
495  double gammaNeutalHadrons = ( t_neutralHadronsEnergy / t_jetEnergy ) / muEnNeutral;
496 
497  // Compute confusion terms for each group based on the jet energy
498  // Formula used for interpolation: Y = ( ( X - X1 )( Y2 - Y1) / ( X2 - X1) ) + Y1
499  if ( 45.0 >= t_jetEnergy ) {
500  t_confusion[ 0 ] = conf45[ 0 ] * gammaChargedHadrons / 100.0;
501  t_confusion[ 1 ] = conf45[ 1 ] * gammaPhotons / 100.0;
502  t_confusion[ 2 ] = conf45[ 2 ] * gammaNeutalHadrons / 100.0;
503  }
504  else if ( 45 < t_jetEnergy && 100.0 >= t_jetEnergy ) {
505  t_confusion[ 0 ] = ( ( ( t_jetEnergy - 45.0 ) * ( conf100[ 0 ] - conf45[ 0 ] )
506  / ( 100.0 - 45.0 ) ) + conf45[ 0 ] ) * gammaChargedHadrons / 100.0;
507  t_confusion[ 1 ] = ( ( ( t_jetEnergy - 45.0 ) * ( conf100[ 1 ] - conf45[ 1 ] )
508  / ( 100.0 - 45.0 ) ) + conf45[ 1 ] ) * gammaPhotons / 100.0;
509  t_confusion[ 2 ] = ( ( ( t_jetEnergy - 45.0 ) * ( conf100[ 2 ] - conf45[ 2 ])
510  / ( 100.0 - 45.0 ) ) + conf45[ 2 ] ) * gammaNeutalHadrons / 100.0;
511  }
512  else if ( 100 < t_jetEnergy && 180.0 >= t_jetEnergy ) {
513  t_confusion[ 0 ] = ( ( ( t_jetEnergy - 100.0 ) * ( conf180[0] - conf100[0] )
514  / ( 180.0 - 100.0 ) ) + conf100[0] ) * gammaChargedHadrons / 100.0;
515  t_confusion[ 1 ] = ( ( ( t_jetEnergy - 100.0 ) * ( conf180[1] - conf100[1] )
516  / ( 180.0 - 100.0 ) ) + conf100[1] ) * gammaPhotons / 100.0;
517  t_confusion[ 2 ] = ( ( ( t_jetEnergy - 100.0 ) * ( conf180[2] - conf100[2] )
518  / ( 180.0 - 100.0 ) ) + conf100[2] ) * gammaNeutalHadrons / 100.0;
519  }
520  else {
521  t_confusion[ 0 ] = ( ( ( t_jetEnergy - 180.0 ) * ( conf250[ 0 ] - conf180[ 0 ] )
522  / ( 250.0 - 180.0 ) ) + conf180[ 0 ] ) * gammaChargedHadrons / 100.0;
523  t_confusion[ 1 ] = ( ( ( t_jetEnergy - 180.0 ) * ( conf250[ 1 ] - conf180[ 1 ] )
524  / ( 250.0 - 180.0 ) ) + conf180[ 1 ] ) * gammaPhotons / 100.0;
525  t_confusion[ 2 ] = ( ( ( t_jetEnergy - 180.0 ) * ( conf250[ 2 ] - conf180[ 2 ] )
526  / ( 250.0 - 180.0 ) ) + conf180[ 2 ] ) * gammaNeutalHadrons / 100.0;
527  }
528  for (size_t i = 0; i < 3; ++i) {
529  streamlog_out(DEBUG) << "Confusion " << i << ":" << t_confusion[i] << std::endl;
530  }
531 
532  return t_confusion;
533 
534 } /* ----- end of function getConfusionSqr ----- */
535 
536 
537 /*
538  * === FUNCTION ======================================================================
539  * Name: getPhotonSigmaESqr
540  * Description: This function computes and returns energy uncertainty SQUARED for
541  * photons using energy resolution of electromagnetic calorimeter
542  * The following formula is used:
543  * sigmaE^2 = aECAL^2 . E + cECAL^2 . E^2
544  * =====================================================================================
545  */
546 double ErrorFlow::getPhotonSigmaESqr ( double t_phEnergy )
547 {
548  double sigmaEnSquared = ( p_aECAL * p_aECAL ) * t_phEnergy +
549  ( p_cECAL * p_cECAL ) * ( t_phEnergy * t_phEnergy );
550 
551  return sigmaEnSquared;
552 
553 } /* ----- end of function ErrorFlow::getPhotonSigmaESqr ----- */
554 
555 
556 /*
557  * === FUNCTION ======================================================================
558  * Name: getNeuHadSigmaESqr
559  * Description: This function computes and returns energy uncertainty SQUARED for
560  * neutral hadrons using energy resolution of hadron calorimeter
561  * The following formula is used:
562  * sigmaE^2 = aHCAL^2 . E + cHCAL^2 . E^2
563  * =====================================================================================
564  */
565 double ErrorFlow::getNeuHadSigmaESqr ( double t_neuHadEnergy )
566 {
567  double sigmaEnSquared = ( p_aHCAL * p_aHCAL ) * t_neuHadEnergy +
568  ( p_cHCAL * p_cHCAL ) * ( t_neuHadEnergy * t_neuHadEnergy );
569 
570  return sigmaEnSquared;
571 
572 } /* ----- end of function ErrorFlow::getNeuHadSigmaESqr ----- */
573 
574 
575 /*
576  * === FUNCTION ======================================================================
577  * Name: ErrorFlow::getTotalMomentum
578  * Description: Computes and returns total momentum from a 3-momentum
579  * =====================================================================================
580  */
581 double ErrorFlow::getTotalMomentum ( const double * t_threeMomentum )
582 {
583  float moX = t_threeMomentum[ 0 ];
584  float moY = t_threeMomentum[ 1 ];
585  float moZ = t_threeMomentum[ 2 ];
586  double totalMomentum = sqrt( moX*moX + moY*moY +moZ*moZ );
587 
588  return totalMomentum;
589 
590 } /* ----- end of function ErrorFlow::getTotalMomentum ----- */
591 
592 
593 /*
594  * === FUNCTION ======================================================================
595  * Name: ErrorFlow::check( LCRunHeader* run )
596  * Description:
597  * =====================================================================================
598  */
599 void ErrorFlow::check( LCEvent * /*evt*/ ) {
600  // nothing to check here - could be used to fill checkplots in reconstruction processor
601 } /* ----- end of function ErrorFlow::check ----- */
602 
603 
604 /*
605  * === FUNCTION ======================================================================
606  * Name: ErrorFlow::end()
607  * Description:
608  * =====================================================================================
609  */
611 
612  // std::cout << "MyProcessor::end() " << name()
613  // << " processed " << _nEvt << " events in " << _nRun << " runs "
614  // << std::endl ;
615 
616 } /* ----- end of function ErrorFlow::end ----- */
double p_scaleConf
Definition: ErrorFlow.h:112
int numChargedPFOs
Definition: ErrorFlow.h:125
double p_aECAL
Definition: ErrorFlow.h:115
int numNeutralPFOs
Definition: ErrorFlow.h:127
double relConfCharged
Definition: ErrorFlow.h:138
double eNeutralPFOs
Definition: ErrorFlow.h:132
std::string p_outputJetCollection
Definition: ErrorFlow.h:100
std::string p_inputJetCollection
Input collection name.
Definition: ErrorFlow.h:99
int p_nEvt
Definition: ErrorFlow.h:146
std::shared_ptr< TTree > tree
Definition: ErrorFlow.h:152
double eLeptonsTotal
Definition: ErrorFlow.h:134
double getNeuHadSigmaESqr(double t_neuHadEnergy)
Definition: ErrorFlow.cc:565
int numPhotons
Definition: ErrorFlow.h:126
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
Definition: ErrorFlow.cc:199
double ePhotons
Definition: ErrorFlow.h:131
bool p_semiLepCorrection
Definition: ErrorFlow.h:104
int p_nRun
Definition: ErrorFlow.h:145
ReconstructedParticleVec::size_type nPFOs
Definition: ErrorFlow.h:153
virtual void end()
Called after data processing for clean up.
Definition: ErrorFlow.cc:610
double p_cHCAL
Definition: ErrorFlow.h:118
double p_CovMatFactorNeutralHadrons
Definition: ErrorFlow.h:109
bool p_propagateConfusiontoMomentumComp
Definition: ErrorFlow.h:106
virtual void init()
Called at the begin of the job before anything is read.
Definition: ErrorFlow.cc:157
bool p_storeTree
Definition: ErrorFlow.h:121
double p_aHCAL
Definition: ErrorFlow.h:117
double absSemiLepResSquared
Definition: ErrorFlow.h:143
virtual void check(LCEvent *evt)
Definition: ErrorFlow.cc:599
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
Definition: ErrorFlow.cc:219
double eChargedPFOs
Definition: ErrorFlow.h:130
double getPhotonSigmaESqr(double t_phEnergy)
Definition: ErrorFlow.cc:546
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
void resetVariables()
Definition: ErrorFlow.cc:437
double p_CovMatFactorPhotons
Definition: ErrorFlow.h:108
double absConfSquared
Definition: ErrorFlow.h:142
double getTotalMomentum(const double *t_threeMomentum)
Definition: ErrorFlow.cc:581
std::string p_inputMCTruth
Definition: ErrorFlow.h:101
double p_semiLepSigmaCorrFactor
Definition: ErrorFlow.h:107
bool p_useFullCovMatNeut
Definition: ErrorFlow.h:122
double relConfNeutral
Definition: ErrorFlow.h:140
ErrorFlow aErrorFlow
Definition: ErrorFlow.cc:40
double eJetTotal
Definition: ErrorFlow.h:133
double relConfPhotons
Definition: ErrorFlow.h:139
double * getRelativeConfusion(double jetEnergy, double chargedHadronsEnergy, double photonsEnergy, double neutralHadronsEnergy, double relConfTerms[])
Definition: ErrorFlow.cc:474
double relConfSquared
Definition: ErrorFlow.h:141
double p_cECAL
Definition: ErrorFlow.h:116
double absDetResSquared
Definition: ErrorFlow.h:137
bool p_confusionterm
Definition: ErrorFlow.h:105