Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

trackhit.cpp

Go to the documentation of this file.
00001 
00002 #include <XANADOO/domain/interface/XANAEsdEvent.h>
00003 #include <XANADOO/XANAClusters/interface/XANACluster.h>
00004 #include <XANADOO/XANAClusters/interface/XANACaloRecHit.h>
00005 #include <XANADOO/XANAClusters/interface/XANAEmCluster.h>
00006 #include <XANADOO/XANAClusters/interface/XANASuperCluster.h>
00007 #include <XANADOO/XANAClusters/interface/XANAHadCluster.h>
00008 #include <XANADOO/XANATracks/interface/XANATrack.h>
00009 #include <XANADOO/XANATracks/interface/XANATrackHit.h>
00010 #include <XANADOO/XANAMcInfo/interface/XANAGeneratorEvent.h>
00011 #include <XANADOO/XANAMcInfo/interface/XANAGeantEvent.h>
00012 #include <XANADOO/XANAMcInfo/interface/XANAGeneratorParticle.h>
00013 #include <XANADOO/XANAElectronCandidate/interface/XANAElectronCandidate.h>
00014 #include <XANADOO/XANAElectronCandidate/interface/XANAElectronTrack.h>
00015 #include <XANADOO/XANAElectronCandidate/interface/XANAElectronSeed.h>
00016 #include <XANADOO/XANAMuons/interface/XANAMuonCandidate.h>
00017 
00018 #include "TTree.h"
00019 #include "TFile.h"
00020 #include "TBranch.h"
00021 #include "TClonesArray.h"
00022 #include "TObjArray.h"
00023 #include "TH1.h"
00024 #include "TH2.h"
00025 #include "TSystem.h"
00026 #include "TROOT.h"
00027 #include "TStyle.h"
00028 #include "TCanvas.h"
00029 #include "TGraph.h" 
00030 #include "TSelector.h"
00031 #include "TApplication.h"
00032 
00033 
00034 #include <string>
00035 
00036 
00037 using namespace std;
00038 
00039 int main(int argc, char** argv)
00040 {
00041   //   Connect to file generated
00042   TFile *f;
00043   if (argc==1) f = new TFile("./SE04_E25_Pall_PT30_step1.root");
00044   else f = new TFile(*++argv);
00045  
00046   //   Read Tree named "T" in memory. Tree pointer is assigned the same name
00047   TTree *T = (TTree*)f->Get("ESD");
00048    
00049   // Reconstructed event
00050   XANAEsdEvent *event = 0;  
00051   T->SetBranchAddress("Event",&event);  
00052   Short_t ne = 0, nt=0, nth =0, neth =0; 
00053   TObjArray *tracks = 0;
00054   TObjArray *trackhits = 0;
00055   TObjArray *electrons = 0;
00056   TObjArray *electronTracks = 0;
00057   TObjArray *electronTrackhits = 0;
00058 
00059   //   Start main loop on all events
00060   Int_t nb = 0; 
00061   Int_t nevent = (Int_t)T->GetEntries();
00062   for (Int_t i=0; i<nevent; i++) {
00063     nb += T->GetEntry(i); 
00064 
00065     cout << "================ Event: " << i << " ================" << endl;    
00066     
00067     // Reconstructed event
00068     cout << "Reconstructed:" ;
00069 
00070     tracks = event->getTracks();
00071     nt  = event->getNumberOfTracks(); 
00072     trackhits = event->getTrackHits();        
00073     nth = event->getNumberOfTrackHits();  
00074     electrons = event->getElectronCandidates();    
00075     ne  = event->getNumberOfElectronCandidates(); 
00076     electronTracks = event->getElectronTracks();
00077     electronTrackhits = event->getEleTrackHits();
00078     neth = event->getNumberOfEleTrackHits();      
00079  
00080     // tracks
00081      XANATrack *tra;
00082      if ( nt != 0 ){
00083        cout << "tracks number: " << nt << endl; 
00084 
00085        // loop on tracks  
00086        int hitcount =0;
00087        for (int it =0; it < nt; it++){ 
00088        tra = (XANATrack*)((*tracks)[it]);
00089 
00090        cout << "track " << it << ": number of hits = "<< tra->getNumberOfHits() << endl;
00091 
00092        for (int ithit = hitcount; ithit < (tra->getNumberOfHits() + hitcount); ithit++){ 
00093        XANATrackHit *trahit = (XANATrackHit*)((*trackhits)[ithit]); 
00094 
00095        cout << "standard track: hit number " << ithit << endl;
00096        cout << "st: new hit" << endl;
00097        cout << trahit->getHitPosition().x() << endl;
00098        cout << trahit->getHitPosition().y() << endl;
00099        cout << trahit->getHitPosition().z() << endl;
00100        cout << "st: new updated state: position" << endl;
00101        cout << trahit->getUpdatedPosition().x() << endl;
00102        cout << trahit->getUpdatedPosition().y() << endl;
00103        cout << trahit->getUpdatedPosition().z() << endl;
00104        cout << "st: new updated state: momentum" << endl;
00105        cout << trahit->getUpdatedMomentum().x() << endl;
00106        cout << trahit->getUpdatedMomentum().y() << endl;
00107        cout << trahit->getUpdatedMomentum().z() << endl;
00108        cout << "st: isStereo" << endl;
00109        cout << trahit->getIsStereo() << endl;
00110  
00111        // checking first and last hit
00112        if ( ithit == hitcount){
00113           cout << "standard" << endl; 
00114           cout << "position" << endl;
00115           cout << "first hit, x" << trahit->getUpdatedPosition().x() << endl;  
00116           cout << "first hit, y" << trahit->getUpdatedPosition().y() << endl;  
00117           cout << "first hit, z" << trahit->getUpdatedPosition().z() << endl;  
00118           cout << "momentum" << endl;
00119           cout << "first hit, px" << trahit->getUpdatedMomentum().x() << endl;  
00120           cout << "first hit, py" << trahit->getUpdatedMomentum().y() << endl;  
00121           cout << "first hit, pz" << trahit->getUpdatedMomentum().z() << endl;  
00122         }
00123        if ( ithit == (tra->getNumberOfHits() + hitcount -1)){
00124          cout << "position" << endl;
00125          cout << "last hit, x" << trahit->getUpdatedPosition().x() << endl;  
00126          cout << "last hit, y" << trahit->getUpdatedPosition().y() << endl;  
00127          cout << "last hit, z" << trahit->getUpdatedPosition().z() << endl;  
00128          cout << "momenutm" << endl;
00129          cout << "last hit, px" << trahit->getUpdatedMomentum().x() << endl;  
00130          cout << "last hit, py" << trahit->getUpdatedMomentum().y() << endl;  
00131          cout << "last hit, pz" << trahit->getUpdatedMomentum().z() << endl;  
00132         }
00133        } // end loop over hits
00134       
00135        // checking first and last hit  
00136        cout << "standard method:" << endl;  
00137        cout << "position" << endl;
00138        cout << "first hit, x" << tra->getPositionAtFirstPoint().x() << endl;  
00139        cout << "first hit, y" << tra->getPositionAtFirstPoint().y() << endl;  
00140        cout << "first hit, z" << tra->getPositionAtFirstPoint().z() << endl;  
00141        cout << "last hit, x"  << tra->getPositionAtLastPoint().x() << endl;  
00142        cout << "last hit, y"  << tra->getPositionAtLastPoint().y() << endl;  
00143        cout << "last hit, z"  << tra->getPositionAtLastPoint().z() << endl;  
00144        cout << "momenutm" << endl;
00145        cout << "first hit, px" << tra->getMomentumAtFirstPoint().x() << endl;  
00146        cout << "first hit, py" << tra->getMomentumAtFirstPoint().y() << endl;  
00147        cout << "first hit, pz" << tra->getMomentumAtFirstPoint().z() << endl;  
00148        cout << "last hit, px"  << tra->getMomentumAtLastPoint().x() << endl;  
00149        cout << "last hit, py"  << tra->getMomentumAtLastPoint().y() << endl;  
00150        cout << "last hit, pz"  << tra->getMomentumAtLastPoint().z() << endl;  
00151       
00152 
00153        hitcount = hitcount + tra->getNumberOfHits(); 
00154        } // end loop on tracks
00155      } // checking tracks
00156     
00157 
00158     // electrons
00159     XANAElectronTrack *eletra;
00160     int elehitcount =0;
00161 
00162     for (Int_t ie=0; ie<ne; ie++) {
00163       XANAElectronCandidate *elec = (XANAElectronCandidate*)((*electrons)[ie]);
00164       cout << "new electron candidate : " << elec << endl;
00165 
00166       if ( elec->getElectronTrack() ){
00167        eletra = elec->getElectronTrack();
00168 
00169        cout << "new electron track: number of hits = "<< eletra->getNumberOfHits() << endl;
00170 
00171        // loop on all elec track hits        
00172        for (int eleithit = elehitcount; eleithit < (eletra->getNumberOfHits() + elehitcount); eleithit++){ 
00173        XANATrackHit *eletrahit = (XANATrackHit*)((*electronTrackhits)[eleithit]); 
00174 
00175        cout << "Electronic track: hit number = " << eleithit << endl;
00176        cout << "new ele hit" << endl;
00177        cout << eletrahit->getHitPosition().x() << endl;
00178        cout << eletrahit->getHitPosition().y() << endl;
00179        cout << eletrahit->getHitPosition().z() << endl;
00180        cout << "new ele updated state: position" << endl;
00181        cout << eletrahit->getUpdatedPosition().x() << endl;
00182        cout << eletrahit->getUpdatedPosition().y() << endl;
00183        cout << eletrahit->getUpdatedPosition().z() << endl;
00184        cout << "new ele updated state: momentum" << endl;
00185        cout << eletrahit->getUpdatedMomentum().x() << endl;
00186        cout << eletrahit->getUpdatedMomentum().y() << endl;
00187        cout << eletrahit->getUpdatedMomentum().z() << endl;
00188        cout << "new ele hit: isStereo" << endl;
00189        cout << eletrahit->getIsStereo().x() << endl;
00190 
00191        // checking first and last hit
00192        if ( eleithit == elehitcount){
00193           cout << "electronic track" << endl;
00194           cout << "position" << endl; 
00195           cout << "first hit, x" << eletrahit->getUpdatedPosition().x() << endl;  
00196           cout << "first hit, y" << eletrahit->getUpdatedPosition().y() << endl;  
00197           cout << "first hit, z" << eletrahit->getUpdatedPosition().z() << endl;  
00198           cout << "momentum" << endl; 
00199           cout << "first hit, px" << eletrahit->getUpdatedMomentum().x() << endl;  
00200           cout << "first hit, py" << eletrahit->getUpdatedMomentum().y() << endl;  
00201           cout << "first hit, pz" << eletrahit->getUpdatedMomentum().z() << endl;  
00202         }
00203        if ( eleithit == (eletra->getNumberOfHits() + elehitcount -1)){
00204          cout << "position" << endl; 
00205          cout << "last hit, x" << eletrahit->getUpdatedPosition().x() << endl;  
00206          cout << "last hit, y" << eletrahit->getUpdatedPosition().y() << endl;  
00207          cout << "last hit, z" << eletrahit->getUpdatedPosition().z() << endl;  
00208          cout << "momentum" << endl; 
00209          cout << "last hit, px" << eletrahit->getUpdatedMomentum().x() << endl;  
00210          cout << "last hit, py" << eletrahit->getUpdatedMomentum().y() << endl;  
00211          cout << "last hit, pz" << eletrahit->getUpdatedMomentum().z() << endl;  
00212         }
00213 
00214        } // end loop over hits
00215 
00216        // checking first and last hit  
00217        cout << "standard method:" << endl;  
00218        cout << "position" << endl; 
00219        cout << "first hit, x" << eletra->getPositionAtFirstPoint().x() << endl;  
00220        cout << "first hit, y" << eletra->getPositionAtFirstPoint().y() << endl;  
00221        cout << "first hit, z" << eletra->getPositionAtFirstPoint().z() << endl;  
00222        cout << "last hit, x"  << eletra->getPositionAtLastPoint().x() << endl;  
00223        cout << "last hit, y"  << eletra->getPositionAtLastPoint().y() << endl;  
00224        cout << "last hit, z"  << eletra->getPositionAtLastPoint().z() << endl;  
00225        cout << "momentum" << endl; 
00226        cout << "first hit, px" << eletra->getMomentumAtFirstPoint().x() << endl;  
00227        cout << "first hit, py" << eletra->getMomentumAtFirstPoint().y() << endl;  
00228        cout << "first hit, pz" << eletra->getMomentumAtFirstPoint().z() << endl;  
00229        cout << "last hit, px"  << eletra->getMomentumAtLastPoint().x() << endl;  
00230        cout << "last hit, py"  << eletra->getMomentumAtLastPoint().y() << endl;  
00231        cout << "last hit, pz"  << eletra->getMomentumAtLastPoint().z() << endl;  
00232 
00233        elehitcount = elehitcount + eletra->getNumberOfHits();
00234       } // ok electron track
00235     } // loop over electron candidates
00236 
00237   event->clear(); 
00238   }
00239   
00240   cout << endl;
00241   cout << nevent << " events and " << nb << " bytes read " << endl;  
00242   cout << endl;
00243   
00244   f->Close();  
00245  
00246 }

Generated on Tue May 10 10:01:24 2005 for XANADOO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002