Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

#include <stdio.h>
#include <stdlib.h>

#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>

#include "base.h"
#include "map.h"

int mapped(){
  char pdfname[256];

  GRID m = mapping();

  TCanvas * c = new TCanvas("Koordinatni sistemi","Koordinatni sistemi",500,500);
  c->Divide(2,2);

  gStyle->SetOptStat(0);
 
  TH2D *mapBack = new TH2D("mapBack", "Mapping - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *posBack = new TH2D("posBack", "Scan Position - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *posChipBack = new TH2D("posChipBack", "Position on chip - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *kvadratki = new TH2D("kvadratki", "", 12, -0.5, 11.5, 12, -0.5, 11.5);

  for (int x=0;x<12;x++){
    for (int y=0;y<12;y++){
      mapBack->Fill(x,y,m.koordinatniSistem[x][y]);
      posBack->Fill(x,y,m.pozicijaPixla[m.koordinatniSistem[x][y]]);
      posChipBack->Fill(x,y,m.pozicijaPixlaNaCipu[m.koordinatniSistem[x][y]]);
      kvadratki->Fill(x,y,144);
    }
  }

  c->cd(1);

    mapBack->GetYaxis()->SetTickLength(0.01);
    mapBack->GetYaxis()->SetLabelOffset(0.03);

    mapBack->GetXaxis()->SetTickLength(0.01);
    mapBack->GetXaxis()->SetLabelOffset(0.03);


    mapBack->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");


  c->cd(3);
    posBack->GetYaxis()->SetTickLength(0.01);
    posBack->GetYaxis()->SetLabelOffset(0.03);

    posBack->GetXaxis()->SetTickLength(0.01);
    posBack->GetXaxis()->SetLabelOffset(0.03);

    posBack->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");

  c->cd(4);
 
    posChipBack->GetYaxis()->SetTickLength(0.01);
    posChipBack->GetYaxis()->SetLabelOffset(0.03);

    posChipBack->GetXaxis()->SetTickLength(0.01);
    posChipBack->GetXaxis()->SetLabelOffset(0.03);

    posChipBack->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");


  sprintf(pdfname,"map.pdf");
  c->SaveAs(pdfname,"pdf");

  return 0;
}
/*
int newFile(){
  GRID m = mapping();
  FILE *f = fopen("map.txt", "w");
  if (f == NULL)
  {
      printf("Error opening file!\n");
      exit(1);
  }
  for (int x=0;x<12;x++){
    for (int y=0;y<12;y++){
      fprintf(f, "%d\t%d\t%d\t%d\t%d\n", m.koordinatniSistemCHIP[y][x], m.koordinatniSistemPIXEL[y][x], x, 11-y,(11-x)+y*12);
    }
  }

  fclose(f);
  return 0;
}

GRID mapping2(){
  int f[6];
  int ndim = 400;
  char line[400];
  GRID m;
  FILE * fp = fopen("mapNEW.map","r");

  while (fgets(line,ndim,fp) != NULL) {
    sscanf(line,"%d%d%d%d%d%d",&f[0],&f[1],&f[2],&f[3],&f[4],&f[5]);
    //m.koordinatniSistem[f[2]][f[3]] = f[0]*36+f[1];
    m.koordinatniSistemCHIP[11-f[2]][11-f[3]] = f[0];
    m.koordinatniSistemPIXEL[11-f[2]][11-f[3]] = f[1];
    m.koordinatniSistem[11-f[2]][11-f[3]] = f[0]*36+f[1];
    m.pozicijaPixla[f[0]*36+f[1]] = f[4];
    m.pozicijaPixlaNaCipu[f[0]*36+f[1]] = f[5];
  }
  fclose(fp);

  TCanvas * c = new TCanvas("Koordinatni sistemi","Koordinatni sistemi",1000,1000);
  c->Divide(2,2);

  //gStyle->SetOptStat(0);
  TH2D *mapBack = new TH2D("mapBack", "Mapping - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *zaporedje = new TH2D("zaporedje", "zaporedje meritve - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *chips = new TH2D("chips", "chips - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *pixelonchp = new TH2D("pixelonchp", "pixelonchp - from back side", 12, -0.5, 11.5, 12, -0.5, 11.5);
  TH2D *kvadratki = new TH2D("kvadratki", "", 12, -0.5, 11.5, 12, -0.5, 11.5);


  for (int x=0;x<12;x++){
    for (int y=0;y<12;y++){
      mapBack->Fill(x,y,m.koordinatniSistem[x][y]);
      zaporedje->Fill(x,y,m.pozicijaPixla[m.koordinatniSistem[x][y]]);
      chips->Fill(x,y,m.pozicijaPixlaNaCipu[m.koordinatniSistem[x][y]]);
      pixelonchp->Fill(x,y,m.koordinatniSistemPIXEL[x][y]);
      //mapBackNew->Fill(x,y,m.koordinatniSistem[y][11-x]);
      //posBack->Fill(x,y,m.pozicijaPixla[m.koordinatniSistem[x][y]]);
      //posChipBack->Fill(x,y,m.pozicijaPixlaNaCipu[m.koordinatniSistem[x][y]]);
      kvadratki->Fill(x,y,144);
    }
  }
  c->cd(1);
    mapBack->GetYaxis()->SetTickLength(0.01);
    mapBack->GetYaxis()->SetLabelOffset(0.03);

    mapBack->GetXaxis()->SetTickLength(0.01);
    mapBack->GetXaxis()->SetLabelOffset(0.03);


    mapBack->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");
  c->cd(2);
    zaporedje->GetYaxis()->SetTickLength(0.01);
    zaporedje->GetYaxis()->SetLabelOffset(0.03);

    zaporedje->GetXaxis()->SetTickLength(0.01);
    zaporedje->GetXaxis()->SetLabelOffset(0.03);


    zaporedje->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");
  c->cd(3);
    chips->GetYaxis()->SetTickLength(0.01);
    chips->GetYaxis()->SetLabelOffset(0.03);

    chips->GetXaxis()->SetTickLength(0.01);
    chips->GetXaxis()->SetLabelOffset(0.03);


    chips->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");
  c->cd(4);
    pixelonchp->GetYaxis()->SetTickLength(0.01);
    pixelonchp->GetYaxis()->SetLabelOffset(0.03);

    pixelonchp->GetXaxis()->SetTickLength(0.01);
    pixelonchp->GetXaxis()->SetLabelOffset(0.03);


    pixelonchp->DrawCopy("TEXT");
    kvadratki->DrawCopy("BOX,SAME");


  return m;
}
*/