CMS 3D CMS Logo

PFRootEventManagerColin Class Reference

#include <RecoParticleFlow/PFRootEvent/interface/PFRootEventManagerColin.h>

Inheritance diagram for PFRootEventManagerColin:

PFRootEventManager

List of all members.

Public Types

enum  Mode { Neutral = 0, HIGH_E_TAUS = 1 }

Public Member Functions

 PFRootEventManagerColin (const char *file)
bool processEntry (int entry)
 process one entry
bool processHIGH_E_TAUS ()
bool processNeutral ()
void readSpecificOptions (const char *file)
void write ()
 ~PFRootEventManagerColin ()

Public Attributes

int mode_
NeutralEventneutralEvent_
TTree * outTreeMy_
TauEventtauEvent_


Detailed Description

Definition at line 63 of file PFRootEventManagerColin.h.


Member Enumeration Documentation

enum PFRootEventManagerColin::Mode

Enumerator:
Neutral 
HIGH_E_TAUS 

Definition at line 80 of file PFRootEventManagerColin.h.

00080             {
00081     Neutral=0,
00082     HIGH_E_TAUS=1
00083   };


Constructor & Destructor Documentation

PFRootEventManagerColin::PFRootEventManagerColin ( const char *  file  ) 

Definition at line 11 of file PFRootEventManagerColin.cc.

References neutralEvent_, outTreeMy_, readSpecificOptions(), and tauEvent_.

00012   : PFRootEventManager(file) {
00013   
00014   tauEvent_ = 0;
00015   neutralEvent_ = 0;
00016   outTreeMy_ = 0;   
00017   
00018   //   readOptions(file, false, false);
00019   
00020   // book histos here
00021   //   neutralEvent_ = new NeutralEvent();  
00022 
00023 
00024   //   tauEvent_ = new TauEvent();  
00025   //   outTree_ = new TTree("Tau","");
00026   //   outTree_->Branch("event","TauEvent", &tauEvent_,32000,2);
00027 
00028   readSpecificOptions(file);
00029 
00030 }

PFRootEventManagerColin::~PFRootEventManagerColin (  ) 

Definition at line 32 of file PFRootEventManagerColin.cc.

00032                                                   {
00033 
00034   //   delete event_;
00035   //   delete outTree_;
00036 }


Member Function Documentation

bool PFRootEventManagerColin::processEntry ( int  entry  )  [virtual]

process one entry

Reimplemented from PFRootEventManager.

Definition at line 77 of file PFRootEventManagerColin.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), HIGH_E_TAUS, mode_, Neutral, outTreeMy_, PFRootEventManager::processEntry(), processHIGH_E_TAUS(), processNeutral(), NeutralEvent::rCode, TauEvent::reset(), and tauEvent_.

00077                                                     {
00078 
00079   tauEvent_->reset();
00080 
00081   if( ! PFRootEventManager::processEntry(entry) ) {
00082     // cerr<<"event was not accepted"<<endl;
00083     // print();
00084     tauEvent_->rCode = 10;
00085     return false; // event not accepted
00086   }
00087 
00088   bool rvalue = false;
00089   switch(mode_) {
00090   case Neutral:
00091     // cout<<"colin: process Neutral"<<endl;
00092     rvalue = processNeutral();
00093     break;
00094   case HIGH_E_TAUS:
00095     // cout<<"colin: process highETaus"<<endl;
00096     rvalue = processHIGH_E_TAUS();
00097     break;
00098   default:
00099     cerr<<"colin: undefined mode"<<endl;
00100     assert(0);
00101   }
00102   outTreeMy_->Fill();
00103 
00104 
00105   outTreeMy_->Fill();
00106 
00107 
00108   outTreeMy_->Fill();
00109 
00110 
00111   return rvalue;
00112 }

bool PFRootEventManagerColin::processHIGH_E_TAUS (  ) 

Definition at line 192 of file PFRootEventManagerColin.cc.

References funct::abs(), reco::PFBlock::associatedElements(), parseConfig::block, reco::PFTrack::charge(), TauEvent::chi2ECAL, reco::PFTrajectoryPoint::ClosestApproach, PFRootEventManager::clustersECAL_, PFRootEventManager::clustersHCAL_, reco::PFSimParticle::daughterIds(), reco::PFBlockElement::ECAL, NeutralEvent::eECAL, NeutralEvent::eHCAL, bookConverter::elements, reco::PFBlock::elements(), NeutralEvent::eNeutral, NeutralEvent::etaECAL, NeutralEvent::etaHCAL, NeutralEvent::etaNeutral, TauEvent::etaTrack, reco::PFBlockElement::HCAL, i, index, edm::Ref< C, T, F >::isNull(), reco::PFBlock::linkData(), NeutralEvent::nECAL, NeutralEvent::nHCAL, reco::PFSimParticle::pdgCode(), PFRootEventManager::pfBlocks_, TauEvent::pHadron, TauEvent::pTrack, TauEvent::ptTrack, NeutralEvent::rCode, PFRootEventManager::recTracks_, edm::OwnVector< T, P >::size(), tauEvent_, reco::PFBlockElement::TRACK, and PFRootEventManager::trueParticles_.

Referenced by processEntry().

00192                                                  {
00193 
00194 
00195   // true info 
00196   // 1 charged hadron, 2 photons
00197   // save charged part mom, save sum E photons
00198   
00199 
00200   int iHadron  = -1;
00201   int iPi0 = -1;
00202   unsigned nStableChargedHadrons=0;
00203   unsigned nPi0=0;
00204   for(unsigned i=0; i<trueParticles_.size(); i++) {
00205     
00206     const reco::PFSimParticle& part = trueParticles_[i];
00207     
00208     int pdgCode = part.pdgCode();
00209     double charge = part.charge();
00210 
00211     if( abs(pdgCode) > 100 &&
00212         charge !=0 && 
00213         part.daughterIds().empty() ) {
00214       nStableChargedHadrons++;
00215       iHadron = i;
00216     }
00217     else if( abs(pdgCode)==111) {
00218       nPi0++;
00219       iPi0 = i; 
00220     } 
00221 
00222     // cout<<i<<" "<<part<<endl;
00223   }
00224 
00225 
00226   // one has to select 1 charged and 2 photons 
00227   // to use this function.
00228 
00229   // even after filtering events with one stable charged particle,
00230   // this particle can be a lepton (eg leptonic pion decay)
00231   if( nStableChargedHadrons==0 ) {
00232     tauEvent_->rCode = 4; 
00233     return false;
00234   }
00235   assert( nStableChargedHadrons==1 );
00236 
00237 
00238   
00239   double pHadron = trueParticles_[iHadron].extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach ).momentum().P(); 
00240   tauEvent_->pHadron = pHadron;
00241 
00242   //  tauEvent_->eEcalHadron = trueParticles_[iHadron].ecalEnergy();
00243   
00244   if(nPi0 == 1) {
00245     math::XYZTLorentzVector pi0mom =  trueParticles_[iPi0].extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach ).momentum();
00246     tauEvent_->eNeutral = pi0mom.E();
00247     tauEvent_->etaNeutral = pi0mom.Eta();
00248   }
00249   else {
00250     tauEvent_->eNeutral = 0;
00251   }
00252 
00253   //   if( tauEvent_->eNeutral > 0.1* tauEvent_->pHadron ) {
00254   //     print();
00255   //   }
00256 
00257 
00258   // check that there is 
00259   // only one track
00260   // 0 or 1 ecal cluster
00261   // 0 or 1 hcal cluster
00262 
00263   if( recTracks_.size() != 1 ) {
00264     //     cout<<"more than 1 track"<<endl;
00265     tauEvent_->rCode = 1;
00266     return false;
00267   }
00268   if( clustersECAL_->size() > 1 ) {
00269     //     cout<<"more than 1 ecal cluster"<<endl;
00270     tauEvent_->rCode = 2;
00271     // return false;
00272   }
00273   if( clustersHCAL_->size() > 1 ) {
00274     //     cout<<"more than 1 hcal cluster"<<endl;
00275     tauEvent_->rCode = 3;
00276     return false;
00277   }
00278   // save track mom + neutral info.
00279 
00280   tauEvent_->pTrack = recTracks_[0].extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach ).momentum().P();
00281   tauEvent_->ptTrack = recTracks_[0].extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach ).momentum().Pt();
00282   tauEvent_->etaTrack = recTracks_[0].extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach ).momentum().Eta();
00283 
00284   // access blocks
00285 
00286   // take the track block
00287 
00288   // look for the closest associated ecal and hcal clusters
00289 
00290   // fill the tree
00291 
00292     
00293 
00294 
00295   for(unsigned i=0; i<pfBlocks_->size(); i++) {
00296     const reco::PFBlock& block = (*pfBlocks_)[i];
00297     
00298     const edm::OwnVector< reco::PFBlockElement >& 
00299       elements = block.elements();
00300     
00301     // look for the track
00302     int iTrack = -1;
00303     unsigned nTracks = 0;
00304     for(unsigned ie=0; ie<elements.size(); ie++) {
00305       if(elements[ie].type() == reco::PFBlockElement::TRACK  ) {
00306         iTrack = ie;
00307         nTracks++;
00308       }
00309     }
00310     
00311     if(nTracks!=1) continue; // no track, or too many tracks in the block
00312     
00313     std::multimap<double, unsigned> sortedElems;
00314     block.associatedElements( iTrack, 
00315                               block.linkData(),
00316                               sortedElems );
00317     
00318     tauEvent_->nECAL=0;
00319     tauEvent_->nHCAL=0;
00320     
00321     typedef std::multimap<double, unsigned>::iterator IE;
00322     for(IE ie = sortedElems.begin(); ie != sortedElems.end(); ++ie ) {
00323       
00324       
00325       double chi2 = ie->first;
00326       unsigned index = ie->second;
00327       
00328       reco::PFBlockElement::Type type = elements[index].type();
00329       
00330       reco::PFClusterRef clusterRef = elements[index].clusterRef();
00331 
00332 
00333       
00334 
00335       if( type == reco::PFBlockElement::ECAL ) {
00336         if(!tauEvent_->nECAL ) { // closest ecal
00337           assert( !clusterRef.isNull() );
00338           tauEvent_->eECAL = clusterRef->energy();
00339           tauEvent_->etaECAL = clusterRef->position().Eta();
00340           tauEvent_->chi2ECAL = chi2;
00341           tauEvent_->nECAL++;
00342         }
00343       }
00344 
00345 
00346       else if( type == reco::PFBlockElement::HCAL ) {
00347         if(!tauEvent_->nHCAL ) { // closest hcal
00348           assert( !clusterRef.isNull() );
00349           tauEvent_->eHCAL = clusterRef->energy();
00350           tauEvent_->etaHCAL = clusterRef->position().Eta();
00351           tauEvent_->nHCAL++;
00352         }
00353       } 
00354     } // eles associated to the track
00355   } // blocks
00356 
00357 
00358 
00359 
00360   return false;    
00361 }

bool PFRootEventManagerColin::processNeutral (  ) 

Definition at line 117 of file PFRootEventManagerColin.cc.

References TestMuL1L2Filter_cff::cerr, NeutralEvent::eECAL, NeutralEvent::eHCAL, lat::endl(), NeutralEvent::eNeutral, eta, NeutralEvent::etaNeutral, edm::HepMCProduct::GetEvent(), i, PFRootEventManager::MCTruth_, NeutralEvent::nECAL, neutralEvent_, NeutralEvent::nHCAL, outTreeMy_, phi, and NeutralEvent::reset().

Referenced by processEntry().

00117                                              {
00118   //   else {
00119   //     cerr<<"event accepted"<<endl;
00120   //   }
00121   
00122   //   if( ! ( (*clustersECAL_).size() <= 1 && 
00123   //      (*clustersHCAL_).size() <= 1 ) ) {
00124   //     cerr<<"wrong number of ECAL or HCAL clusters :"
00125   //    <<(*clustersECAL_).size()<<","<<(*clustersHCAL_).size()<<endl;
00126   //     return false; 
00127   //   }
00128   // 1 HCAL cluster
00129   
00130   neutralEvent_->reset();
00131   
00132   // particle
00133 
00134   const HepMC::GenEvent* myGenEvent = MCTruth_.GetEvent();
00135   if(!myGenEvent) {
00136     assert(0);
00137   }
00138 
00139   if( myGenEvent->particles_size() != 1 ) {
00140     cerr<<"wrong number of particles:"
00141         <<myGenEvent->particles_size()<<endl;
00142     return 0;
00143   }
00144 
00145   // take first particle  
00146   const HepMC::GenParticle* particle = *(myGenEvent->particles_begin() );
00147   
00148   // and check that it's a K0L 
00149   if( particle->pdg_id() != 130 ) {
00150     cerr<<"not a K0L : "<<particle->pdg_id()<<endl;
00151     return false;
00152   }
00153 
00154   neutralEvent_->eNeutral = particle->momentum().e();
00155 
00156   double eta =  particle->momentum().eta();
00157   double phi =  particle->momentum().phi();
00158   neutralEvent_->etaNeutral = eta;
00159   
00160 
00161   neutralEvent_->nECAL = (*clustersECAL_).size();
00162 
00163   // look for the closest ECAL cluster from the particle.
00164 
00165   double minDist2 = 9999999;
00166   // int iClosest = -1;
00167   for( unsigned i=0; i<(*clustersECAL_).size(); ++i) {
00168     double deta = (*clustersECAL_)[i].position().Eta() - eta;
00169     double dphi = (*clustersECAL_)[i].position().Phi() - phi;
00170     double dist2 = deta*deta + dphi*dphi;
00171     if(dist2 < minDist2) {
00172       minDist2 = dist2;
00173       neutralEvent_->eECAL = (*clustersECAL_)[i].energy();
00174     }
00175   }
00176 
00177 
00178   neutralEvent_->nHCAL = (*clustersHCAL_).size();
00179   if( (*clustersHCAL_).size() == 1 ) {
00180     neutralEvent_->eHCAL = (*clustersHCAL_)[0].energy();
00181   }
00182 
00183   
00184   outTreeMy_->Fill();
00185   
00186   if(  neutralEvent_->nECAL<1 && neutralEvent_->eNeutral<1 )
00187     return true;
00188   else return false;
00189 }

void PFRootEventManagerColin::readSpecificOptions ( const char *  file  )  [virtual]

Reimplemented from PFRootEventManager.

Definition at line 39 of file PFRootEventManagerColin.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), cmsRelvalreport::exit, IO::GetOpt(), HIGH_E_TAUS, mode_, Neutral, neutralEvent_, PFRootEventManager::options_, PFRootEventManager::outFile_, outTreeMy_, and tauEvent_.

Referenced by PFRootEventManagerColin().

00039                                                                   {
00040 
00041 
00042 
00043   cout<<"calling PFRootEventManagerColin::readSpecificOptions"<<endl; 
00044   //   PFRootEventManager::readOptions(file, refresh, reconnect);
00045 
00046   
00047   options_->GetOpt("colin", "mode", mode_);
00048 
00049   if(outTreeMy_) delete outTreeMy_;
00050   
00051   outFile_->cd();
00052   switch(mode_) {
00053   case Neutral:
00054     cout<<"colin: Neutral mode"<<endl;
00055     neutralEvent_ = new NeutralEvent();  
00056     outTreeMy_ = new TTree("Neutral","");
00057     outTreeMy_->Branch("event","NeutralEvent", &neutralEvent_,32000,2);
00058     gDirectory->ls();
00059     break;
00060   case HIGH_E_TAUS:
00061     cout<<"colin: highETaus mode"<<endl;
00062     tauEvent_ = new TauEvent();  
00063     outTreeMy_ = new TTree("Tau","");
00064     outTreeMy_->Branch("event","TauEvent", &tauEvent_,32000,2);
00065     gDirectory->ls();
00066     break;
00067   default:
00068     cerr<<"colin: undefined mode"<<endl;
00069     exit(1);
00070   }
00071 }

void PFRootEventManagerColin::write ( void   )  [virtual]

Reimplemented from PFRootEventManager.

Definition at line 366 of file PFRootEventManagerColin.cc.

References PFRootEventManager::outFile_, outTreeMy_, and PFRootEventManager::write().

00366                                     {
00367   // write histos here
00368   outFile_->cd();
00369   outTreeMy_->Write();
00370 
00371   PFRootEventManager::write();
00372 }


Member Data Documentation

int PFRootEventManagerColin::mode_

Definition at line 88 of file PFRootEventManagerColin.h.

Referenced by processEntry(), and readSpecificOptions().

NeutralEvent* PFRootEventManagerColin::neutralEvent_

Definition at line 86 of file PFRootEventManagerColin.h.

Referenced by PFRootEventManagerColin(), processNeutral(), and readSpecificOptions().

TTree* PFRootEventManagerColin::outTreeMy_

Definition at line 85 of file PFRootEventManagerColin.h.

Referenced by PFRootEventManagerColin(), processEntry(), processNeutral(), readSpecificOptions(), and write().

TauEvent* PFRootEventManagerColin::tauEvent_

Definition at line 87 of file PFRootEventManagerColin.h.

Referenced by PFRootEventManagerColin(), processEntry(), processHIGH_E_TAUS(), and readSpecificOptions().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:29:48 2009 for CMSSW by  doxygen 1.5.4