Gryfindor_phil.cxx File Reference

#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "TFile.h"
#include "TROOT.h"
#include "TH1.h"
#include "TF1.h"
#include "TH2.h"
#include "TF2.h"
#include "TH3.h"
#include "TStyle.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TMath.h"
#include "TMinuit.h"
#include "TNtuple.h"
#include "TLatex.h"
#include "TLine.h"
#include "TFrame.h"
#include "TEllipse.h"
#include "detector/detector.h"

Go to the source code of this file.

Functions

TROOT simple ("stuff","stuff")
void Draw (Detector *detector[10][21], int start_plane, int pick_led, int led_pattern)
void DrawFourPlanes (Detector *detector_one, Detector *detector_two, Int_t start_plane, Int_t led)
int SanityCheck (int plane, int chip, int channel)
int GetPixel (int channel)
Int_t main (Int_t argv, char **argc)

Function Documentation

void Draw ( Detector detector[10][21],
int  start_plane,
int  pick_led,
int  led_pattern 
)

Definition at line 183 of file Gryfindor_phil.cxx.

References DrawFourPlanes(), and fname.

00184 {
00185   static TCanvas *c1=0, *c2=0;
00186   static bool first = true;
00187   if (first) {
00188     c1 = new TCanvas("fourplanes","fourplanes",0,0,600,750);
00189     c2 = new TCanvas("fourmoreplanes","fourmoreplanes",600,0,600,750);
00190     first = false;
00191   }
00192   c1->Clear();
00193   c2->Clear();
00194   c1->cd();
00195  if(start_plane < 65)
00196       DrawFourPlanes(detector[0][pick_led],detector[0][pick_led],start_plane,led_pattern);
00197     else if(start_plane >64 && start_plane < 129)
00198       DrawFourPlanes(detector[2][pick_led],detector[2][pick_led],start_plane,led_pattern);
00199     else if(start_plane >129 && start_plane < 193)
00200       DrawFourPlanes(detector[4][pick_led],detector[4][pick_led],start_plane,led_pattern);
00201  // else if(start_plane >192 && start_plane < 256)
00202    //     DrawFourPlanes(detector[6][pick_led],detector[6][pick_led],start_plane,led_pattern);
00203  c2->cd();
00204  if(start_plane < 65)
00205       DrawFourPlanes(detector[1][pick_led],detector[1][pick_led],start_plane,led_pattern);
00206     else if(start_plane >64 && start_plane < 129)
00207       DrawFourPlanes(detector[3][pick_led],detector[3][pick_led],start_plane,led_pattern);
00208  //else if(start_plane >129 && start_plane < 193)
00209       //DrawFourPlanes(detector[5][pick_led],detector[5][pick_led],start_plane,led_pattern);
00210       // else if(start_plane >192 && start_plane < 256)
00211       //DrawFourPlanes(detector[7][pick_led],detector[7][pick_led],start_plane,led_pattern);
00212 
00213  c1->Update();
00214  c2->Update();
00215 
00216  char c;
00217  cout<<"Print?"<<endl;
00218  cin >>c;
00219  if (c=='p') {
00220    char fname[100];
00221    sprintf(fname,"plane%d_led%d_even.eps",start_plane,pick_led);
00222    c1->Print(fname);
00223    sprintf(fname,"plane%d_led%d_odd.eps",start_plane,pick_led);
00224    c2->Print(fname);
00225  }
00226 
00227 }

void DrawFourPlanes ( Detector detector_one,
Detector detector_two,
Int_t  start_plane,
Int_t  led 
)

Definition at line 233 of file Gryfindor_phil.cxx.

References boxes, Detector::GetPixelMean(), Detector::GetPixelRMS(), pixels, plane_lims, plane_one_east, plane_one_west, plane_two_east, plane_two_west, pmts, and strip_starts.

00233                                                                                                 {
00234   TVirtualPad *pixels[4][3][16];
00235   TVirtualPad *pmts[4][3];
00236   TVirtualPad *boxes[4];
00237 
00238   TLatex l;
00239   l.SetTextAlign(22);
00240   l.SetTextSize(0.04);
00241   char buffer[100];
00242   sprintf(buffer,"   LED %d",led);
00243   l.DrawLatex(0.5,0.22,buffer);
00244   sprintf(buffer,"   Planes %d - %d",start_plane,start_plane+3);
00245   l.DrawLatex(0.5,0.72,buffer);
00246   l.SetTextSize(0.025);
00247   l.DrawLatex(0.05,0.1,"W, odd");
00248   l.DrawLatex(0.05,0.35,"W, even");
00249   l.DrawLatex(0.05,0.6,"E, odd");
00250   l.DrawLatex(0.05,0.85,"E, even");
00251   boxes[3] = new TPad("box_0","box_0",0.10,0.01,0.99,0.20,19);
00252   boxes[2] = new TPad("box_0","box_0",0.10,0.26,0.99,0.45,19);
00253   boxes[1] = new TPad("box_0","box_0",0.10,0.51,0.99,0.70,19);
00254   boxes[0] = new TPad("box_0","box_0",0.10,0.76,0.99,0.95,19);
00255   
00256   boxes[0]->Draw();
00257   boxes[1]->Draw();
00258   boxes[2]->Draw();
00259   boxes[3]->Draw();
00260   
00261   boxes[0]->Divide(3,1);
00262   boxes[1]->Divide(3,1);
00263   boxes[2]->Divide(3,1);
00264   boxes[3]->Divide(3,1);
00265   
00266   for(Int_t i=0;i<4;i++){
00267     for(Int_t j=0;j<3;j++){
00268       boxes[i]->cd(j+1);
00269       pmts[i][j] = gPad;
00270       pmts[i][j]->Divide(4,4);
00271       for(Int_t k=0;k<16;k++){
00272         pmts[i][j]->cd(k+1);
00273         int pix = (k/4)*4 + (4-k%4)-1;
00274         //cout<<k<<" "<<pix<<endl;
00275         pixels[i][j][pix]=gPad;
00276       }
00277     }
00278   }
00279 
00280   for(Int_t strip = strip_starts[led-1];strip < (strip_starts[led-1]+plane_lims[led-1]);strip++){
00281     
00282     pixels[0][(plane_one_east[strip]-1)/16][(plane_one_east[strip]-1)%16]->SetFillColor(4);
00283     pixels[1][(plane_one_east[strip]-1)/16][(plane_one_east[strip]-1)%16]->SetFillColor(4);
00284     pixels[2][(plane_one_west[strip]-1)/16][(plane_one_west[strip]-1)%16]->SetFillColor(4);
00285     pixels[3][(plane_one_west[strip]-1)/16][(plane_one_west[strip]-1)%16]->SetFillColor(4);
00286   }
00287   int switched_led;
00288   switched_led = (led-1)-1;
00289   if(switched_led <0) switched_led =19;
00290   
00291   for(Int_t strip = strip_starts[switched_led];strip < (strip_starts[switched_led]+plane_lims[switched_led]);strip++){
00292     pixels[0][(plane_two_east[strip]-1)/16][(plane_two_east[strip]-1)%16]->SetFillColor(3);
00293     pixels[1][(plane_two_east[strip]-1)/16][(plane_two_east[strip]-1)%16]->SetFillColor(3);
00294     pixels[2][(plane_two_west[strip]-1)/16][(plane_two_west[strip]-1)%16]->SetFillColor(3);
00295     pixels[3][(plane_two_west[strip]-1)/16][(plane_two_west[strip]-1)%16]->SetFillColor(3);
00296   }
00297   
00298   
00299   Double_t mean;
00300 
00301   TEllipse *markers[4][3][16]={0};
00302 
00303   for(Int_t plane=0;plane<4;plane++){
00304     for(Int_t pmt = 0; pmt < 3; pmt++){
00305       for(Int_t pixel =0; pixel<16; pixel++){
00306         mean =  detector_one->GetPixelMean(0,start_plane+plane,pmt,pixel);
00307         if(mean > 0){
00308           if(plane%2!=0){
00309             pixels[0][pmt][pixel]->cd();
00310             markers[0][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00311             markers[0][pmt][pixel]->SetFillColor(1);
00312             markers[0][pmt][pixel]->Draw();
00313           }
00314           else{
00315             pixels[1][pmt][pixel]->cd();
00316             markers[1][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00317             markers[1][pmt][pixel]->SetFillColor(1);
00318             markers[1][pmt][pixel]->Draw();
00319           }
00320         }
00321       }
00322     }
00323   }
00324 
00325 
00326   Double_t npe;
00327   Double_t rms;
00328 
00329   for(Int_t plane=0;plane<4;plane++){
00330     for(Int_t pmt = 0; pmt < 3; pmt++){
00331       for(Int_t pixel =0; pixel<16; pixel++){
00332         mean =  detector_two->GetPixelMean(1,start_plane+plane,pmt,pixel);
00333         rms =  detector_two->GetPixelRMS(1,start_plane+plane,pmt,pixel);
00334         if(mean > 0){
00335           //      npe = pow(rms/mean,2);
00336           if(plane%2!=0){
00337             pixels[2][pmt][pixel]->cd();
00338             markers[2][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00339             markers[2][pmt][pixel]->SetFillColor(1);
00340             markers[2][pmt][pixel]->Draw();
00341           }
00342           else{
00343             pixels[3][pmt][pixel]->cd();
00344             markers[3][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00345             markers[3][pmt][pixel]->SetFillColor(1);
00346             markers[3][pmt][pixel]->Draw();
00347           }
00348         }
00349       }
00350     }
00351   }
00352 };

int GetPixel ( int  channel  ) 
Int_t main ( Int_t  argv,
char **  argc 
)

Definition at line 40 of file Gryfindor_phil.cxx.

References Draw(), DrawFourPlanes(), infile, and Detector::SetStats().

00041 {
00042   TApplication *theApp=new TApplication("App", &argv, argc);
00043   
00044   TFile *infile = new TFile("drift.root");
00045 
00046   TTree *li_tree = (TTree*) infile->Get("li_tree");
00047 
00048   Int_t calibpoint;
00049   Int_t pulserbox;
00050   Int_t led;
00051   Int_t pulse_height;
00052   Int_t pulse_width;
00053   Int_t period;
00054   Int_t calibtype;
00055   Int_t timestamp;
00056   Int_t pulses;
00057 
00058   Int_t crate;
00059   Int_t chAdd;
00060   Int_t vaarc;
00061   Int_t vmm;
00062   Int_t vaadc;
00063   
00064   Int_t plane;
00065   Int_t chip;
00066   Int_t channel;
00067  
00068   Double_t mean;
00069   Double_t rms;
00070 
00071   Int_t no_entries;
00072 
00073   li_tree->SetBranchAddress("calibpoint",&calibpoint);
00074   li_tree->SetBranchAddress("pulserbox",&pulserbox);
00075   li_tree->SetBranchAddress("led",&led);
00076   li_tree->SetBranchAddress("pulse_height",&pulse_height);
00077   li_tree->SetBranchAddress("pulse_width",&pulse_width);
00078   li_tree->SetBranchAddress("period",&period);
00079   li_tree->SetBranchAddress("calibtype",&calibtype);
00080   li_tree->SetBranchAddress("pulses",&pulses);
00081   li_tree->SetBranchAddress("timestamp",&timestamp);
00082 
00083   li_tree->SetBranchAddress("crate",&crate);
00084   li_tree->SetBranchAddress("chAdd",&chAdd);
00085   li_tree->SetBranchAddress("vaarc",&vaarc);
00086   li_tree->SetBranchAddress("vmm",&vmm);
00087   li_tree->SetBranchAddress("vaadc",&vaadc);
00088 
00089   li_tree->SetBranchAddress("plane",&plane);
00090   li_tree->SetBranchAddress("chip",&chip);
00091   li_tree->SetBranchAddress("channel",&channel);
00092 
00093   li_tree->SetBranchAddress("no_entries",&no_entries);
00094   li_tree->SetBranchAddress("mean",&mean);
00095   li_tree->SetBranchAddress("rms",&rms);
00096 
00097   Stat_t no_events = li_tree->GetEntries();
00099   
00100   Detector *detector[10][21]={0};
00101   Double_t progress_percentage;
00102   progress_percentage=0;
00103  
00104   cout << endl;
00105   cout <<  " *************************************** " << endl;
00106   cout <<  " ** Initialised objects to hold data  ** " << endl;
00107   cout <<  " **         Reading in data           ** " << endl;
00108   cout <<  " **  0%------------------------100%   ** " << endl;
00109   cout <<  " **  ";
00110   
00111   for(Int_t index = 0; index<no_events;index++){
00112     li_tree->GetEntry(index);
00113     //cout<<pulserbox<<" "<<led<<endl;    
00114     if(detector[pulserbox][21-led] ==0)
00115       detector[pulserbox][21-led] = new Detector();
00116     
00117     if(plane > 0)
00118       detector[pulserbox][21-led]->SetStats(crate%2,plane,chip,channel,no_entries,mean,rms);
00119     if( (index/no_events) > (progress_percentage+0.1) ){
00120       cout << "***";
00121       progress_percentage = index/no_events;
00122     }
00123   }
00124   cout << "***";
00125   cout <<  "   ** " << endl;
00126   cout <<  " *************************************** " << endl;
00127   cout <<  endl;
00128 
00130   // Now posses objects with all channel  //
00131   // pulsing details for all channels     //
00133 
00134 
00135   
00136   Int_t pick_led;
00137   Int_t led_pattern;
00138   Int_t start_plane;
00139   pick_led =1;
00140   int pulser_pick=0;
00141   cout << " Which 4 plane number? (ie 1,5,9,13...) : " ;
00142   cin >> start_plane;
00143 
00144   for (;;start_plane+=4) {
00145  
00146   for (int led=1;led<21;led++) {
00147     pick_led = led;
00148     led_pattern = led;
00149     Draw(detector,start_plane,pick_led,led_pattern);
00150   }
00151   
00152   
00153 #if 0  
00154   while(pick_led > 0){
00155     cout << " Which led No      : ";
00156     cin >> pick_led;
00157     cout << " Which led pattern : ";
00158     cin >> led_pattern;
00159 
00160     Draw(detector,start_plane,pick_led,led_pattern);
00161 
00162     if(start_plane < 65)
00163       DrawFourPlanes(detector[0][pick_led],detector[0][pick_led],start_plane,led_pattern);
00164     else if(start_plane >64 && start_plane < 129)
00165       DrawFourPlanes(detector[2][pick_led],detector[2][pick_led],start_plane,led_pattern);
00166     else if(start_plane >129 && start_plane < 193)
00167       DrawFourPlanes(detector[4][pick_led],detector[4][pick_led],start_plane,led_pattern);
00168     else if(start_plane >192 && start_plane < 256)
00169       DrawFourPlanes(detector[6][pick_led],detector[6][pick_led],start_plane,led_pattern);
00170 
00171 
00172   }
00173 #endif  
00174   
00175   
00176   }
00177   
00178 
00179     theApp->Run(kTRUE);
00180 }

int SanityCheck ( int  plane,
int  chip,
int  channel 
)

Definition at line 356 of file Gryfindor_phil.cxx.

00356                                                 {
00357    if(plane < 1 || plane > 248)
00358     return 0;
00359   if(chip < 0 || chip > 2)
00360     return 0;
00361   if(channel <0 || channel > 22)
00362     return 0;
00363   return 1;
00364 }

TROOT simple ( "stuff"  ,
"stuff"   
)

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1