/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/verif.cpp File Reference

#include <iostream>
#include <stdlib.h>
#include <map>
#include <string>
#include "TROOT.h"
#include "TGraph.h"
#include "TStyle.h"
#include <TFile.h>
#include <TTree.h>
#include <TLegend.h>
#include <TKey.h>
#include <TH1I.h>
#include <TH2I.h>
#include <TText.h>
#include <TCanvas.h>
#include <TPaveLabel.h>
#include "Run.hh"
#include "Detector.hh"
#include "XMLTool.hh"
#include "Toolbox.hh"
#include "MicroException.hh"
#include "Log.hh"
#include "root/MTRun.hh"
#include "root/MTEvent.hh"
#include "root/MTChannel.hh"
#include "root/CaloEvent.hh"
#include "root/CaloHit.hh"
#include "tools/Arguments.hh"
#include "Chamber.hh"

Include dependency graph for verif.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file verif.cpp.

00050                                 {
00051 
00052 
00053   FILELog::ReportingLevel() = FILELog::FromString(INFO);
00054 
00055   Arguments arg(argc,argv,"monitoring inputFile outputFile -l evtNum");
00056   if (arg.getNbOfArgs() != 2 ) { arg.usage() ; exit(-1);}
00057   string rootName = arg.getArgument(1);
00058   string outputFileName = arg.getArgument(2);
00059 
00060   TFile *output= new TFile(outputFileName.c_str(),"RECREATE");
00061 
00062 
00063   Char_t flag[20];
00064   TTree *flagTree = new TTree("FLAG", "evant flag");
00065   flagTree->Branch("Flag", flag,"flag/C");
00066    
00067 
00068   UInt_t eventLimit = 0;
00069   if ( arg.getOption("-l").size() != 0 )
00070   {
00071     eventLimit = atoi(arg.getOption("-l").c_str());
00072   }
00073 
00074   bool construct = false;
00075 
00076   TFile f(rootName.c_str());
00077 
00078 
00079   TH2I* xy = NULL;
00080   TIter nextkey(f.GetListOfKeys());
00081   TKey *key;
00082 
00083   TH2I* hists[100];
00084   while (key = (TKey*)nextkey()) 
00085   {
00086     TTree *tree = (TTree*)key->ReadObj();
00087     FILE_LOG(logINFO  ) << "New TTree [" << tree->GetName() << endl;
00088     Int_t max = 10400*96; // 10400 micro * 96 pad
00089 
00090     CaloEvent *evt =  new CaloEvent();
00091     TBranch *branch= tree->GetBranch("CaloEvent");
00092     branch->SetAddress(&evt);
00093     CaloHit* channel =NULL;
00094     int nbEntries = tree->GetEntries();
00095     if ( eventLimit == 0 ) { eventLimit = 100; }
00096     unsigned int interval = (unsigned int) eventLimit / 10;
00097     if (interval == 0) interval = 1;
00098     for ( int evtNum = 0; evtNum <eventLimit ; evtNum++)
00099     {
00100       tree->GetEntry(evtNum);
00101       string name =  "event_" ; 
00102       Toolbox::addIntToString(name,evt->GetEventId());
00103       TH2I* xy = new TH2I("name", "title",96,0,max,96,0,max);
00104       hists[evtNum] = xy;
00105       int nbHits = evt->GetNHits();
00106 
00107       for(int i=0 ; i < nbHits ; i++)
00108       {
00109         channel = (CaloHit*)evt->GetHits()->UncheckedAt(i);
00110         xy->Fill(channel->GetY(),channel->GetX(),1);
00111       }
00112         FILE_LOG(logINFO  ) << "Write Event[" << evtNum << "] \t\t\t\t\t\t\t\t\t\t\t\r" << flush;
00113     }
00114  }
00115 
00116 
00117 
00118   output->cd();
00119 
00120 
00121   for ( unsigned int i =  0 ; i < eventLimit ; i++)
00122   {
00123     hists[i]->Write();
00124   }
00125 
00126   output->Close();
00127   f.Close(); 
00128 
00129   cout <<endl << endl << "Done" << endl;
00130   
00131 return 0;
00132 }


Generated on Mon Jan 7 13:17:26 2013 for MicromegasFramework by  doxygen 1.4.7