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
00080 TH1I * dacAll = new TH1I("all","",512,0,4096);
00081 TH1I * dacPed = new TH1I("ped","",512,0,4096);
00082 TH1I * dac0 = new TH1I("c0","",2048,0,4096);
00083 TH1I * dac1 = new TH1I("c1","",2048,0,4096);
00084 TH1I * dac2 = new TH1I("c2","",2048,0,4096);
00085 TH2I * histo2 = new TH2I("analog2","",3,1,4,4096,0,4096);
00086
00087 UInt_t nb_ped=0 ;
00088
00089 TFile f(rootName.c_str());
00090 TIter nextkey(f.GetListOfKeys());
00091 TKey *key;
00092 while (key = (TKey*)nextkey())
00093 {
00094 TTree *tree = (TTree*)key->ReadObj();
00095
00096 MTEvent *evt = new MTEvent();
00097 TBranch *branch= tree->GetBranch("MTEvent");
00098 branch->SetAddress(&evt);
00099
00100 MTChannel* channel =NULL;
00101 int nbEntries = tree->GetEntries();
00102
00103 for ( int evtNum = 0; evtNum < nbEntries ; evtNum++)
00104 {
00105 tree->GetEntry(evtNum);
00106 nbEvt++;
00107
00108 UInt_t channel66 = 0;
00109 UInt_t channel68 = 0;
00110
00111 UInt_t absTime = 0 ;
00112
00113 int nbChannel = evt->GetNchannel();
00114 for(int i=0;i<nbChannel ;i++)
00115 {
00116 nbHit++;
00117 channel = (MTChannel*)evt->GetChannels()->UncheckedAt(i);
00118
00119
00120
00121
00122
00123 absTime = channel->GetBcId_Abs() - (channel->GetBcId_Dif() - channel->GetBcId_Hit() );
00124 UInt_t nbHitPerAbsTime = evt->GetNbHitPerAbsTime(channel->GetBoardId(), absTime) ;
00125
00126
00127 if ( channel->GetAnalogValue() != 0 )
00128 {
00129 if ( channel->GetChipId() == 67 )
00130 {
00131 if ( channel->GetHardId() == 54 )
00132 { UInt_t adc = 4096-channel->GetAnalogValue();
00133
00134 if ( channel->GetDigitalValue() == 0 && nb_ped < 300)
00135 { dacPed->Fill(adc);
00136
00137 nb_ped++;
00138 }
00139
00140
00141 if (nbHitPerAbsTime < 4)
00142 {
00143
00144
00145 if ( channel->GetDigitalValue() == 1 )
00146 {
00147 dac0->Fill(adc);
00148 histo2->Fill(channel->GetDigitalValue(),adc);
00149 dacAll->Fill(adc);
00150 }
00151
00152 if ( channel->GetDigitalValue() == 2 )
00153 {
00154 dac1->Fill(adc);
00155 histo2->Fill(channel->GetDigitalValue(),adc);
00156 dacAll->Fill(adc);
00157 }
00158
00159 if ( channel->GetDigitalValue() == 3 )
00160 {
00161
00162
00163
00164 }
00165 }
00166 }
00167 }
00168 }}
00169 }
00170 }
00171 TCanvas * c0 = new TCanvas("c0","Prototype m2");
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 dacPed->Draw("");
00182 dacPed->Fit("gaus","R", "SAME", 1140, 1200);
00183
00184 dacPed->GetFunction("gaus")->SetLineColor(kBlue+1);
00185 dacPed->GetYaxis()->SetRangeUser(0,210);
00186 dacPed->GetXaxis()->SetTitle("ADC count");
00187 dacPed->GetYaxis()->SetTitle("N");
00188 dacAll->Draw("sames");
00189 dacAll->Fit("landau","R", "SAME", 1100, 1800);
00190 dacAll->GetFunction("landau")->SetLineColor(kOrange+5);
00191
00192
00193
00194
00195
00196 c0->Update();
00197
00198 TPaveStats *p1 = (TPaveStats*) dacPed->GetListOfFunctions()->FindObject("stats");
00199
00200
00201 dacPed->GetListOfFunctions()->Remove(p1);
00202 dacPed->SetStats(0);
00203 p1->SetTextColor(kBlue+1);
00204 p1->SetX1NDC(0.75);
00205 p1->SetX2NDC(0.9);
00206 p1->SetY1NDC(0.8);
00207 p1->SetY2NDC(0.9);
00208 p1->Draw();
00209
00210
00211
00212
00213 TPaveStats *p2 = (TPaveStats*) dacAll->GetListOfFunctions()->FindObject("stats");
00214
00215 dacAll->GetListOfFunctions()->Remove(p2);
00216 dacAll->SetStats(0);
00217 p2->SetTextColor(kOrange+5);
00218 p2->SetX1NDC(0.75);
00219 p2->SetX2NDC(0.9);
00220 p2->SetY1NDC(0.7);
00221 p2->SetY2NDC(0.8);
00222 p2->Draw();
00223
00224
00225
00226
00227
00228 c0->Update();
00229 theApp->Run();
00230 delete theApp;
00231 return 0 ;
00232 }
00233
00234
00235
00236