00001
00002
00003 #include <iostream.h>
00004 #include <fstream.h>
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 #include <string.h>
00008
00009 #include "TFile.h"
00010 #include "TROOT.h"
00011 #include "TH1.h"
00012 #include "TF1.h"
00013 #include "TH2.h"
00014 #include "TF2.h"
00015 #include "TH3.h"
00016
00017 #include "TStyle.h"
00018
00019 #include "TApplication.h"
00020 #include "TCanvas.h"
00021 #include "TMath.h"
00022 #include "TMinuit.h"
00023 #include "TNtuple.h"
00024 #include "TLatex.h"
00025 #include "TLine.h"
00026 #include "TFrame.h"
00027 #include "TEllipse.h"
00028
00029
00030 #include "detector/detector.h"
00031
00032 TROOT simple("stuff","stuff");
00033
00034 void DrawFourPlanes(Detector *detector_one,Detector *detector_two, Int_t start_plane,Int_t led);
00035 int SanityCheck(int plane,int chip,int channel);
00036 int GetPixel(int channel);
00037
00038 Int_t main(Int_t argv, char **argc)
00039 {
00040 TApplication *theApp=new TApplication("App", &argv, argc);
00041
00042 TFile *infile = new TFile("drift.root");
00043
00044 TTree *li_tree = (TTree*) infile->Get("li_tree");
00045
00046 Int_t calibpoint;
00047 Int_t pulserbox;
00048 Int_t led;
00049 Int_t pulse_height;
00050 Int_t pulse_width;
00051 Int_t period;
00052 Int_t calibtype;
00053 Int_t timestamp;
00054 Int_t pulses;
00055
00056 Int_t crate;
00057 Int_t chAdd;
00058 Int_t vaarc;
00059 Int_t vmm;
00060 Int_t vaadc;
00061
00062 Int_t plane;
00063 Int_t chip;
00064 Int_t channel;
00065
00066 Double_t mean;
00067 Double_t rms;
00068
00069 Int_t no_entries;
00070
00071 li_tree->SetBranchAddress("calibpoint",&calibpoint);
00072 li_tree->SetBranchAddress("pulserbox",&pulserbox);
00073 li_tree->SetBranchAddress("led",&led);
00074 li_tree->SetBranchAddress("pulse_height",&pulse_height);
00075 li_tree->SetBranchAddress("pulse_width",&pulse_width);
00076 li_tree->SetBranchAddress("period",&period);
00077 li_tree->SetBranchAddress("calibtype",&calibtype);
00078 li_tree->SetBranchAddress("pulses",&pulses);
00079 li_tree->SetBranchAddress("timestamp",×tamp);
00080
00081 li_tree->SetBranchAddress("crate",&crate);
00082 li_tree->SetBranchAddress("chAdd",&chAdd);
00083 li_tree->SetBranchAddress("vaarc",&vaarc);
00084 li_tree->SetBranchAddress("vmm",&vmm);
00085 li_tree->SetBranchAddress("vaadc",&vaadc);
00086
00087 li_tree->SetBranchAddress("plane",&plane);
00088 li_tree->SetBranchAddress("chip",&chip);
00089 li_tree->SetBranchAddress("channel",&channel);
00090
00091 li_tree->SetBranchAddress("no_entries",&no_entries);
00092 li_tree->SetBranchAddress("mean",&mean);
00093 li_tree->SetBranchAddress("rms",&rms);
00094
00095 Stat_t no_events = li_tree->GetEntries();
00097
00098 Detector *detector[4][21]={0};
00099 Double_t progress_percentage;
00100 progress_percentage=0;
00101
00102 cout << endl;
00103 cout << " *************************************** " << endl;
00104 cout << " ** Initialised objects to hold data ** " << endl;
00105 cout << " ** Reading in data ** " << endl;
00106 cout << " ** 0%------------------------100% ** " << endl;
00107 cout << " ** ";
00108
00109 for(Int_t index = 0; index<no_events;index++){
00110 li_tree->GetEntry(index);
00111
00112 if(detector[pulserbox][21-led] ==0)
00113 detector[pulserbox][21-led] = new Detector();
00114
00115 if(plane > 0)
00116 detector[pulserbox][21-led]->SetStats(crate%2,plane,chip,channel,no_entries,mean,rms);
00117 if( (index/no_events) > (progress_percentage+0.1) ){
00118 cout << "***";
00119 progress_percentage = index/no_events;
00120 }
00121 }
00122 cout << "***";
00123 cout << " ** " << endl;
00124 cout << " *************************************** " << endl;
00125 cout << endl;
00126
00128
00129
00131
00132
00133 Int_t pick_led;
00134 Int_t led_pattern;
00135 Int_t start_plane;
00136 pick_led =1;
00137 int pulser_pick=0;
00138 cout << " Which 4 plane number? (ie 1,5,9,13...) : " ;
00139 cin >> start_plane;
00140
00141
00142
00143
00144 while(pick_led > 0){
00145 cout << " Which led No : ";
00146 cin >> pick_led;
00147 cout << " Which led pattern : ";
00148 cin >> led_pattern;
00149 if(start_plane < 65)
00150 DrawFourPlanes(detector[0][pick_led],detector[0][pick_led],start_plane,led_pattern);
00151 else if(start_plane >64 && start_plane < 129)
00152 DrawFourPlanes(detector[2][pick_led],detector[2][pick_led],start_plane,led_pattern);
00153 else if(start_plane >129 && start_plane < 193)
00154 DrawFourPlanes(detector[4][pick_led],detector[4][pick_led],start_plane,led_pattern);
00155 else if(start_plane >192 && start_plane < 256)
00156 DrawFourPlanes(detector[6][pick_led],detector[6][pick_led],start_plane,led_pattern);
00157 }
00158
00159
00160
00161
00162
00163
00164 theApp->Run(kTRUE);
00165 }
00166
00167
00168
00169
00170
00171 void DrawFourPlanes(Detector *detector_one,Detector *detector_two, Int_t start_plane, Int_t led){
00172 TCanvas *fourplanes = new TCanvas("fourplanes","fourplanes",0,0,600,750);
00173 TVirtualPad *pixels[4][3][16];
00174 TVirtualPad *pmts[4][3];
00175 TVirtualPad *boxes[4];
00176
00177 boxes[3] = new TPad("box_0","box_0",0.10,0.01,0.99,0.20,19);
00178 boxes[2] = new TPad("box_0","box_0",0.10,0.26,0.99,0.45,19);
00179 boxes[1] = new TPad("box_0","box_0",0.10,0.51,0.99,0.70,19);
00180 boxes[0] = new TPad("box_0","box_0",0.10,0.76,0.99,0.95,19);
00181
00182 boxes[0]->Draw();
00183 boxes[1]->Draw();
00184 boxes[2]->Draw();
00185 boxes[3]->Draw();
00186
00187 boxes[0]->Divide(3,1);
00188 boxes[1]->Divide(3,1);
00189 boxes[2]->Divide(3,1);
00190 boxes[3]->Divide(3,1);
00191
00192 for(Int_t i=0;i<4;i++){
00193 for(Int_t j=0;j<3;j++){
00194 boxes[i]->cd(j+1);
00195 pmts[i][j] = gPad;
00196 pmts[i][j]->Divide(4,4);
00197 for(Int_t k=0;k<16;k++){
00198 pmts[i][j]->cd(k+1);
00199 pixels[i][j][k]=gPad;
00200 }
00201 }
00202 }
00203
00204 for(Int_t strip = strip_starts[led-1];strip < (strip_starts[led-1]+plane_lims[led-1]);strip++){
00205
00206 pixels[0][(plane_one_east[strip]-1)/16][(plane_one_east[strip]-1)%16]->SetFillColor(4);
00207 pixels[1][(plane_one_east[strip]-1)/16][(plane_one_east[strip]-1)%16]->SetFillColor(4);
00208 pixels[2][(plane_one_west[strip]-1)/16][(plane_one_west[strip]-1)%16]->SetFillColor(4);
00209 pixels[3][(plane_one_west[strip]-1)/16][(plane_one_west[strip]-1)%16]->SetFillColor(4);
00210 }
00211 int switched_led;
00212 switched_led = (led-1)-1;
00213 if(switched_led <0) switched_led =19;
00214
00215 for(Int_t strip = strip_starts[switched_led];strip < (strip_starts[switched_led]+plane_lims[switched_led]);strip++){
00216 pixels[0][(plane_two_east[strip]-1)/16][(plane_two_east[strip]-1)%16]->SetFillColor(4);
00217 pixels[1][(plane_two_east[strip]-1)/16][(plane_two_east[strip]-1)%16]->SetFillColor(4);
00218 pixels[2][(plane_two_west[strip]-1)/16][(plane_two_west[strip]-1)%16]->SetFillColor(4);
00219 pixels[3][(plane_two_west[strip]-1)/16][(plane_two_west[strip]-1)%16]->SetFillColor(4);
00220 }
00221
00222
00223 Double_t mean;
00224
00225 TEllipse *markers[4][3][16]={0};
00226
00227 for(Int_t plane=0;plane<4;plane++){
00228 for(Int_t pmt = 0; pmt < 3; pmt++){
00229 for(Int_t pixel =0; pixel<16; pixel++){
00230 mean = detector_one->GetPixelMean(0,start_plane+plane,pmt,pixel);
00231 if(mean > 0){
00232 if(plane%2!=0){
00233 pixels[0][pmt][pixel]->cd();
00234 markers[0][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00235 markers[0][pmt][pixel]->SetFillColor(1);
00236 markers[0][pmt][pixel]->Draw();
00237 }
00238 else{
00239 pixels[1][pmt][pixel]->cd();
00240 markers[1][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00241 markers[1][pmt][pixel]->SetFillColor(1);
00242 markers[1][pmt][pixel]->Draw();
00243 }
00244 }
00245 }
00246 }
00247 }
00248
00249
00250 Double_t npe;
00251 Double_t rms;
00252
00253 for(Int_t plane=0;plane<4;plane++){
00254 for(Int_t pmt = 0; pmt < 3; pmt++){
00255 for(Int_t pixel =0; pixel<16; pixel++){
00256 mean = detector_two->GetPixelMean(1,start_plane+plane,pmt,pixel);
00257 rms = detector_two->GetPixelRMS(1,start_plane+plane,pmt,pixel);
00258 if(mean > 0){
00259
00260 if(plane%2!=0){
00261 pixels[2][pmt][pixel]->cd();
00262 markers[2][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00263 markers[2][pmt][pixel]->SetFillColor(1);
00264 markers[2][pmt][pixel]->Draw();
00265 }
00266 else{
00267 pixels[3][pmt][pixel]->cd();
00268 markers[3][pmt][pixel] = new TEllipse(0.5,0.5,((mean/16000.0)/2.0),((mean/16000.0)/2.0));
00269 markers[3][pmt][pixel]->SetFillColor(1);
00270 markers[3][pmt][pixel]->Draw();
00271 }
00272 }
00273 }
00274 }
00275 }
00276 fourplanes->Update();
00277 };
00278
00279
00280
00281 int SanityCheck(int plane,int chip, int channel){
00282 if(plane < 1 || plane > 248)
00283 return 0;
00284 if(chip < 0 || chip > 2)
00285 return 0;
00286 if(channel <0 || channel > 22)
00287 return 0;
00288 return 1;
00289 }
00290