/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/analog.cpp File Reference

#include <map>
#include "TKey.h"
#include <TROOT.h>
#include <TStyle.h>
#include <TRint.h>
#include <TTree.h>
#include <TCanvas.h>
#include "TH1.h"
#include "TF1.h"
#include <TH1I.h>
#include <TH2I.h>
#include <TFile.h>
#include <stdlib.h>
#include <TSystem.h>
#include <iostream>
#include "TApplication.h"
#include <sstream>
#include "Log.hh"
#include <Rtypes.h>
#include "TColor.h"
#include "TFunction.h"
#include "TAttLine.h"
#include "TPaveStats.h"
#include "MicroException.hh"
#include <string>
#include "root/MTChannel.hh"
#include "root/MTEvent.hh"

Include dependency graph for analog.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file analog.cpp.

00039                               {
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 ;     // cut on number of pedestal event
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 //        if (channel->GetChipId() == 67 && channel->GetHardId() == 53 ) { channel66 =  channel->GetDigitalValue(); ;} 
00120 //        if (channel->GetChipId() ==67 && channel->GetHardId() == 55 ) { channel68 =  channel->GetDigitalValue();}
00121 
00122 
00123                 absTime = channel->GetBcId_Abs() - (channel->GetBcId_Dif() - channel->GetBcId_Hit() ); // see src/analyse/root/example.cpp
00124                 UInt_t nbHitPerAbsTime = evt->GetNbHitPerAbsTime(channel->GetBoardId(), absTime) ; // see src
00125                 
00126 
00127         if ( channel->GetAnalogValue() != 0 )//&& channel->GetDigitalValue() > 0 )// && channel->GetDigitalValue() < 3)
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                                         //dacAll->Fill(adc);
00137                                         nb_ped++;
00138                                 }
00139 
00140             
00141             if (nbHitPerAbsTime < 4)
00142                 {
00143             
00144  //             if (  channel->GetDigitalValue() == 1  && adc < 1400) 
00145               if (  channel->GetDigitalValue() == 1  ) 
00146               {     
00147                 dac0->Fill(adc);
00148                 histo2->Fill(channel->GetDigitalValue(),adc);
00149                 dacAll->Fill(adc);
00150               }
00151               //if (  channel->GetDigitalValue() == 2  && adc >= 1200 && adc <  1700) 
00152               if (  channel->GetDigitalValue() == 2 ) 
00153               {
00154                 dac1->Fill(adc);
00155                 histo2->Fill(channel->GetDigitalValue(),adc);
00156                 dacAll->Fill(adc);
00157               }
00158               //if (  channel->GetDigitalValue() == 3  && adc  >=1600)
00159               if (  channel->GetDigitalValue() == 3 )
00160               {
00161                 /* dac2->Fill(adc);
00162                  histo2->Fill(channel->GetDigitalValue(),adc);*/
00163                 // dacAll->Fill(adc);
00164               }
00165             }
00166           }
00167         }
00168       }} //break;
00169     }
00170   }
00171    TCanvas * c0 = new TCanvas("c0","Prototype m2");//,0,0,800,600);
00172 //   c0->Divide(3,2);
00173   
00174    //c0->cd(1);
00175    //dac0->Draw();
00176    //c0->cd(2);
00177    //dac1->Draw();
00178    //c0->cd(3);
00179    //dac2->Draw();
00180    //c0->cd(4);
00181    dacPed->Draw("");
00182    dacPed->Fit("gaus","R", "SAME", 1140, 1200);
00183 //   dacPed->Fit("gaus");
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         //dacAll->GetYaxis()->SetRangeUser(0,300);
00195         
00196         c0->Update();   // Create the TGRAPH. IF not present, following lines
00197 
00198         TPaveStats *p1 = (TPaveStats*) dacPed->GetListOfFunctions()->FindObject("stats");
00199 //      dacPed->GetListOfFunctions()->Print();
00200 //      p1->Print();
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         // NEED SAMES (!=SAME) in Drawin histo !!!!!
00212 //      dacAll->GetListOfFunctions()->Print();
00213         TPaveStats *p2 = (TPaveStats*) dacAll->GetListOfFunctions()->FindObject("stats");
00214 //      p2->Print();
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 }


Generated on Mon Jun 11 16:57:23 2012 for MicromegasFramework by  doxygen 1.4.7