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