Example #1
0
void tpcanalspectra(Int_t isec =1, Int_t r1= 2)
{
   AliTPCParam * tpcparam = gtpc->GetParam();
 //make window for displaying results
  TCanvas  * c_occu = new TCanvas("occuhis","Occupancy dependence",700,900);
  c_occu->Update();
  TPad * pad1 = new TPad("ocpad1","occupancy1",0.05,0.61,0.95,0.95,21);
  pad1->Draw();
  TPad * pad2 = new TPad("ocpad2","occupancy",0.05,0.61,0.95,0.95,21);
  pad2->Draw();

  TPad * pad3 = new TPad("ocpad3","occupancy1",0.05,0.25,0.95,0.60,21);
  pad3->Draw();
  TPad * pad4 = new TPad("ocpad4","occupancy",0.05,0.25,0.95,0.60,21);
  pad4->Draw();

  //add comments to the histograms 
  TPaveText * comment = new TPaveText(0.05,0.03,0.95,0.2,"NDC");
  comment->SetTextAlign(12);
  comment->SetFillColor(42);
  comment->ReadFile("comment.txt");
  comment->Draw();
  TH2F  his
  //prepare histogram 
  for (Int_t i=1;i<irow;i+=lstep)
    { 
      tpcanal(isec,i,10,&res[0],kFALSE,tmin);
    }
  //plot occupancy histogram
  
  pad1->SetGridx();
  pad1->SetGridy();
}
Example #2
0
void tpcdraw(Int_t sec, Int_t row, Int_t pad)
{
   gStyle->SetOptStat(0); 
  //calculate occupancy for selected sector and pad row 
  //for selected pad is obtained signal shape 
  Double_t par[3];
  gtpc.SetSecRowTime(sec,row);
  gtpc.SetHisto(pad);
  gtpc.Draw("box");  
  //plot histograms with specified options
  //move pads to another position be possible add text
  gtpc.GetPad1().SetPad(0.05,0.72,0.95,0.95);
  gtpc.GetPad2().SetPad(0.05,0.47,0.95,0.70); 
  gtpc.GetPad3().SetPad(0.05,0.22,0.95,0.45);  
  //fit histogram of occupancy on specified range <150,500> 
  gtpc.GetPad2().cd();
  g1 = new TF1("pol0_r","pol0",150,500); 
  gtpc.GetHis3()->Fit("pol0_r","R0Q");    
  g1->GetParameters(&par[0]);
  Float_t error = g1->GetParError(0);
  fitText = new TPaveText(0.15,0.7,0.3,0.9,"NDC");
  fitText->AddText("p0 fit on interval <150-500>");
  char s[100];
  sprintf(s,"%0.3f+- %0.3f",par[0],error);
  fitText->AddText(s);
  fitText->Draw();
  gtpc.GetPad2().Update();     
  //set logarithmic 
  gtpc.GetPad3().cd();
  gtpc.GetPad3().SetLogy();  
   gtpc.GetPad3().Draw();    
  //add comments to the histograms 
  gtpc.GetCanvas().cd();
  TPaveText * comment = new TPaveText(0.05,0.03,0.95,0.2,"NDC");
  comment->SetTextAlign(12);
  comment->SetFillColor(42);
  comment->ReadFile("comment.txt");
  comment->Draw();
  gtpc.GetCanvas().Update();
  

}
Example #3
0
void oDependence()
{
  //set plot options
  gStyle->SetOptFit(1); 
  gStyle->SetOptStat(1);  
  TCanvas  * c1 = new TCanvas("canPRF","Pad response function",700,900);
  TPad * pad1 = new TPad("pad1THR","",0.05,0.55,0.45,0.95,21);
  pad1->Draw();
  TPad * pad2 = new TPad("pad2PRF","",0.55,0.55,0.95,0.95,21);
  pad2->Draw(); 
  TPad * pad3 = new TPad("pad3PRF","",0.55,0.05,0.95,0.45,21);
  pad3->Draw(); 
 
  pad1->cd();
  pad1->SetGridx();
  pad1->SetGridy();
  pad2->SetGridx();
  pad2->SetGridy();
  pad3->SetGridx();
  pad3->SetGridy();

  //make histogram of threshold dependence
  TH1F * hotd =new TH1F("Occupancy dependence on threshold",
			"Ocupancy at first pad row as function of threshold",
                        25,0.,25.);

  hotd->SetBinContent(5,0.625);
  hotd->SetBinError(5,0.02);
  hotd->SetBinContent(10,0.559);
  hotd->SetBinError(10,0.02); 
  hotd->SetBinContent(20,0.478);
  hotd->SetBinError(20,0.02);
  hotd->SetXTitle("Threshold   [channels]");
  hotd->SetYTitle("occupancy");
  hotd->Fit("pol1","+");  
  hotd->Draw("error");
  //make histogram of PRF  dependence
  TH1F * hoprfd =new TH1F("Occupancy dependence on PRF width",
			"Occupancy at first pad row as function of generic PRF sigma for  2.05x0.35 cm pad size ",
                        65, 0.,6.5);
  hoprfd->SetBinContent(10,0.492);
  hoprfd->SetBinError(10,0.02);

  hoprfd->SetBinContent(20,0.524);
  hoprfd->SetBinError(20,0.02); 

  hoprfd->SetBinContent(30,0.559);
  hoprfd->SetBinError(30,0.02);
  hoprfd->SetXTitle("Sigma of PRF   [mm]");
  hoprfd->SetYTitle("occupancy");
  pad2->cd();
  hoprfd->Fit("pol1","+");  
  hoprfd->Draw("error");
  pad2->Draw();
  //pad 3 histogram  
  pad3->cd();
   TH1F * hoprfd88 =new TH1F("Occupancy dependence on PRF width 08x08",
			"Occupancy at first pad row as function of generic PRF sigma for  0.8x0.8 cm pad size ",
                        65, 0.,6.5);

  hoprfd88->SetBinContent(20,0.322);
  hoprfd88->SetBinError(20,0.02);

  hoprfd88->SetBinContent(30,0.344);
  hoprfd88->SetBinError(30,0.02); 

  hoprfd88->SetBinContent(40,0.369);
  hoprfd88->SetBinError(40,0.02);
 
  hoprfd88->SetBinContent(60,0.416);
  hoprfd88->SetBinError(60,0.02);
  hoprfd88->SetXTitle("Sigma of PRF   [mm]");
  hoprfd88->SetYTitle("occupancy");
  hoprfd88->Fit("pol1","+");  
  hoprfd88->Draw("error");
  c1->cd();
  TPaveText * comment = new TPaveText(0.05,0.15,0.45,0.35,"NDC");
  comment->SetTextAlign(12);
  comment->SetFillColor(42);  
  comment->ReadFile("commentdep.txt");  
  comment->Draw();

}
Example #4
0
void tpcanalall(Int_t isec =1, Int_t lstep = 1,Float_t tmin=400)
{
   AliTPCParam * tpcparam = gtpc->GetParam();
 //make window for displaying results
  TCanvas  * c_occu = new TCanvas("coccu","Occupancy dependence",700,900);
  c_occu->Update();
  TPad * pad1 = new TPad("occupancy","occupancy",0.05,0.25,0.95,0.95,21);
  pad1->Draw();
  //add comments to the histograms 
  TPaveText * comment = new TPaveText(0.05,0.03,0.95,0.2,"NDC");
  comment->SetTextAlign(12);
  comment->SetFillColor(42);
  comment->ReadFile("comment.txt");
  comment->Draw();
  //prepare histogram 
  Int_t irow = tpcparam->GetNRow(isec);
  Float_t xmin = tpcparam->GetPadRowRadii(isec,1);
  Float_t xmax = tpcparam->GetPadRowRadii(isec,irow);  
  pad1->cd();
  char s[220];
  char sh[220];
  sprintf(s,"occu_sector%d",isec);
  sprintf(sh,"Occupancy in sector %d as function of pad raw",isec);  
  TH1F * occudep = new TH1F(s,sh,300,xmin,xmax);
  Float_t   res[20];
  Float_t   x;
  for (Int_t i=2;i<irow;i+=lstep)
    { 
      tpcanal(isec,i,10,&res[0],kFALSE,tmin);
      x = tpcparam->GetPadRowRadii(isec,i) ;
      Int_t index = (300*(x-xmin))/(xmax-xmin);
      cout<<i<<"  "<<index<<"   "<<x<<"   "<<res[0]<<"   "<<res[1]<<"\n";  
      occudep->SetBinContent(index,res[0]);
      occudep->SetBinError(index,res[1]);      
    }
  //plot occupancy histogram
  
  pad1->SetGridx();
  pad1->SetGridy();
  gStyle->SetOptFit(0);       
  occudep->Draw("error");
  occudep->SetXTitle("pad row center position [cm]");
  occudep->SetYTitle("occupancy"); 
 
  //fit occupancy dependence
  //linear fit
  TF1 * g1 = new TF1("pol1_r","pol1");  
  occudep->Fit("pol1_r","+Q"); 
  Double_t par[3];
  Float_t error[3]; 
  Float_t chi;
  g1->GetParameters(&par[0]);
  error[0]=g1->GetParError(0);
  error[1]=g1->GetParError(1);   
  Float_t  chi = g1->GetChisquare();
  sprintf(s,"Linear fit     ocupancy = (%2.3f - %2.3f) +(%2.1f+- %2.1f).r   chi2 = %2.2f",
	  par[0],error[0],1000*par[1],1000*error[1],chi);
  comment->AddText(s);
 //(1-exp([0]1/(r*2+[1]**2)  fit
   TF1 * g1 = new TF1("polm1",occur,1,00,1);  
    occudep->Fit("polm1","+Q"); 
    Double_t par[3];
    Float_t error[3]; 
    g1->GetParameters(&par[0]);
    error[0]=g1->GetParError(0);
    //    error[1]=g1->GetParError(1);
    chi = g1->GetChisquare();
    sprintf(s,"(1-exp(P1/(x^2) fit   P1=(%2.3f+- %2.3f)    chi2=%2.2f ",
  	  par[0],error[0],chi);
    comment->AddText(s);
  c_occu->Update();
    
}
Example #5
0
void tpccfind(Int_t threshold, Float_t thr = 2,
	      Int_t i1 = 2, Int_t i2 = 2, 
	      Int_t tharea =20, Int_t thmax=100)
{  
  ///////////////////////GRAPHICS//DECLARATION//////////////////////
  TCanvas  * c1 = new TCanvas("padcluster","Cluster finder 1",700,900);
  c1->cd();
  TCanvas  * c2 = new TCanvas("padcluster2","Cluster finder 2",700,900);
  c2->cd();
  c1->cd();
  TPad * pad11 = new TPad("pad11","",0.01,0.76,0.48,0.95,21);
  pad11->Draw();
  TPad * pad12 = new TPad("pad12","",0.51,0.76,0.95,0.95,21);
  pad12->Draw();
  TPad * pad21 = new TPad("pad21","",0.01,0.56,0.49,0.74,21);
  pad21->Draw();
  TPad * pad22 = new TPad("pad22","",0.51,0.56,0.95,0.74,21);
  pad22->Draw();
  TPad * pad31 = new TPad("pad31","",0.01,0.36,0.49,0.54,21);
  pad31->Draw();
  TPad * pad32 = new TPad("pad32","",0.51,0.36,0.95,0.54,21);
  pad32->Draw();
  TPad * pad41 = new TPad("pad41","",0.01,0.16,0.49,0.34,21);
  pad41->Draw();
  TPad * pad42 = new TPad("pad42","",0.51,0.16,0.95,0.34,21);
  pad42->Draw();

  c2->cd();
  TPad * pad11_2 = new TPad("pad11_2","",0.01,0.76,0.48,0.95,21);
  pad11_2->Draw();
  TPad * pad12_2 = new TPad("pad12_2","",0.51,0.76,0.95,0.95,21);
  pad12_2->Draw();
  /////////////////////HISTOGRAMS///DECLARATION///////////////////////
  pad11->cd();
  TH1F * hsx = new TH1F("hsx","Sigma of distribution in time",40,0,2);
  pad12->cd();
  TH1F * hsy = new TH1F("hsy","Sigma of distribution in pads",40,0,2);

  pad21->cd();
  TProfile * hsx2 = new TProfile("hsx2","Sigma of distribution in time",
			 20,100,500);
  pad22->cd();
  TProfile * hsy2 = new TProfile("hsy2","Sigma of distribution in pads",
			 20,100,500);

  pad31->cd();
  TH1F * harea = new TH1F("harea","Area of the peak",26,0,52);
  pad32->cd();
  TH1F * hmax = new TH1F("hmax","Maximal amplitude in peak",30,0,150);
 

  pad41->cd();  
  TProfile * harea2= new TProfile("harea2","Area dependence z coordinata",
			 20,100,500);
  pad42->cd();
  TProfile * hmax2 = new TProfile("hmax2","Maximal amplitude dependence",
			 20,100,500);
  pad41->cd();  

  pad11_2->cd();
  TProfile * harea2p= new TProfile("harea2p","Area dependence on pad coordinata",
			 20,0,100);
  pad12_2->cd();
  TProfile * hmax2p = new TProfile("hmax2p","Maximal amplitude dependence on pad",
			 20,0,50);
  //////////////////CALCULATION//////////////////////////////////////////

  for (Int_t k = i1;k <=i2; k++)
    {
      tpcanal(1,k,10,0,kFALSE);
      TClusterFinder * cf=new TClusterFinder(0,0,threshold,1);
      cf->GetHisto(&gtpc.GetHis1());
      TClonesArray * arr = cf->FindClusters();
      cf->Delete();
      Int_t size = arr->GetEntries();
      
      if ( size>0 )   
	for (Int_t i=0 ; i<size;i++)
	  {
	    Int_t index;
	    TCluster *c=(TCluster*)arr->UncheckedAt(i);
	    hsx->Fill(TMath::Sqrt(c.fSigmaX2));
	    hsy->Fill(TMath::Sqrt(c.fSigmaY2));    
	    if  (TMath::Sqrt(c.fSigmaX2)<thr)
	      hsx2->Fill(c.fX,TMath::Sqrt(c.fSigmaX2),1);
	    if  (TMath::Sqrt(c.fSigmaY2)<thr)
	      hsy2->Fill(c.fX,TMath::Sqrt(c.fSigmaY2),1);       
	    hmax->Fill(c.fMax);
	    harea->Fill(c.fArea);
	    if (c.fArea<tharea)  harea2->Fill(c.fX,c.fArea,1);
            if (c.fMax<thmax) hmax2->Fill(c.fX,c.fMax,1);
	    if (c.fArea<tharea)  harea2p->Fill(c.fY,c.fArea,1);
            if (c.fMax<thmax) hmax2p->Fill(c.fY,c.fMax,1);
	    
	  }
    } 
  gStyle->SetOptStat(1);
  pad11->cd();
  hsx->Draw();
  pad12->cd();
  hsy->Draw();

  pad21->cd();
  hsx2->Draw();
  pad22->cd();
  hsy2->Draw();

  pad31->cd();
  harea->Draw();
  pad32->cd();
  hmax->Draw();

  pad41->cd();
  harea2->Draw();
  pad42->cd();
  hmax2->Draw();


  c1->cd();
  TPaveText * comment = new TPaveText(0.05,0.02,0.95,0.14,"NDC");
  comment->SetTextAlign(12);
  comment->SetFillColor(42);   
  comment->ReadFile("clusters.txt");
  comment->Draw();
  c2->cd();
  pad11_2->cd();
  harea2p->Draw();
  pad12_2->cd();
  hmax2p->Draw();


}
Example #6
0
void tpcanal(Int_t sec, Int_t row, Int_t pad, Float_t * res=0, 
	     Bool_t bdraw = kTRUE,Float_t xmin=400,Float_t xmax=500)
{
  //calculate occupancy
  Double_t par[3];
  gtpc.SetSecRowTime(sec,row);
  gtpc.SetHisto(pad);
  //fit occupancy dependence

  gStyle->SetOptStat(0); 
  g1 = new TF1("pol0_r","pol0",xmin,xmax);  
  gtpc.GetHis3()->Fit("pol0_r","R0Q");  
  char s[100];
  
  if (bdraw == kTRUE) 
    {       
      gtpc.Draw("box");
      gtpc.GetPad3().cd();
      gtpc.GetPad3().SetGridx();
      gtpc.GetPad3().SetGridy();       
      gtpc.GetPad3().SetLogy();          
      gtpc.GetPad3().Draw();
      gtpc.GetPad2().cd();
      gtpc.GetPad2().SetGridx();
      gtpc.GetPad2().SetGridy();   
      fitText = new TPaveText(0.1,0.7,0.4,0.9,"NDC");
      gtpc.GetHis3()->Draw();
      sprintf(s,"p0 fit on interval %3.0f+- %3.0f",xmin,xmax);
      fitText->AddText(s);
    }
  g1->GetParameters(&par[0]);
  Float_t error = g1->GetParError(0);

  sprintf(s,"%0.3f+- %0.3f",par[0],error);
  if (bdraw == kTRUE)
    {
      gtpc.GetHis3()->Fit("pol0_r","R0Q");  
      fitText->AddText(s);
      fitText->Draw();
      gtpc.GetPad2().Update();  

      //plot histograms with specified options
      //move pads to another position be possible add text
      gtpc.GetPad1().SetPad(0.05,0.72,0.95,0.95);
      gtpc.GetPad2().SetPad(0.05,0.47,0.95,0.70); 
      gtpc.GetPad3().SetPad(0.05,0.22,0.95,0.45);  
      //add comments to the histograms 
      gtpc.GetCanvas().cd();
      TPaveText * comment = new TPaveText(0.05,0.03,0.95,0.2,"NDC");
      comment->SetTextAlign(12);
      comment->SetFillColor(42);   
      comment->ReadFile("comment.txt");
      comment->Draw();
    }  
  if (res != 0)
    {
      res[0] = par[0];
      res[1] = error;
      cout<<s<<"   "<<res[0]<<"   "<<res[1]<<"\n";
    }
}
Example #7
0
File: fit1.C Project: Y--/root
void fit1() {
   TCanvas *c1 = new TCanvas("c1_fit1","The Fit Canvas",200,10,700,500);
   c1->SetGridx();
   c1->SetGridy();
   c1->GetFrame()->SetFillColor(21);
   c1->GetFrame()->SetBorderMode(-1);
   c1->GetFrame()->SetBorderSize(5);

   gBenchmark->Start("fit1");
   //
   // We connect the ROOT file generated in a previous tutorial
   // (see <a href="fillrandom.C.nbconvert.ipynb">Filling histograms with random numbers from a function</a>) 
   //
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/fit/");
   TFile *file = TFile::Open("fillrandom.root");
   if (!file) {
      gROOT->ProcessLine(Form(".x %s../hist/fillrandom.C",dir.Data()));
      file = TFile::Open("fillrandom.root");
      if (!file) return;
   }

   //
   // The function "ls()" lists the directory contents of this file
   //
   file->ls();

   //
   // Get object "sqroot" from the file. Undefined objects are searched
   // for using gROOT->FindObject("xxx"), e.g.:
   // TF1 *sqroot = (TF1*) gROOT.FindObject("sqroot")
   //
   TF1 * sqroot = 0;
   file->GetObject("sqroot",sqroot);
   if (!sqroot){
      Error("fit1.C","Cannot find object sqroot of type TF1\n");
      return;
   }
   sqroot->Print();

   //
   // Now get and fit histogram h1f with the function sqroot
   //
   TH1F* h1f = 0;
   file->GetObject("h1f",h1f);
   if (!h1f){
      Error("fit1.C","Cannot find object h1f of type TH1F\n");
      return;
   }
   h1f->SetFillColor(45);
   h1f->Fit("sqroot");

   // We now annotate the picture by creating a PaveText object
   // and displaying the list of commands in this macro
   //
   TPaveText * fitlabel = new TPaveText(0.6,0.4,0.9,0.75,"NDC");
   fitlabel->SetTextAlign(12);
   fitlabel->SetFillColor(42);
   fitlabel->ReadFile(Form("%sfit1_C.txt",dir.Data()));
   fitlabel->Draw();
   c1->Update();
   gBenchmark->Show("fit1");
}