00001
00002 #include <map>
00003 #include "TKey.h"
00004 #include <TROOT.h>
00005 #include <TStyle.h>
00006 #include <TRint.h>
00007 #include <TKey.h>
00008 #include <TTree.h>
00009 #include <TCanvas.h>
00010 #include "TH1.h"
00011 #include "TF1.h"
00012 #include <TH1I.h>
00013 #include <TH2I.h>
00014 #include <TFile.h>
00015 #include <stdlib.h>
00016 #include <TSystem.h>
00017 #include <iostream>
00018 #include "TApplication.h"
00019 #include <sstream>
00020 #include "Log.hh"
00021 #include <Rtypes.h>
00022 #include <TCanvas.h>
00023 #include "TColor.h"
00024 #include "TFunction.h"
00025 #include "TAttLine.h"
00026 #include "TPaveStats.h"
00027 #include "MicroException.hh"
00028 #include <string>
00029
00030
00031
00032
00033 #include "root/MTChannel.hh"
00034 #include "root/MTEvent.hh"
00035
00036 using namespace std;
00037
00038
00039 int main(int argc, char**argv){
00040 gROOT->Reset();
00041
00042 gROOT->SetStyle("Plain");
00043 gStyle->SetTitleBorderSize(0);
00044 gStyle->SetTitleX(0.35);
00045 gStyle->SetTitleY(0.995);
00046
00047 gStyle->SetFrameFillStyle(0);
00048 gStyle->SetOptStat("");
00049 gStyle->SetOptFit(0111);
00050 gStyle->SetStatX(0.9);
00051 gStyle->SetStatY(0.9);
00052 gStyle->SetStatH(0.1);
00053 gStyle->SetStatW(0.1);
00054
00055 gStyle->SetOptStat("") ;
00056 gStyle->SetOptFit(0000);
00057
00058 gStyle->SetOptStat("");
00059 gStyle->SetOptFit(10001);
00060
00061
00062
00063
00064 if ( argc !=2 ) {
00065 FILE_LOG(logERROR) << "usage: analog rootFile " << endl;
00066 exit(1);
00067 }
00068
00069 string rootName;
00070 rootName.assign(argv[1]);
00071 int nbHit = 0;
00072 int nbEvt = 0;
00073
00074 TApplication *theApp = NULL;
00075
00076 theApp = new TRint("App",NULL,NULL );
00077
00078
00079 TFile *output= new TFile("output.root","RECREATE");
00080
00081
00082 UInt_t nb_ped=0 ;
00083
00084 TFile f(rootName.c_str());
00085 TIter nextkey(f.GetListOfKeys());
00086 TKey *key;
00087 while (key = (TKey*)nextkey())
00088 {
00089 TTree *tree = (TTree*)key->ReadObj();
00090
00091 MTEvent *evt = new MTEvent();
00092 TBranch *branch= tree->GetBranch("MTEvent");
00093 branch->SetAddress(&evt);
00094
00095 MTChannel* channel =NULL;
00096 int nbEntries = tree->GetEntries();
00097
00098 for ( int evtNum = 0; evtNum < 5 ; evtNum++)
00099 {
00100 cout << "New dacPed" << endl;
00101 TH1I * dacPed = new TH1I("ped","",100000,0,50000);
00102 tree->GetEntry(evtNum);
00103 nbEvt++;
00104 UInt_t channel68 = 0;
00105
00106 UInt_t absTime = 0 ;
00107
00108 int nbChannel = evt->GetNchannel();
00109 for(int i=0;i<nbChannel ;i++)
00110 {
00111 nbHit++;
00112 channel = (MTChannel*)evt->GetChannels()->UncheckedAt(i);
00113
00114 UInt_t adc = channel->GetAnalogValue();
00115 UInt_t id = channel->GetSoftId().GetValue() - 304000000;
00116
00117 cout << "Id[" << id << "] adc" << adc << endl;
00118
00119 dacPed->Fill(id,adc);
00120 }
00121 output->cd();
00122 dacPed->Write("");
00123 }
00124 }
00125
00126
00127 theApp->Run();
00128 delete theApp;
00129 return 0 ;
00130 }
00131
00132
00133
00134