/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/TB2010/Testbeam_june_10/Gassiplex/Beam_profile/Beam_profile.C

Go to the documentation of this file.
00001 {gROOT->Reset();
00002   
00003   gSystem->Load("/LC/Detecteurs/MicroMegas/Offline/micromegasFrameWork/trunk/libMicro.so");
00004   gStyle->SetPalette(1);
00005   gStyle->SetOptStat(0);
00006 
00007 
00008   bool plot = 1;
00009   bool fit = 1;
00010   
00011 
00012 
00013   int cut = 30;
00014 
00015 
00016 
00017 
00018   //read file info from xml
00019   std::ifstream xml;
00020   xml.open("gassiplex_beam_profile.xml",ifstream::in);
00021   std::string line="";
00022   std::string lineb="";
00023   while(line.find("path=")==string::npos || lineb.find("<output")==string::npos)
00024    {
00025         lineb=line;
00026         xml>>line;
00027    }
00028   int start = line.find("\"")+1;
00029   int end =  line.rfind("\"")-6;
00030   TString address = line.substr(start,end);
00031 
00032 
00033 
00034 
00035   int nchannel = 0;
00036   float xpos = 0;
00037   float ypos = 0;
00038   float adc = 0;
00039   int content = 0;
00040 
00041   TH2F ** hxy = new TH2F[4];
00042   for(int chb = 0;chb<4;chb++){hxy[chb] = new TH2F(Form("hxy_%i",chb),Form("Chamber %i;y (cm);x (cm)",chb),32,0,32,12,0,12);}
00043   
00044 
00045 
00046 
00047 
00048   cout << "open rootfile "<<address<<endl;
00049   TFile *f = new TFile(address);
00050 
00051   TIter nextkey(f.GetListOfKeys());
00052   TKey *key;
00053 
00054 
00055   while (key = (TKey*)nextkey()) {
00056     
00057     TTree *tree = (TTree*)key->ReadObj();                
00058     MTRun* run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun");
00059     //run->Info();
00060 
00061     int nEvent = tree.GetEntries();
00062     cout <<"nEvent="<<nEvent<<endl;
00063 
00064 
00065   MTEvent *evt = new MTEvent();
00066 
00067   TBranch *branch= tree->GetBranch("MTEvent");
00068   branch->SetAddress(&evt);
00069 
00070 
00071   int chamber;
00072   int progress=0;
00073 
00074   
00075   for (int i=0;i<nEvent;i++){  
00076     
00077     if(progress!=(100*i)/nEvent){progress=(100*i/nEvent);cout<<"Progress "<<progress+1<<" %\t\r"<<flush;}
00078     tree.GetEntry(i);
00079     nchannel = evt->GetNchannel();
00080     
00081     for(int chan=0;chan<nchannel;chan++){
00082       
00083       MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(chan);
00084       
00085       chamber = channel->GetChamberId()-1;
00086       adc = channel->GetAnalogValue();
00087       xpos = channel->GetX();
00088       ypos = channel->GetY();
00089       
00090       if(adc>cut){hxy[chamber]->Fill(ypos,xpos);}}}}
00091  
00092 
00093 
00094 
00095 
00096 
00097   if (plot){
00098 
00099     TCanvas * c0 = new TCanvas("c0","",10,10,700,700);
00100     c0->Divide(2,2);
00101 
00102     for(int chb = 0;chb<4;chb++){
00103 
00104         c0->cd(chb+1);
00105         hxy[chb]->Draw("zcol");}}
00106 
00107 
00108 
00109 
00110 
00111 if (fit){
00112 
00113 
00114  hx1 = hxy[0]->ProjectionX();
00115  hy1 = hxy[0]->ProjectionY();
00116 
00117  hx2 = hxy[1]->ProjectionX();
00118  hy2 = hxy[1]->ProjectionY();
00119 
00120  hx3 = hxy[2]->ProjectionX();
00121  hy3 = hxy[2]->ProjectionY();
00122 
00123  hx4 = hxy[3]->ProjectionX();
00124  hy4 = hxy[3]->ProjectionY();}}
00125 

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