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

debugMCinfo.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/XANAMcInfo/interface/XANAGeneratorEvent.h>
00010 #include <XANADOO/XANAMcInfo/interface/XANAGeantEvent.h>
00011 #include <XANADOO/XANAMcInfo/interface/XANAGeneratorParticle.h>
00012 #include <XANADOO/XANAElectronCandidate/interface/XANAElectronCandidate.h>
00013 #include <XANADOO/XANAElectronCandidate/interface/XANAElectronTrack.h>
00014 #include <XANADOO/XANAElectronCandidate/interface/XANAElectronSeed.h>
00015 #include <XANADOO/XANAMuons/interface/XANAMuonCandidate.h>
00016 
00017 #include <XANADOO/XANAMcInfo/interface/XANAGeantTrack.h>
00018 #include <XANADOO/XANAMcInfo/interface/XANAGeantVertex.h>
00019 
00020 #include "TTree.h"
00021 #include "TFile.h"
00022 #include "TBranch.h"
00023 #include "TClonesArray.h"
00024 #include "TObjArray.h"
00025 #include "TH1.h"
00026 #include "TH2.h"
00027 #include "TSystem.h"
00028 #include "TROOT.h"
00029 
00030 #include <string>
00031 
00032 
00033 using namespace std;
00034 
00035 int main(int argc, char** argv)
00036 {
00037    //   Connect to file generated
00038    TFile *f;
00039    if (argc==1) f = new TFile("h300eemm.root");
00040    else f = new TFile(*++argv);
00041 
00042    //   Read Tree named "T" in memory. Tree pointer is assigned the same name
00043    TTree *T = (TTree*)f->Get("ESD");
00044 
00045 
00046    // Reconstructed event
00047    XANAEsdEvent *event = 0;  
00048    T->SetBranchAddress("Event",&event);
00049 
00050    // MC information (generator and GEANT event)
00051    XANAGeneratorEvent *generatorEvent = new XANAGeneratorEvent();
00052    TBranch *branchGeneratorEvent = T->GetBranch("GeneratorEvent");
00053    branchGeneratorEvent->SetAddress(&generatorEvent);
00054 
00055    XANAGeantEvent *geantEvent = new XANAGeantEvent();
00056    TBranch *branchGeantEvent = T->GetBranch("GeantEvent");
00057    branchGeantEvent->SetAddress(&geantEvent);
00058 
00059    Short_t mc_ngt = 0, mc_ngv = 0;  
00060 
00061    TFile *fout = new TFile("debugMC.root","RECREATE");
00062    TH2F *h_xy = new TH2F("x-y view","x-y view",400,-200.,200.,400,-200.,200.);
00063    TH2F *h_rz = new TH2F("r-z view","r-z view",800,-400.,400.,200,0.,200.);
00064    TH1F *h_r = new TH1F("r","r",200,0.,200.);
00065    
00066    //   Start main loop on all events
00067    Int_t nb = 0; 
00068    Int_t nevent = (Int_t)T->GetEntries();
00069    cout << "Going to read " << nevent << " events" << endl;
00070    for (Int_t i=0; i<nevent; i++) {
00071       nb += T->GetEntry(i); 
00072 
00073       cout << "================ Event: " << i << " ================" << endl;    
00074 
00075 
00076          // generator event
00077          cout << "--> new generator event" << endl;
00078          cout << endl;
00079 
00080          // GEANT event
00081          mc_ngt = geantEvent->getNumberOfGeantTracks();
00082          mc_ngv = geantEvent->getNumberOfGeantVertices();
00083          cout << "--> new GEANT event" << endl;
00084          cout << "      num of Geant tracks        = " << mc_ngt << endl;
00085          cout << "      num of Geant vertices      = " << mc_ngv << endl;
00086          cout << "    tracks ( piD --> momentum, mother index ):" << endl;
00087          
00088          XANAGeantTrack *geantTrack = 0;
00089          for (Int_t ig=0; ig<mc_ngt; ig++) {
00090             geantTrack = (XANAGeantTrack*)geantEvent->getGeantTracks()->At(ig);
00091             Int_t pID = geantTrack->getPartId();
00092             Int_t mother = geantTrack->getMotherIndex();
00093             cout << pID << "  -->  " << geantTrack->getMomentum() << ", " << mother<<  endl;
00094             XANAGeneratorParticle *genPart = geantTrack->getGeneratorParticle();
00095             if (genPart) {
00096               cout << " Parent generator particle " << genPart << endl;
00097               genPart->print();
00098             }
00099          }
00100 
00101          gROOT->SetStyle("Plain");
00102          // impact point histos
00103          for (Int_t ig=0; ig<mc_ngv; ig++) {
00104             XANAGeantVertex *geantVertex = (XANAGeantVertex*)geantEvent->getGeantVertices()->At(ig);
00105             Int_t mc_not = geantVertex->getNumberOfTracks();
00106             for (Int_t ig=0; ig<mc_not; ig++) {
00107                XANAGeantTrack *geantTrack = (XANAGeantTrack*)geantVertex->getTracks()->At(ig);
00108 //             cout << geantTrack->getPartId() << endl;
00109                if( geantTrack->getPartId() == -103) {
00110                   Float_t x = geantVertex->getPosition().x();
00111                   Float_t y = geantVertex->getPosition().y();
00112                   Float_t z = geantVertex->getPosition().z();
00113                   if (z<275) {
00114                      h_xy->Fill(x,y);
00115                      h_rz->Fill(z,sqrt(x*x+y*y));
00116                      h_r->Fill(sqrt(x*x+y*y));
00117                   }
00118                }
00119             }
00120          }
00121 
00122 
00123          event->clear(); 
00124          generatorEvent->clear();
00125          geantEvent->clear();
00126       }
00127 
00128    cout << endl;
00129    cout << nevent << " events and " << nb << " bytes read " << endl;  
00130    cout << endl;
00131 
00132    fout->Write();
00133    fout->Close();
00134 
00135    f->Close();  
00136 }
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152          /*
00153          cout << "    vertices:" << endl;
00154          for (Int_t ig=0; ig<mc_ngv; ig++) {
00155             XANAGeantVertex *geantVertex = (XANAGeantVertex*)geantEvent->getGeantVertices()->At(ig);
00156             cout << "      vertex position  = " << geantVertex->getPosition() << endl;
00157             Int_t mc_not = geantVertex->getNumberOfTracks();
00158             cout << "      vertex tracks: " << mc_not << endl;
00159             for (Int_t ig=0; ig<mc_not; ig++) {
00160                XANAGeantTrack *geantTrack = (XANAGeantTrack*)geantVertex->getTracks()->At(ig);
00161 //             cout << "        particle Id                = " << geantTrack->getPartId() << "   (" << ig << ")" << endl;
00162 //             cout << "        momentum                   = " << geantTrack->getMomentum() << "   (" << ig << ")" << endl;
00163                XANAGeneratorParticle *genPart = geantTrack->getGeneratorParticle();
00164                cout << geantTrack << " " << genPart << endl;
00165                cout << " genPart -- " << genPart->getPartId() << "  " << genPart->getMo1() << endl;
00166             }
00167          }
00168          */

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