#include <iostream>
#include <stdlib.h>
#include <vector>
#include "TString.h"
#include "TApplication.h"
#include <TStyle.h>
#include <TFile.h>
#include <TTree.h>
#include <TKey.h>
#include "BeamProfile.hh"
#include "Run.hh"
#include "Detector.hh"
#include "XMLTool.hh"
#include "Toolbox.hh"
#include "MicroException.hh"
#include "Log.hh"
#include "Chamber.hh"
#include "Board.hh"
#include "Chip.hh"
#include "Dif.hh"
#include "root/MTRun.hh"
#include "root/MTEvent.hh"
Include dependency graph for beamProfile.cpp:
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 44 of file beamProfile.cpp.
00044 { 00045 00046 00047 FILELog::ReportingLevel() = FILELog::FromString(INFO); 00048 string filename ; 00049 ui32 nbEvents = 0; 00050 ui32 nbChannels = 0; 00051 00052 // Manage command options 00053 //if ( argc == 1) 00054 //{ 00055 //cout << endl << "usage: beamProfile [root file Name]" << endl ; 00056 //cout << "help: beamProfile -h " << endl; 00057 //exit(0); 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 // Build detector from XML file 00070 Detector detector; 00071 // Get detector information 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 // Create ROOT Application 00083 TApplication theApp("App", 0, NULL); 00084 gStyle->SetPalette(1); 00085 00086 // Open root file 00087 int nchannel = 0; 00088 00089 TFile f(filename.c_str()); 00090 cout<<"reading File : "<<filename<<endl; 00091 00092 // Get TTree list form root file 00093 TIter nextkey(f.GetListOfKeys()); 00094 TKey *key; 00095 00096 // Loop over TTree ( one TTree by rawfile ) 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 //Get Run information ( name, date, dif and chip confiration ) 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 // Get number of event for current TTree 00111 int nEvent = tree->GetEntries(); 00112 00113 // Get TTree MTEvent branch 00114 MTEvent *evt = new MTEvent(); 00115 TBranch *branch= tree->GetBranch("MTEvent"); 00116 branch->SetAddress(&evt); 00117 00118 00119 // Loop over events 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 // Print computate status 00125 //if (i%10 == 0){cout<<(float)(i*100)/(float)(nEvent)<<" %"<<"\r"<<flush;} 00126 00127 // Get ith event 00128 tree->GetEntry(i); 00129 // Get number of MTChannel for this event 00130 nchannel = evt->GetNchannel(); 00131 manager.FillHotChamber(*evt); 00132 00133 // loop over MTChannel 00134 for (int j=0;j<nchannel;j++) 00135 { 00136 nbChannels++; 00137 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j); 00138 // Get x,y position 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 //manager.FillTimestamp(*channel); 00151 00152 } 00153 } // End of event loop. 00154 } // end while over TTree 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 }