00001 {
00002 gROOT->Reset();
00003 gStyle->SetPalette(1);
00004 gSystem->Load("/LC/Detecteurs/MicroMegas/Offline/micromegasFrameWork/trunk/lib/libMicro.so");
00005
00006
00007 bool plot = 1;
00008 bool print = 1;
00009 bool signal_to_noise = 0;
00010
00011 int nhit_cut = 1e9;
00012
00013 TString file = "b0702_10_acq_HR2_02072010_1302_merged.root";
00014
00015
00016
00017 TString filename = "/lapp_data/LC/Detecteurs/MicroMegas/data/TB2010/SPS_H4_june_2010/Root_files/pro/"+file;
00018
00019 int tested_chip = 124;
00020
00021
00022 float nTrees= 0;
00023
00024
00025
00026 Long64_t t,t1,t2,t3,dt;
00027 int nchannel = 0;
00028 int hardid = 0;
00029 int softid = 0;
00030 int chipid = 0;
00031 int nhit = 0;
00032 int xpos = 0;
00033 int ypos = 0;
00034 int zpos = 0;
00035 int adc = 0;
00036 int nevent = 0;
00037 int nhit = 0;
00038 int nhit_intime = 0;
00039 int nhit_intime_tot = 0;
00040
00041 TH1I * hdt = new TH1I("hdt","Time to trigger; #Deltat (clock cycle)",400,-10,390);
00042
00043 TH2I * hxy_m2 = new TH2I("hxy_m2","Raw profile;x (cm);y (cm)",96,0,96,96,0,96);
00044 TH2I * hxy_m2_cut = new TH2I("hxy_m2_cut","Profile after time cut;x (cm);y (cm)",96,0,96,96,0,96);
00045
00046 TH1I * hxy_m2_cut_px = new TH1I("hxy_m2_cut_px","Profile after time cut;x (cm)",96,-0,96);
00047 TH1I * hxy_m2_cut_py = new TH1I("hxy_m2_cut_py","Profile after time cut;y (cm)",96,-0,96);
00048
00049 TH1I * hnhit = new TH1I("hnhit","Number of hits",3200,0,3200);
00050 TH1I * hnhit_intime = new TH1I("hnhit_intime","Number of his after time cut",3200,0,3200);
00051
00052
00053
00054 TFile *f = new TFile(filename);
00055 cout<<"reading File : "<<filename<<endl;
00056
00057 TIter nextkey(f.GetListOfKeys());
00058 TKey *key;
00059
00060 while (key = (TKey*)nextkey()) {
00061
00062 TTree *tree = (TTree*)key->ReadObj();
00063 MTRun* run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun");
00064
00065 nTrees++;
00066 float nEvent = tree.GetEntries();
00067 cout <<"nEvent="<<nEvent<<endl;
00068
00069 MTEvent *evt = new MTEvent();
00070
00071 TBranch *branch= tree->GetBranch("MTEvent");
00072 branch->SetAddress(&evt);
00073
00074
00075
00076
00077
00078
00079
00080 for (int i=0;i<nEvent;i++){
00081
00082 if (i%100==0){cout<<i<<" \r"<<flush;}
00083
00084 nevent++;
00085 tree.GetEntry(i);
00086 nchannel = evt->GetNchannel();
00087
00088 nhit = 0;
00089 nhit_intime = 0;
00090
00091 for (int j=0;j<nchannel;j++){
00092
00093 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00094
00095 if (channel->GetChamberId()==5){
00096
00097 nhit++;
00098
00099
00100
00101 xpos = channel->GetX();
00102 ypos = channel->GetY();
00103
00104 hardid = channel->GetHardId();
00105
00106 hxy_m2->Fill(ypos,xpos);
00107
00108 t1 = channel->GetBcId_Abs();
00109 t2 = channel->GetBcId_Dif();
00110 t3 = channel->GetBcId_Hit();
00111 dt = (t2-t3);
00112 t = (t1 - (t2-t3));
00113
00114 hdt->Fill(dt);
00115
00116 if (dt>=6 && dt<=7){
00117
00118 nhit_intime++;
00119 nhit_intime_tot++;
00120
00121 hxy_m2_cut_px->Fill(ypos);
00122 hxy_m2_cut_py->Fill(xpos);
00123 hxy_m2_cut->Fill(ypos,xpos);}}}
00124
00125 hnhit->Fill(nhit);
00126 hnhit_intime->Fill(nhit_intime);}}
00127
00128
00129
00130 double noise = 0;
00131 double snr = 0;
00132
00133 noise = hdt->Integral(20,400)*2./380.;
00134 signal = hdt->Integral(17,18)-noise;
00135 snr = floor(signal/noise);
00136
00137 cout<<endl;
00138 cout<<"Signal = "<<signal<<endl;
00139 cout<<"Noise = "<<noise<<endl;
00140 cout<<"Signal to noise ratio = "<<snr<<endl;
00141 cout<<"Raw eff = "<<(hdt->Integral(17,18)-noise*2)/hdt->GetEntries()*100.<<" %"<<endl;
00142 cout<<"SNR = "<<snr<<endl;
00143
00144
00145 }