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

readTrackhit.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  
00109        // checking first and last hit
00110        if ( ithit == hitcount){
00111           cout << "standard" << endl; 
00112           cout << "position" << endl;
00113           cout << "first hit, x" << trahit->getUpdatedPosition().x() << endl;  
00114           cout << "first hit, y" << trahit->getUpdatedPosition().y() << endl;  
00115           cout << "first hit, z" << trahit->getUpdatedPosition().z() << endl;  
00116           cout << "momentum" << endl;
00117           cout << "first hit, px" << trahit->getUpdatedMomentum().x() << endl;  
00118           cout << "first hit, py" << trahit->getUpdatedMomentum().y() << endl;  
00119           cout << "first hit, pz" << trahit->getUpdatedMomentum().z() << endl;  
00120         }
00121        if ( ithit == (tra->getNumberOfHits() + hitcount -1)){
00122          cout << "position" << endl;
00123          cout << "last hit, x" << trahit->getUpdatedPosition().x() << endl;  
00124          cout << "last hit, y" << trahit->getUpdatedPosition().y() << endl;  
00125          cout << "last hit, z" << trahit->getUpdatedPosition().z() << endl;  
00126          cout << "momenutm" << endl;
00127          cout << "last hit, px" << trahit->getUpdatedMomentum().x() << endl;  
00128          cout << "last hit, py" << trahit->getUpdatedMomentum().y() << endl;  
00129          cout << "last hit, pz" << trahit->getUpdatedMomentum().z() << endl;  
00130         }
00131        } // end loop over hits
00132       
00133        // checking first and last hit  
00134        cout << "standard method:" << endl;  
00135        cout << "position" << endl;
00136        cout << "first hit, x" << tra->getPositionAtFirstPoint().x() << endl;  
00137        cout << "first hit, y" << tra->getPositionAtFirstPoint().y() << endl;  
00138        cout << "first hit, z" << tra->getPositionAtFirstPoint().z() << endl;  
00139        cout << "last hit, x"  << tra->getPositionAtLastPoint().x() << endl;  
00140        cout << "last hit, y"  << tra->getPositionAtLastPoint().y() << endl;  
00141        cout << "last hit, z"  << tra->getPositionAtLastPoint().z() << endl;  
00142        cout << "momenutm" << endl;
00143        cout << "first hit, px" << tra->getMomentumAtFirstPoint().x() << endl;  
00144        cout << "first hit, py" << tra->getMomentumAtFirstPoint().y() << endl;  
00145        cout << "first hit, pz" << tra->getMomentumAtFirstPoint().z() << endl;  
00146        cout << "last hit, px"  << tra->getMomentumAtLastPoint().x() << endl;  
00147        cout << "last hit, py"  << tra->getMomentumAtLastPoint().y() << endl;  
00148        cout << "last hit, pz"  << tra->getMomentumAtLastPoint().z() << endl;  
00149       
00150 
00151        hitcount = hitcount + tra->getNumberOfHits(); 
00152        } // end loop on tracks
00153      } // checking tracks
00154     
00155 
00156     // electrons
00157     XANAElectronTrack *eletra;
00158     int elehitcount =0;
00159 
00160     for (Int_t ie=0; ie<ne; ie++) {
00161       XANAElectronCandidate *elec = (XANAElectronCandidate*)((*electrons)[ie]);
00162       cout << "new electron candidate : " << elec << endl;
00163 
00164       if ( elec->getElectronTrack() ){
00165        eletra = elec->getElectronTrack();
00166 
00167        cout << "new electron track: number of hits = "<< eletra->getNumberOfHits() << endl;
00168 
00169        // loop on all elec track hits        
00170        for (int eleithit = elehitcount; eleithit < (eletra->getNumberOfHits() + elehitcount); eleithit++){ 
00171        XANATrackHit *eletrahit = (XANATrackHit*)((*electronTrackhits)[eleithit]); 
00172 
00173        cout << "Electronic track: hit number = " << eleithit << endl;
00174        cout << "new ele hit" << endl;
00175        cout << eletrahit->getHitPosition().x() << endl;
00176        cout << eletrahit->getHitPosition().y() << endl;
00177        cout << eletrahit->getHitPosition().z() << endl;
00178        cout << "new ele updated state: position" << endl;
00179        cout << eletrahit->getUpdatedPosition().x() << endl;
00180        cout << eletrahit->getUpdatedPosition().y() << endl;
00181        cout << eletrahit->getUpdatedPosition().z() << endl;
00182        cout << "new ele updated state: momentum" << endl;
00183        cout << eletrahit->getUpdatedMomentum().x() << endl;
00184        cout << eletrahit->getUpdatedMomentum().y() << endl;
00185        cout << eletrahit->getUpdatedMomentum().z() << endl;
00186 
00187        // checking first and last hit
00188        if ( eleithit == elehitcount){
00189           cout << "electronic track" << endl;
00190           cout << "position" << endl; 
00191           cout << "first hit, x" << eletrahit->getUpdatedPosition().x() << endl;  
00192           cout << "first hit, y" << eletrahit->getUpdatedPosition().y() << endl;  
00193           cout << "first hit, z" << eletrahit->getUpdatedPosition().z() << endl;  
00194           cout << "momentum" << endl; 
00195           cout << "first hit, px" << eletrahit->getUpdatedMomentum().x() << endl;  
00196           cout << "first hit, py" << eletrahit->getUpdatedMomentum().y() << endl;  
00197           cout << "first hit, pz" << eletrahit->getUpdatedMomentum().z() << endl;  
00198         }
00199        if ( eleithit == (eletra->getNumberOfHits() + elehitcount -1)){
00200          cout << "position" << endl; 
00201          cout << "last hit, x" << eletrahit->getUpdatedPosition().x() << endl;  
00202          cout << "last hit, y" << eletrahit->getUpdatedPosition().y() << endl;  
00203          cout << "last hit, z" << eletrahit->getUpdatedPosition().z() << endl;  
00204          cout << "momentum" << endl; 
00205          cout << "last hit, px" << eletrahit->getUpdatedMomentum().x() << endl;  
00206          cout << "last hit, py" << eletrahit->getUpdatedMomentum().y() << endl;  
00207          cout << "last hit, pz" << eletrahit->getUpdatedMomentum().z() << endl;  
00208         }
00209 
00210        } // end loop over hits
00211 
00212        // checking first and last hit  
00213        cout << "standard method:" << endl;  
00214        cout << "position" << endl; 
00215        cout << "first hit, x" << eletra->getPositionAtFirstPoint().x() << endl;  
00216        cout << "first hit, y" << eletra->getPositionAtFirstPoint().y() << endl;  
00217        cout << "first hit, z" << eletra->getPositionAtFirstPoint().z() << endl;  
00218        cout << "last hit, x"  << eletra->getPositionAtLastPoint().x() << endl;  
00219        cout << "last hit, y"  << eletra->getPositionAtLastPoint().y() << endl;  
00220        cout << "last hit, z"  << eletra->getPositionAtLastPoint().z() << endl;  
00221        cout << "momentum" << endl; 
00222        cout << "first hit, px" << eletra->getMomentumAtFirstPoint().x() << endl;  
00223        cout << "first hit, py" << eletra->getMomentumAtFirstPoint().y() << endl;  
00224        cout << "first hit, pz" << eletra->getMomentumAtFirstPoint().z() << endl;  
00225        cout << "last hit, px"  << eletra->getMomentumAtLastPoint().x() << endl;  
00226        cout << "last hit, py"  << eletra->getMomentumAtLastPoint().y() << endl;  
00227        cout << "last hit, pz"  << eletra->getMomentumAtLastPoint().z() << endl;  
00228 
00229        elehitcount = elehitcount + eletra->getNumberOfHits();
00230       } // ok electron track
00231     } // loop over electron candidates
00232 
00233   event->clear(); 
00234   }
00235   
00236   cout << endl;
00237   cout << nevent << " events and " << nb << " bytes read " << endl;  
00238   cout << endl;
00239   
00240   f->Close();  
00241  
00242 }

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