00001
00002 #include <map>
00003 #include "TKey.h"
00004 #include "TList.h"
00005 #include <TROOT.h>
00006 #include <TRint.h>
00007 #include <TKey.h>
00008 #include <TList.h>
00009 #include <TTree.h>
00010 #include <TFile.h>
00011 #include <stdlib.h>
00012 #include <TSystem.h>
00013 #include <iostream>
00014 #include <sstream>
00015 #include "Log.hh"
00016
00017 #include "MicroException.hh"
00018 #include <string>
00019
00020 #include "mysql/Mysql.hh"
00021
00022
00023 #include "root/MTRun.hh"
00024 #include "root/MTTrack.hh"
00025 #include "root/MTChamber.hh"
00026 #include "root/MTDetector.hh"
00027 #include "root/MTBoard.hh"
00028 #include "root/MTChip.hh"
00029 #include "root/MTChannel.hh"
00030 #include "root/MTEvent.hh"
00031 #include "root/MTDif.hh"
00032 #include "root/MTHardroc1Chip.hh"
00033 #include "root/MTHardroc2Chip.hh"
00034 #include "root/MTDiracChip.hh"
00035 #include "root/MTMicrorocChip.hh"
00036
00037
00038 using namespace std;
00039
00040
00041 int main(int argc, char**argv){
00042
00043 if ( argc !=2 ) {
00044 FILE_LOG(logERROR) << "usage: example rootFile " << endl;
00045 exit(1);
00046 }
00047
00048 string rootName;
00049 rootName.assign(argv[1]);
00050 int nbHit = 0;
00051 int nbEvt = 0;
00052
00053 TFile f(rootName.c_str());
00054 f.ls();
00055
00056
00057
00058 TIter nextkey(f.GetListOfKeys());
00059 TKey *key;
00060 while (key = (TKey*)nextkey())
00061 {
00062 TTree *tree = (TTree*)key->ReadObj();
00063
00064
00065 MTEvent *evt = new MTEvent();
00066 TBranch *branch= tree->GetBranch("MTEvent");
00067 branch->SetAddress(&evt);
00068
00069 MTChannel* channel =NULL;
00070 int nbEntries = tree->GetEntries();
00071
00072 for ( int evtNum = 0; evtNum < 2 ; evtNum++)
00073 {
00074 tree->GetEntry(evtNum);
00075 nbEvt++;
00076 bool show = false;
00077
00078
00079
00080
00081 UInt_t evtMin = 0xffffffff;
00082 UInt_t evtMax = 0x0;
00083
00084 int nbChannel = evt->GetNchannel();
00085
00086 for(int i=0;i<nbChannel ;i++)
00087 {
00088 nbHit++;
00089 channel = (MTChannel*)evt->GetChannels()->UncheckedAt(i);
00090
00091
00092 i32 deltaT = channel->GetBcId_Dif() - channel->GetBcId_Hit();
00093 ui32 absTime = channel->GetAbsTime();
00094 if (deltaT < 0 )
00095 {
00096 cout << "deltaT < 0"<<endl;
00097 }
00098 show = true;
00099 cout << "**** Event Information "<< dec << evtNum+1 << "/" << nbEntries<< " ****" << endl;
00100 cout << " channel num : " << i <<endl;
00101 cout << " deltaT : " << deltaT <<endl;
00102 cout << " bcId dif: " << channel->GetBcId_Dif() <<endl;
00103 cout << " bcId hit: " << channel->GetBcId_Hit() <<endl;
00104 cout << " event id:" << evt->GetEventId() <<endl;
00105
00106 cout << " chamber id: " << channel->GetChamberId() <<endl;
00107 cout << " dif id: " << channel->GetDifId() <<endl;
00108 cout << " boardId id: " << channel->GetBoardId() <<endl;
00109 cout << " chip id(format dec):" << dec << channel->GetChipId() <<endl;
00110 cout << " hard id : " << dec << channel->GetHardId() <<endl;
00111 cout << " bcId abs: " << channel->GetBcId_Abs() <<endl;
00112 cout << " absolute time:bcid_abs - (bcid_dif - bcid_hit) " << absTime <<endl;
00113 cout << " nbHit for this absolute time:" << evt->GetNbHitPerAbsTime(channel->GetSoftId().GetBoardId(),absTime)<<endl;
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 if ( absTime > evtMax ) evtMax = absTime;
00125 if ( absTime < evtMin ) evtMin = absTime;
00126 }
00127 cout << "Min Evt absTime: " << evtMin << endl;
00128 cout << "Max Evt absTime: " << evtMax << endl;
00129 }
00130 cout << "End of TTree[" << tree->GetName() << "]" <<endl;
00131 cout << endl << "** Nombre d Event["<< nbEvt <<"] ** "<< endl;
00132 cout << endl << "** Nombre de Hits["<< nbHit <<"] ** "<< endl;
00133
00134 }
00135 return 0 ;
00136 }
00137
00138
00139
00140