Exemplo n.º 1
0
// Open a FITS file and retrieve the first plane of the image array 
// as a TASImage object
void FITS_tutorial3()
{
   printf("\n\n--------------------------------\n");
   printf("WELCOME TO FITS tutorial #3 !!!!\n");
   printf("--------------------------------\n");
   printf("We're gonna open a FITS file that contains several image\n");
   printf("extensions. The primary HDU contains no data.\n");
   printf("Data copyright: NASA\n\n");
   
   if (!gROOT->IsBatch()) {
      //printf("Press ENTER to start..."); getchar();
   }
   
   // Open extensions 1 to 5 from file
   //printf("Press ENTER to see a canvas with all images within the file:"); getchar();
   
   TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 700);
   c->Divide(2,3);
   for (int i=1; i <= 5; i++) {
      TFITSHDU *hdu = new TFITSHDU("sample3.fits", i);
      if (hdu == 0) {
         printf("ERROR: could not access the HDU\n"); return;
      }
      
      TASImage *im = hdu->ReadAsImage(0);
      c->cd(i);
      im->Draw();
      delete hdu;
   }
}
Exemplo n.º 2
0
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) {

        if (rPerformance){

                TLatex *alice = new TLatex(0.65,0.47,"Performance");
                alice->SetNDC();
                alice->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice->SetTextSize(0.05);
                alice->SetLineWidth(2);
                alice->Draw();

                TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
                alice2->SetNDC();
                alice2->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice2->SetTextSize(0.05);
                alice2->SetLineWidth(2);
                alice2->Draw();

                TText *date = new TText(0.68,0.35,cStamp2);
                date->SetNDC();
                date->SetTextFont(42);
                date->SetTextSize(0.04);
                date->Draw();

                //Acquire canvas proportions
                Double_t AliLogo_LowX = 0.67;
                Double_t AliLogo_LowY = 0.53;
                Double_t AliLogo_Height = 0.22;
                //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
                Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

                TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
                //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
                myPadSetUp(myPadLogo,0,0,0,0);
                //myPadLogo->SetFixedAspectRatio(1);
                myPadLogo->Draw();
                myPadLogo->cd();
                TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
                myAliceLogo->Draw();
        }

        if (rWrite == 1)
                c2->SaveAs(Form("%s.png",name));

        if (rWrite == 2)
                c2->SaveAs(Form("%s.eps",name));

}
Exemplo n.º 3
0
void ALICEWorkInProgress(TCanvas *c,TString today){
 //date must be in the form: 04/05/2010
 if(today=="today"){
   TDatime startt;                                                                                                                                                        
   int date=startt.GetDate();

   int y=date/10000;
   int m=(date%10000)/100;
   int d=date%100;


   today="";
   today+=d;
   if(m<10)
     today.Append("/0");
   else today.Append("/");
   today+=m;
   today.Append("/");
   today+=y;  

 }
 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",0.67,0.65,0.82,0.89);
 //  myPadLogo->SetFillColor(2); 
 myPadLogo->SetBorderMode(0);
 myPadLogo->SetBorderSize(2);
 myPadLogo->SetFrameBorderMode(0);
 myPadLogo->SetLeftMargin(0.0);
 myPadLogo->SetTopMargin(0.0);
 myPadLogo->SetBottomMargin(0.0);
 myPadLogo->SetRightMargin(0.0);
 myPadLogo->Draw();
 myPadLogo->cd();
 TASImage *myAliceLogo = new TASImage("/u/mfasel/work/electron/Spectrum/alice_logo.png");
 myAliceLogo->Draw();
 c->cd();
 TPaveText* t1=new TPaveText(0.59,0.59,0.89,0.66,"NDC");
 t1->SetFillStyle(0);
 t1->SetBorderSize(0);
 t1->AddText(0.,0.,"ALICE Performance");
 t1->SetTextColor(kRed);
 t1->SetTextFont(42);
 t1->Draw();
 TPaveText* t2=new TPaveText(0.59,0.54,0.89,0.60,"NDC");
 t2->SetFillStyle(0);
 t2->SetBorderSize(0);
 t2->SetTextColor(kRed);
 t2->SetTextFont(52);
 t2->AddText(0.,0.,today.Data());
 t2->Draw();
}
Exemplo n.º 4
0
void DrawALICELogo(Bool_t prel, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
{
    // correct for aspect ratio of figure plus aspect ratio of pad (coordinates are NDC!)
    x2 = x1 + (y2 - y1) * (466. / 523) * gPad->GetWh() * gPad->GetHNDC() / (gPad->GetWNDC() * gPad->GetWw());
    // Printf("%f %f %f %f", x1, x2, y1, y2);

    TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo", x1, y1, x2, y2);
    myPadLogo->SetLeftMargin(0);
    myPadLogo->SetTopMargin(0);
    myPadLogo->SetRightMargin(0);
    myPadLogo->SetBottomMargin(0);
    myPadLogo->Draw();
    myPadLogo->cd();
    TASImage *myAliceLogo = new TASImage((prel) ? "~/alice_logo_preliminary.eps" : "~/alice_logo_performance.eps");
    myAliceLogo->Draw();
}
Exemplo n.º 5
0
void DrawALICELogo(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
{
// Correct for aspect ratio of figure plus aspect ratio of pad.
// Coordinates are NDC!

  x2 = x1 + (y2 - y1)*0.891*gPad->GetCanvas()->GetWindowHeight()*gPad->GetHNDC() / (gPad->GetWNDC() * gPad->GetCanvas()->GetWindowWidth());
  
  TPad *myPadLogo = new TPad("myPadLogo","Pad for ALICE Logo", x1, y1, x2, y2);
  myPadLogo->SetLeftMargin(0);
  myPadLogo->SetTopMargin(0);
  myPadLogo->SetRightMargin(0);
  myPadLogo->SetBottomMargin(0);
  myPadLogo->Draw();
  myPadLogo->cd();
  TASImage *myAliceLogo = 
  new TASImage("alice_logo_preliminary.eps");
  myAliceLogo->Draw("same");
}
Exemplo n.º 6
0
drawMultiplicity(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) {

        prepareAll();

        TFile *f = new TFile(infilename, "read");

        int minMultBin = 0; // 0, 2, 3
        int maxMultBin = 6; // 2, 6, 8

        double EvMultall = 0;

        for (int i = minMultBin; i < maxMultBin; i++) {

                if (i == minMultBin)
                        TH1D* hEvMult =(TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i));
                else
                        hEvMult->Add((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)));

                EvMultall += ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries();
                cout << "MultBin " << i << " " << ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries() << endl;
                //delete hEvMult;
        }

        cout << "Number of events (all bins): " << EvMultall << endl;

        TCanvas *c2 = new TCanvas("mult", "Event Multiplicity");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        c2->SetLogy();

        hEvMult->GetXaxis()->SetTitle("multiplicity");
        hEvMult->GetYaxis()->SetTitle("number of events");
        hEvMult->GetXaxis()->SetRangeUser(0,4000);
        hEvMult->Draw("");

        if (rPerformance){
                TLatex *alice = new TLatex(0.35,0.27,"Performance");
                alice->SetNDC();
                alice->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice->SetTextSize(0.05);
                alice->SetLineWidth(2);
                alice->Draw();

                TLatex *alice2 = new TLatex(0.32,0.21,"LHC10h - Pass2");
                alice2->SetNDC();
                alice2->SetTextColor(myDarkRed);
                alice->SetTextFont(42);
                alice2->SetTextSize(0.05);
                alice2->SetLineWidth(2);
                alice2->Draw();

                TText *date = new TText(0.38,0.15,cStamp2);
                date->SetNDC();
                date->SetTextFont(42);
                date->SetTextSize(0.04);
                date->Draw();

                //Acquire canvas proportions
                Double_t AliLogo_LowX = 0.37;
                Double_t AliLogo_LowY = 0.33;
                Double_t AliLogo_Height = 0.22;
                //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
                Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

                TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
                //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
                myPadSetUp(myPadLogo,0,0,0,0);
                //myPadLogo->SetFixedAspectRatio(1);
                myPadLogo->Draw();
                myPadLogo->cd();
                TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
                myAliceLogo->Draw();
        }

        if (rWrite == 1)
                c2->SaveAs(Form("multiplicity%s.png",system));

        if (rWrite == 2)
                c2->SaveAs(Form("multiplicity%s.eps",system));

}
Exemplo n.º 7
0
// Open a FITS file and retrieve the first plane of the image array 
// as a TASImage object
void FITS_tutorial1()
{
   printf("\n\n--------------------------------\n");
   printf("WELCOME TO FITS tutorial #1 !!!!\n");
   printf("--------------------------------\n");
   printf("We're gonna open a FITS file that contains only the\n");
   printf("primary HDU, consisting on an image.\n");
   printf("The object you will see is a snapshot of the NGC7662 nebula,\n");
   printf("which was taken by the author on November 2009 in Barcelona (CATALONIA).\n\n");
      
   if (!gROOT->IsBatch()) {
      //printf("Press ENTER to start..."); getchar();
   }
   
   // Open primary HDU from file
   TFITSHDU *hdu = new TFITSHDU("sample1.fits");
   if (hdu == 0) {
      printf("ERROR: could not access the HDU\n"); return;
   }
   printf("File successfully open!\n");
   
   // Dump the HDUs within the FITS file
   // and also their metadata
   //printf("Press ENTER to see summary of all data stored in the file:"); getchar();
   
   hdu->Print("F+");
   
   printf("....................................\n");
   // Here we get the exposure time.
   //printf("Press ENTER to retrieve the exposure time from the HDU metadata..."); getchar();
   printf("Exposure time = %s\n", hdu->GetKeywordValue("EXPTIME").Data());

   
   // Read the primary array as a matrix,
   // selecting only layer 0.
   // This function may be useful to
   // do image processing.
   printf("....................................\n");
   printf("We can read the image as a matrix of values.\n");
   printf("This feature is useful to do image processing, e.g:\n");
   printf("histogram equalization, custom filtering, ...\n");
   //printf("Press ENTER to continue..."); getchar();
   
   TMatrixD *mat = hdu->ReadAsMatrix(0);
   mat->Print();
   delete mat;
   
   // Read the primary array as an image,
   // selecting only layer 0.
   printf("....................................\n");
   printf("Now the primary array will be read both as an image and as a histogram,\n");
   printf("and they will be shown in a canvas.\n");
   //printf("Press ENTER to continue..."); getchar();
   
   TASImage *im = hdu->ReadAsImage(0);
   
   // Read the primary array as a histogram.
   // Depending on array dimensions, returned
   // histogram will be 1D, 2D or 3D
   TH1 *hist = hdu->ReadAsHistogram();
   
   
   TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 300);
   c->Divide(2,1);
   c->cd(1);
   im->Draw();
   c->cd(2);
   hist->Draw("COL");

   // Clean up
   delete hdu;
}