/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/TB2010/Testbeam_june_10/Complete_detector/Add_profiles.C

Go to the documentation of this file.
00001  {gROOT->Reset();
00002   gStyle->SetPalette(1);
00003 
00004 
00005   int chip = 124;
00006   int volt = 410;
00007   TString position = "d";
00008 
00009   bool far_from_off_cut = 1;
00010   bool display = 1;
00011 
00012   int xmin = 0;
00013   int xmax = 0;
00014   int ymin = 0;
00015   int ymax = 0;
00016 
00017 
00018   TGraph * tg_x = new TGraph();
00019   TGraph * tg_y = new TGraph();
00020 
00021   tg_x->SetMarkerStyle(20);
00022   tg_y->SetMarkerStyle(20);
00023 
00024   TH1I * hdeltax = new TH1I("hdeltax","Offset m2/telescope hit positions along X; x_{profile m2}-x_{telescope} (cm)",96*2,-96,96);
00025   TH1I * hdeltay = new TH1I("hdeltay","Offset m2/telescope hit positions along Y; y_{profile m2}-y_{telescope} (cm)",96*2,-96,96);
00026 
00027 
00028 
00029   
00030 
00031   /*RUN 420 V - CHIP 124*/
00032 
00033   if (chip==124 && volt==420){
00034 
00035     xmin = 8;
00036     xmax = 16;
00037     ymin = 24;
00038     ymax = 32;
00039 
00040     if (position == "e"){
00041 
00042       int ntfile = 4;
00043       TString file1 = "b0624_5_acq_HR2_24062010_0634";
00044       TString file2 = "b0624_6_acq_HR2_24062010_0650";
00045       TString file3 = "b0624_7_acq_HR2_24062010_0726";
00046       TString file4 = "b0624_8_acq_HR2_24062010_0809";}
00047   
00048     if (position == "c"){
00049 
00050       int ntfile = 2;
00051       TString file1 = "b0624_12_acq_HR2_24062010_0914";
00052       TString file2 = "b0624_23_acq_HR2_24062010_1202";}}
00053 
00054 
00055 
00056   /*RUN 410 V - CHIP 124*/
00057 
00058   if (chip == 124 && volt==410){
00059 
00060     xmin = 8;
00061     xmax = 16;
00062     ymin = 24;
00063     ymax = 32;
00064 
00065     if (position == "pp"){
00066       int ntfile = 2;
00067       TString file1 = "b0702_9_acq_HR2_02072010_1136";
00068       TString file2 = "b0702_10_acq_HR2_02072010_1302";}
00069 
00070     if (position == "d"){
00071 
00072       int ntfile = 5;
00073       TString file1 = "b0701_2_acq_HR2_01072010_1731";
00074       TString file2 = "b0701_6_acq_HR2_01072010_1808";
00075       TString file3 = "b0701_7_acq_HR2_01072010_1830";
00076       TString file4 = "b0701_9_acq_HR2_01072010_1854";
00077       TString file5 = "b0701_12_acq_HR2_01072010_1923";}
00078 
00079     if (position == "b"){
00080 
00081       int ntfile = 5;
00082       TString file1 = "b0701_13_acq_HR2_01072010_2036";
00083       TString file2 = "b0701_15_acq_HR2_01072010_2102";
00084       TString file3 = "b0701_16_acq_HR2_01072010_2121";
00085       TString file4 = "b0701_17_acq_HR2_01072010_2136";
00086       TString file5 = "b0701_18_acq_HR2_01072010_2154";}
00087 
00088     if (position == "a"){
00089 
00090       int ntfile = 5;
00091       TString file1 = "b0701_19_acq_HR2_01072010_2210";
00092       TString file2 = "b0701_24_acq_HR2_01072010_2237";
00093       TString file3 = "b0701_25_acq_HR2_01072010_2255";
00094       TString file4 = "b0701_27_acq_HR2_01072010_2317";
00095       TString file5 = "b0701_29_acq_HR2_01072010_2336";}
00096 
00097     if (position == "c"){
00098 
00099       int ntfile = 4;
00100       TString file1 = "b0702_17_acq_HR2_02072010_1705";
00101       TString file2 = "b0702_18_acq_HR2_02072010_1723";
00102       TString file3 = "b0702_19_acq_HR2_02072010_1738";
00103       TString file4 = "b0702_20_acq_HR2_02072010_1753";}}
00104 
00105 
00106 
00107 
00108   /*RUN 410 V - CHIP 114*/
00109 
00110   if (chip == 114 && volt==410){
00111 
00112     xmin = 16;
00113     xmax = 24;
00114     ymin = 40;
00115     ymax = 48;
00116 
00117     if (position == "d"){
00118       
00119       int ntfile = 3;
00120       TString file1 = "b0702_27_acq_HR2_02072010_2016";
00121       TString file2 = "b0702_28_acq_HR2_02072010_2036";
00122       TString file3 = "b0702_29_acq_HR2_02072010_2056";}
00123     
00124     if (position == "c"){
00125       
00126       int ntfile = 3;
00127       TString file1 = "b0702_30_acq_HR2_02072010_2118";
00128       TString file2 = "b0702_31_acq_HR2_02072010_2137";
00129       TString file3 = "b0702_33_acq_HR2_02072010_2306";}
00130     
00131     if (position == "a"){
00132 
00133       int ntfile = 3;
00134       TString file1 = "b0702_34_acq_HR2_02072010_2323";
00135       TString file2 = "b0704_1_acq_HR2_04072010_0804";
00136       TString file3 = "b0704_2_acq_HR2_04072010_0824";}
00137 
00138     if (position == "b"){
00139       
00140       int ntfile = 5;
00141       TString file1 = "b0702_21_acq_HR2_02072010_1902";
00142       TString file2 = "b0702_22_acq_HR2_02072010_1914";
00143       TString file3 = "b0702_23_acq_HR2_02072010_1927";
00144       TString file4 = "b0702_24_acq_HR2_02072010_1941";
00145       TString file5 = "b0702_25_acq_HR2_02072010_1959";}}
00146 
00147 
00148 
00149   /*RUN 410 V - CHIP 134*/
00150   
00151   if (chip == 134 && volt==410){
00152 
00153     xmin = 0;
00154     xmax = 8;
00155     ymin = 8;
00156     ymax = 16;
00157 
00158     if (position == "c"){
00159 
00160       int ntfile = 3;
00161       TString file1 = "b0705_1_acq_HR2_05072010_1333";
00162       TString file2 = "b0705_6_acq_HR2_05072010_1823";
00163       TString file3 = "b0705_7_acq_HR2_05072010_1844";}
00164 
00165     if (position == "a"){
00166       
00167       int ntfile = 4;
00168       TString file1 = "b0705_11_acq_HR2_05072010_1906";
00169       TString file2 = "b0705_12_acq_HR2_05072010_1925";
00170       TString file3 = "b0705_13_acq_HR2_05072010_1944";
00171       TString file4 = "b0705_15_acq_HR2_05072010_2030";}
00172 
00173     if (position == "b"){
00174 
00175       int ntfile = 3;
00176       TString file1 = "b0705_16_acq_HR2_05072010_2042";
00177       TString file2 = "b0705_17_acq_HR2_05072010_2101";
00178       TString file3 = "b0706_3_acq_HR2_06072010_0946";}
00179 
00180     if (position == "d"){
00181 
00182       int ntfile = 2;
00183       TString file1 = "b0706_5_acq_HR2_06072010_1028";
00184       TString file2 = "b0706_6_acq_HR2_06072010_1047";}}
00185   
00186 
00187 
00188   /*RUN 410 V - CHIP 138*/
00189 
00190   if (chip == 138 && volt==410){
00191 
00192     xmin = 0;
00193     xmax = 8;
00194     ymin = 40;
00195     ymax = 48;
00196 
00197     if (position == "d"){
00198       
00199       int ntfile = 3;
00200       TString file1 = "b0704_7_acq_HR2_04072010_1032";
00201       TString file2 = "b0704_8_acq_HR2_04072010_1049";
00202       TString file3 = "b0704_9_acq_HR2_04072010_1100";}
00203       //TString file4 = "b0704_11_acq_HR2_04072010_1123";}
00204 
00205     if (position == "b"){
00206 
00207       int ntfile = 3;
00208       TString file1 = "b0704_13_acq_HR2_04072010_1149";
00209       TString file2 = "b0704_15_acq_HR2_04072010_1214";
00210       TString file3 = "b0704_16_acq_HR2_04072010_1233";}
00211 
00212     if (position == "a"){
00213 
00214       int ntfile = 3;
00215       TString file1 = "b0704_17_acq_HR2_04072010_1342";
00216       TString file2 = "b0704_18_acq_HR2_04072010_1400";
00217       TString file3 = "b0704_19_acq_HR2_04072010_1420";}
00218 
00219     if (position == "c"){
00220       
00221       int ntfile = 3;
00222       TString file1 = "b0704_20_acq_HR2_04072010_1438";
00223       TString file2 = "b0704_21_acq_HR2_04072010_1457";
00224       TString file3 = "b0704_22_acq_HR2_04072010_1516";}}
00225 
00226 
00227 
00228 
00229   if ((chip==124 || chip==114 || chip==134 || chip==138)){
00230 
00231 
00232 
00233 
00234   TString dir = "/LC/Detecteurs/MicroMegas/Offline/micromegasFrameWork/trunk/src/analyse/TB2010/Testbeam_june_10/Complete_detector/Profiles/";  
00235 
00236   if (ntfile>=1){TString tfile1 = dir + file1 + "_profile.root";TFile tf1(tfile1.Data());}
00237   if (ntfile>=2){TString tfile2 = dir + file2 + "_profile.root";TFile tf2(tfile2.Data());}
00238   if (ntfile>=3){TString tfile3 = dir + file3 + "_profile.root";TFile tf3(tfile3.Data());}
00239   if (ntfile>=4){TString tfile4 = dir + file4 + "_profile.root";TFile tf4(tfile4.Data());}
00240   if (ntfile>=5){TString tfile5 = dir + file5 + "_profile.root";TFile tf5(tfile5.Data());}
00241 
00242 
00243 
00244 
00245 
00246 
00247 
00248 
00249   TH2I * hxy_m2_cut_telescope[6][16];
00250   TString name,title;
00251   for (int i=3;i<9;i++){
00252     for (int j=8;j<24;j++){
00253       name = Form("hxy_m2_cut_telescope_%i_%i",i,j);
00254       title = Form("Hit in m2 after cut for telescope track at (%i,%i);x (cm);y (cm)",i,j);
00255       hxy_m2_cut_telescope[i-3][j-8] = new TH2I(name,title,96,0,96,96,0,96);}}
00256 
00257   TString name2 = "hxy_m2_cut_track";
00258   TH2I * hxy_m2_cut_track = new TH2I(name2,"Hits in m2 after time cut for telescope tracks;x (cm);y (xm)",96,0,96,96,0,96);
00259   
00260 
00261 
00262 
00263   for (int i=0;i<6;i++){
00264     for (int j=0;j<16;j++){
00265 
00266       name = Form("hxy_m2_cut_telescope_%i_%i",i+3,j+8);
00267 
00268       if (ntfile>=1){
00269         TH2I * h  = (TH2I*)tf1.Get(name);
00270         TH2I * h2 = (TH2I*)tf1.Get(name2);
00271         hxy_m2_cut_telescope[i][j]->Add(h);
00272         hxy_m2_cut_track->Add(h2);}
00273 
00274       if (ntfile>=2){
00275         TH2I * h = (TH2I*)tf2.Get(name);
00276         TH2I * h2 = (TH2I*)tf1.Get(name2);
00277         hxy_m2_cut_telescope[i][j]->Add(h);
00278         hxy_m2_cut_track->Add(h2);}
00279 
00280       if (ntfile>=3){
00281         TH2I * h = (TH2I*)tf3.Get(name);
00282         TH2I * h2 = (TH2I*)tf1.Get(name2);
00283         hxy_m2_cut_telescope[i][j]->Add(h);
00284         hxy_m2_cut_track->Add(h2);}
00285 
00286       if (ntfile>=4){
00287         TH2I * h = (TH2I*)tf4.Get(name);
00288         TH2I * h2 = (TH2I*)tf1.Get(name2);
00289         hxy_m2_cut_telescope[i][j]->Add(h);
00290         hxy_m2_cut_track->Add(h2);}
00291 
00292       if (ntfile>=5){
00293         TH2I * h = (TH2I*)tf5.Get(name);
00294         TH2I * h2 = (TH2I*)tf1.Get(name2);
00295         hxy_m2_cut_telescope[i][j]->Add(h);
00296         hxy_m2_cut_track->Add(h2);}
00297 
00298     }}
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307   int xprofile = 0;
00308   int yprofile = 0;
00309   int xprofile_m2 = 0;
00310   int yprofile_m2 = 0;
00311   int nentries = 0;
00312   int nentry_max = 0;
00313   int content = 0;
00314   int xtelescope_max = 0;
00315   int ytelescope_max = 0;
00316   bool far_from_off = 1;
00317 
00318   TH2I * hxy_stat = new TH2I("hxy_stat","",32,0,32,12,0,12);
00319   TH2I * hxy_stat_cut = new TH2I("hxy_stat_cut","",32,0,32,12,0,12);
00320 
00321   for (int i=3;i<9;i++){
00322     for (int j=8;j<24;j++){
00323 
00324       far_from_off = 1;
00325 
00326       nentries = hxy_m2_cut_telescope[i-3][j-8]->GetEntries();
00327       hxy_stat->SetBinContent(j+1,i+1,nentries);
00328 
00329       xprofile_m2 = hxy_m2_cut_telescope[i-3][j-8]->ProjectionX()->GetMaximumBin()-1;
00330       yprofile_m2 = hxy_m2_cut_telescope[i-3][j-8]->ProjectionY()->GetMaximumBin()-1;
00331 
00332       if (far_from_off_cut){
00333 
00334       if (chip == 114 || chip == 138){
00335         if (((xprofile_m2>=xmax-3) && (xprofile_m2<=xmax-1) && (yprofile_m2>=ymin+3) && (yprofile_m2<=ymax-1)) ||
00336             ((xprofile_m2==xmax-2) && (yprofile_m2==ymin+2)) ||
00337             ((xprofile_m2==xmax-1) && (yprofile_m2==ymin+2))){far_from_off=0;}}
00338 
00339       if (chip == 124 || chip == 134){
00340         if (((xprofile_m2>=xmax-3) && (xprofile_m2<=xmax-1) && (yprofile_m2>=ymin+3) && (yprofile_m2<=ymax-3)) ||
00341             ((xprofile_m2==xmax-2) && (yprofile_m2==ymin+2)) ||
00342             ((xprofile_m2==xmax-1) && (yprofile_m2==ymin+2))){far_from_off=0;}}}
00343       
00344 
00345       if (display){cout<<"Telescope "<<i<<" "<<j<<" -> profile at "<<xprofile_m2<<" "<<yprofile_m2<<" with "<<nentries<<" entries - far_from_off = "<<far_from_off<<endl;}
00346 
00347       if (far_from_off && nentries>=20){
00348         tg_x->SetPoint(tg_x->GetN(),i,xprofile_m2);
00349         tg_y->SetPoint(tg_y->GetN(),j,yprofile_m2);
00350         hdeltax->Fill(xprofile_m2 - i);
00351         hdeltay->Fill(yprofile_m2 - j);}
00352 
00353       if (far_from_off){hxy_stat_cut->SetBinContent(j+1,i+1,1);}
00354 
00355       if (far_from_off && nentries>=nentry_max){
00356 
00357         xtelescope_max = i;
00358         ytelescope_max = j;
00359         nentry_max = nentries;}}}
00360 
00361 
00362   xprofile_m2 = hxy_m2_cut_telescope[xtelescope_max-3][ytelescope_max-8]->ProjectionX()->GetMaximumBin()-1;
00363   yprofile_m2 = hxy_m2_cut_telescope[xtelescope_max-3][ytelescope_max-8]->ProjectionY()->GetMaximumBin()-1;
00364 
00365   //xprofile_m2 = hxy_m2_cut_telescope[xtelescope_max-3][ytelescope_max-8]->ProjectionX()->GetMean();
00366   //yprofile_m2 = hxy_m2_cut_telescope[xtelescope_max-3][ytelescope_max-8]->ProjectionY()->GetMean();
00367         
00368 
00369   cout<<endl;
00370   cout<<"M2 profile maximum for tracks traversing telescope at "<<xtelescope_max<<" "<<ytelescope_max<<endl;
00371   cout<<" corresponding point on m2 chamber is at "<<xprofile_m2<<" "<<yprofile_m2<<endl;
00372   cout<<endl;
00373 
00374 
00375   
00376   int delta_x = xprofile_m2 - xtelescope_max;
00377   int delta_y = yprofile_m2 - ytelescope_max;
00378 
00379 
00380   cout<<"Offsets"<<endl;
00381   cout<<" delta_x = "<<delta_x<<endl;
00382   cout<<" delta_y = "<<delta_y<<endl;
00383   cout<<endl;
00384 
00385 
00386   delta_x = hdeltax->GetMaximumBin()-1 - 96;
00387   delta_y = hdeltay->GetMaximumBin()-1 - 96;
00388 
00389 
00390   cout<<"Offsets from offset distribution maxima"<<endl;
00391   cout<<" delta_x = "<<delta_x<<endl;
00392   cout<<" delta_y = "<<delta_y<<endl;
00393   cout<<endl;
00394 
00395 
00396 
00397 
00398 
00399   
00400   
00401   hxy_m2_cut_track->GetXaxis()->SetRangeUser(xmin,xmax-1);
00402   hxy_m2_cut_track->GetYaxis()->SetRangeUser(ymin,ymax-1);
00403 
00404   TCanvas * c0 = new TCanvas("c0","",10,10,1500,500);
00405   c0->Divide(3,1);
00406   c0->cd(1);
00407   hxy_m2_cut_track->Draw("zcol");
00408   c0->cd(2);
00409   hdeltax->GetXaxis()->SetRangeUser(hdeltax->GetMean()-5*hdeltax->GetRMS(),hdeltax->GetMean()+5*hdeltax->GetRMS());
00410   hdeltax->Draw();
00411   c0->cd(3);
00412   hdeltay->GetXaxis()->SetRangeUser(hdeltay->GetMean()-5*hdeltay->GetRMS(),hdeltay->GetMean()+5*hdeltay->GetRMS());
00413   hdeltay->Draw();
00414 
00415 
00416 
00417   }
00418 
00419 }

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7