00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #include <iostream>
00011 #include <stdlib.h>
00012 #include <vector>
00013 
00014 
00015 #include "TString.h"
00016 #include "TApplication.h"
00017 #include <TStyle.h>
00018 #include <TFile.h>
00019 #include <TTree.h>
00020 #include <TKey.h>
00021 
00022 
00023 #include "BeamProfile.hh"
00024 #include "Run.hh"
00025 #include "Detector.hh"
00026 #include "XMLTool.hh"
00027 #include "Toolbox.hh"
00028 #include "MicroException.hh"
00029 #include "Log.hh"
00030 #include "Chamber.hh"
00031 
00032 #include "Board.hh"
00033 #include "Chip.hh"
00034 #include "Dif.hh"
00035 
00036 #include "root/MTRun.hh"
00037 #include "root/MTEvent.hh"
00038 
00039 
00040 using namespace std;
00041 
00042 
00043 
00044 int main(int argc, char** argv) {
00045 
00046 
00047 FILELog::ReportingLevel() = FILELog::FromString(INFO);
00048 string filename ;
00049 ui32 nbEvents = 0;
00050 ui32 nbChannels = 0;
00051 
00052 
00053 
00054 
00055     
00056     
00057     
00058 
00059 BeamProfile manager(argc,argv);
00060 
00061 filename = manager.getFileName();
00062 
00063 if ( filename.empty())
00064 {
00065     cout << "a root file name is mandatory. Please use -f option to set it. " << endl;
00066     exit(0);
00067 }
00068 
00069 
00070         Detector detector;
00071         
00072         if ( ! manager.getXMLFileName().empty())
00073         {
00074             SteerDesc steerDesc;
00075             XMLTool xml;
00076             xml.parse(steerDesc, manager.getXMLFileName());
00077             detector.build(steerDesc);
00078             manager.SetDetector(&detector);
00079         }
00080 
00081 
00082 
00083 TApplication theApp("App", 0, NULL);
00084 gStyle->SetPalette(1);
00085 
00086 
00087 int nchannel = 0;
00088 
00089 TFile f(filename.c_str());
00090 cout<<"reading File : "<<filename<<endl;
00091 
00092 
00093 TIter nextkey(f.GetListOfKeys());
00094 TKey *key;
00095 
00096 
00097 while (key = (TKey*)nextkey())
00098 {
00099     TTree *tree = (TTree*)key->ReadObj();
00100     if ( tree == NULL) { exit(0);} ;
00101 
00102           if  (manager.getShowRunInfo())
00103                 {
00104                     
00105         MTRun* run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun");
00106         if ( run != NULL) run->Info();
00107           }
00108                  FILE_LOG(logINFO  ) << endl << "TTree[" <<tree->GetName() << "]" << endl;
00109 
00110                 
00111     int nEvent = tree->GetEntries();
00112 
00113                 
00114     MTEvent *evt = new MTEvent();
00115     TBranch *branch= tree->GetBranch("MTEvent");
00116     branch->SetAddress(&evt);
00117 
00118 
00119                 
00120     for (int i=0;i<nEvent;i++)
00121     {
00122         nbEvents++;
00123                          if ( nbEvents % 100 == 0) FILE_LOG(logINFO  ) << "Event " << i+1 <<" / " << nEvent << "\r" << flush;
00124                 
00125                 
00126 
00127                 
00128         tree->GetEntry(i);
00129                                 
00130         nchannel = evt->GetNchannel();
00131                     manager.FillHotChamber(*evt);
00132 
00133                                 
00134         for (int j=0;j<nchannel;j++)
00135         {
00136             nbChannels++;
00137             MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00138                                                 
00139 
00140                              manager.FillXyDist(*channel);
00141 
00142                              manager.FillHitPerChipDist(*channel);
00143 
00144                        manager.FillHitPerChannel(*channel);
00145 
00146                              manager.FillDeltaT(*channel);
00147 
00148                             manager.FillHotChip(*channel);
00149 
00150             
00151 
00152         }
00153     } 
00154 } 
00155 
00156 manager.DrawXyDist();
00157 manager.DrawHitPerChipDist();
00158 manager.DrawHitPerChannelDist();
00159 manager.DrawDeltaT();
00160 manager.DrawHotChamber();
00161 
00162 
00163 manager.PrintHotChip();
00164 cout << endl <<endl << "----------- SUCCESS ---------------" << endl;
00165 cout << endl << "----------- " << nbEvents <<" events, " << nbChannels << " channels. ---------------" << endl;
00166 cout << " Close Root  ( or  press Ctrl^C ) to finish."<< endl;
00167 
00168 theApp.Run();
00169 return (EXIT_SUCCESS);
00170 }
00171 
00172 
00173