00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <stdlib.h>
00012 #include <map>
00013 #include <string>
00014
00015
00016 #include "TROOT.h"
00017 #include "TGraph.h"
00018 #include "TStyle.h"
00019 #include <TFile.h>
00020 #include <TTree.h>
00021 #include <TLegend.h>
00022 #include <TKey.h>
00023 #include <TH1I.h>
00024 #include <TH2I.h>
00025 #include <TText.h>
00026 #include <TCanvas.h>
00027 #include <TPaveLabel.h>
00028
00029
00030 #include "Run.hh"
00031 #include "Detector.hh"
00032 #include "XMLTool.hh"
00033 #include "Toolbox.hh"
00034 #include "MicroException.hh"
00035 #include "Log.hh"
00036
00037 #include "root/MTRun.hh"
00038 #include "root/MTEvent.hh"
00039 #include "root/MTChannel.hh"
00040 #include "root/CaloEvent.hh"
00041 #include "root/CaloHit.hh"
00042 #include "tools/Arguments.hh"
00043
00044 #include "Chamber.hh"
00045 #include "Detector.hh"
00046 using namespace std;
00047
00048
00049
00050 int main(int argc, char** argv) {
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;
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 }
00133
00134
00135
00136