8 #include <marlin/AIDAProcessor.h>
9 #include <AIDA/IHistogramFactory.h>
10 #include <AIDA/ICloud1D.h>
13 #include "IMPL/LCEventImpl.h"
14 #include "IMPL/LCCollectionVec.h"
15 #include "IMPL/SimCalorimeterHitImpl.h"
16 #include "IMPL/CalorimeterHitImpl.h"
17 #include "IMPL/MCParticleImpl.h"
18 #include "IMPL/TrackerHitImpl.h"
19 #include "IMPL/TrackImpl.h"
20 #include "IMPL/ClusterImpl.h"
21 #include "IMPL/ReconstructedParticleImpl.h"
22 #include "IMPL/ParticleIDImpl.h"
23 #include "IMPL/LCFlagImpl.h"
25 #include "IMPL/LCRelationImpl.h"
28 #include <EVENT/LCCollection.h>
29 #include <EVENT/ReconstructedParticle.h>
31 using namespace lcio ;
32 using namespace marlin ;
35 vector <double>
legendre_recursive(
const double& x ,
const int& n,
const vector<int> moments );
43 _description =
"Fox calculates Fox-Wolfram moments" ;
48 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
49 "NameOfReconstructedParticlesCollection" ,
50 "Name of the ReconstructedParticle collection" ,
52 std::string(
"RecoParticles") ) ;
54 vector<int> momentsToCalculate;
56 registerProcessorParameter(
"CalculateFoxWolframMoments",
57 "Numbers of the moments that are to be calculate 0-th is calculate by default",
85 vector<ReconstructedParticle*> rpart;
90 LCCollection* col = evt->getCollection(
_colName ) ;
92 vector < int > moments;
99 sort(moments.begin(),moments.end());
100 unsigned int largest_moment;
101 largest_moment=*max_element(moments.begin(),moments.end());
104 vector <double> outputMoments;
105 for (
unsigned int jj=0 ; jj < moments.size();jj++) outputMoments.push_back(0.0);
109 unsigned int nRecP = col->getNumberOfElements();
111 for(
unsigned int kk=0; kk< nRecP ; kk++)
113 rpart.push_back(dynamic_cast<ReconstructedParticle*>( col->getElementAt( kk ) ));
121 for(
unsigned int i=0; i<nRecP; i++)
123 pi=
const_cast<double*
>((rpart[i])->getMomentum());
124 pimod=sqrt( pi[0]*pi[0]+ pi[1]*pi[1]+ pi[2]*pi[2]);
125 for (
unsigned int j=0;j<nRecP; j++)
126 {
double cosThetaIJ=0.0;
127 pj=
const_cast<double*
>((rpart[j])->getMomentum());
128 pjmod=sqrt( pj[0]*pj[0]+ pj[1]*pj[1]+ pj[2]*pj[2]);
129 eVisible+=(rpart[j])->getEnergy();
130 if ( (pimod!=0.0)&&(pjmod!=0))
131 cosThetaIJ= (pi[0]*pj[0]+ pi[1]*pj[1]+ pi[2]*pj[2])/(pimod*pjmod);
134 vector <double > legendreOutput(
legendre_recursive(cosThetaIJ,largest_moment,moments));
135 for (
unsigned int kk=0; kk<legendreOutput.size(); kk++)
137 outputMoments[kk]+=pimod*pjmod*legendreOutput[kk];
143 for (
unsigned int kk=0; kk<outputMoments.size(); kk++)
145 outputMoments[kk]=outputMoments[kk]/(eVisible*eVisible);
148 for (
unsigned int kk=0; kk<outputMoments.size(); kk++)
152 string nth= dtes.str();
153 string base_name=
"FoxWolfram_moment(";
154 base_name=base_name+nth+
")";
155 col->parameters().setValue(base_name.c_str(),(float)outputMoments[kk]);
162 }
catch(DataNotAvailableException &
e) {}
186 vector <double> lr,rr;
189 for (
int i=2;i<n+1;i++)
190 lr.push_back(((1.0/i)*((2.0*i-1.0)*x*lr[i-1]-(i-1.0)*lr[i-2])));
191 for (
unsigned int i=0;i<moments.size();i++)
192 rr.push_back(lr[moments[i]]);
std::vector< int > _momentsToCalculate
Vector of moments orders to be calculated.
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
std::string _colName
Input collection name.
virtual void init()
Called at the begin of the job before anything is read.
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
Processor calculates Fox-Wolfram moments.
virtual void end()
Called after data processing for clean up.
vector< double > legendre_recursive(const double &x, const int &n, const vector< int > moments)
virtual void check(LCEvent *evt)