ARA ROOT v3.13 Software

AraEvent/RawAtriStationEvent.cxx

00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #include "RawAtriStationEvent.h"
00011 #include <iostream>
00012 #include <fstream>
00013 #include <cstring>
00014 #include "TMath.h"
00015 ClassImp(RawAtriStationEvent);
00016 
00017 RawAtriStationEvent::RawAtriStationEvent()   
00018 {  
00019   //Default Constructor
00020 }
00021 
00022 RawAtriStationEvent::~RawAtriStationEvent() {
00023    //Default Destructor
00024 }
00025 
00026 
00027 RawAtriStationEvent::RawAtriStationEvent(AraStationEventHeader_t *hdPtr, char *dataBuffer) // Assignment constructor
00028   :RawAraStationEvent(&(hdPtr->gHdr))
00029 {
00030   
00031 
00032    unixTime=hdPtr->unixTime;
00033    unixTimeUs=hdPtr->unixTimeUs;
00034    eventNumber=hdPtr->eventNumber;
00035    ppsNumber=hdPtr->ppsNumber;
00036    numStationBytes=hdPtr->numBytes;
00037    versionId=hdPtr->versionNumber;
00038    timeStamp=hdPtr->timeStamp;
00039    timeStamp ^= (timeStamp >> 1);
00040    timeStamp ^= (timeStamp >> 2);
00041    timeStamp ^= (timeStamp >> 4);
00042    timeStamp ^= (timeStamp >> 8);
00043    timeStamp ^= (timeStamp >> 16);
00044 
00045 
00046    eventId=hdPtr->eventId;
00047    //   std::cerr << eventNumber << "\t" << versionId << "\t" << ppsNumber << "\t" << timeStamp << "\t" << eventId << std::endl;
00048    numReadoutBlocks=hdPtr->numReadoutBlocks; 
00049    
00050    for(int trig=0;trig<MAX_TRIG_BLOCKS;trig++) {
00051      triggerInfo[trig]=hdPtr->triggerInfo[trig];
00052      triggerBlock[trig]=hdPtr->triggerBlock[trig];
00053    }
00054 
00055    int uptoByte=0;
00056    //   std::cerr << "numReadoutBlocks " << numReadoutBlocks << "\n";
00057    for(int block=0;block<numReadoutBlocks;block++) {
00058      AraStationEventBlockHeader_t *blkPtr = (AraStationEventBlockHeader_t*)&dataBuffer[uptoByte];     
00059      uptoByte+=sizeof(AraStationEventBlockHeader_t);
00060      AraStationEventBlockChannel_t *chanPtr = (AraStationEventBlockChannel_t*)&dataBuffer[uptoByte];
00061      RawAtriStationBlock blocky(blkPtr,chanPtr);
00062      blockVec.push_back(blocky);
00063      int numChan=blocky.getNumChannels();
00064 
00065      // std::cout << "block " << block << " numChan " << numChan 
00066      //                <<  " irsBlockNumber " << (blkPtr->irsBlockNumber&0x1ff)
00067      //                << " channelMask " << blkPtr->channelMask << "\t"
00068      //                << " uptoByte " << uptoByte << "\n";
00069      // numChan=8; //HArd wire for testing
00070      uptoByte+=sizeof(AraStationEventBlockChannel_t)*numChan;
00071    }
00072    //   std::cerr << sizeof(AraStationEventHeader_t) << "\n";
00073    if(uptoByte!=int(numStationBytes))    
00074      std::cerr << "Error assigned " << uptoByte <<  " bytes out of " << numStationBytes << "\n";
00075 }
00076 
00077 RawAtriStationEvent::RawAtriStationEvent(AraStationEventHeader_t *hdPtr, char *dataBuffer, AraStationId_t forcedStationId) // Assignment constructor
00078   :RawAraStationEvent(&(hdPtr->gHdr))
00079 {
00080   //JPD The same as above but forcing the stationId value
00081   stationId = forcedStationId;
00082 
00083   
00084   unixTime=hdPtr->unixTime;
00085   unixTimeUs=hdPtr->unixTimeUs;
00086   eventNumber=hdPtr->eventNumber;
00087   versionId=hdPtr->versionNumber;
00088   ppsNumber=hdPtr->ppsNumber;
00089   numStationBytes=hdPtr->numBytes;
00090   //   std::cerr << eventNumber << "\t" << ppsNumber << "\t" << numStationBytes;
00091    timeStamp=hdPtr->timeStamp;
00092    timeStamp ^= (timeStamp >> 1);
00093    timeStamp ^= (timeStamp >> 2);
00094    timeStamp ^= (timeStamp >> 4);
00095    timeStamp ^= (timeStamp >> 8);
00096    timeStamp ^= (timeStamp >> 16);
00097 
00098 
00099 
00100    eventId=hdPtr->eventId;
00101    numReadoutBlocks=hdPtr->numReadoutBlocks; 
00102    
00103    for(int trig=0;trig<MAX_TRIG_BLOCKS;trig++) {
00104      triggerInfo[trig]=hdPtr->triggerInfo[trig];
00105      triggerBlock[trig]=hdPtr->triggerBlock[trig];
00106    }
00107 
00108    int uptoByte=0;
00109    //   std::cerr << "numReadoutBlocks " << numReadoutBlocks << "\n";
00110    for(int block=0;block<numReadoutBlocks;block++) {
00111      AraStationEventBlockHeader_t *blkPtr = (AraStationEventBlockHeader_t*)&dataBuffer[uptoByte];     
00112      uptoByte+=sizeof(AraStationEventBlockHeader_t);
00113      AraStationEventBlockChannel_t *chanPtr = (AraStationEventBlockChannel_t*)&dataBuffer[uptoByte];
00114      RawAtriStationBlock blocky(blkPtr,chanPtr);
00115      blockVec.push_back(blocky);
00116      int numChan=blocky.getNumChannels();
00117 
00118      // std::cout << "block " << block << " numChan " << numChan 
00119      //                <<  " irsBlockNumber " << (blkPtr->irsBlockNumber&0x1ff)
00120      //                << " channelMask " << blkPtr->channelMask << "\t"
00121      //                << " uptoByte " << uptoByte << "\n";
00122      // numChan=8; //HArd wire for testing
00123      uptoByte+=sizeof(AraStationEventBlockChannel_t)*numChan;
00124    }
00125    //   std::cerr << sizeof(AraStationEventHeader_t) << "\n";
00126    if(uptoByte!=int(numStationBytes))    
00127      std::cerr << "Error assigned " << uptoByte <<  " bytes out of " << numStationBytes << "\n";
00128 }
00129 
00130 Int_t RawAtriStationEvent::getFirstCapArray(Int_t dda)
00131 {
00132 
00133   for(int i=0;i<DDA_PER_ATRI;i++){
00134     int this_dda = this->blockVec.at(i).getDda();
00135     if(this_dda==dda) return this->blockVec.at(i).getCapArray();
00136   }  
00137   return -1;
00138   
00139 
00140 }
00141 
00142 
00143 
00144 bool RawAtriStationEvent::isCalpulserEvent(){
00145   Int_t pulserTime=0;
00146 
00147   if(stationId==ARA_STATION1B) pulserTime=254;
00148   else if(stationId==ARA_STATION2) pulserTime=245;
00149   else if(stationId==ARA_STATION3) pulserTime=245;
00150   else return false;
00151 
00152   if(TMath::Abs((Int_t)timeStamp-pulserTime)<1e4){
00153     return true;
00154   }
00155   else{
00156     return false;
00157   }
00158 }
00159 
00160 
00161 Bool_t RawAtriStationEvent::isTrigType(Int_t bit){
00162   if(bit >= MAX_TRIG_BLOCKS ){
00163     fprintf(stderr, "%s -- bit %i too high!\n", __FUNCTION__, bit);
00164     return kFALSE;
00165   }
00166   if(triggerInfo[bit]) return kTRUE;
00167   else return kFALSE;
00168 
00169 
00170 }
00171 
00172 Bool_t RawAtriStationEvent::isTriggerChanHigh(Int_t bit){
00173   if(!isRFTrigger() || bit >= 16) return kFALSE;
00174   if(triggerInfo[0] & (1<<bit)) return kTRUE;
00175   else return kFALSE;
00176   
00177 }
00178 
00179 Int_t RawAtriStationEvent::numTriggerChansHigh(){
00180 
00181   Int_t numChans=0;
00182   for(Int_t i=0;i<16;i++){
00183     if(isTriggerChanHigh(i)) numChans++;
00184   }
00185   return numChans;
00186 
00187 }

Generated on Mon Dec 9 13:20:21 2013 for ARA ROOT v3.13 Software by doxygen 1.4.7