Commit 94cfffcb by dauncey

### Rewriting AnalysisPhoton

parent 1ea3f838
No preview for this file type
 ... ... @@ -75,8 +75,9 @@ The resulting RMS using the best fit values is given by \end{eqnarray*} But since the solution is defined by $Ma=v$, then $a^T M a = a^T v$. Hence \mathrm{RMS}^2_\mathrm{min} = \frac{1}{N} \sum_e T_e^2 - a^T M a = \frac{1}{N} \sum_e T_e^2 - v^T M^{-1} v \mathrm{RMS}^2_\mathrm{min} = \frac{1}{N} \left(\sum_e T_e^2\right) - a^T M a = \frac{1}{N} \left(\sum_e T_e^2\right) - v^T M^{-1} v = \frac{1}{N} \left(\sum_e T_e^2\right) - a^T v The above can be extended slightly, which may improve the energy response linearity as well as the RMS. The energy estimation for the event (i.e. the ... ...
 ... ... @@ -10,12 +10,15 @@ #include "TH1F.h" #include "TH2F.h" #include "TProfile.h" #include "TVectorD.h" #include "TMatrixDSym.h" #include "Random.hh" #include "TE1F.hh" #include "TE2F.hh" #include "AnalysisBase.hh" #include "SubAnalysisPhotonSimHit.hh" #include "SubAnalysisPhotonTrgHit.hh" #include "Event.hh" #include "ErrorMatrix.hh" ... ... @@ -26,7 +29,113 @@ public: enum { kNumberOfTests=AdcReading::fMaximumNumberOfMethods+26 }; /* class Coefficients { public: enum { kNumberOfCoefficients=Geometry::kNumberOfLayers }; Coefficients() : fSum(kNumberOfCoefficients), fSSq(kNumberOfCoefficients) { fNum=0.0; for(unsigned i(0);i0.5); if(fNum==1.0) return; for(unsigned i(0);i> n; assert(n==kNumberOfCoefficients); fin >> fNum; double d; for(unsigned i(0);i> d; fSum(i)=d; } for(unsigned i(0);i> d; fSSq(i,j)=d; } } } void write(const std::string &fName) { std::ofstream fout(fName.c_str()); if(!fout) return; normalise(); fout << kNumberOfCoefficients; fout << fNum << std::endl; for(unsigned i(0);iFill(i,fErrorMatrix.fSum[i]); std::cout << "fErrMean[" << i << "]=" << fErrorMatrix.fSum[i] ... ... @@ -2425,7 +2547,8 @@ public: hErrMatrix->Fill(i,j,em[i][j]);//fErrorMatrix.fSSq[i][j]); hCovMatrix->Fill(i,j,em[i][j]/sqrt(em[i][i]*em[j][j]));//fErrorMatrix.fSSq[i][j]/sqrt(fErrorMatrix.fSSq[i][i]*fErrorMatrix.fSSq[j][j])); } } } */ } bool fitC3dShape(const double *a, double &et) { ... ... @@ -2621,10 +2744,15 @@ public: //double stInv(1.0/proj.position().sinTheta()); /* if(proj.position().rho()> 30.0 && proj.position().rho()<145.0 //&& stInv>=2.5 && stInv<3.0 ) good=true; */ if(fabs(proj.position().eta())>=1.7 && fabs(proj.position().eta())< 2.7) good=true; } } ... ... @@ -2709,8 +2837,14 @@ public: double tanMax[2]; double phiMax[2]; //simEvent(event); //return true; if(fSimEvent) fSAPSimHit.event(event); //event->digHitNoiseCreator(); //event->digHitProcessor(); //event->trgHitProcessor(); if(fTrgEvent) fSAPTrgHit.event(event); return true; for(unsigned e(0);e
 #ifndef Coefficients_HH #define Coefficients_HH #include "TVectorD.h" #include "TMatrixDSym.h" class Coefficients { public: enum { kNumberOfCoefficients=Geometry::kNumberOfHGCLayers+Geometry::kNumberOfBHLayers }; Coefficients(bool b=false) : fPlainRms(b), fSum(kNumberOfCoefficients), fCoe(kNumberOfCoefficients), fSSq(kNumberOfCoefficients) { fNum=0.0; fErg=0.0; for(unsigned i(0);i0.5); assert(lm!=0); uint64_t one(1); TVectorD sum(fSum); for(unsigned i(0);i> n; if(n!=kNumberOfCoefficients) return false; fin >> fNum >> fErg; double d; for(unsigned i(0);i> d; fSum(i)=d; } for(unsigned i(0);i> d; fSSq(i,j)=d; } } if(!fin) return false; return true; } bool write(const std::string &fName) { std::ofstream fout(fName.c_str()); if(!fout) return false; fout << kNumberOfCoefficients << " " << std::setprecision(12) << fNum << " " << std::setprecision(12) << fErg << std::endl; for(unsigned i(0);i
 ... ... @@ -602,6 +602,8 @@ public: } void trgHitProcessor() { std::cout << "Event::trgHitProcessor called" << std::endl; for(unsigned e(0);e
 ... ... @@ -49,11 +49,13 @@ class ReadSimHitTTree { fTTree->SetBranchAddress( "SimHit_E", &_SimHit_E ); fTTree->SetBranchAddress( "SimHit_Id_BH", &_SimHit_Id_BH ); fTTree->SetBranchAddress( "SimHit_E_BH", &_SimHit_E_BH ); fTTree->SetBranchAddress( "StringTestVector", &_SimHit_str ); _SimHit_Id=0; _SimHit_E=0; _SimHit_Id_BH=0; _SimHit_E_BH=0; _SimHit_str=0; if(PrintLevel::print(2)) std::cout << "ReadSimHitTTree opening file " << fFileName <<" successful" << std::endl; ... ... @@ -115,7 +117,15 @@ class ReadSimHitTTree { vHbh.push_back(s); } } if(_SimHit_str!=0) { std::cout << "_SimHit_str size = " << _SimHit_str->size() << std::endl; std::vector &vStr(*_SimHit_str); for(unsigned j(0);j<_SimHit_str->size() && j<100;j++){ if(vStr[j]!="abc0") std::cout << "Line " << j << " = " << vStr[j] << std::endl; } } return true; } ... ... @@ -163,6 +173,8 @@ class ReadSimHitTTree { std::vector *_SimHit_Id_BH; std::vector *_SimHit_E_BH; std::vector *_SimHit_str; }; #endif
 ... ... @@ -47,6 +47,12 @@ public: return fEvent; } // Position Point point() const { return Geometry::point(*this); } // Deposited energy in GeV double deposit() const { return fScale*fDeposit; ... ... @@ -64,6 +70,11 @@ public: return Constants::fMipPerGev[Geometry::numberOfSublayers(layer(),wafer())-1]*deposit(); } // Equivalent transverse number of MIPs double transverseMips() const { return mips()*point().sinTheta(); } // Equivalent incoming energy in GeV double energy() const { return mips()*Calibration::layerWeight(layer()); ... ... @@ -71,7 +82,7 @@ public: // Equivalent incoming transverse energy in GeV double transverseEnergy() const { return energy()*Geometry::point(*this).sinTheta(); return energy()*point().sinTheta(); } bool read(std::istream &fin) { ... ...
 #ifndef SubAnalysisPhotonSimHit_HH #define SubAnalysisPhotonSimHit_HH #include #include #include #include #include #include #include "TH1F.h" #include "TH2F.h" #include "TProfile.h" #include "TH1A.hh" #include "Average.hh" #include "Coefficients.hh" #include "utilities.cc" class SubAnalysisPhotonSimHit { public: SubAnalysisPhotonSimHit(const std::string &sRoot="", const std::string &sOut="") : fName("SubAnalysisPhotonSimHit"), fFile((sOut==""?"":sOut+"/")+fName+(sRoot==""?sRoot:"_"+sRoot)) { nEvt=0; hEvent=new TH1F((fName+"_Event").c_str(), ";Layer;Number of trgHits",100,0.0,1000.0); for(unsigned l(0);lrmsSq) { rmsSqMin=rmsSq; std::cout << "New minimum " << rmsSqMin << " found for lm = " << printBin(lm) << std::endl; } } */ uint64_t lm(0x000ffffffaaaaaaa); std::cout << "k = " << k << " RMS^2 for trigger coeffs = " << vCoefficients[k][4].solve(lm) << std::endl; vCoefficients[k][4].print(); std::cout << "k = " << k << " RMS^2 for all coeffs = " << vCoefficients[k][4].solve() << std::endl; vCoefficients[k][4].print(); TVectorD c4(vCoefficients[k][4].coefficients()); assert(vTVectorD[k].size()==vTruthE.size()); double rmsSq(0.0),rmsSqOverE(0.0); for(unsigned i(0);i