00001 #include "emcDataFormatter.h"
00002 #include "EmcIndexer.h"
00003 #include "emcRawDataAccessor.h"
00004 #include "emcRawDataObject.h"
00005 #include "Event.h"
00006 #include "EmcDynamicData.h"
00007
00008 using namespace std;
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 bool emcDataFormatter::fillRDO(Event * ev){
00029
00030
00031 emcRawDataAccessor * rda = emcRawDataAccessor::GetInstance();
00032 emcRawDataObject * rdo = rda->GetRawDataObject() ;
00033 EmcDynamicData * fDynamicData = rda->GetDynamicData() ;
00034 const SuperModule * SMMap = fDynamicData->getSMMap();
00035 struct emcChannelLongList ecl[144];
00036 int nw;
00037 int NumberOfChannels;
00038
00039
00040 for(int iSM=0;iSM<fDynamicData->getnSM(); iSM++){
00041 empty(rdo, iSM);
00042 int packetId = 8001+SMMap[iSM].absPosition;
00043 Packet * p = ev->getPacket(packetId);
00044
00045 if(p) {
00046 int ctac = p->iValue(0,"AMU");
00047 int cpre = p->iValue(1,"AMU");
00048 int cpost= p->iValue(2,"AMU");
00049 rdo->SetCells(iSM, ctac, cpre, cpost);
00050 int hF = p->getHitFormat();
00051 NumberOfChannels = p->fillIntArray ( (int *) ecl, sizeof(*ecl), &nw, "SPARSE");
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 int start = iSM*144;
00067 delete p;
00068 if((packetId<=8172||packetId>=8176) ||
00069
00070 (packetId>8172&&packetId<8176&&NumberOfChannels>72)) {
00071
00072
00073 for (int i=0; i< NumberOfChannels; i++){
00074 int errCode = 0;
00075 int tac = 4095-ecl[i].time;
00076 int hg_pre = 4095-ecl[i].highpre;
00077 int hg_post = 4095-ecl[i].highpost;
00078 int lg_pre = 4095-ecl[i].lowpre;
00079 int lg_post = 4095-ecl[i].lowpost;
00080 if(tac <=TAC_MIN||tac >=TAC_MAX) errCode |= TAC_OUT;
00081 if(hg_pre <=HG_MIN ||hg_pre >=HG_MAX) errCode |= HG_PRE_OUT;
00082 if(hg_post<=HG_MIN ||hg_post>=HG_MAX) errCode |= HG_POST_OUT;
00083 if(lg_pre <=LG_MIN ||lg_pre >=LG_MAX) errCode |= LG_PRE_OUT;
00084 if(lg_post<=LG_MIN ||lg_post>=LG_MAX) errCode |= LG_POST_OUT;
00085 rdo->Set(start+ecl[i].channel, tac, hg_post, lg_post, hg_pre, lg_pre, errCode);
00086
00087 }
00088 } else {
00089
00090 for (int i=0; i< NumberOfChannels; i++){
00091 int errCode = 0;
00092 int tac = 4095-ecl[i].time;
00093 int hg_pre = 4095-ecl[i].highpre;
00094 int hg_post = 4095-ecl[i].highpost;
00095 int lg_pre = 4095-ecl[i].lowpre;
00096 int lg_post = 4095-ecl[i].lowpost;
00097 if(tac <=TAC_MIN||tac >=TAC_MAX) errCode |= TAC_OUT;
00098 if(hg_pre <=HG_MIN ||hg_pre >=HG_MAX) errCode |= HG_PRE_OUT;
00099 if(hg_post<=HG_MIN ||hg_post>=HG_MAX) errCode |= HG_POST_OUT;
00100 if(lg_pre <=LG_MIN ||lg_pre >=LG_MAX) errCode |= LG_PRE_OUT;
00101 if(lg_post<=LG_MIN ||lg_post>=LG_MAX) errCode |= LG_POST_OUT;
00102 int ch = ecl[i].channel;
00103 int loc = ch%24 + (ch/24)*48;
00104 rdo->Set(start+loc, tac, hg_post, lg_post, hg_pre, lg_pre, errCode);
00105
00106 }
00107 }
00108
00109 }
00110 }
00111 return true;
00112 }
00113
00114 void emcDataFormatter::empty(emcRawDataObject * rdo, const int iSM){
00115 int start = iSM*144;
00116 for (int i=0; i<144; i++){
00117 rdo->Set(start+i, 0,0,0,0,0,CHANNEL_DISABLED);
00118 }
00119 rdo->resetAMUAddresses(iSM);
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129