ARA ROOT Test BEd Software

AraDisplay/AraCanvasMaker.cxx

00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include <fstream>
00009 #include <iostream>
00010 #include "AraCanvasMaker.h"
00011 #include "AraGeomTool.h"
00012 #include "UsefulAraEvent.h"
00013 #include "AraWaveformGraph.h"
00014 #include "AraEventCorrelator.h"
00015 #include "AraFFTGraph.h"
00016 #include "araDefines.h"
00017 
00018 
00019 #include "TString.h"
00020 #include "TObjArray.h"
00021 #include "TObjString.h"
00022 #include "TVector3.h"
00023 #include "TROOT.h"
00024 #include "TPaveText.h"
00025 #include "TPad.h"
00026 #include "TText.h"
00027 #include "TLatex.h"
00028 #include "TGraph.h"
00029 #include "TStyle.h"
00030 #include "TCanvas.h"
00031 #include "TAxis.h"
00032 #include "TH1.h"
00033 #include "TH2.h"
00034 #include "TList.h"
00035 #include "TFile.h"
00036 #include "TObject.h"
00037 #include "TTimeStamp.h"
00038 #include "TGeoManager.h"
00039 #include "TGeoVolume.h"
00040 #include "TView3D.h"
00041 
00042 #include "FFTtools.h"
00043 
00044 
00045 AraCanvasMaker*  AraCanvasMaker::fgInstance = 0;
00046 AraGeomTool *fACMGeomTool=0;
00047 
00048 
00049 
00050 
00051 AraWaveformGraph *grElec[NUM_DIGITIZED_CHANNELS]={0}; 
00052 AraWaveformGraph *grElecFiltered[NUM_DIGITIZED_CHANNELS]={0};
00053 AraWaveformGraph *grElecHilbert[NUM_DIGITIZED_CHANNELS]={0};
00054 AraFFTGraph *grElecFFT[NUM_DIGITIZED_CHANNELS]={0};
00055 AraFFTGraph *grElecAveragedFFT[NUM_DIGITIZED_CHANNELS]={0};
00056 
00057 AraWaveformGraph *grRFChan[RFCHANS_PER_STATION]={0};
00058 AraWaveformGraph *grRFChanFiltered[RFCHANS_PER_STATION]={0};
00059 AraWaveformGraph *grRFChanHilbert[RFCHANS_PER_STATION]={0};
00060 AraFFTGraph *grRFChanFFT[RFCHANS_PER_STATION]={0};
00061 AraFFTGraph *grRFChanAveragedFFT[RFCHANS_PER_STATION]={0};
00062 
00063 
00064 TH1D *AraCanvasMaker::getFFTHisto(int ant)
00065 {
00066   if(ant<0 || ant>=RFCHANS_PER_STATION) return NULL;
00067   if(grRFChan[ant])
00068     return grRFChan[ant]->getFFTHisto();
00069     return NULL;
00070 
00071 }
00072 
00073 AraCanvasMaker::AraCanvasMaker(AraCalType::AraCalType_t calType)
00074 {
00075   //Default constructor
00076   fACMGeomTool=AraGeomTool::Instance();
00077   fNumAntsInMap=4;
00078   fWebPlotterMode=0;
00079   fPassBandFilter=0;
00080   fNotchFilter=0;
00081   fLowPassEdge=200;
00082   fHighPassEdge=1200;
00083   fLowNotchEdge=235;
00084   fHighNotchEdge=500;
00085   fMinVoltLimit=-60;
00086   fMaxVoltLimit=60;
00087   fPhiMax=0;
00088   fMinClockVoltLimit=-200;
00089   fMaxClockVoltLimit=200;
00090   fAutoScale=1;
00091   fMinTimeLimit=0;
00092   fMaxTimeLimit=250;
00093   if(AraCalType::hasCableDelays(calType)) {
00094     fMinTimeLimit=-200;
00095     fMaxTimeLimit=150;
00096   }
00097   fMinPowerLimit=-60;
00098   fMaxPowerLimit=60;
00099   fMinFreqLimit=0;
00100   fMaxFreqLimit=1200;
00101   fWaveformOption=AraDisplayFormatOption::kWaveform;
00102   fRedoEventCanvas=0;
00103   //fRedoSurfCanvas=0;
00104   fLastWaveformFormat=AraDisplayFormatOption::kWaveform;
00105   fNewEvent=1;
00106   fCalType=calType;
00107   fCorType=AraCorrelatorType::kSphericalDist40;
00108   fgInstance=this;
00109   memset(grElec,0,sizeof(AraWaveformGraph*)*NUM_DIGITIZED_CHANNELS);
00110   memset(grElecFiltered,0,sizeof(AraWaveformGraph*)*NUM_DIGITIZED_CHANNELS);
00111   memset(grElecHilbert,0,sizeof(AraWaveformGraph*)*NUM_DIGITIZED_CHANNELS);
00112   memset(grElecFFT,0,sizeof(AraFFTGraph*)*NUM_DIGITIZED_CHANNELS);
00113   memset(grElecAveragedFFT,0,sizeof(AraFFTGraph*)*NUM_DIGITIZED_CHANNELS);
00114 
00115   memset(grRFChan,0,sizeof(AraWaveformGraph*)*RFCHANS_PER_STATION);
00116   memset(grRFChanFiltered,0,sizeof(AraWaveformGraph*)*RFCHANS_PER_STATION);
00117   memset(grRFChanHilbert,0,sizeof(AraWaveformGraph*)*RFCHANS_PER_STATION);
00118   memset(grRFChanFFT,0,sizeof(AraFFTGraph*)*RFCHANS_PER_STATION);
00119   memset(grRFChanAveragedFFT,0,sizeof(AraFFTGraph*)*RFCHANS_PER_STATION);  
00120   switch(fCalType) {
00121   case AraCalType::kNoCalib:
00122     fMaxVoltLimit=3000;
00123     fMinVoltLimit=1000;
00124   case AraCalType::kJustUnwrap:
00125     fMinTimeLimit=0;
00126     fMaxTimeLimit=260;
00127     break;
00128   default:
00129     break;
00130   }
00131 
00132 
00133 }
00134 
00135 AraCanvasMaker::~AraCanvasMaker()
00136 {
00137    //Default destructor
00138 }
00139 
00140 
00141 
00142 //______________________________________________________________________________
00143 AraCanvasMaker*  AraCanvasMaker::Instance()
00144 {
00145    //static function
00146    return (fgInstance) ? (AraCanvasMaker*) fgInstance : new AraCanvasMaker();
00147 }
00148 
00149 
00150 TPad *AraCanvasMaker::getEventInfoCanvas(UsefulAraEvent *evPtr,  TPad *useCan, Int_t runNumber)
00151 {
00152    static UInt_t lastEventNumber=0;
00153    static TPaveText *leftPave=0;
00154    static TPaveText *midLeftPave=0;
00155    static TPaveText *midRightPave=0;
00156    static TPaveText *rightPave=0;
00157 
00158 
00159    if(!fACMGeomTool)
00160       fACMGeomTool=AraGeomTool::Instance();
00161    char textLabel[180];
00162    TPad *topPad;
00163    if(!useCan) {
00164       topPad = new TPad("padEventInfo","padEventInfo",0.2,0.9,0.8,1);
00165       topPad->Draw();
00166    }
00167    else {
00168       topPad=useCan;
00169    } 
00170    if(1) {
00171      fNewEvent=1;
00172      topPad->Clear();
00173      topPad->SetTopMargin(0.05);
00174      topPad->Divide(4,1);
00175      topPad->cd(1);
00176      if(leftPave) delete leftPave;
00177      leftPave = new TPaveText(0,0.1,1,0.9);
00178      leftPave->SetName("leftPave");
00179      leftPave->SetBorderSize(0);
00180      leftPave->SetFillColor(0);
00181      leftPave->SetTextAlign(13);
00182      if(runNumber) {
00183        sprintf(textLabel,"Run: %d",runNumber);
00184        TText *runText = leftPave->AddText(textLabel);
00185        runText->SetTextColor(50);
00186      }
00187      sprintf(textLabel,"Event: %d",evPtr->head.eventNumber);
00188      TText *eventText = leftPave->AddText(textLabel);
00189      eventText->SetTextColor(50);
00190      leftPave->Draw();
00191 
00192 
00193      topPad->cd(2);
00194      gPad->SetRightMargin(0);
00195      gPad->SetLeftMargin(0);
00196      if(midLeftPave) delete midLeftPave;
00197      midLeftPave = new TPaveText(0,0.1,0.99,0.9);
00198      midLeftPave->SetName("midLeftPave");
00199      midLeftPave->SetBorderSize(0);
00200      midLeftPave->SetTextAlign(13);
00201      TTimeStamp trigTime((time_t)evPtr->head.unixTime,(Int_t)1000*evPtr->head.unixTimeUs);
00202      sprintf(textLabel,"Time: %s",trigTime.AsString("s"));
00203      TText *timeText = midLeftPave->AddText(textLabel);
00204      timeText->SetTextColor(1);
00205      sprintf(textLabel,"Sub: %f",(trigTime.GetNanoSec()/1e9));
00206      TText *timeText2 = midLeftPave->AddText(textLabel);
00207      timeText2->SetTextColor(1);
00208      midLeftPave->Draw();
00209      //     midLeftPave->Modified();
00210      gPad->Modified();
00211      gPad->Update();
00212      
00213      topPad->cd(3);
00214      if(midRightPave) delete midRightPave;
00215      midRightPave = new TPaveText(0,0.1,1,0.95);
00216      midRightPave->SetBorderSize(0);
00217      midRightPave->SetTextAlign(13);
00218      sprintf(textLabel,"PPS Num %d",
00219              evPtr->trig.ppsNum);
00220      midRightPave->AddText(textLabel);
00221      sprintf(textLabel,"Trig Type %d%d%d",
00222              evPtr->trig.isInTrigType(2),
00223              evPtr->trig.isInTrigType(1),
00224              evPtr->trig.isInTrigType(0));
00225      midRightPave->AddText(textLabel);
00226      sprintf(textLabel,"Pattern %d%d%d%d%d%d%d%d",
00227              evPtr->trig.isInTrigPattern(7),
00228              evPtr->trig.isInTrigPattern(6),
00229              evPtr->trig.isInTrigPattern(5),
00230              evPtr->trig.isInTrigPattern(4),
00231              evPtr->trig.isInTrigPattern(3),
00232              evPtr->trig.isInTrigPattern(2),
00233              evPtr->trig.isInTrigPattern(1),
00234              evPtr->trig.isInTrigPattern(0));
00235      midRightPave->AddText(textLabel);
00236      midRightPave->Draw();
00237 
00238      
00239      topPad->cd(4);
00240      if(rightPave) delete rightPave;
00241      rightPave = new TPaveText(0,0.1,1,0.95);
00242      rightPave->SetBorderSize(0);
00243      rightPave->SetTextAlign(13); 
00244      rightPave->Draw();
00245      topPad->Update();
00246      topPad->Modified();
00247                
00248      lastEventNumber=evPtr->head.eventNumber;
00249    }
00250       
00251    return topPad;
00252 }
00253 
00254 
00255 TPad *AraCanvasMaker::quickGetEventViewerCanvasForWebPlottter(UsefulAraEvent *evPtr,  TPad *useCan)
00256 {
00257   TPad *retCan=0;
00258   fWebPlotterMode=1;
00259   //  static Int_t lastEventView=0;
00260 
00261   if(fAutoScale) {
00262     fMinVoltLimit=1e9;
00263     fMaxVoltLimit=-1e9;
00264     fMinClockVoltLimit=1e9;
00265     fMaxClockVoltLimit=-1e9;
00266   }
00267 
00268 
00269 
00270   for(int chan=0;chan<NUM_DIGITIZED_CHANNELS;chan++) {
00271     if(grElec[chan]) delete grElec[chan];
00272     if(grElecFFT[chan]) delete grElecFFT[chan];
00273     if(grElecHilbert[chan]) delete grElecHilbert[chan];
00274     grElec[chan]=0;
00275     grElecFFT[chan]=0;
00276     grElecHilbert[chan]=0;
00277     //    if(grElecAveragedFFT[chan]) delete grElecAveragedFFT[chan];
00278     
00279     TGraph *grTemp = evPtr->getGraphFromElecChan(chan);
00280     grElec[chan] = new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00281     grElec[chan]->setElecChan(chan);
00282       //      std::cout << evPtr->head.eventNumber << "\n";
00283       //      std::cout << surf << "\t" << chan << "\t" 
00284       //                << grElec[chan]->GetRMS(2) << std::endl;
00285     
00286     if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT) {
00287       TGraph *grTempFFT = grElec[chan]->getFFT();
00288       grElecFFT[chan]=new AraFFTGraph(grTempFFT->GetN(),
00289                                       grTempFFT->GetX(),
00290                                       grTempFFT->GetY());
00291       if(!grElecAveragedFFT[chan]) {
00292         grElecAveragedFFT[chan]=new AraFFTGraph(grTempFFT->GetN(),
00293                                       grTempFFT->GetX(),
00294                                       grTempFFT->GetY());
00295       }
00296       else {
00297         grElecAveragedFFT[chan]->AddFFT(grElecFFT[chan]);
00298       }
00299       delete grTempFFT;      
00300     }
00301 
00302 
00303     if(fAutoScale) {
00304       Int_t numPoints=grTemp->GetN();
00305       Double_t *yVals=grTemp->GetY();
00306         
00307       for(int i=0;i<numPoints;i++) {    
00308         if(yVals[i]<fMinVoltLimit)
00309           fMinVoltLimit=yVals[i];
00310         if(yVals[i]>fMaxVoltLimit)
00311           fMaxVoltLimit=yVals[i];       
00312       }      
00313     }
00314 
00315     delete grTemp;
00316   }
00317 
00318   
00319 
00320   for(int rfchan=0;rfchan<RFCHANS_PER_STATION;rfchan++) {
00321     if(grRFChan[rfchan]) delete grRFChan[rfchan];
00322     if(grRFChanFFT[rfchan]) delete grRFChanFFT[rfchan];
00323     if(grRFChanHilbert[rfchan]) delete grRFChanHilbert[rfchan];
00324     grRFChan[rfchan]=0;
00325     grRFChanFFT[rfchan]=0;
00326     grRFChanHilbert[rfchan]=0;
00327     //    if(grRFChanAveragedFFT[chan]) delete grRFChanAveragedFFT[chan];
00328     //Need to work out how to do this
00329     TGraph *grTemp = evPtr->getGraphFromRFChan(rfchan);
00330     grRFChan[rfchan] = new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00331     grRFChan[rfchan]->setRFChan(rfchan);
00332       //      std::cout << evPtr->head.eventNumber << "\n";
00333       //      std::cout << surf << "\t" << chan << "\t" 
00334       //                << grElec[chan]->GetRMS(2) << std::endl;
00335     
00336  
00337     if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT) {
00338       TGraph *grTempFFT = grRFChan[rfchan]->getFFT();
00339       grRFChanFFT[rfchan]=new AraFFTGraph(grTempFFT->GetN(),
00340                                       grTempFFT->GetX(),
00341                                       grTempFFT->GetY());
00342       if(!grRFChanAveragedFFT[rfchan]) {
00343         grRFChanAveragedFFT[rfchan]=new AraFFTGraph(grTempFFT->GetN(),
00344                                       grTempFFT->GetX(),
00345                                       grTempFFT->GetY());
00346       }
00347       else {
00348         grRFChanAveragedFFT[rfchan]->AddFFT(grRFChanFFT[rfchan]);
00349       }
00350       delete grTempFFT;      
00351     }
00352 
00353 
00354 
00355     if(fAutoScale) {
00356       Int_t numPoints=grTemp->GetN();
00357       Double_t *yVals=grTemp->GetY();
00358         
00359       for(int i=0;i<numPoints;i++) {    
00360         if(yVals[i]<fMinVoltLimit)
00361           fMinVoltLimit=yVals[i];
00362         if(yVals[i]>fMaxVoltLimit)
00363           fMaxVoltLimit=yVals[i];       
00364       }      
00365     }
00366     delete grTemp;
00367   }
00368 
00369 
00370   if(fAutoScale) {
00371     if(fCalType!=AraCalType::kNoCalib && fCalType!=AraCalType::kJustUnwrap) {
00372       if(fMaxVoltLimit>-1*fMinVoltLimit) {
00373         fMinVoltLimit=-1*fMaxVoltLimit;
00374       }
00375       else {
00376         fMaxVoltLimit=-1*fMinVoltLimit;
00377       }
00378     }
00379   
00380 
00381    if(fMaxClockVoltLimit>-1*fMinClockVoltLimit) {
00382       fMinClockVoltLimit=-1*fMaxClockVoltLimit;
00383     }
00384     else {
00385       fMaxClockVoltLimit=-1*fMinClockVoltLimit;
00386     }
00387   }
00388     
00389 
00390   fRedoEventCanvas=0;
00391 
00392   retCan=AraCanvasMaker::getCanvasForWebPlotter(evPtr,useCan);
00393 
00394  
00395 
00396   return retCan;
00397 
00398 }
00399 
00400 TPad *AraCanvasMaker::getEventViewerCanvas(UsefulAraEvent *evPtr,
00401                                            TPad *useCan)
00402 {
00403   TPad *retCan=0;
00404 
00405   static UInt_t lastEventNumber=0;
00406 
00407   if(fAutoScale) {
00408     fMinVoltLimit=1e9;
00409     fMaxVoltLimit=-1e9;
00410     fMinClockVoltLimit=0;
00411     fMaxClockVoltLimit=0;
00412   }
00413 
00414 
00415 
00416   for(int chan=0;chan<NUM_DIGITIZED_CHANNELS;chan++) {
00417     if(grElec[chan]) delete grElec[chan];
00418     if(grElecFFT[chan]) delete grElecFFT[chan];
00419     if(grElecHilbert[chan]) delete grElecHilbert[chan];
00420     grElec[chan]=0;
00421     grElecFFT[chan]=0;
00422     grElecHilbert[chan]=0;
00423     
00424     TGraph *grTemp = evPtr->getGraphFromElecChan(chan);
00425     grElec[chan] = new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00426     grElec[chan]->setElecChan(chan);
00427 
00428 
00429     if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT) {
00430       TGraph *grTempFFT = grElec[chan]->getFFT();
00431       grElecFFT[chan]=new AraFFTGraph(grTempFFT->GetN(),
00432                                       grTempFFT->GetX(),
00433                                       grTempFFT->GetY());
00434       if(!grElecAveragedFFT[chan]) {
00435         grElecAveragedFFT[chan]=new AraFFTGraph(grTempFFT->GetN(),
00436                                       grTempFFT->GetX(),
00437                                       grTempFFT->GetY());
00438       }
00439       else {
00440         grElecAveragedFFT[chan]->AddFFT(grElecFFT[chan]);
00441       }
00442       delete grTempFFT;      
00443     }
00444 
00445 
00446     if(fAutoScale) {
00447       Int_t numPoints=grTemp->GetN();
00448       Double_t *yVals=grTemp->GetY();
00449         
00450       if(chan%9==8) {
00451         //Clock channel
00452         for(int i=0;i<numPoints;i++) {  
00453           if(yVals[i]<fMinClockVoltLimit)
00454             fMinClockVoltLimit=yVals[i];
00455           if(yVals[i]>fMaxClockVoltLimit)
00456             fMaxClockVoltLimit=yVals[i];        
00457         }      
00458       }
00459       else{
00460         for(int i=0;i<numPoints;i++) {  
00461           if(yVals[i]<fMinVoltLimit)
00462             fMinVoltLimit=yVals[i];
00463           if(yVals[i]>fMaxVoltLimit)
00464             fMaxVoltLimit=yVals[i];     
00465         }      
00466       }
00467     }
00468 
00469     delete grTemp;
00470   }
00471   //  std::cout << "Limits\t" << fMinVoltLimit << "\t" << fMaxVoltLimit << "\n";
00472 
00473 
00474   for(int rfchan=0;rfchan<RFCHANS_PER_STATION;rfchan++) {
00475     if(grRFChan[rfchan]) delete grRFChan[rfchan];
00476     if(grRFChanFFT[rfchan]) delete grRFChanFFT[rfchan];
00477     if(grRFChanHilbert[rfchan]) delete grRFChanHilbert[rfchan];
00478     grRFChan[rfchan]=0;
00479     grRFChanFFT[rfchan]=0;
00480     grRFChanHilbert[rfchan]=0;
00481     //Need to work out how to do this
00482     TGraph *grTemp = evPtr->getGraphFromRFChan(rfchan);
00483     grRFChan[rfchan] = new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00484     grRFChan[rfchan]->setRFChan(rfchan);
00485       //      std::cout << evPtr->head.eventNumber << "\n";
00486       //      std::cout << surf << "\t" << chan << "\t" 
00487       //                << grElec[chan]->GetRMS(2) << std::endl;
00488     
00489     if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT) {
00490       TGraph *grTempFFT = grRFChan[rfchan]->getFFT();
00491       grRFChanFFT[rfchan]=new AraFFTGraph(grTempFFT->GetN(),
00492                                       grTempFFT->GetX(),
00493                                       grTempFFT->GetY());
00494       if(!grRFChanAveragedFFT[rfchan]) {
00495         grRFChanAveragedFFT[rfchan]=new AraFFTGraph(grTempFFT->GetN(),
00496                                       grTempFFT->GetX(),
00497                                       grTempFFT->GetY());
00498       }
00499       else {
00500         grRFChanAveragedFFT[rfchan]->AddFFT(grRFChanFFT[rfchan]);
00501       }
00502       delete grTempFFT;      
00503     }
00504     if(fAutoScale) {
00505       Int_t numPoints=grTemp->GetN();
00506       Double_t *yVals=grTemp->GetY();
00507         
00508       for(int i=0;i<numPoints;i++) {    
00509         if(yVals[i]<fMinVoltLimit)
00510           fMinVoltLimit=yVals[i];
00511         if(yVals[i]>fMaxVoltLimit)
00512           fMaxVoltLimit=yVals[i];       
00513       }      
00514     }
00515     delete grTemp;
00516   }
00517 
00518   if(fAutoScale) {
00519 
00520     if(fCalType!=AraCalType::kNoCalib && fCalType!=AraCalType::kJustUnwrap) {
00521       if(fMaxVoltLimit>-1*fMinVoltLimit) {
00522         fMinVoltLimit=-1*fMaxVoltLimit;
00523       }
00524       else {
00525         fMaxVoltLimit=-1*fMinVoltLimit;
00526       }
00527       if(fMaxClockVoltLimit>-1*fMinClockVoltLimit) {
00528         fMinClockVoltLimit=-1*fMaxClockVoltLimit;
00529       }
00530       else {
00531         fMaxClockVoltLimit=-1*fMinClockVoltLimit;
00532       }
00533     }
00534   }
00535     
00536   //  std::cout << "Limits\t" << fMinVoltLimit << "\t" << fMaxVoltLimit << "\n";
00537 
00538 
00539   fRedoEventCanvas=0;
00540   fNewEvent=0;
00541 
00542   fRedoEventCanvas=0;
00543   if(fLastWaveformFormat!=fWaveformOption) fRedoEventCanvas=1;
00544 
00545   
00546   if(fCanvasLayout==AraDisplayCanvasLayoutOption::kElectronicsView) {
00547     retCan=AraCanvasMaker::getElectronicsCanvas(evPtr,useCan);
00548   }
00549   else if(fCanvasLayout==AraDisplayCanvasLayoutOption::kRFChanView) {
00550     retCan=AraCanvasMaker::getRFChannelCanvas(evPtr,useCan);
00551   }
00552   else if(fCanvasLayout==AraDisplayCanvasLayoutOption::kAntennaView) {
00553     retCan=AraCanvasMaker::getAntennaCanvas(evPtr,useCan);
00554   }
00555   else if(fCanvasLayout==AraDisplayCanvasLayoutOption::kIntMapView) {
00556     retCan=AraCanvasMaker::getIntMapCanvas(evPtr,useCan);
00557   }
00558 
00559 
00560   fLastWaveformFormat=fWaveformOption;
00561   fLastCanvasView=fCanvasLayout;
00562 
00563   return retCan;
00564 
00565 }
00566 
00567 
00568 TPad *AraCanvasMaker::getElectronicsCanvas(UsefulAraEvent *evPtr,TPad *useCan)
00569 {
00570   //  gStyle->SetTitleH(0.1);
00571   gStyle->SetOptTitle(0); 
00572   
00573   if(!fACMGeomTool)
00574     fACMGeomTool=AraGeomTool::Instance();
00575   char textLabel[180];
00576   char padName[180];
00577   TPad *canElec=0;
00578   TPad *plotPad=0;
00579   if(!useCan) {
00580     canElec = (TPad*) gROOT->FindObject("canElec");
00581     if(!canElec) {
00582       canElec = new TCanvas("canElec","canElec",1000,600);
00583     }
00584     canElec->Clear();
00585     canElec->SetTopMargin(0);
00586     TPaveText *leftPave = new TPaveText(0.05,0.92,0.95,0.98);
00587     leftPave->SetBorderSize(0);
00588     sprintf(textLabel," Event %d",evPtr->head.eventNumber);
00589     TText *eventText = leftPave->AddText(textLabel);
00590     eventText->SetTextColor(50);
00591     leftPave->Draw();
00592     plotPad = new TPad("canElecMain","canElecMain",0,0,1,0.9);
00593     plotPad->Draw();
00594   }
00595   else {
00596     plotPad=useCan;
00597   }
00598   plotPad->cd();
00599   setupElecPadWithFrames(plotPad);
00600 
00601 
00602 
00603   int count=0;
00604 
00605   // A
00606   // 1 3 5 7 9 
00607   // 2 4 6 8 
00608   // B
00609   // 1 3 5 7 9 
00610   // 2 4 6 8 
00611   // C
00612   // 1 3 5 7 9 
00613   // 2 4 6 8 
00614 
00615   for(int row=0;row<6;row++) {    
00616     for(int column=0;column<5;column++) {
00617       plotPad->cd();
00618       int labChip=(row/2); //0, 1 or 2
00619       int channel=(row%2)+2*column;
00620       int chanIndex=channel+9*labChip;
00621       if(channel>8) continue;
00622 
00623       sprintf(padName,"elecChanPad%d",column+row*5);
00624       //      std::cout << chanIndex << "\t" << labChip << "\t" << channel << "\t" << padName << "\n";
00625       TPad *paddy1 = (TPad*) plotPad->FindObject(padName);
00626       paddy1->SetEditable(kTRUE);
00627       deleteTGraphsFromElecPad(paddy1,chanIndex);
00628 
00629 
00630 
00631       if(fWaveformOption==AraDisplayFormatOption::kPowerSpectralDensity){
00632         if(!grElecFFT[chanIndex]) {
00633           TGraph *grTemp=grElec[chanIndex]->getFFT();
00634           grElecFFT[chanIndex]=new AraFFTGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00635           delete grTemp;
00636         }
00637         grElecFFT[chanIndex]->Draw("l");
00638       }
00639       else if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT){
00640         grElecAveragedFFT[chanIndex]->Draw("l");
00641       }
00642       else if(fWaveformOption==AraDisplayFormatOption::kHilbertEnvelope) {
00643         if(!grElecHilbert[chanIndex]) {
00644           TGraph *grTemp=grElec[chanIndex]->getHilbert();
00645           grElecHilbert[chanIndex]=new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00646           delete grTemp;
00647         }
00648         grElecHilbert[chanIndex]->Draw("l");
00649       }
00650       else if(fWaveformOption==AraDisplayFormatOption::kWaveform){
00651 
00652         grElec[chanIndex]->Draw("l");
00653         
00654         
00655         if(fAutoScale) {
00656           TList *listy = gPad->GetListOfPrimitives();
00657           for(int i=0;i<listy->GetSize();i++) {
00658             TObject *fred = listy->At(i);
00659             TH1F *tempHist = (TH1F*) fred;
00660             if(tempHist->InheritsFrom("TH1")) {
00661               if(channel<8) {
00662                 tempHist->GetYaxis()->SetRangeUser(fMinVoltLimit,fMaxVoltLimit);
00663               }
00664               else {
00665                 tempHist->GetYaxis()->SetRangeUser(fMinClockVoltLimit,fMaxClockVoltLimit);
00666               }
00667             }
00668           }
00669         }
00670       }
00671 
00672 
00673       count++;
00674       paddy1->SetEditable(kFALSE);
00675     }
00676   }
00677 
00678   if(!useCan)
00679     return canElec;
00680   else
00681     return plotPad;
00682   
00683 
00684 }
00685 
00686 
00687 TPad *AraCanvasMaker::getCanvasForWebPlotter(UsefulAraEvent *evPtr,
00688                                              TPad *useCan)
00689 {
00690   //  gStyle->SetTitleH(0.1);
00691   gStyle->SetOptTitle(0); 
00692 
00693   if(!fACMGeomTool)
00694     fACMGeomTool=AraGeomTool::Instance();
00695   char textLabel[180];
00696   char padName[180];
00697   TPad *canRFChan=0;
00698   TPad *plotPad=0;
00699   if(!useCan) {
00700     canRFChan = (TPad*) gROOT->FindObject("canRFChan");
00701     if(!canRFChan) {
00702       canRFChan = new TCanvas("canRFChan","canRFChan",1000,600);
00703     }
00704     canRFChan->Clear();
00705     canRFChan->SetTopMargin(0);
00706     TPaveText *leftPave = new TPaveText(0.05,0.92,0.95,0.98);
00707     leftPave->SetBorderSize(0);
00708     sprintf(textLabel,"Event %d",evPtr->head.eventNumber);
00709     TText *eventText = leftPave->AddText(textLabel);
00710     eventText->SetTextColor(50);
00711     leftPave->Draw();
00712     plotPad = new TPad("canRFChanMain","canRFChanMain",0,0,1,0.9);
00713     plotPad->Draw();
00714   }
00715   else {
00716     plotPad=useCan;
00717   }
00718   plotPad->cd();
00719   setupRFChanPadWithFrames(plotPad);
00720 
00721 
00722 
00723   int count=0;
00724 
00725 
00726   //  1  2  3  4
00727   //  5  6  7  8
00728   //  9 10 11 12
00729   // 13 14 15 16
00730 
00731   for(int column=0;column<4;column++) {
00732     for(int row=0;row<4;row++) {
00733       plotPad->cd();
00734       int rfChan=column+4*row;
00735 
00736       sprintf(padName,"rfChanPad%d",column+4*row);
00737       TPad *paddy1 = (TPad*) plotPad->FindObject(padName);
00738       paddy1->SetEditable(kTRUE);
00739       deleteTGraphsFromRFPad(paddy1,rfChan);
00740       paddy1->cd();
00741      
00742       grRFChan[rfChan]->Draw("l");
00743 
00744       if(fAutoScale) {
00745         TList *listy = gPad->GetListOfPrimitives();
00746         for(int i=0;i<listy->GetSize();i++) {
00747             TObject *fred = listy->At(i);
00748             TH1F *tempHist = (TH1F*) fred;
00749             if(tempHist->InheritsFrom("TH1")) {
00750               tempHist->GetYaxis()->SetRangeUser(fMinVoltLimit,fMaxVoltLimit);
00751 
00752             }
00753         }
00754       }
00755 
00756 
00757       count++;
00758       paddy1->SetEditable(kFALSE);
00759     }
00760   }
00761 
00762   if(!useCan)
00763     return canRFChan;
00764   else
00765     return plotPad;
00766   
00767 
00768 }
00769 
00770 TPad *AraCanvasMaker::getRFChannelCanvas(UsefulAraEvent *evPtr,
00771                                          TPad *useCan)
00772 {
00773    //  gStyle->SetTitleH(0.1);
00774   gStyle->SetOptTitle(0); 
00775 
00776   if(!fACMGeomTool)
00777     fACMGeomTool=AraGeomTool::Instance();
00778   char textLabel[180];
00779   char padName[180];
00780   TPad *canRFChan=0;
00781   TPad *plotPad=0;
00782   if(!useCan) {
00783     canRFChan = (TPad*) gROOT->FindObject("canRFChan");
00784     if(!canRFChan) {
00785       canRFChan = new TCanvas("canRFChan","canRFChan",1000,600);
00786     }
00787     canRFChan->Clear();
00788     canRFChan->SetTopMargin(0);
00789     TPaveText *leftPave = new TPaveText(0.05,0.92,0.95,0.98);
00790     leftPave->SetBorderSize(0);
00791     sprintf(textLabel,"Event %d",evPtr->head.eventNumber);
00792     TText *eventText = leftPave->AddText(textLabel);
00793     eventText->SetTextColor(50);
00794     leftPave->Draw();
00795     plotPad = new TPad("canRFChanMain","canRFChanMain",0,0,1,0.9);
00796     plotPad->Draw();
00797   }
00798   else {
00799     plotPad=useCan;
00800   }
00801   plotPad->cd();
00802   setupRFChanPadWithFrames(plotPad);
00803 
00804 
00805   
00806   for(int column=0;column<4;column++) {
00807     for(int row=0;row<4;row++) {
00808       plotPad->cd();
00809       int rfChan=column+4*row;
00810       
00811       sprintf(padName,"rfChanPad%d",column+4*row);
00812       TPad *paddy1 = (TPad*) plotPad->FindObject(padName);
00813       paddy1->SetEditable(kTRUE);
00814       deleteTGraphsFromRFPad(paddy1,rfChan);
00815       paddy1->cd();
00816       
00817       if(fWaveformOption==AraDisplayFormatOption::kPowerSpectralDensity){
00818         if(!grRFChanFFT[rfChan]) {
00819           TGraph *grTemp=grRFChan[rfChan]->getFFT();
00820           grRFChanFFT[rfChan]=new AraFFTGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00821           delete grTemp;
00822         }
00823         grRFChanFFT[rfChan]->Draw("l");
00824       }
00825       else if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT){
00826         grRFChanAveragedFFT[rfChan]->Draw("l");
00827       }
00828       else if(fWaveformOption==AraDisplayFormatOption::kHilbertEnvelope) {
00829         if(!grRFChanHilbert[rfChan])  {
00830           TGraph *grTemp=grRFChan[rfChan]->getHilbert();
00831           grRFChanHilbert[rfChan]=new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00832           delete grTemp;
00833         }
00834         grRFChanHilbert[rfChan]->Draw("l");
00835       }
00836       else if(fWaveformOption==AraDisplayFormatOption::kWaveform) {
00837         grRFChan[rfChan]->Draw("l");
00838 
00839         if(fAutoScale) {
00840           TList *listy = gPad->GetListOfPrimitives();
00841           for(int i=0;i<listy->GetSize();i++) {
00842             TObject *fred = listy->At(i);
00843             TH1F *tempHist = (TH1F*) fred;
00844             if(tempHist->InheritsFrom("TH1")) {
00845               tempHist->GetYaxis()->SetRangeUser(fMinVoltLimit,fMaxVoltLimit);
00846             }
00847           }
00848         }
00849       }
00850 
00851       paddy1->SetEditable(kFALSE);
00852     }
00853   }
00854   
00855   
00856   if(!useCan)
00857     return canRFChan;
00858   else 
00859     return plotPad;
00860   
00861 }
00862 
00863 
00864 TPad *AraCanvasMaker::getAntennaCanvas(UsefulAraEvent *evPtr,
00865                                        TPad *useCan)
00866 {
00867    //  gStyle->SetTitleH(0.1);
00868   gStyle->SetOptTitle(0); 
00869 
00870   if(!fACMGeomTool)
00871     fACMGeomTool=AraGeomTool::Instance();
00872   char textLabel[180];
00873   char padName[180];
00874   TPad *canRFChan=0;
00875   TPad *plotPad=0;
00876   if(!useCan) {
00877     canRFChan = (TPad*) gROOT->FindObject("canRFChan");
00878     if(!canRFChan) {
00879       canRFChan = new TCanvas("canRFChan","canRFChan",1000,600);
00880     }
00881     canRFChan->Clear();
00882     canRFChan->SetTopMargin(0);
00883     TPaveText *leftPave = new TPaveText(0.05,0.92,0.95,0.98);
00884     leftPave->SetBorderSize(0);
00885     sprintf(textLabel,"Event %d",evPtr->head.eventNumber);
00886     TText *eventText = leftPave->AddText(textLabel);
00887     eventText->SetTextColor(50);
00888     leftPave->Draw();
00889     plotPad = new TPad("canRFChanMain","canRFChanMain",0,0,1,0.9);
00890     plotPad->Draw();
00891   }
00892   else {
00893     plotPad=useCan;
00894   }
00895   plotPad->cd();
00896   setupAntPadWithFrames(plotPad);
00897 
00898   //  int rfChanMap[4][4]={
00899   AraAntPol::AraAntPol_t polMap[4][4]={{AraAntPol::kVertical,AraAntPol::kVertical,AraAntPol::kVertical,AraAntPol::kVertical},
00900                                        {AraAntPol::kVertical,AraAntPol::kVertical,AraAntPol::kSurface,AraAntPol::kSurface},
00901                                        {AraAntPol::kHorizontal,AraAntPol::kHorizontal,AraAntPol::kHorizontal,AraAntPol::kHorizontal},
00902                                        {AraAntPol::kHorizontal,AraAntPol::kHorizontal,AraAntPol::kHorizontal,AraAntPol::kHorizontal}};
00903   int antPolNumMap[4][4]={{0,1,2,3},{4,5,0,1},{0,1,2,3},{4,5,6,7}};
00904   
00905 
00906 
00907   
00908   for(int row=0;row<4;row++) {
00909     for(int column=0;column<4;column++) {
00910       plotPad->cd();
00911       int rfChan=fACMGeomTool->getRFChanByPolAndAnt(polMap[row][column],antPolNumMap[row][column]);
00912       //      std::cout << row << "\t" << column << "\t" << rfChan << "\n";
00913       
00914       sprintf(padName,"antPad%d_%d",column,row);
00915       TPad *paddy1 = (TPad*) plotPad->FindObject(padName);
00916       paddy1->SetEditable(kTRUE);
00917       deleteTGraphsFromRFPad(paddy1,rfChan);
00918       paddy1->cd();
00919       
00920       if(fWaveformOption==AraDisplayFormatOption::kPowerSpectralDensity){
00921         if(!grRFChanFFT[rfChan]) {        
00922           TGraph *grTemp=grRFChan[rfChan]->getFFT();
00923           grRFChanFFT[rfChan]=new AraFFTGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00924           delete grTemp;
00925         }
00926         grRFChanFFT[rfChan]->Draw("l");
00927       }
00928       else if(fWaveformOption==AraDisplayFormatOption::kAveragedFFT){
00929         grRFChanAveragedFFT[rfChan]->Draw("l");
00930       }
00931       else if(fWaveformOption==AraDisplayFormatOption::kHilbertEnvelope) {
00932         if(!grRFChanHilbert[rfChan]) {    
00933           TGraph *grTemp=grRFChan[rfChan]->getHilbert();
00934           grRFChanHilbert[rfChan]=new AraWaveformGraph(grTemp->GetN(),grTemp->GetX(),grTemp->GetY());
00935           delete grTemp;
00936         }
00937         grRFChanHilbert[rfChan]->Draw("l");
00938       }
00939       else if(fWaveformOption==AraDisplayFormatOption::kWaveform) {
00940         grRFChan[rfChan]->Draw("l");
00941 
00942         if(fAutoScale) {
00943           TList *listy = gPad->GetListOfPrimitives();
00944           for(int i=0;i<listy->GetSize();i++) {
00945             TObject *fred = listy->At(i);
00946             TH1F *tempHist = (TH1F*) fred;
00947             if(tempHist->InheritsFrom("TH1")) {
00948               tempHist->GetYaxis()->SetRangeUser(fMinVoltLimit,fMaxVoltLimit);
00949             }
00950           }
00951         }
00952       }
00953 
00954       paddy1->SetEditable(kFALSE);
00955     }
00956   }
00957   
00958   
00959   if(!useCan)
00960     return canRFChan;
00961   else 
00962     return plotPad;
00963   
00964 }
00965 
00966 
00967 TPad *AraCanvasMaker::getIntMapCanvas(UsefulAraEvent *evPtr,
00968                                        TPad *useCan)
00969 {
00970   static UInt_t lastEventNumber=0;
00971   static UInt_t lastUnixTime=0;
00972   static UInt_t lastUnixTimeUs=0;
00973   Int_t sameEvent=0;
00974   if(lastEventNumber==evPtr->head.eventNumber) {
00975     if(lastUnixTime==evPtr->head.unixTime) {
00976       if(lastUnixTimeUs==evPtr->head.unixTimeUs) {
00977         sameEvent=1;
00978       }
00979     }
00980   }
00981   lastEventNumber=evPtr->head.eventNumber;
00982   lastUnixTime=evPtr->head.unixTime;
00983   lastUnixTimeUs=evPtr->head.unixTimeUs;
00984   
00985 
00986    //  gStyle->SetTitleH(0.1);
00987   gStyle->SetOptTitle(0); 
00988 
00989   if(!fACMGeomTool)
00990     fACMGeomTool=AraGeomTool::Instance();
00991   char textLabel[180];
00992   char padName[180];
00993   TPad *canIntMap=0;
00994   TPad *plotPad=0;
00995   if(!useCan) {
00996     canIntMap = (TPad*) gROOT->FindObject("canIntMap");
00997     if(!canIntMap) {
00998       canIntMap = new TCanvas("canIntMap","canIntMap",1000,600);
00999     }
01000     canIntMap->Clear();
01001     canIntMap->SetTopMargin(0);
01002     TPaveText *leftPave = new TPaveText(0.05,0.92,0.95,0.98);
01003     leftPave->SetBorderSize(0);
01004     sprintf(textLabel,"Event %d",evPtr->head.eventNumber);
01005     TText *eventText = leftPave->AddText(textLabel);
01006     eventText->SetTextColor(50);
01007     leftPave->Draw();
01008     plotPad = new TPad("canIntMapMain","canIntMapMain",0,0,1,0.9);
01009     plotPad->Draw();
01010   }
01011   else {
01012     plotPad=useCan;
01013   }
01014   plotPad->cd();
01015   plotPad->Clear();
01016   AraEventCorrelator *araCorPtr = AraEventCorrelator::Instance(fNumAntsInMap);
01017   static TH2D* histMapH=0;  
01018   static TH2D* histMapV=0;  
01019   plotPad->Divide(1,2);
01020   plotPad->cd(1);
01021   
01022   if(histMapV) {
01023     if(!sameEvent) {
01024       delete histMapV;
01025       histMapV=0;
01026     }
01027   }
01028 
01029   
01030   if(!histMapV)
01031     histMapV =araCorPtr->getInterferometricMap(evPtr,AraAntPol::kVertical,fCorType);
01032   histMapV->SetName("histMapV");
01033   histMapV->SetTitle("Vertical Polarisation");
01034   histMapV->SetXTitle("Azimuth (Degrees)");
01035   histMapV->SetYTitle("Elevation (Degrees)");
01036   histMapV->SetStats(0);
01037   //  histMapV->SetMaximum(1);
01038   //  histMapV->SetMinimum(-1);
01039   histMapV->Draw("colz");
01040 
01041   plotPad->cd(2);
01042   if(histMapH) {
01043     if(!sameEvent) {
01044       delete histMapH;
01045       histMapH=0;
01046     }
01047   }
01048   if(!histMapH)
01049     histMapH =araCorPtr->getInterferometricMap(evPtr,AraAntPol::kHorizontal,fCorType);
01050   histMapH->SetName("histMapH");
01051   histMapH->SetTitle("Hertical Polarisation");
01052   histMapH->SetXTitle("Azimuth (Degrees)");
01053   histMapH->SetYTitle("Elevation (Degrees)");
01054   histMapH->SetStats(0);
01055   //  histMapH->SetMaximum(1);
01056   //  histMapH->SetMinimum(-1);
01057   histMapH->Draw("colz");
01058   
01059   
01060 
01061 
01062   
01063   if(!useCan)
01064     return canIntMap;
01065   else 
01066     return plotPad;
01067   
01068 }
01069 
01070 
01071 
01072 
01073 
01074 
01075 
01076 void AraCanvasMaker::setupElecPadWithFrames(TPad *plotPad)
01077 {
01078   char textLabel[180];
01079   char padName[180];
01080   plotPad->cd();
01081   if(fLastCanvasView!=AraDisplayCanvasLayoutOption::kElectronicsView) {
01082     plotPad->Clear();
01083   } 
01084   if(fRedoEventCanvas){
01085     plotPad->Clear();
01086   }
01087 
01088   fLastCanvasView=AraDisplayCanvasLayoutOption::kElectronicsView; 
01089 
01090   static int elecPadsDone=0;
01091   if(elecPadsDone && !fRedoEventCanvas) {
01092     int errors=0;
01093     for(int i=0;i<30;i++) {
01094       sprintf(padName,"elecChanPad%d",i);
01095       TPad *paddy = (TPad*) plotPad->FindObject(padName);
01096       if(!paddy)
01097         errors++;
01098     }
01099     if(!errors)
01100       return;
01101   }
01102 
01103   elecPadsDone=1;
01104     
01105 
01106   Double_t left[5]={0.04,0.23,0.42,0.61,0.80};
01107   Double_t right[5]={0.23,0.42,0.61,0.80,0.99};
01108   Double_t top[6]={0.93,0.78,0.63,0.48,0.33,0.18};
01109   Double_t bottom[6]={0.78,0.63,0.48,0.33,0.18,0.03};
01110   
01111   //Now add some labels around the plot
01112   TLatex texy;
01113   texy.SetTextSize(0.03); 
01114   texy.SetTextAlign(12);  
01115   for(int column=0;column<5;column++) {
01116     sprintf(textLabel,"Chan %d/%d",1+(2*column),2+(2*column));
01117     if(column==4)
01118       texy.DrawTextNDC(right[column]-0.1,0.97,textLabel);
01119     else
01120       texy.DrawTextNDC(right[column]-0.09,0.97,textLabel);
01121   }
01122   texy.SetTextAlign(21);  
01123   texy.SetTextAngle(90);
01124   texy.DrawTextNDC(left[0]-0.01,bottom[0],"A");
01125   texy.DrawTextNDC(left[0]-0.01,bottom[2],"B");
01126   texy.DrawTextNDC(left[0]-0.01,bottom[4],"C");
01127 
01128   // A
01129   // 1 3 5 7 9 
01130   // 2 4 6 8 
01131   // B
01132   // 1 3 5 7 9 
01133   // 2 4 6 8 
01134   // C
01135   // 1 3 5 7 9 
01136   // 2 4 6 8 
01137 
01138   int count=0;
01139 
01140 
01141 
01142 
01143   for(int row=0;row<6;row++) {
01144     for(int column=0;column<5;column++) {
01145       plotPad->cd();
01146       //      if(row%2==1 && column==4) continue;
01147       sprintf(padName,"elecChanPad%d",column+5*row);
01148       TPad *paddy1 = new TPad(padName,padName,left[column],bottom[row],right[column],top[row]);   
01149       paddy1->SetTopMargin(0);
01150       paddy1->SetBottomMargin(0);
01151       paddy1->SetLeftMargin(0);
01152       paddy1->SetRightMargin(0);
01153       if(column==4)
01154         paddy1->SetRightMargin(0.01);
01155       if(column==0)
01156         paddy1->SetLeftMargin(0.1);
01157       if(row==5)
01158         paddy1->SetBottomMargin(0.1);
01159       paddy1->Draw();
01160       paddy1->cd();
01161 
01162       TH1F *framey=0;
01163       
01164 
01165       //      std::cout << "Limits\t" << fMinVoltLimit << "\t" << fMaxVoltLimit << "\n";
01166   
01167 
01168       if(fWaveformOption==AraDisplayFormatOption::kWaveform || fWaveformOption==AraDisplayFormatOption::kHilbertEnvelope) 
01169         framey = (TH1F*) paddy1->DrawFrame(0,fMinVoltLimit,250,fMaxVoltLimit);
01170         //      framey = (TH1F*) paddy1->DrawFrame(fMinTimeLimit,fMinVoltLimit,fMaxTimeLimit,fMaxVoltLimit);
01171       else if(fWaveformOption==AraDisplayFormatOption::kFFT || fWaveformOption==AraDisplayFormatOption::kAveragedFFT)
01172         framey = (TH1F*) paddy1->DrawFrame(fMinFreqLimit,fMinPowerLimit,fMaxFreqLimit,fMaxPowerLimit); 
01173 
01174       framey->GetYaxis()->SetLabelSize(0.08);
01175       framey->GetYaxis()->SetTitleSize(0.1);
01176       framey->GetYaxis()->SetTitleOffset(0.5);
01177          
01178       if(row==4) {
01179         framey->GetXaxis()->SetLabelSize(0.09);
01180         framey->GetXaxis()->SetTitleSize(0.09);
01181         framey->GetYaxis()->SetLabelSize(0.09);
01182         framey->GetYaxis()->SetTitleSize(0.09);
01183       }
01184       if(fWebPlotterMode && column!=0) {
01185          framey->GetYaxis()->SetLabelSize(0);
01186          framey->GetYaxis()->SetTitleSize(0);
01187          framey->GetYaxis()->SetTitleOffset(0);
01188       }
01189       count++;
01190     }
01191   }
01192 
01193 }
01194 
01195 
01196 
01197 void AraCanvasMaker::setupRFChanPadWithFrames(TPad *plotPad)
01198 {
01199   static int rfChanPadsDone=0;
01200   char textLabel[180];
01201   char padName[180];
01202   plotPad->cd();
01203   if(fLastCanvasView!=AraDisplayCanvasLayoutOption::kRFChanView) {
01204     plotPad->Clear();
01205   }
01206 
01207   if(fRedoEventCanvas && rfChanPadsDone){
01208     plotPad->Clear();
01209   }
01210 
01211   fLastCanvasView=AraDisplayCanvasLayoutOption::kRFChanView;
01212 
01213   if(rfChanPadsDone && !fRedoEventCanvas) {
01214     int errors=0;
01215     for(int rfChan=0;rfChan<RFCHANS_PER_STATION;rfChan++) {
01216         sprintf(padName,"rfChanPad%d",rfChan);
01217         TPad *paddy = (TPad*) plotPad->FindObject(padName);
01218         if(!paddy)
01219           errors++;
01220     }
01221     if(!errors)
01222       return;
01223   }
01224   
01225   
01226   rfChanPadsDone=1;
01227   
01228   
01229   Double_t left[4]={0.04,0.27,0.50,0.73};
01230   Double_t right[4]={0.27,0.50,0.73,0.96};
01231   Double_t top[4]={0.95,0.72,0.49,0.26};
01232   Double_t bottom[4]={0.72,0.49,0.26,0.03};
01233   
01234   //Now add some labels around the plot
01235   TLatex texy;
01236   texy.SetTextSize(0.03); 
01237   texy.SetTextAlign(12);  
01238   for(int column=0;column<4;column++) {
01239     sprintf(textLabel,"%d/%d",1+column,5+column);
01240     if(column==3)
01241       texy.DrawTextNDC(right[column]-0.12,0.97,textLabel);
01242     else
01243       texy.DrawTextNDC(right[column]-0.12,0.97,textLabel);
01244   }
01245   texy.SetTextAlign(21);  
01246   texy.SetTextAngle(90);
01247   texy.DrawTextNDC(left[0]-0.01,bottom[0]+0.1,"1-4");
01248   texy.DrawTextNDC(left[0]-0.01,bottom[1]+0.1,"5-8");
01249   texy.DrawTextNDC(left[0]-0.01,bottom[2]+0.1,"9-12");
01250   texy.DrawTextNDC(left[0]-0.01,bottom[3]+0.1,"13-16");
01251 
01252  
01253   int count=0;
01254 
01255   //  1  2  3  4
01256   //  5  6  7  8
01257   //  9 10 11 12
01258   // 13 14 15 16
01259 
01260   for(int column=0;column<4;column++) {
01261     for(int row=0;row<4;row++) {
01262       plotPad->cd();
01263       //      int rfChan=column+4*row;
01264       sprintf(padName,"rfChanPad%d",column+4*row);
01265       TPad *paddy1 = new TPad(padName,padName,left[column],bottom[row],right[column],top[row]);   
01266       paddy1->SetTopMargin(0);
01267       paddy1->SetBottomMargin(0);
01268       paddy1->SetLeftMargin(0);
01269       paddy1->SetRightMargin(0);
01270       if(column==3)
01271         paddy1->SetRightMargin(0.01);
01272       if(column==0)
01273         paddy1->SetLeftMargin(0.1);
01274       if(row==3)
01275         paddy1->SetBottomMargin(0.1);
01276       paddy1->Draw();
01277       paddy1->cd();
01278       TH1F *framey=0;
01279       if(fWaveformOption==AraDisplayFormatOption::kFFT || fWaveformOption==AraDisplayFormatOption::kAveragedFFT){
01280           framey = (TH1F*) paddy1->DrawFrame(fMinFreqLimit,fMinPowerLimit,fMaxFreqLimit,fMaxPowerLimit);
01281       }
01282       else if(fWaveformOption==AraDisplayFormatOption::kWaveform || 
01283               fWaveformOption==AraDisplayFormatOption::kHilbertEnvelope) {
01284         if(row<3) {
01285           framey = (TH1F*) paddy1->DrawFrame(fMinTimeLimit,fMinVoltLimit,fMaxTimeLimit,fMaxVoltLimit);
01286         }
01287         else{
01288           framey = (TH1F*) paddy1->DrawFrame(fMinTimeLimit,fMinClockVoltLimit,fMaxTimeLimit,fMaxClockVoltLimit);
01289         }
01290       }
01291 
01292       framey->GetYaxis()->SetLabelSize(0.1);
01293       framey->GetYaxis()->SetTitleSize(0.1);
01294       framey->GetYaxis()->SetTitleOffset(0.5);
01295       if(row==3) {
01296         framey->GetXaxis()->SetLabelSize(0.09);
01297         framey->GetXaxis()->SetTitleSize(0.09);
01298         framey->GetYaxis()->SetLabelSize(0.09);
01299         framey->GetYaxis()->SetTitleSize(0.09);
01300       }
01301       if(fWebPlotterMode && column!=0) {
01302          framey->GetYaxis()->SetLabelSize(0);
01303          framey->GetYaxis()->SetTitleSize(0);
01304          framey->GetYaxis()->SetTitleOffset(0);
01305       }
01306 
01307       count++;
01308     }
01309   }
01310 }
01311 
01312 
01313 
01314 void AraCanvasMaker::setupAntPadWithFrames(TPad *plotPad)
01315 {
01316   static int antPadsDone=0;
01317   char textLabel[180];
01318   char padName[180];
01319   plotPad->cd();
01320   if(fLastCanvasView!=AraDisplayCanvasLayoutOption::kAntennaView) {
01321     plotPad->Clear();
01322   }
01323 
01324   if(fRedoEventCanvas && antPadsDone){
01325     plotPad->Clear();
01326   }
01327 
01328   fLastCanvasView=AraDisplayCanvasLayoutOption::kAntennaView;
01329 
01330   if(antPadsDone && !fRedoEventCanvas) {
01331     int errors=0;
01332     for(int column=0;column<4;column++) {
01333       for(int row=0;row<4;row++) {
01334         sprintf(padName,"antPad%d_%d",column,row);
01335         TPad *paddy = (TPad*) plotPad->FindObject(padName);
01336         if(!paddy)
01337           errors++;
01338       }
01339     }
01340     if(!errors)
01341       return;
01342   }
01343   
01344   
01345   antPadsDone=1;
01346   
01347   
01348   Double_t left[4]={0.04,0.27,0.50,0.73};
01349   Double_t right[4]={0.27,0.50,0.73,0.96};
01350   Double_t top[4]={0.95,0.72,0.49,0.26};
01351   Double_t bottom[4]={0.72,0.49,0.26,0.03};
01352   
01353   //Now add some labels around the plot
01354   TLatex texy;
01355   texy.SetTextSize(0.03); 
01356   texy.SetTextAlign(12);  
01357   for(int column=0;column<4;column++) {
01358     sprintf(textLabel,"%d/%d",1+column,5+column);
01359     if(column==3)
01360       texy.DrawTextNDC(right[column]-0.12,0.97,textLabel);
01361     else
01362       texy.DrawTextNDC(right[column]-0.12,0.97,textLabel);
01363   }
01364   texy.SetTextAlign(21);  
01365   texy.SetTextAngle(90);
01366   texy.DrawTextNDC(left[0]-0.01,bottom[0]+0.1,"V");
01367   texy.DrawTextNDC(left[0]-0.01,bottom[1]+0.1,"V/S");
01368   texy.DrawTextNDC(left[0]-0.01,bottom[2]+0.1,"H");
01369   texy.DrawTextNDC(left[0]-0.01,bottom[3]+0.1,"H");
01370 
01371  
01372   int count=0;
01373 
01374 
01375 
01376   
01377   for(int column=0;column<4;column++) {
01378     for(int row=0;row<4;row++) {
01379       plotPad->cd();
01380       sprintf(padName,"antPad%d_%d",column,row);
01381     
01382       TPad *paddy1 = new TPad(padName,padName,left[column],bottom[row],right[column],top[row]);   
01383       paddy1->SetTopMargin(0);
01384       paddy1->SetBottomMargin(0);
01385       paddy1->SetLeftMargin(0);
01386       paddy1->SetRightMargin(0);
01387       if(column==3)
01388         paddy1->SetRightMargin(0.01);
01389       if(column==0)
01390         paddy1->SetLeftMargin(0.1);
01391       if(row==3)
01392         paddy1->SetBottomMargin(0.1);
01393       paddy1->Draw();
01394       paddy1->cd();
01395       TH1F *framey=0;
01396       if(fWaveformOption==AraDisplayFormatOption::kFFT || fWaveformOption==AraDisplayFormatOption::kAveragedFFT){
01397           framey = (TH1F*) paddy1->DrawFrame(fMinFreqLimit,fMinPowerLimit,fMaxFreqLimit,fMaxPowerLimit);
01398       }
01399       else if(fWaveformOption==AraDisplayFormatOption::kWaveform || 
01400               fWaveformOption==AraDisplayFormatOption::kHilbertEnvelope) {
01401         if(row<3) {
01402           framey = (TH1F*) paddy1->DrawFrame(fMinTimeLimit,fMinVoltLimit,fMaxTimeLimit,fMaxVoltLimit);
01403         }
01404         else{
01405           framey = (TH1F*) paddy1->DrawFrame(fMinTimeLimit,fMinClockVoltLimit,fMaxTimeLimit,fMaxClockVoltLimit);
01406         }
01407       }
01408 
01409       framey->GetYaxis()->SetLabelSize(0.1);
01410       framey->GetYaxis()->SetTitleSize(0.1);
01411       framey->GetYaxis()->SetTitleOffset(0.5);
01412       if(row==3) {
01413         framey->GetXaxis()->SetLabelSize(0.09);
01414         framey->GetXaxis()->SetTitleSize(0.09);
01415         framey->GetYaxis()->SetLabelSize(0.09);
01416         framey->GetYaxis()->SetTitleSize(0.09);
01417       }
01418       if(fWebPlotterMode && column!=0) {
01419          framey->GetYaxis()->SetLabelSize(0);
01420          framey->GetYaxis()->SetTitleSize(0);
01421          framey->GetYaxis()->SetTitleOffset(0);
01422       }
01423       count++;
01424     }
01425   }
01426 }
01427 
01428 
01429 
01430 void AraCanvasMaker::deleteTGraphsFromElecPad(TPad *paddy,int chan)
01431 {
01432   paddy->cd();
01433   if(fLastWaveformFormat==AraDisplayFormatOption::kWaveform) paddy->GetListOfPrimitives()->Remove(grElec[chan]);
01434   else if(fLastWaveformFormat==AraDisplayFormatOption::kFFT) paddy->GetListOfPrimitives()->Remove(grElecFFT[chan]); 
01435   else if(fLastWaveformFormat==AraDisplayFormatOption::kAveragedFFT) paddy->GetListOfPrimitives()->Remove(grElecAveragedFFT[chan]); 
01436   else if(fLastWaveformFormat==AraDisplayFormatOption::kHilbertEnvelope) paddy->GetListOfPrimitives()->Remove(grElecHilbert[chan]);  
01437   //  paddy->Update();
01438 }
01439 
01440 
01441 void AraCanvasMaker::deleteTGraphsFromRFPad(TPad *paddy,int rfchan)
01442 {
01443   paddy->cd();
01444   if(fLastWaveformFormat==AraDisplayFormatOption::kWaveform) paddy->GetListOfPrimitives()->Remove(grRFChan[rfchan]);
01445   else if(fLastWaveformFormat==AraDisplayFormatOption::kFFT) paddy->GetListOfPrimitives()->Remove(grRFChanFFT[rfchan]); 
01446   else if(fLastWaveformFormat==AraDisplayFormatOption::kAveragedFFT) paddy->GetListOfPrimitives()->Remove(grRFChanAveragedFFT[rfchan]); 
01447   else if(fLastWaveformFormat==AraDisplayFormatOption::kHilbertEnvelope) paddy->GetListOfPrimitives()->Remove(grRFChanHilbert[rfchan]);  
01448   //  paddy->Update();
01449 }
01450 
01451 
01452 void AraCanvasMaker::resetAverage() 
01453 {
01454   for(int chan=0;chan<NUM_DIGITIZED_CHANNELS;chan++) {
01455     if(grElecAveragedFFT[chan]) {
01456       delete grElecAveragedFFT[chan];
01457       grElecAveragedFFT[chan]=0;
01458     }
01459   }
01460   for(int rfchan=0;rfchan<RFCHANS_PER_STATION;rfchan++) {
01461     if(grRFChanAveragedFFT[rfchan]) {
01462       delete grRFChanAveragedFFT[rfchan];
01463       grRFChanAveragedFFT[rfchan]=0;
01464     }
01465   }
01466 }
01467 
01468 
01469 

Generated on Wed Aug 8 16:18:55 2012 for ARA ROOT Test Bed Software by doxygen 1.4.7