• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/Users/jmonk/Physics/ForIA/src/AnalysisTools/MatchToTruth.cxx

Go to the documentation of this file.
00001 #include "ForIA/AnalysisTools/MatchToTruth.hh"
00002 #include "ForIA/Utils.hh"
00003 #include "ForIA/ConfigurationFile.hh"
00004 namespace ForIA {
00005   // constructor
00006   MatchToTruth::MatchToTruth() {
00007   }
00008   
00009   void MatchToTruth::init(){
00010     
00011     // grab the truth partciles
00012     ConfigurationFile configFile;
00013     configFile.init("analysis_config.dat");
00014     
00015     double TruthE,TruthET,TruthEtaMin, TruthEtaMax;
00016     configFile.readInto( TruthE, "TruthE", 0.);
00017     configFile.readInto( TruthET, "TruthET", 0.);
00018     configFile.readInto( TruthEtaMin, "TruthEtaMin", 0.0);
00019     configFile.readInto( TruthEtaMax, "TruthEtaMax", 4.8);
00020     
00021     
00022     m_truthSelection.setEMin( TruthE );
00023     m_truthSelection.setPTMin( TruthET );
00024     m_truthSelection.setEtaMin( TruthEtaMin );
00025     m_truthSelection.setEtaMax( TruthEtaMax );
00026     m_truthSelection.setIsPrimary(true);
00027     
00028     m_truthSelection.setPdgId(22);    
00029     
00030     return;
00031   }
00032   
00033   bool MatchToTruth::setEvent(const Event& evt) {
00034     m_truthSelection.setEvent(evt);
00035     return true;
00036   }
00037 
00038   float MatchToTruth::MinEta() {
00039 
00040     TruthParticleVector truthVectors = m_truthSelection.particles();
00041     float minEta = 99.0F;
00042     for(TruthParticleVector::const_iterator truth = truthVectors.begin();
00043         truth != truthVectors.end(); ++truth){
00044       float feta = fabs((*truth)->eta());
00045       if (feta < minEta) minEta = feta;
00046     }
00047     return minEta;
00048   }
00049 
00050 
00051   bool MatchToTruth::Match(const MomentumVector& fourVectors) {
00052     
00053     TruthParticleVector truthVectors = m_truthSelection.particles();
00054     std::cout<<"Matching "<<fourVectors.size() << " " << truthVectors.size() << std::endl;
00055     for(MomentumVector::const_iterator fourVector = fourVectors.begin();
00056         fourVector != fourVectors.end(); ++fourVector){
00057 //      float minDR = 99.0F;
00058       for(TruthParticleVector::const_iterator truth = truthVectors.begin();
00059           truth != truthVectors.end(); ++truth){
00060         // std::cout<<(*fourVector)->eta() << " " << (*truth)->eta()<<std::endl;
00061         // float DR = Kinematics::deltaR((*fourVector),(*truth));
00062         //if (DR < minDR) minDR = DR;
00063       }
00064     }
00065     return true;
00066   }
00067   
00068  float MatchToTruth::MatchDR(IFourMomentumConstPtr p1) {
00069 
00070      TruthParticleVector truthVectors = m_truthSelection.particles();
00071      float minDR = 99.0F;
00072      for(TruthParticleVector::const_iterator truth = truthVectors.begin();
00073            truth != truthVectors.end(); ++truth){
00074        //       std::cout<<p1->eta() << " " << (*truth)->eta()<<std::endl;
00075          float DR = deltaR(p1,(*truth));
00076          if (DR < minDR) {
00077            minDR = DR;
00078          }
00079      }
00080      return minDR;
00081   }
00082 
00083 
00084 
00085 IFourMomentumConstPtr  MatchToTruth::MatchedParticle(IFourMomentumConstPtr p1) {
00086 
00087      TruthParticleVector truthVectors = m_truthSelection.particles();
00088      IFourMomentumConstPtr t1;
00089      float minDR = 99.0F;
00090      for(TruthParticleVector::const_iterator truth = truthVectors.begin();
00091            truth != truthVectors.end(); ++truth){
00092        //       std::cout<<p1->eta() << " " << (*truth)->eta()<<std::endl;
00093          float DR = deltaR(p1,(*truth));
00094          if (DR < minDR) {
00095            minDR = DR;
00096            t1 = (*truth);
00097          }
00098      }
00099      return t1;
00100   }
00101 
00102 }

Generated on Mon Jul 30 2012 16:56:35 for ForIA by  doxygen 1.7.2