AraEvent/UsefulAtriStationEvent.cxx
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 #include "UsefulAtriStationEvent.h" 00011 #include "AraEventCalibrator.h" 00012 #include "FFTtools.h" 00013 #include "AraGeomTool.h" 00014 #include "TH1.h" 00015 #include <iostream> 00016 #include <fstream> 00017 #include <cstring> 00018 ClassImp(UsefulAtriStationEvent); 00019 00020 AraEventCalibrator *fCalibrator; 00021 00022 UsefulAtriStationEvent::UsefulAtriStationEvent() 00023 { 00024 //Default Constructor 00025 fNumChannels=0; 00026 fCalibrator=0; 00027 } 00028 00029 UsefulAtriStationEvent::~UsefulAtriStationEvent() { 00030 //Default Destructor 00031 fNumChannels=0; 00032 fCalibrator=0; 00033 } 00034 00035 UsefulAtriStationEvent::UsefulAtriStationEvent(RawAtriStationEvent *rawEvent, AraCalType::AraCalType_t calType) 00036 :RawAtriStationEvent(*rawEvent) 00037 { 00038 fCalibrator=AraEventCalibrator::Instance(); 00039 fNumChannels=0; 00040 fCalibrator->calibrateEvent(this,calType); 00041 // fprintf(stderr, "UsefulAtriStationEvent::UsefulAtriStationEvent() -- finished constructing event\n"); //DEBUG 00042 00043 } 00044 00045 00046 TGraph *UsefulAtriStationEvent::getGraphFromElecChan(int chanId) 00047 { 00048 std::map< Int_t, std::vector <Double_t> >::iterator timeMapIt; 00049 timeMapIt=fTimes.find(chanId); 00050 if(timeMapIt==fTimes.end()) { 00051 // This channel doesn't exist. We don't return a null pointer, 00052 // we return an empty graph. 00053 // RJN should fix this as it is a silly idea 00054 return new TGraph; 00055 } 00056 00057 TGraph *gr = new TGraph(fTimes[chanId].size(),&(fTimes[chanId][0]),&(fVolts[chanId][0])); 00058 00059 //Why do we need to sort the array. Shouldn't this be done in AraEventCalibrator?? 00060 //FIXME -- jpd - this is my dumb idea 00061 gr->Sort(); 00062 00063 return gr; 00064 } 00065 00066 TGraph *UsefulAtriStationEvent::getGraphFromRFChan(int chan) 00067 { 00068 Int_t elecChan = AraGeomTool::Instance()->getElecChanFromRFChan(chan,stationId); 00069 if(elecChan < 0){ 00070 return NULL; 00071 } 00072 00073 return getGraphFromElecChan(elecChan); 00074 } 00075 00076 00077 TGraph *UsefulAtriStationEvent::getFFTForRFChan(int chan) 00078 { 00079 00080 // static AraGeomTool *fGeomTool = AraGeomTool::Instance(); 00081 TGraph *gr = getGraphFromRFChan(chan); 00082 if(!gr) return NULL; 00083 Double_t newX[512],newY[512]; 00084 Double_t intSample=1; 00085 Int_t maxSamps=256; 00086 // if(fGeomTool->getNumLabChansForChan(chan)==2) { 00087 intSample=0.5; 00088 maxSamps=512; 00089 // } 00090 00091 00092 TGraph *grInt = FFTtools::getInterpolatedGraph(gr,intSample); 00093 00094 00095 Int_t numSamps = grInt->GetN(); 00096 Double_t *xVals = grInt->GetX(); 00097 Double_t *yVals = grInt->GetY(); 00098 for(int i=0;i<maxSamps;i++) { 00099 if(i<numSamps) { 00100 newX[i]=xVals[i]; 00101 newY[i]=yVals[i]; 00102 } 00103 else { 00104 newX[i]=newX[i-1]+intSample; 00105 newY[i]=0; 00106 } 00107 } 00108 TGraph *grNew = new TGraph(maxSamps,newX,newY); 00109 TGraph *grFFT = FFTtools::makePowerSpectrumMilliVoltsNanoSecondsdB(grNew); 00110 delete gr; 00111 delete grNew; 00112 delete grInt; 00113 return grFFT; 00114 } 00115 00116 00117 TH1D *UsefulAtriStationEvent::getFFTHistForRFChan(int chan) 00118 { 00119 00120 Int_t numBins=256; 00121 Double_t minX=0.0; 00122 Double_t maxX=1000.0; 00123 minX = minX - ( (maxX-minX)/numBins/2.0 ); // adjust histogram edges so that the bin centers 00124 maxX = maxX + ( (maxX-minX)/numBins/2.0 ); // of the histograms are aligned with graph [add bdf] 00125 numBins++; 00126 char histName[180]; 00127 sprintf(histName,"%s_ffthist",this->GetName()); 00128 TH1D *histFFT = new TH1D(histName,histName,numBins,minX,maxX); 00129 if(fillFFTHistoForRFChan(chan,histFFT)==0) 00130 return histFFT; 00131 return NULL; 00132 00133 } 00134 00135 int UsefulAtriStationEvent::fillFFTHistoForRFChan(int chan, TH1D *histFFT) 00136 { 00137 00138 TGraph *grFFT =getFFTForRFChan(chan); 00139 if(!grFFT) return -1; 00140 Double_t *xVals=grFFT->GetX(); 00141 Double_t *yVals=grFFT->GetY(); 00142 Int_t numPoints=grFFT->GetN(); 00143 for(int i=0;i<numPoints;i++) { 00144 histFFT->Fill(xVals[i],yVals[i]); 00145 } 00146 delete grFFT; 00147 return 0; 00148 00149 } 00150 00151 00152 00153 Int_t UsefulAtriStationEvent::getNumRFChannels() 00154 { 00155 return AraGeomTool::Instance()->getStationInfo(stationId)->getNumRFChans(); 00156 00157 }
Generated on Mon Dec 9 13:20:21 2013 for ARA ROOT v3.13 Software by
