00001 {
00002 gROOT->Reset();
00003 gROOT->SetStyle("Bold");
00004 gStyle->SetPalette(1);
00005 gSystem->Load("~/Micromegas/Analyse/trunk/lib/libMicro.so");
00006
00007
00008
00009
00010
00011
00012
00013 Int_t plot = 4555;
00014
00015
00016 Int_t blabla = 2;
00017
00018
00019 Int_t asu[6];
00020 for(int it=0;it<6;it++) asu[it] = it+13;
00021
00022
00023 Int_t nb_square = 20;
00024 Int_t list_square[nb_square] = {105,375,558,1090,1356,1600,2212,2563,2970,2985,2985,3481,3481,3633,3736,4481,4562,4606,5329,5662};
00025
00026
00027 Int_t threshold = 30;
00028
00029
00030 string file = "05082011_1055_MGT.root";
00031
00032
00033
00034
00035 TFile *f = new TFile(file.c_str());
00036 if(blabla==1||blabla==2||blabla==3){
00037 cout<<endl;
00038 cout<<"reading File : "<<file<<endl;
00039 }
00040
00041
00042 TIter nextkey(f.GetListOfKeys());
00043 TKey *key;
00044
00045
00046 UInt_t counter = 0;
00047 UInt_t channels_asu[6][128];
00048 UInt_t nb_border[6][128];
00049 UInt_t nb_tot;
00050
00051 Int_t xpos;
00052 Int_t ypos;
00053
00054
00055
00056
00057
00058
00059 if(plot != 0){
00060 TH2I *hxy = new TH2I("hxy","Hit position distribution;y (cm);x (cm)",96,0,96,96,0,96);
00061 TCanvas *c0 = new TCanvas("c0", "Prototype m2", 100, 50, 500, 500);
00062 }
00063
00064 if(blabla==1||blabla==2||blabla==3) cout<<endl;
00065
00066
00067
00068 while (key = (TKey*)nextkey()) {
00069
00070 counter++;
00071 if(blabla==1||blabla==2||blabla==3) cout<<"key number = "<<counter<<endl;
00072
00073 TTree *tree = (TTree*)key->ReadObj();
00074 MTRun* run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun");
00075
00076 Int_t nEvent = tree.GetEntries();
00077 if(blabla==1||blabla==2||blabla==3) cout <<"Nevent = "<<nEvent<<endl;
00078
00079
00080
00081 MTEvent *evt = new MTEvent();
00082
00083 TBranch *branch= tree->GetBranch("MTEvent");
00084 branch->SetAddress(&evt);
00085
00086 UInt_t list_event[nEvent];
00087
00088
00089 for (int bd=0;bd<=5;bd++) for (int ti=0;ti<128;ti++) nb_border[bd][ti] = 0;
00090 nb_tot=0;
00091
00092
00093
00094 for (int i=0;i<nEvent-1;i++){
00095
00096
00097 bool I_am_a_square_event = 0;
00098 for (int it=0;it<nb_square;it++) if (i+1==list_square[it]) I_am_a_square_event = 1;
00099 if (I_am_a_square_event==1) continue;
00100
00101
00102 for (int bd=0;bd<=5;bd++) for (int ti=0;ti<128;ti++) channels_asu[bd][ti] = 0;
00103
00104 tree.GetEntry(i);
00105
00106 UInt_t nchannel = evt->GetNchannel();
00107 UInt_t board_id;
00108 UInt_t mem_order;
00109
00110 if(blabla==3) cout<<"Event "<<i+1<<" / "<<nEvent<<"; nb of channels= "<<nchannel<<endl;
00111
00112
00113
00114 for (int j=0;j<nchannel;j++){
00115
00116
00117 board_id = 0;
00118 mem_order = 0;
00119
00120
00121 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00122
00123
00124 board_id = channel->GetBoardId();
00125
00126
00127 mem_order = channel->GetMemoryOrder();
00128
00129
00130 if (board_id==asu[0]) if (xpos == 000000 || xpos == 310000 || ypos == 000000 || ypos == 470000) channels_asu[0][mem_order]++;
00131 if (board_id==asu[1]) if (xpos == 000000 || xpos == 310000 || ypos == 480000 || ypos == 960000) channels_asu[1][mem_order]++;
00132 if (board_id==asu[2]) if (xpos == 320000 || xpos == 640000 || ypos == 000000 || ypos == 470000) channels_asu[2][mem_order]++;
00133 if (board_id==asu[3]) if (xpos == 320000 || xpos == 640000 || ypos == 480000 || ypos == 960000) channels_asu[3][mem_order]++;
00134 if (board_id==asu[4]) if (xpos == 650000 || xpos == 960000 || ypos == 000000 || ypos == 470000) channels_asu[4][mem_order]++;
00135 if (board_id==asu[5]) if (xpos == 650000 || xpos == 960000 || ypos == 480000 || ypos == 960000) channels_asu[5][mem_order]++;
00136
00137
00138 xpos = channel->GetX()/10000;
00139 ypos = channel->GetY()/10000;
00140
00141 if(blabla==3) cout<<"Channel : "<<channel<<"; hit on asu "<<board_id<<"; at memory order "<<mem_order<<", x= "<<xpos<<", y= "<<ypos<<endl;
00142
00143
00144 if (plot==i+1) hxy->Fill(ypos,xpos);
00145 }
00146
00147
00148 for (int bd=0;bd<=5;bd++) {
00149 for (int ti=0;ti<128;ti++) {
00150 if (channels_asu[bd][ti]>= threshold) {
00151
00152 if(blabla==3) cout <<bd<<" "<<ti;
00153 if(blabla==2||blabla==3) cout <<" -> event: "<<i+1<<" = border in asu no "<<asu[bd]<<" at memory order "<<ti<<" with Nhits = "<<channels_asu[bd][ti]<<endl;
00154
00155
00156 nb_border[bd][ti]++;
00157
00158 nb_tot++;
00159
00160
00161 list_event[nb_tot-1] = i+1;
00162 }
00163 }
00164 }
00165
00166 if (plot==i+1){
00167 hxy->SetTitle("Hits position");
00168 hxy.GetXaxis()->SetTitle("X (cm)");
00169 hxy.GetYaxis()->SetTitle("Y (cm)");
00170 hxy->Draw("zcol");
00171 }
00172 }
00173
00174
00175 if(blabla==2||blabla==3) cout<<endl;
00176 if(blabla==1||blabla==2||blabla==3) {
00177
00178 cout<<"In key "<<counter<<" Nb tot evt border = "<<nb_tot<<endl;
00179
00180 cout<<"List of border events: "<<endl;
00181 for(int it=0;it<nb_tot;it++) cout<<" "<<list_event[it];
00182 cout<<endl<<endl;
00183 }
00184 if(blabla==2||blabla==3) {
00185 cout<<"Hereafter I show the nb of event border in each board/asu at each time:"<<endl<<endl<<"Board/asu i"<<endl<<"memory order:";
00186 for (int ti=0;ti<128;ti++) cout<<" "<<ti;
00187 cout<<endl;
00188 for (int bd=0;bd<=5;bd++) {
00189 cout<<endl;
00190 cout<<"Board/asu "<<asu[bd]<<endl;
00191 for (int ti=0;ti<128;ti++) {
00192 cout<<" "<<nb_border[bd][ti];
00193 nb_border[bd][ti] = 0;
00194
00195 }
00196 cout<<endl;
00197 }
00198 cout<<endl;
00199 }
00200 }
00201 }
00202