AraEvent/AraEventCalibrator.cxx
00001 00002 00003 00004 00005 00006 00007 00008 00009 #include "AraEventCalibrator.h" 00010 #include "UsefulIcrrStationEvent.h" 00011 #include "UsefulAtriStationEvent.h" 00012 #include "AraGeomTool.h" 00013 #include "TMath.h" 00014 #include "TGraph.h" 00015 #include "FFTtools.h" 00016 #include <iostream> 00017 #include <fstream> 00018 #include <cstring> 00019 #include <zlib.h> 00020 #include <cstdlib> 00021 00022 00023 Bool_t AraCalType::hasCableDelays(AraCalType::AraCalType_t calType) 00024 { 00025 if(calType==kFirstCalibPlusCables || calType==kSecondCalibPlusCables) 00026 return kTRUE; 00027 return kFALSE; 00028 } 00029 00030 Bool_t AraCalType::hasInterleaveCalib(AraCalType::AraCalType_t calType) 00031 { 00032 if(calType==kFirstCalibPlusCables || calType==kSecondCalibPlusCables || 00033 calType==kFirstCalib || calType==kSecondCalib) 00034 return kTRUE; 00035 return kFALSE; 00036 } 00037 00038 Bool_t AraCalType::hasBinWidthCalib(AraCalType::AraCalType_t calType) 00039 { 00040 if(calType>=kFirstCalib) 00041 return kTRUE; 00042 return kFALSE; 00043 } 00044 00045 00046 Bool_t AraCalType::hasClockAlignment(AraCalType::AraCalType_t calType) 00047 { 00048 if(calType==kSecondCalibPlusCables || 00049 calType==kSecondCalib) 00050 return kTRUE; 00051 return kFALSE; 00052 } 00053 00054 00055 00056 Bool_t AraCalType::hasPedestalSubtraction(AraCalType::AraCalType_t calType) 00057 { 00058 if(calType==kNoCalib) return kFALSE; 00059 return kTRUE; 00060 } 00061 00062 Bool_t AraCalType::hasCommonMode(AraCalType::AraCalType_t calType) 00063 { 00064 return kFALSE; 00065 if(calType==kNoCalib) return kFALSE; 00066 return kTRUE; 00067 } 00068 00069 00070 00071 ClassImp(AraEventCalibrator); 00072 00073 AraEventCalibrator * AraEventCalibrator::fgInstance=0; 00074 00075 00076 AraEventCalibrator::AraEventCalibrator() 00077 { 00078 for(int station=0;station<ICRR_NO_STATIONS;station++) gotPedFile[station]=0; 00079 fGotAtriPedFile=0; 00080 loadIcrrCalib(); 00081 loadAtriCalib(); 00082 //Default Constructor 00083 } 00084 00085 AraEventCalibrator::~AraEventCalibrator() { 00086 //Default Destructor 00087 } 00088 00089 //______________________________________________________________________________ 00090 AraEventCalibrator* AraEventCalibrator::Instance() 00091 { 00092 00093 // printf("AraEventCalibrator::Instance() creating an instance of the calibrator\n"); 00094 //static function 00095 if(fgInstance) 00096 return fgInstance; 00097 00098 fgInstance = new AraEventCalibrator(); 00099 00100 // printf("AraEventCalibrator::Instance() finished creating an instance of the calibrator\n"); 00101 return fgInstance; 00102 } 00103 00104 00105 void AraEventCalibrator::setPedFile(char fileName[], UInt_t stationId) 00106 { 00107 strncpy(pedFile[stationId],fileName,FILENAME_MAX); 00108 if(stationId==0) fprintf(stdout, "AraEventCalibrator::setPedFile() setting TestBed pedFile to %s\n", pedFile[stationId]); 00109 if(stationId==1) fprintf(stdout, "AraEventCalibrator::setPedFile() setting Station1 pedFile to %s\n", pedFile[stationId]); 00110 00111 gotPedFile[stationId]=1; 00112 loadIcrrPedestals(); 00113 } 00114 00115 void AraEventCalibrator::loadIcrrPedestals() 00116 { 00117 //TestBed 00118 if(!gotPedFile[0]) { 00119 char *pedFileEnv = getenv( "ARA_PEDESTAL_FILE" ); 00120 if ( pedFileEnv == NULL ) { 00121 char calibDir[FILENAME_MAX]; 00122 char *calibEnv=getenv("ARA_CALIB_DIR"); 00123 if(!calibEnv) { 00124 char *utilEnv=getenv("ARA_UTIL_INSTALL_DIR"); 00125 if(!utilEnv) { 00126 sprintf(calibDir,"calib"); 00127 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():TestBed: INFO - Pedestal file [from ./calib]"); 00128 } else { 00129 sprintf(calibDir,"%s/share/araCalib",utilEnv); 00130 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():TestBed: INFO - Pedestal file [from ARA_UTIL_INSTALL_DIR/share/calib]"); 00131 } 00132 } 00133 else { 00134 strncpy(calibDir,calibEnv,FILENAME_MAX); 00135 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():TestBed INFO - Pedestal file [from ARA_CALIB_DIR]"); 00136 } 00137 sprintf(pedFile[0],"%s/ICRR/TestBed/peds_1294924296.869787.run001202.dat",calibDir); 00138 fprintf(stdout," = %s\n",pedFile[0]); 00139 } // end of IF-block for pedestal file not specified by environment variable 00140 else { 00141 strncpy(pedFile[0],pedFileEnv,FILENAME_MAX); 00142 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():TestBed: INFO - Pedestal file [from ARA_PEDESTAL_FILE] = %s\n",pedFile[0]); 00143 } // end of IF-block for pedestal file specified by environment variable 00144 } 00145 00146 //Station1 00147 if(!gotPedFile[1]) { 00148 char *pedFileEnv = getenv( "ARA_PEDESTAL_FILE" ); 00149 if ( pedFileEnv == NULL ) { 00150 char calibDir[FILENAME_MAX]; 00151 char *calibEnv=getenv("ARA_CALIB_DIR"); 00152 if(!calibEnv) { 00153 char *utilEnv=getenv("ARA_UTIL_INSTALL_DIR"); 00154 if(!utilEnv) { 00155 sprintf(calibDir,"calib"); 00156 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():Station1: INFO - Pedestal file [from ./calib]"); 00157 } else { 00158 sprintf(calibDir,"%s/share/araCalib",utilEnv); 00159 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():Station1: INFO - Pedestal file [from ARA_UTIL_INSTALL_DIR/share/calib]"); 00160 } 00161 } 00162 else { 00163 strncpy(calibDir,calibEnv,FILENAME_MAX); 00164 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():Station1: INFO - Pedestal file [from ARA_CALIB_DIR]"); 00165 } 00166 sprintf(pedFile[1],"%s/ICRR/Station1/peds_1326108401.602169.run003747.dat",calibDir); 00167 fprintf(stdout," = %s\n",pedFile[1]); 00168 } // end of IF-block for pedestal file not specified by environment variable 00169 else { 00170 strncpy(pedFile[1],pedFileEnv,FILENAME_MAX); 00171 fprintf(stdout,"AraEventCalibrator::loadIcrrPedestals():Station1: INFO - Pedestal file [from ARA_PEDESTAL_FILE] = %s\n",pedFile[1]); 00172 } // end of IF-block for pedestal file specified by environment variable 00173 } 00174 00175 FullLabChipPedStruct_t peds; 00176 00177 //TestBed 00178 gzFile inPedTB = gzopen(pedFile[0],"r"); 00179 if( !inPedTB ){ 00180 fprintf(stderr,"ERROR - Failed to open pedestal file for TestBed %s.\n",pedFile[0]); 00181 return; 00182 } 00183 00184 int nRead = gzread(inPedTB,&peds,sizeof(FullLabChipPedStruct_t)); 00185 if( nRead != sizeof(FullLabChipPedStruct_t)){ 00186 int numErr; 00187 fprintf(stderr,"ERROR - Error reading pedestal file %s; %s\n",pedFile[0],gzerror(inPedTB,&numErr)); 00188 gzclose(inPedTB); 00189 return; 00190 } 00191 00192 int chip,chan,samp; 00193 for(chip=0;chip<LAB3_PER_ICRR;++chip) { 00194 for(chan=0;chan<CHANNELS_PER_LAB3;++chan) { 00195 int chanIndex = chip*CHANNELS_PER_LAB3+chan; 00196 for(samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;++samp) { 00197 pedestalData[0][chip][chan][samp]=peds.chan[chanIndex].pedMean[samp]; 00198 } 00199 } 00200 } 00201 gzclose(inPedTB); 00202 gotPedFile[0]=1; 00203 00204 //Station1 00205 gzFile inPedAra1 = gzopen(pedFile[1],"r"); 00206 if( !inPedAra1 ){ 00207 fprintf(stderr,"ERROR - Failed to open pedestal file for Station1 %s\n",pedFile[1]); 00208 return; 00209 } 00210 00211 nRead = gzread(inPedAra1,&peds,sizeof(FullLabChipPedStruct_t)); 00212 if( nRead != sizeof(FullLabChipPedStruct_t)){ 00213 int numErr; 00214 fprintf(stderr,"ERROR - Error reading pedestal file %s; %s\n",pedFile[1],gzerror(inPedAra1,&numErr)); 00215 gzclose(inPedAra1); 00216 return; 00217 } 00218 00219 for(chip=0;chip<LAB3_PER_ICRR;++chip) { 00220 for(chan=0;chan<CHANNELS_PER_LAB3;++chan) { 00221 int chanIndex = chip*CHANNELS_PER_LAB3+chan; 00222 for(samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;++samp) { 00223 pedestalData[1][chip][chan][samp]=peds.chan[chanIndex].pedMean[samp]; 00224 } 00225 } 00226 } 00227 gzclose(inPedAra1); 00228 gotPedFile[1]=1; 00229 00230 } 00231 00232 int AraEventCalibrator::doBinCalibration(UsefulIcrrStationEvent *theEvent, int chanIndex,int overrideRCO) 00233 { 00234 int stationId=theEvent->stationId; 00235 00236 int nChip=theEvent->chan[chanIndex].chanId/CHANNELS_PER_LAB3; 00237 int nChan=theEvent->chan[chanIndex].chanId%CHANNELS_PER_LAB3; 00238 int rco=overrideRCO; 00239 if(overrideRCO!=0 && overrideRCO!=1) 00240 rco=theEvent->getRCO(chanIndex); 00241 int hbwrap = theEvent->chan[chanIndex].chipIdFlag&0x08; 00242 char hbextra = (theEvent->chan[chanIndex].chipIdFlag&0xf0)>>4; 00243 short hbstart=theEvent->chan[chanIndex].firstHitbus; 00244 short hbend=theEvent->chan[chanIndex].lastHitbus+hbextra; 00245 00246 00247 00248 double calTime=0; 00249 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;++samp){ 00250 rawadc[samp]=theEvent->chan[chanIndex].data[samp]; 00251 if(theEvent->chan[chanIndex].data[samp]==0){ 00252 calwv[samp]=0; 00253 pedsubadc[samp]=0; 00254 }else{ 00255 pedsubadc[samp]=rawadc[samp]-pedestalData[stationId][nChip][nChan][samp]; 00256 calwv[samp]=pedsubadc[samp]*ADCMV; 00257 if(calwv[samp]>SATURATION) calwv[samp]=SATURATION; 00258 if(calwv[samp]<-1*SATURATION) calwv[samp]=-1*SATURATION; 00259 } 00260 } 00261 00262 00263 if(nChan==0 || (overrideRCO==0 || overrideRCO==1)) { 00264 //Do the calibration for each chip 00265 calTime=0; 00266 int ir=0; 00267 if(hbwrap){ // Wrapped hitbus 00268 for(int samp=hbstart+1;samp<hbend;++samp) { 00269 tempTimeNums[ir++]=calTime; 00270 calTime+=binWidths[stationId][nChip][rco][samp]; 00271 } 00272 } 00273 else{ 00274 for(int samp=hbend+1;samp<MAX_NUMBER_SAMPLES_LAB3;++samp) { 00275 tempTimeNums[ir++]=calTime; 00276 calTime+=binWidths[stationId][nChip][1-rco][samp]; 00277 } 00278 //Now add epsilon 00279 calTime+=epsilonVals[stationId][nChip][rco]; //Need to check if this is rco or 1-rco 00280 for(int samp=0;samp<hbstart;++samp) { 00281 tempTimeNums[ir++]=calTime; 00282 calTime+=binWidths[stationId][nChip][rco][samp]; 00283 } 00284 } 00285 for(int samp=ir;samp<MAX_NUMBER_SAMPLES_LAB3;++samp) { 00286 tempTimeNums[samp]=calTime; 00287 calTime+=1; 00288 } 00289 TMath::Sort(MAX_NUMBER_SAMPLES_LAB3,tempTimeNums,indexNums,kFALSE); 00290 } 00291 // ... and rotate 00292 int ir=0; 00293 int numValid=0; 00294 if(hbwrap){ // Wrapped hitbus 00295 for(int samp=hbstart+1;samp<hbend;++samp) 00296 v[ir++]=calwv[samp]; 00297 }else{ 00298 for(int samp=hbend+1;samp<MAX_NUMBER_SAMPLES_LAB3;++samp) 00299 v[ir++]=calwv[samp]; 00300 for(int samp=0;samp<hbstart;++samp) 00301 v[ir++]=calwv[samp]; 00302 } 00303 numValid=ir; 00304 // Fill in remaining bins with zeros 00305 for(int samp=ir;samp<MAX_NUMBER_SAMPLES_LAB3;++samp) 00306 v[samp]=0; 00307 00308 //Now we just have to make sure the times are monotonically increasing 00309 for(int i=0;i<MAX_NUMBER_SAMPLES_LAB3;i++) { 00310 calTimeNums[i]=tempTimeNums[indexNums[i]]; 00311 calVoltNums[i]=v[indexNums[i]]; 00312 // std::cout << i << "\t" << indexNums[i] << "\t" << calTimeNums[i] << "\t" << calVoltNums[i] << "\n"; 00313 } 00314 return numValid; 00315 } 00316 00317 00318 void AraEventCalibrator::calibrateEvent(UsefulIcrrStationEvent *theEvent, AraCalType::AraCalType_t calType) 00319 { 00320 int stationId=theEvent->stationId; 00321 static int gotPeds=0; 00322 if(!gotPeds) 00323 loadIcrrPedestals(); 00324 gotPeds=1; 00325 if(AraCalType::hasBinWidthCalib(calType)) 00326 theEvent->guessRCO(0); //Forces the calculation of the RCO phase from the clock 00327 00328 //set the number of rfchans in the event 00329 00330 00331 //jpd make these defines! 00332 if(stationId==0) theEvent->numRFChans=16; 00333 else theEvent->numRFChans=20; 00334 00335 // Calibrate waveforms 00336 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;++samp){ 00337 sampNums[samp]=samp; 00338 timeNums[samp]=samp*NSPERSAMP; 00339 } 00340 00341 for(int chanIndex = 0; chanIndex < NUM_DIGITIZED_ICRR_CHANNELS; ++chanIndex ){ 00342 int numValid=doBinCalibration(theEvent,chanIndex); 00343 00344 00345 00346 //Now we stuff it back into the UsefulIcrrStationEvent object 00347 00348 if(calType==AraCalType::kNoCalib) { 00349 theEvent->fNumPoints[chanIndex]=MAX_NUMBER_SAMPLES_LAB3; 00350 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00351 theEvent->fVolts[chanIndex][samp]=rawadc[samp]; 00352 theEvent->fTimes[chanIndex][samp]=sampNums[samp]; 00353 } 00354 } 00355 if(calType==AraCalType::kJustUnwrap || calType==AraCalType::kADC) { 00356 theEvent->fNumPoints[chanIndex]=numValid; 00357 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00358 theEvent->fTimes[chanIndex][samp]=sampNums[samp]; 00359 if(samp<numValid) { 00360 theEvent->fVolts[chanIndex][samp]=v[samp]; 00361 } 00362 else { 00363 theEvent->fVolts[chanIndex][samp]=0; 00364 } 00365 } 00366 } 00367 if(calType==AraCalType::kVoltageTime) { 00368 theEvent->fNumPoints[chanIndex]=numValid; 00369 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00370 theEvent->fTimes[chanIndex][samp]=timeNums[samp]; 00371 if(samp<numValid) { 00372 theEvent->fVolts[chanIndex][samp]=v[samp]; 00373 } 00374 else { 00375 theEvent->fVolts[chanIndex][samp]=0; 00376 } 00377 } 00378 } 00379 if(calType==AraCalType::kJustPed) { 00380 theEvent->fNumPoints[chanIndex]=MAX_NUMBER_SAMPLES_LAB3; 00381 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00382 theEvent->fVolts[chanIndex][samp]=pedsubadc[samp]; 00383 theEvent->fTimes[chanIndex][samp]=sampNums[samp]; 00384 } 00385 } 00386 if(AraCalType::hasBinWidthCalib(calType)) { 00387 //Almost always want this 00388 theEvent->fNumPoints[chanIndex]=numValid; 00389 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00390 theEvent->fTimes[chanIndex][samp]=calTimeNums[samp]; 00391 if(samp<numValid) { 00392 theEvent->fVolts[chanIndex][samp]=calVoltNums[samp]; 00393 } 00394 else { 00395 theEvent->fVolts[chanIndex][samp]=0; 00396 } 00397 } 00398 } 00399 } 00400 00401 //Now we have done the initial bin-by-bin and epsilon calibrations 00402 //Next up is to do the clock alignment 00403 if(AraCalType::hasClockAlignment(calType)) { 00404 //All of the higher calibrations do some form of clock alignment 00405 calcClockAlignVals(theEvent,calType); 00406 for(int chanIndex = 0; chanIndex < NUM_DIGITIZED_ICRR_CHANNELS; ++chanIndex ){ 00407 int nChip=theEvent->chan[chanIndex].chanId/CHANNELS_PER_LAB3; 00408 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00409 theEvent->fTimes[chanIndex][samp]+=clockAlignVals[stationId][nChip]; 00410 } 00411 } 00412 } 00413 00414 00415 00416 00417 //For now we just have the one calibration type for interleaving 00418 AraGeomTool *tempGeom = AraGeomTool::Instance(); 00419 00420 for(int rfchan = 0; rfchan < (theEvent->numRFChans); ++rfchan ){ 00421 // printf("AraEventCalibrator::calibrateEvent() rfchan %i stationId %i\n", rfchan, stationId); 00422 00423 memset(theEvent->fVoltsRF[rfchan],0,sizeof(Double_t)*2*MAX_NUMBER_SAMPLES_LAB3); 00424 memset(theEvent->fTimesRF[rfchan],0,sizeof(Double_t)*2*MAX_NUMBER_SAMPLES_LAB3); 00425 00426 00427 if(tempGeom->getNumLabChansForChan(rfchan, stationId)==2) { 00428 // printf("interleaved channel\n"); 00429 // std::cout << rfchan << "\t" 00430 // << tempGeom->getFirstLabChanIndexForChan(rfchan, stationId) << "\t" 00431 // << tempGeom->getSecondLabChanIndexForChan(rfchan, stationId) << "\n"; 00432 00433 //printf("rfchan %i stationId %i labChip %i FirstLabChan %i SecondLabChan %i numLabChans %i labChans[0] %i labChans[1] %i\n", rfchan, stationId, tempGeom->getLabChipForChan(rfchan, stationId), tempGeom->getFirstLabChanForChan(rfchan, stationId), tempGeom->getSecondLabChanForChan(rfchan, stationId),tempGeom->getNumLabChansForChan(rfchan, stationId), tempGeom->getFirstLabChanIndexForChan(rfchan, stationId), tempGeom->getSecondLabChanIndexForChan(rfchan, stationId)); 00434 00435 int ci1=tempGeom->getFirstLabChanIndexForChan(rfchan, stationId); 00436 int ci2=tempGeom->getSecondLabChanIndexForChan(rfchan, stationId); 00437 theEvent->fNumPointsRF[rfchan]=theEvent->fNumPoints[ci1]+theEvent->fNumPoints[ci2]; 00438 //Need to zero mean, maybe should do this in each half seperately? 00439 //RJN hack 13/01/11 00440 double mean=0; 00441 for(int i=0;i<theEvent->fNumPoints[ci1];i++) { 00442 mean+=theEvent->fVolts[ci1][i]; 00443 } 00444 for(int i=0;i<theEvent->fNumPoints[ci2];i++) { 00445 mean+=theEvent->fVolts[ci2][i]; 00446 } 00447 mean/=theEvent->fNumPointsRF[rfchan]; 00448 00449 //Only the interleaved types have any special calib here 00450 if(AraCalType::hasInterleaveCalib(calType)) { 00451 int i1=0; 00452 int i2=0; 00453 for(int i=0;i<theEvent->fNumPointsRF[rfchan];i++) { 00454 if(i1<theEvent->fNumPoints[ci1] && i2<theEvent->fNumPoints[ci2]) { 00455 //Both in play 00456 if(theEvent->fTimes[ci1][i1]<(theEvent->fTimes[ci2][i2]+interleaveVals[stationId][rfchan])) { 00457 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci1][i1]; 00458 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci1][i1]-mean; 00459 // std::cout << "A: " << i << "\t" << theEvent->fTimesRF[rfchan][i] << "\n"; 00460 00461 i1++; 00462 continue; 00463 } 00464 else { 00465 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci2][i2]+interleaveVals[stationId][rfchan]; 00466 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci2][i2]-mean; 00467 // std::cout << "B: " << i << "\t" << theEvent->fTimesRF[rfchan][i] << "\n"; 00468 i2++; 00469 continue; 00470 } 00471 } 00472 else if(i1<theEvent->fNumPoints[ci1]) { 00473 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci1][i1]; 00474 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci1][i1]-mean; 00475 i1++; 00476 // std::cout << "C: " << i << "\t" << theEvent->fTimesRF[rfchan][i] << "\n"; 00477 continue; 00478 } 00479 else if(i2<theEvent->fNumPoints[ci2]) { 00480 00481 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci2][i2]+interleaveVals[stationId][rfchan]; 00482 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci2][i2]-mean; 00483 // std::cout << "D: " << i << "\t" << theEvent->fTimesRF[rfchan][i] << "\n"; 00484 i2++; 00485 continue; 00486 } 00487 } 00488 }//interleaved 00489 00490 else { 00491 for(int i=0;i<theEvent->fNumPointsRF[rfchan];i++) { 00492 if(i%2==0) { 00493 //ci2 00494 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci2][i/2]; 00495 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci2][i/2]; 00496 } 00497 else { 00498 //ci1 00499 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci1][i/2]; 00500 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci1][i/2]+0.5*NSPERSAMP; 00501 } 00502 00503 } 00504 } 00505 00506 }//numLabChans==2 00507 else if(tempGeom->isDiplexed(rfchan, stationId)==0){ 00508 // printf("non-interleaved non-diplexed channel\n"); 00509 // std::cout << rfchan << "\t" 00510 // << tempGeom->getFirstLabChanIndexForChan(rfchan) << "\n"; 00511 int ci=tempGeom->getFirstLabChanIndexForChan(rfchan, stationId); 00512 theEvent->fNumPointsRF[rfchan]=theEvent->fNumPoints[ci]; 00513 00514 //Need to zero mean the data 00515 double mean=0; 00516 for(int i=0;i<theEvent->fNumPoints[ci];i++) { 00517 mean+=theEvent->fVolts[ci][i]; 00518 } 00519 mean/=theEvent->fNumPoints[ci]; 00520 00521 for(int i=0;i<theEvent->fNumPointsRF[rfchan];i++) { 00522 theEvent->fVoltsRF[rfchan][i]=theEvent->fVolts[ci][i]-mean; 00523 theEvent->fTimesRF[rfchan][i]=theEvent->fTimes[ci][i]; 00524 00525 } 00526 }//isDiplexed==0 00527 else if(tempGeom->isDiplexed(rfchan, stationId)==1){ 00528 // printf("non-interleaved diplexed channel\n"); 00529 //now need to work out how to do a diplexed channel 00530 //find lab channel from which to derived rfchan 00531 int ci=tempGeom->getFirstLabChanIndexForChan(rfchan,stationId); 00532 int noPoints=theEvent->fNumPoints[ci]; 00533 Double_t lowPassFreq=tempGeom->getLowPassFilter(rfchan,stationId); 00534 Double_t highPassFreq=tempGeom->getHighPassFilter(rfchan,stationId); 00535 00536 TGraph *gUnfiltered = new TGraph(noPoints, theEvent->fTimes[ci], theEvent->fVolts[ci]); 00537 00538 TGraph *gFiltered = FFTtools::simplePassBandFilter(gUnfiltered, highPassFreq, lowPassFreq); 00539 Double_t *filteredT = gFiltered->GetX(); 00540 Double_t *filteredV = gFiltered->GetY(); 00541 00542 00543 for(int i=0;i<noPoints;i++){ 00544 theEvent->fTimesRF[rfchan][i]=filteredT[i]; 00545 theEvent->fVoltsRF[rfchan][i]=filteredV[i]; 00546 } 00547 theEvent->fNumPointsRF[rfchan]=noPoints; 00548 00549 delete gFiltered; 00550 delete gUnfiltered; 00551 00552 }//isDiplexed==1 00553 00554 if(AraCalType::hasCableDelays(calType)) { 00555 Double_t delay=tempGeom->fStationInfo[stationId].fAntInfo[rfchan].cableDelay; 00556 // delay-=180; //Just an arbitrary offset 00557 for(int i=0;i<theEvent->fNumPointsRF[rfchan];i++) { 00558 theEvent->fTimesRF[rfchan][i]-=delay; 00559 } 00560 } 00561 00562 00563 } 00564 00565 // printf("calibrated the event\n"); 00566 00567 } 00568 00569 void AraEventCalibrator::loadIcrrCalib() 00570 { 00571 char calibFile[FILENAME_MAX]; 00572 char calibDir[FILENAME_MAX]; 00573 char *calibEnv=getenv("ARA_CALIB_DIR"); 00574 if(!calibEnv) { 00575 char *utilEnv=getenv("ARA_UTIL_INSTALL_DIR"); 00576 if(!utilEnv) 00577 sprintf(calibDir,"calib"); 00578 else 00579 sprintf(calibDir,"%s/share/araCalib",utilEnv); 00580 } 00581 else { 00582 strncpy(calibDir,calibEnv,FILENAME_MAX); 00583 } 00584 int chip,rco,chan; 00585 00586 //Icrr 00587 //Bin Width Calib 00588 sprintf(calibFile,"%s/ICRR/TestBed/binWidths.txt",calibDir); 00589 std::ifstream BinFileTB(calibFile); 00590 double width; 00591 while(BinFileTB >> chip >> rco) { 00592 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00593 BinFileTB >> width; 00594 binWidths[0][chip][rco][samp]=width; 00595 } 00596 } 00597 //Epsilon Calib 00598 sprintf(calibFile,"%s/ICRR/TestBed/epsilonFile.txt",calibDir); 00599 std::ifstream EpsFileTB(calibFile); 00600 double epsilon; 00601 while(EpsFileTB >> chip >> rco >> epsilon) { 00602 epsilonVals[0][chip][rco]=epsilon; 00603 } 00604 //Interleave Calib 00605 sprintf(calibFile,"%s/ICRR/TestBed/interleaveFile.txt",calibDir); 00606 std::ifstream IntFileTB(calibFile); 00607 double interleave; 00608 while(IntFileTB >> chip >> chan >> interleave) { 00609 interleaveVals[0][chan+4*chip]=interleave; 00610 } 00611 00612 //Station1 00613 //Bin Width Calib 00614 00615 sprintf(calibFile,"%s/ICRR/Station1/binWidths.txt",calibDir); 00616 std::ifstream BinFileAra1(calibFile); 00617 while(BinFileAra1 >> chip >> rco) { 00618 for(int samp=0;samp<MAX_NUMBER_SAMPLES_LAB3;samp++) { 00619 BinFileAra1 >> width; 00620 binWidths[1][chip][rco][samp]=width; 00621 } 00622 } 00623 //Epsilon Calib 00624 sprintf(calibFile,"%s/ICRR/Station1/epsilonFile.txt",calibDir); 00625 std::ifstream EpsFileAra1(calibFile); 00626 while(EpsFileAra1 >> chip >> rco >> epsilon) { 00627 epsilonVals[1][chip][rco]=epsilon; 00628 } 00629 //Interleave Calib 00630 sprintf(calibFile,"%s/ICRR/Station1/interleaveFile.txt",calibDir); 00631 std::ifstream IntFileAra1(calibFile); 00632 while(IntFileAra1 >> chip >> chan >> interleave) { 00633 interleaveVals[1][chan+4*chip]=interleave; 00634 } 00635 } 00636 00637 00638 00639 void AraEventCalibrator::calcClockAlignVals(UsefulIcrrStationEvent *theEvent, AraCalType::AraCalType_t calType) 00640 { 00641 int stationId=theEvent->stationId; 00642 00643 if(!AraCalType::hasClockAlignment(calType)) return; 00644 TGraph *grClock[LAB3_PER_ICRR]={0}; 00645 Double_t lag[LAB3_PER_ICRR]={0}; 00646 for(int chip=0;chip<LAB3_PER_ICRR;chip++) { 00647 clockAlignVals[stationId][chip]=0; 00648 int chanIndex=ICRR1_CLOCK_CHANNEL+CHANNELS_PER_LAB3*chip; 00649 grClock[chip]=theEvent->getGraphFromElecChan(chanIndex); 00650 lag[chip]=estimateClockLag(grClock[chip]); 00651 delete grClock[chip]; 00652 00653 if(chip>0) { 00654 //Then can actually do some alignment 00655 clockAlignVals[stationId][chip]=lag[0]-lag[chip]; 00656 //The below fudge factors were "tuned" using pulser data 00657 // to try and remove period ambiguities resulting from wrong cycle lag 00658 if(lag[chip]<8 && lag[0]>9) 00659 clockAlignVals[stationId][chip]-=25; 00660 if(lag[chip]>9 && lag[0]<7) 00661 clockAlignVals[stationId][chip]+=25; 00662 // std::cout << "clockAlignVals[ " << chip << "] = " << clockAlignVals[chip] << "\n"; 00663 } 00664 00665 } 00666 } 00667 00668 00669 Double_t AraEventCalibrator::estimateClockLag(TGraph *grClock) 00670 { 00671 // This funciton estimates the clock lag (i.e. phase but expressed in terms of a deltaT between 0 and 1 period) by just using all the negative-positive zero crossing 00672 00673 Double_t period=ICRR1_CLOCK_PERIOD; 00674 Double_t mean=grClock->GetMean(2); 00675 Int_t numPoints=grClock->GetN(); 00676 if(numPoints<3) return 0; 00677 Double_t *tVals=grClock->GetX(); 00678 Double_t *vVals=grClock->GetY(); 00679 00680 Double_t zc[1000]={0}; 00681 Double_t rawZc[1000]={0}; 00682 int countZC=0; 00683 for(int i=2;i<numPoints;i++) { 00684 if(vVals[i-1]<0 && vVals[i]>0) { 00685 Double_t x1=tVals[i-1]; 00686 Double_t x2=tVals[i]; 00687 Double_t y1=vVals[i-1]-mean; 00688 Double_t y2=vVals[i]-mean; 00689 // std::cout << i << "\t" << y2 << "\t" << y1 << "\t" << (y2-y1) << "\n"; 00690 zc[countZC]=(((0-y1)/(y2-y1))*(x2-x1))+x1; 00691 rawZc[countZC]=zc[countZC]; 00692 countZC++; 00693 // if(countZC==1) 00694 // break; 00695 } 00696 00697 } 00698 00699 Double_t firstZC=zc[0]; 00700 while(firstZC>period) firstZC-=period; 00701 Double_t meanZC=0; 00702 Double_t meanZC2=0; 00703 for(int i=0;i<countZC;i++) { 00704 while((zc[i])>period) zc[i]-=period; 00705 if(TMath::Abs((zc[i]-period)-firstZC)<TMath::Abs(zc[i]-firstZC)) 00706 zc[i]-=period; 00707 if(TMath::Abs((zc[i]+period)-firstZC)<TMath::Abs(zc[i]-firstZC)) 00708 zc[i]+=period; 00709 meanZC+=zc[i]; 00710 meanZC2+=zc[i]*zc[i]; 00711 // std::cout << i << "\t" << zc[i] << "\t" << rawZc[i] << "\n"; 00712 } 00713 meanZC/=countZC; 00714 meanZC2/=countZC; 00715 // Double_t rms=TMath::Sqrt(meanZC2-meanZC*meanZC); 00716 // std::cout << meanZC << "\t" << rms << "\n"; 00717 return meanZC; 00718 00719 } 00720 00721 void AraEventCalibrator::fillRCOGuessArray(UsefulIcrrStationEvent *theEvent, int rcoGuess[LAB3_PER_ICRR]) 00722 { 00723 for(int chip=0;chip<LAB3_PER_ICRR;chip++) { 00724 int chanIndex=ICRR1_CLOCK_CHANNEL+CHANNELS_PER_LAB3*chip; 00725 rcoGuess[chip]=theEvent->getRawRCO(chanIndex); 00726 00727 Double_t period[2]={0}; 00728 Double_t rms[2]={0}; 00729 for(int rcoTest=0;rcoTest<2;rcoTest++) { 00730 int numValid=doBinCalibration(theEvent,chanIndex,rcoTest); 00731 period[rcoTest]=estimateClockPeriod(numValid,rms[rcoTest]); 00732 } 00733 00734 Double_t periodTest=(TMath::Abs(period[0]-ICRR1_CLOCK_PERIOD)-TMath::Abs(period[1]-ICRR1_CLOCK_PERIOD)); 00735 Double_t rmsTest=(rms[0]-rms[1]); 00736 if(periodTest<0) { 00737 rcoGuess[chip]=0; 00738 if(TMath::Abs(periodTest)<0.5 && rmsTest>0) 00739 rcoGuess[chip]=1; 00740 } 00741 else { 00742 rcoGuess[chip]=1; 00743 if(TMath::Abs(periodTest)<0.5 && rmsTest<0) { 00744 rcoGuess[chip]=0; 00745 } 00746 } 00747 if(rms[rcoGuess[chip]]>4) { 00748 rcoGuess[chip]=theEvent->getRawRCO(chanIndex); 00749 } 00750 00751 // std::cout << "AraEventCalibrator:\t" << period[0] << "\t" << period[1] << "\n"; 00752 // std::cout << "AraEventCalibrator:\t" << periodTest << "\t" << rmsTest << "\t" << rcoGuess[chip] << "\n"; 00753 } 00754 } 00755 00756 00757 00758 Double_t AraEventCalibrator::estimateClockPeriod(Int_t numPoints, Double_t &rms) 00759 { 00760 // This funciton estimates the period by just using all the negative-positive zero crossing 00761 if(numPoints<3) return 0; 00762 Double_t mean=0; 00763 Double_t vVals[MAX_NUMBER_SAMPLES_LAB3]={0}; 00764 for(int i=0;i<numPoints;i++) { 00765 mean+=calVoltNums[i]; 00766 } 00767 mean/=numPoints; 00768 for(int i=0;i<numPoints;i++) { 00769 vVals[i]=calVoltNums[i]-mean; 00770 } 00771 00772 00773 Double_t zc[1000]={0}; 00774 Double_t periods[1000]={0}; 00775 int countZC=0; 00776 for(int i=2;i<numPoints;i++) { 00777 if(vVals[i-1]<0 && vVals[i]>0) { 00778 Double_t x1=calTimeNums[i-1]; 00779 Double_t x2=calTimeNums[i]; 00780 Double_t y1=vVals[i-1]; 00781 Double_t y2=vVals[i]; 00782 // std::cout << i << "\t" << y2 << "\t" << y1 << "\t" << (y2-y1) << "\n"; 00783 Double_t zcTime=(((0-y1)/(y2-y1))*(x2-x1))+x1; 00784 if(countZC>0) { 00785 if((zcTime-zc[countZC-1])<10) 00786 continue; 00787 } 00788 zc[countZC]=zcTime; 00789 countZC++; 00790 // if(countZC==1) 00791 // break; 00792 } 00793 } 00794 00795 if(countZC<2) return 0; 00796 00797 00798 int countPeriods=0; 00799 Double_t meanPeriod=0; 00800 Double_t meanPeriodSq=0; 00801 for(int i=1;i<countZC;i++) { 00802 periods[countPeriods]=zc[i]-zc[i-1]; 00803 meanPeriod+=periods[countPeriods]; 00804 meanPeriodSq+=periods[countPeriods]*periods[countPeriods]; 00805 countPeriods++; 00806 } 00807 meanPeriod/=countPeriods; 00808 meanPeriodSq/=countPeriods; 00809 rms=TMath::Sqrt(meanPeriodSq-meanPeriod*meanPeriod); 00810 00811 return meanPeriod; 00812 } 00813 00814 void AraEventCalibrator::calibrateEvent(UsefulAtriStationEvent *theEvent, AraCalType::AraCalType_t calType) 00815 { 00816 00817 //Really what we will do here is just kNoCalib 00818 static int gotPeds=0; 00819 if(!gotPeds) { 00820 loadAtriPedestals(); 00821 gotPeds=1; 00822 } 00823 00824 //Step one is loop over the blocks 00825 00826 std::vector<RawAtriStationBlock>::iterator blockIt; 00827 std::vector< std::vector<UShort_t> >::iterator vecVecIt; 00828 std::map< Int_t, std::vector <Double_t> >::iterator timeMapIt; 00829 std::map< Int_t, std::vector <Double_t> >::iterator voltMapIt; 00830 std::map< Int_t, std::vector <Double_t> >::iterator voltMapIt2; 00831 std::vector< UShort_t >::iterator shortIt; 00832 for(blockIt = theEvent->blockVec.begin(); 00833 blockIt!=theEvent->blockVec.end(); 00834 blockIt++) { 00835 //Step two is determine the channel Ids 00836 Int_t irsChan[8]; 00837 Int_t numChans=0; 00838 for(Int_t bit=0;bit<8;bit++) { 00839 Int_t mask=(1<<bit); 00840 if((blockIt->channelMask)&mask) { 00841 irsChan[numChans]=bit; 00842 numChans++; 00843 } 00844 } 00845 // std::cout << "Got numChans " << numChans << "\n"; 00846 00847 //Step three is loop over the channels within a block 00848 Int_t uptoChan=0; 00849 for(vecVecIt=blockIt->data.begin(); 00850 vecVecIt!=blockIt->data.end(); 00851 vecVecIt++) { 00852 Int_t chanId=irsChan[uptoChan] | ((blockIt->channelMask&0x300)>>5); 00853 Int_t chan=irsChan[uptoChan]; 00854 Int_t dda=blockIt->getDda(); 00855 Int_t block=blockIt->getBlock(); 00856 Int_t capArray=blockIt->getCapArray(); 00857 // std::cout << "Got chanId " << chanId << "\t" << irsChan[uptoChan] << "\t" 00858 // << dda << "\t" << block << "\t" << RawAtriStationEvent::getPedIndex(dda,block,chan,0) << "\n"; 00859 uptoChan++; 00860 00861 //Step four is to check if we have already got this chanId 00862 00863 timeMapIt=theEvent->fTimes.find(chanId); 00864 Double_t time=0; 00865 Int_t firstTime=1; 00866 if(timeMapIt==theEvent->fTimes.end()) { 00867 //First time round for this channel 00868 std::vector <Double_t> tempTimes; 00869 std::vector <Double_t> tempVolts; 00870 //Now need to insert empty vector into map 00871 theEvent->fTimes.insert( std::pair< Int_t, std::vector <Double_t> >(chanId,tempTimes)); 00872 theEvent->fVolts.insert( std::pair< Int_t, std::vector <Double_t> >(chanId,tempVolts)); 00873 theEvent->fNumChannels++; 00874 } 00875 else { 00876 //Just get the last time 00877 time=timeMapIt->second.back(); 00878 // if(dda==1 &&chan==1) 00879 // std::cout << "Last time " << time << "\t" << timeMapIt->second.size() << "\n"; 00880 firstTime=0; 00881 } 00882 00883 //Set the iterators to point to the correct channel in the map 00884 timeMapIt=theEvent->fTimes.find(chanId); 00885 voltMapIt=theEvent->fVolts.find(chanId); 00886 00887 int samp=0; 00888 int index=0; 00889 //Now loop over the 64 samples 00890 Double_t tempTimes[SAMPLES_PER_BLOCK]; 00891 Double_t tempVolts[SAMPLES_PER_BLOCK]; 00892 Int_t voltIndex[SAMPLES_PER_BLOCK]; 00893 00894 //Here is the Epsilon calibration 00895 if(AraCalType::hasBinWidthCalib(calType)) { 00896 if(!firstTime) { 00897 //Add on the time between blocks 00898 time+=fAtriEpsilonTimes[dda][chan][capArray]; 00899 // if(dda==1 && chan==1) 00900 // std::cout << "Block " << time << "\t" << fAtriEpsilonTimes[dda][chan][capArray] << "\n"; 00901 00902 } 00903 } 00904 00905 for(shortIt=vecVecIt->begin(); 00906 shortIt!=vecVecIt->end(); 00907 shortIt++) { 00908 00909 if(AraCalType::hasBinWidthCalib(calType)) { 00910 00911 //Now need to work out where to place the sample 00912 voltIndex[samp]=fAtriSampleIndex[dda][chan][capArray][samp]; 00913 00914 //Now get the time 00915 tempTimes[samp]=time+fAtriSampleTimes[dda][chan][capArray][samp]; 00916 00917 // if(dda==1 && chan==1) { 00918 // // std::cout << dda << "\t" << chan << "\t" << capArray << "\t" << samp << "\t" << fAtriSampleTimes[dda][chan][capArray][samp] << "\n"; 00919 // std::cout << index << "\t" << tempTimes[samp] << "\t" << time << "\n"; 00920 // } 00921 00922 } 00923 else { 00924 time+=1; 00925 tempTimes[samp]=time; 00926 voltIndex[samp]=samp; 00927 } 00928 00929 //Now the voltage part 00930 if(!AraCalType::hasPedestalSubtraction(calType)) 00931 tempVolts[samp]=(*shortIt); 00932 else { 00933 tempVolts[samp]=(*shortIt)-(Int_t)fAtriPeds[RawAtriStationEvent::getPedIndex(dda,block,chan,samp)]; 00934 // if(dda==3 && samp<2) { 00935 // std::cout << (*shortIt) << "\t" << (Int_t)fAtriPeds[RawAtriStationEvent::getPedIndex(dda,block,chan,samp)] << "\n"; 00936 // } 00937 } 00938 samp++; 00939 } 00940 00941 for(samp=0;samp<SAMPLES_PER_BLOCK;samp++) { 00942 timeMapIt->second.push_back(tempTimes[samp]); 00943 voltMapIt->second.push_back(tempVolts[voltIndex[samp]]); //Filling with volts 00944 00945 } 00946 00947 00948 } 00949 } 00950 00951 if(hasCommonMode(calType)) { 00952 //Then we need to do a common mode correction 00953 //loop over dda 00954 //loop over chan 00955 //loop over times and subtract one 00956 00957 for(int dda=0;dda<DDA_PER_ATRI;dda++) { 00958 for(Int_t chan=0;chan<5;chan++) { 00959 Int_t chanId=chan+RFCHAN_PER_DDA*dda; 00960 voltMapIt=theEvent->fVolts.find(chanId); 00961 Int_t chanId2=5+RFCHAN_PER_DDA*dda; 00962 voltMapIt2=theEvent->fVolts.find(chanId2); 00963 00964 Int_t numPoints=(voltMapIt->second).size(); 00965 for(int samp=0;samp<numPoints;samp++) { 00966 voltMapIt->second[samp]-=voltMapIt2->second[samp]; 00967 } 00968 } 00969 } 00970 00971 } 00972 00973 00974 00975 } 00976 00977 00978 00979 void AraEventCalibrator::setAtriPedFile(char *filename) 00980 { 00981 strncpy(fAtriPedFile,filename,FILENAME_MAX); 00982 fGotAtriPedFile=1; 00983 loadAtriPedestals(); 00984 } 00985 00986 void AraEventCalibrator::loadAtriPedestals() 00987 { 00988 if(!fGotAtriPedFile) { 00989 char *pedFileEnv = getenv( "ARA_ONE_PEDESTAL_FILE" ); 00990 if ( pedFileEnv == NULL ) { 00991 char calibDir[FILENAME_MAX]; 00992 char *calibEnv=getenv("ARA_CALIB_DIR"); 00993 if(!calibEnv) { 00994 char *utilEnv=getenv("ARA_UTIL_INSTALL_DIR"); 00995 if(!utilEnv) { 00996 sprintf(calibDir,"calib"); 00997 fprintf(stdout,"AraEventCalibrator::loadAtriPedestals(): INFO - Pedestal file [from ./calib]"); 00998 } else { 00999 sprintf(calibDir,"%s/share/araCalib",utilEnv); 01000 fprintf(stdout,"AraEventCalibrator::loadAtriPedestals(): INFO - Pedestal file [from ARA_UTIL_INSTALL_DIR/share/calib]"); 01001 } 01002 } 01003 else { 01004 strncpy(calibDir,calibEnv,FILENAME_MAX); 01005 fprintf(stdout,"AraEventCalibrator::loadAtriPedestals(): INFO - Pedestal file [from ARA_CALIB_DIR]"); 01006 } 01007 sprintf(fAtriPedFile,"%s/ATRI/araAtriPedestals.txt",calibDir); 01008 fprintf(stdout," = %s\n",fAtriPedFile); 01009 } // end of IF-block for pedestal file not specified by environment variable 01010 else { 01011 strncpy(fAtriPedFile,pedFileEnv,FILENAME_MAX); 01012 fprintf(stdout,"AraEventCalibrator::loadAtriPedestals(): INFO - Pedestal file [from ARA_ONE_PEDESTAL_FILE] = %s\n",fAtriPedFile); 01013 } // end of IF-block for pedestal file specified by environment variable 01014 } 01015 01016 01017 //Pedestal file 01018 std::ifstream PedFile(fAtriPedFile); 01019 Int_t dda,block,chan; 01020 UShort_t pedVal; 01021 01022 fAtriPeds = new UShort_t [DDA_PER_ATRI*BLOCKS_PER_DDA*RFCHAN_PER_DDA*SAMPLES_PER_BLOCK]; 01023 if(!fAtriPeds) { 01024 std::cerr << "Can not allocate memory for pedestal file\n"; 01025 exit(0); 01026 } 01027 01028 01029 01030 while(PedFile >> dda >> block >> chan) { 01031 for(int samp=0;samp<SAMPLES_PER_BLOCK;samp++) { 01032 PedFile >> pedVal; 01033 fAtriPeds[RawAtriStationEvent::getPedIndex(dda,block,chan,samp)]=pedVal; 01034 } 01035 } 01036 01037 } 01038 01039 01040 void AraEventCalibrator::loadAtriCalib() 01041 { 01042 char calibFile[FILENAME_MAX]; 01043 char calibDir[FILENAME_MAX]; 01044 char *calibEnv=getenv("ARA_CALIB_DIR"); 01045 if(!calibEnv) { 01046 char *utilEnv=getenv("ARA_UTIL_INSTALL_DIR"); 01047 if(!utilEnv) 01048 sprintf(calibDir,"calib"); 01049 else 01050 sprintf(calibDir,"%s/share/araCalib",utilEnv); 01051 } 01052 else { 01053 strncpy(calibDir,calibEnv,FILENAME_MAX); 01054 } 01055 01056 int dda,chan,sample,capArray; 01057 sprintf(calibFile,"%s/ATRI/araAtriSampleTiming.txt",calibDir); 01058 std::ifstream SampleFile(calibFile); 01059 for(dda=0;dda<DDA_PER_ATRI;dda++) { 01060 for(chan=0;chan<RFCHAN_PER_DDA;chan++) { 01061 for(capArray=0;capArray<2;capArray++) { 01062 for(sample=0;sample<SAMPLES_PER_BLOCK;sample++) { 01063 fAtriSampleTimes[dda][chan][capArray][sample]=sample/3.2; 01064 fAtriSampleIndex[dda][chan][capArray][sample]=sample; 01065 } 01066 fAtriEpsilonTimes[dda][chan][capArray]=1/3.2; 01067 } 01068 } 01069 } 01070 01071 Double_t value; 01072 Int_t index; 01073 while(SampleFile >> dda >> chan >> capArray) { 01074 // std::cout << dda << "\t" << chan << "\t" << capArray << "\t"; 01075 for(sample=0;sample<SAMPLES_PER_BLOCK;sample++) { 01076 SampleFile >> index; 01077 fAtriSampleIndex[dda][chan][capArray][sample]=index; 01078 // std::cout << fAtriSampleIndex[dda][chan][ << " "; 01079 } 01080 01081 SampleFile >> dda >> chan >> capArray; 01082 for(sample=0;sample<SAMPLES_PER_BLOCK;sample++) { 01083 SampleFile >> value; 01084 fAtriSampleTimes[dda][chan][capArray][sample]=value; 01085 // std::cout << fAtriSampleTimes[dda][chan][capArray][sample] << " "; 01086 } 01087 // std::cout << "\n"; 01088 } 01089 }
Generated on Wed Aug 8 16:20:07 2012 for ARA ROOT Test Bed Software by
