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

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

Go to the documentation of this file.
00001 #include "ForIA/AnalysisTools/SimpleTruthSelection.hh"
00002 #include "ForIA/Event.hh"
00003 #include <cmath>
00004 
00005 namespace ForIA{
00006  
00007   SimpleTruthSelection::SimpleTruthSelection(): FourVectorSelection(), m_charge(ANY), m_haveSetPT(false), 
00008                                                 m_haveSetE(false),m_haveSetET(false),m_haveSetEta(false), 
00009                                                 m_haveSetCharged(false),m_haveSetChargedET(false), m_haveSetNeutralET(false),
00010                                                 m_haveSetChargedP(false), m_haveSetNeutralP(false),
00011                                                 m_haveSetSpeciesDepSel(false), m_haveSetBarcode(false), 
00012                                                 m_haveSetIsPrimary(false), m_haveSetID(false){}
00013     
00014   
00015   const TruthParticleVector &SimpleTruthSelection::particles()const{
00016     if(m_freshEvent) fillVectors();
00017     return m_passedParticles;
00018   }
00019   
00020   const TruthParticleVector &SimpleTruthSelection::rejectedParticles()const{
00021     if(m_freshEvent) fillVectors();
00022     return m_rejectedParticles;
00023   }
00024   
00025   bool SimpleTruthSelection::setEMin(double e){
00026     if(!m_canSetCuts) return false;
00027     m_haveSetE = true;
00028     m_eMin = e;
00029     return true;
00030   }
00031 
00032  bool SimpleTruthSelection::setETMin(double et){
00033     if(!m_canSetCuts) return false;
00034     m_haveSetET = true;
00035     m_etMin = et;
00036     return true; 
00037   }
00038 
00039   bool SimpleTruthSelection::setPTMin(double pt){
00040     if(!m_canSetCuts) return false;
00041     m_haveSetPT = true;
00042     m_ptMin = pt;
00043     return true; 
00044   }
00045 
00046   bool SimpleTruthSelection::setEtaMin(double eta){
00047     if(!m_canSetCuts) return false;
00048     m_haveSetEta = true;
00049     m_etaMin = eta;
00050     return true;
00051   }
00052   
00053   bool SimpleTruthSelection::setEtaMax(double eta){
00054     if(!m_canSetCuts) return false;
00055     m_haveSetEta = true;
00056     m_etaMax = eta;
00057     return true;    
00058   }
00059   
00060   bool SimpleTruthSelection::setCharged(charge chrg){
00061     if(!m_canSetCuts) return false;
00062     m_haveSetCharged = true;
00063     m_charge = chrg;
00064     return true;
00065   }
00066 
00067   bool SimpleTruthSelection::setChargedETMin(double et){
00068     if(!m_canSetCuts) return false;
00069     m_haveSetChargedET = true;
00070     m_chargedEtMin = et;
00071     return true;
00072   }
00073  
00074   bool SimpleTruthSelection::setNeutralETMin(double et){
00075     if(!m_canSetCuts) return false;
00076     m_haveSetNeutralET = true;
00077     m_neutralEtMin = et;
00078     return true;
00079   }
00080 
00081   bool SimpleTruthSelection::setChargedPMin(double p){
00082     if(!m_canSetCuts) return false;
00083     m_haveSetChargedP = true;
00084     m_chargedPMin = p;
00085     return true;
00086   }
00087 
00088   bool SimpleTruthSelection::setNeutralPMin(double p){
00089     if(!m_canSetCuts) return false;
00090     m_haveSetNeutralP = true;
00091     m_neutralPMin = p;
00092     return true;
00093   }
00094 
00095   bool SimpleTruthSelection::setSpeciesDepETMin(double etaMin, double etaMax, double etCharged, double etNeutral){
00096     if(!m_canSetCuts) return false;
00097     if(etaMax != 0.0F) m_haveSetSpeciesDepSel = true;
00098     m_speciesDepEtaMin = etaMin;
00099     m_speciesDepEtaMax = etaMax;
00100     m_chargedEtMin = etCharged;
00101     m_neutralEtMin = etNeutral;
00102     return true;
00103   }
00104 
00105   bool SimpleTruthSelection::setSpeciesDepPMin(double etaMin, double etaMax, double pCharged, double pNeutral){
00106     if(!m_canSetCuts) return false;
00107     m_haveSetSpeciesDepSel = true;
00108     m_haveSetChargedP = true;
00109     m_haveSetNeutralP = true;
00110     m_speciesDepEtaMin = etaMin;
00111     m_speciesDepEtaMax = etaMax;
00112     m_chargedPMin = pCharged;
00113     m_neutralPMin = pNeutral;
00114     return true;
00115   }
00116   
00117   bool SimpleTruthSelection::setBarcodeMax(int bcode){
00118     if(!m_canSetCuts) return false;
00119     m_haveSetBarcode = true;
00120     m_barcodeMax = bcode;
00121     return true;
00122   }
00123   
00124   bool SimpleTruthSelection::setIsPrimary(bool isPrimary){
00125     if(!m_canSetCuts) return false;
00126     m_haveSetIsPrimary = true;
00127     m_isPrimary = isPrimary;
00128     return true;
00129   }
00130 
00131   bool SimpleTruthSelection::setPdgId(int pdgID){
00132     if(!m_canSetCuts) return false;
00133     m_haveSetID = true;
00134     m_pdgID = pdgID;
00135     return true;
00136   }
00137   
00138   void SimpleTruthSelection::fillVectors()const{
00139 
00140     m_freshEvent = false;
00141     
00142     m_passedParticles.clear();
00143     m_passedFourVectors.clear();
00144     m_rejectedParticles.clear();
00145     m_rejectedFourVectors.clear();
00146 
00147     if(m_event == 0) return;
00148 
00149     TruthParticleVector input = m_event->truthParticles();
00150     //    sort( input.begin(), input.end(), SortEt );
00151     //    std::cout<<"NEw ECENT " << std::endl;
00152     for(TruthParticleVector::const_iterator particle = input.begin();
00153         particle != input.end(); ++particle){
00154 
00155       bool isGenStable = true;
00156       if(m_haveSetIsPrimary ){
00157 
00158         isGenStable = (  ((*particle)->status()%1000 == 1) ||
00159                         // need vertex bar code ((*particle)->status()==2 && vertex_barcode <-200000) ||
00160                         ((*particle)->status()%1000 == 2 &&  (*particle)->status() > 1000)
00161                          );
00162 
00163         isGenStable = isGenStable  &&  (  (*particle)->barcode()<200000 );
00164         isGenStable = isGenStable && ! (abs( (*particle)->pdgId() ) == 21 && (*particle)->E()==0);
00165       }
00166 
00167     
00168 
00169       bool passedCuts = isGenStable;
00170       //first check if Eta/Species dependent cuts are requested
00171       bool isTagged = false;
00172       if(m_haveSetSpeciesDepSel && passedCuts){
00173         if ( fabs((*particle)->eta()) > m_speciesDepEtaMin && fabs((*particle)->eta()) < m_speciesDepEtaMax ){
00174           double p = 0;
00175           if( sin((*particle)->theta()) != 0 || fabs(sin((*particle)->theta())) > 0.000001 ) 
00176             p = (*particle)->PT() / sin((*particle)->theta());
00177           //check if particles is charged
00178           //if ( (*particle)->charge() != 0 && (*particle)->ET() < m_chargedEtMin ){
00179           if( (*particle)->charge() != 0 ){
00180             if( m_haveSetChargedET && (*particle)->ET() < m_chargedEtMin ){
00181               passedCuts = false; 
00182               isTagged = true;
00183             }
00184             if( m_haveSetChargedP && fabs(p) < m_chargedPMin ){
00185               passedCuts = false;
00186               isTagged = true;
00187             }
00188           }
00189           //check if particle is neutral
00190           //if ( (*particle)->charge() == 0 && (*particle)->ET() < m_neutralEtMin ){
00191           if ( (*particle)->charge() == 0 ){ 
00192             if( m_haveSetNeutralET && (*particle)->ET() < m_neutralEtMin ){
00193               passedCuts = false;
00194               isTagged = true;
00195             }
00196             if( m_haveSetNeutralP && fabs(p) < m_neutralPMin ){
00197               passedCuts = false;
00198               isTagged = true;
00199             }
00200           }
00201         }//end species dependent cuts
00202         //else? what about forward particles
00203         /*
00204         else if( (*particle)->ET() < m_neutralEtMin ){
00205           passedCuts = false;
00206           isTagged = true;
00207         }
00208         */
00209       }
00210       //apply generic cuts otherwise
00211       if(!isTagged){
00212         if(m_haveSetPT  && passedCuts) passedCuts = ((*particle)->PT() > m_ptMin); //std::cout<<"here 6a " << passedCuts <<std::endl; 
00213         if(m_haveSetET  && passedCuts) passedCuts = ((*particle)->ET() > m_etMin);  //std::cout<<"here 6b "<< m_etMin<<" " << passedCuts <<std::endl;
00214         if(m_haveSetE   && passedCuts) passedCuts = ((*particle)->E() > m_eMin);  //std::cout<<"here 6c " << passedCuts <<std::endl;
00215         if(m_haveSetEta && passedCuts) passedCuts = (fabs((*particle)->eta()) < m_etaMax);  //std::cout<<"here 6d " << passedCuts <<std::endl;
00216       }
00217       if(m_haveSetBarcode && passedCuts){ passedCuts = ((*particle)->barcode() < m_barcodeMax);
00218         std::cout << "ZXCV barcodeMax = " << m_barcodeMax << std::endl;}
00219       // if(m_haveSetIsPrimary && passedCuts) passedCuts = (m_isPrimary == ((*particle)->barcode() < 200000 && (*particle)->barcode() != 0));
00220       
00221       
00222       if(m_haveSetCharged && passedCuts){
00223         
00224         switch(m_charge){
00225         case NEUTRAL:
00226           if((*particle)->charge() != 0) passedCuts = false;
00227           break;
00228         case CHARGED:
00229           if((*particle)->charge() == 0) passedCuts = false;
00230           break;
00231         case POSITIVE:
00232           if((*particle)->charge() <= 0) passedCuts = false;
00233           break;
00234         case NEGATIVE:
00235           if((*particle)->charge() >= 0) passedCuts = false;
00236           break;
00237           
00238         case ANY:
00239           
00240         default:
00241           break;
00242         }
00243       }
00244       if(passedCuts){
00245         
00246         m_passedParticles.push_back(*particle);
00247         m_passedFourVectors.push_back(*particle);
00248       }else if(isGenStable){
00249         m_rejectedParticles.push_back(*particle);
00250         m_rejectedFourVectors.push_back(*particle);
00251       }
00252     }
00253     
00254     return;
00255   }
00256   
00257 }
00258 

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