/** @file * $Source: /home/cvsmanager/yoda/techmodel/physics/TofReader.cpp,v $ * $Id: TofReader.cpp,v 4.4 2005/05/28 10:44:13 kusanagi Exp $ * $Author: kusanagi $ * * Implementation of the CalorimeterReader class. */ #include #include #include #include "TofReader.h" extern "C" { extern struct { int tdcid[12]; int evcount[12]; int tdcmask[12]; int adc[4][12]; int tdc[4][12]; int temp1[12]; int temp2[12]; } tofvar_; void tofunpack_(unsigned char[], long int*, int*); //Struct per il passaggio di dati da e verso la chiamata fortran } using namespace pamela; using namespace pamela::tof; static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.tof.TofReader")); /** * Constructor. */ TofReader::TofReader(void): TechmodelAlgorithm(PacketType::Physics, "TechmodelTofReader") { logger->debug(_T("Construnctor")); tof = new TofEvent(); } /** * Get a string with the version info of the algorithm. */ std::string TofReader::GetVersionInfo(void) const { return "$Header: /home/cvsmanager/yoda/techmodel/physics/TofReader.cpp,v 4.4 2005/05/28 10:44:13 kusanagi Exp $"; } /** * Initialize the algorithm with a special run. This will initialize the * event reader routines for all packet types. */ void TofReader::Init(PamelaRun *run) { logger->debug(_T("Initialize")); SetInputStream(run); run->WriteSubPacket(this, &tof, tof->Class()); } /** * Unpack the tof event from an input file. */ void TofReader::RunEvent(int EventNumber) { } /** * Unpack the Tof data event from the physical packet. */ void TofReader::RunEvent(int EventNumber, const char subData[], long int length) { std::stringstream oss; char *data = new char[length]; memcpy(data, subData, length); int ERROR = 0; /*unsigned short convdata[length]; for (int i = 0; iwarn(oss.str().c_str()); } // In case of "ERROR != 0" the calunpack will take care to set all // parameters to zero //} else { // only for a variable tof->tof1int = evento_.IEV2; // memcpy(tof->tof1int, tofvar_.tof1int, sizeof(tofvar_.tof1int)); // printf("tof->tof1int[1] %i \n",tof->tof1int[0]); // for (int i = 0; i < 6; i++){ // tof->tof1int[i] = tofvar_.tof1int[i]; //}; // printf("tof->tof1int[2] %i \n",tof->tof1int[1]); memcpy(tof->tdcid, tofvar_.tdcid, sizeof(tof->tdcid)); memcpy(tof->evcount, tofvar_.evcount, sizeof(tof->evcount)); memcpy(tof->tdcmask, tofvar_.tdcmask, sizeof(tof->tdcmask)); memcpy(tof->temp1, tofvar_.temp1, sizeof(tof->temp1)); memcpy(tof->temp2, tofvar_.temp2, sizeof(tof->temp2)); //--------have to invert array because of FORTRAN <-> C different management of the indexes // int temptofmat[6][12]; // memcpy(temptofmat, toftest_.tofmat, sizeof(temptofmat)); // for (int i = 0; i < 6; i++){ // for (int j = 0; j < 12; j++){ // tof->tofmat[j][i] = temptofmat[i][j]; // } // } int tmpadc[12][4]; int tmptdc[12][4]; memcpy(tmpadc, tofvar_.adc, sizeof(tmpadc)); memcpy(tmptdc, tofvar_.tdc, sizeof(tmptdc)); for (int i = 0; i < 12; i++){ for (int j = 0; j < 4; j++){ tof->adc[j][i] = tmpadc[i][j]; tof->tdc[j][i] = tmptdc[i][j]; } } delete [] data; }