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