/** @file * $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $ * $Id: TrackerReader.cpp,v 1.2 2004/07/17 20:03:48 kusanagi Exp $ * $Author: kusanagi $ * * Implementation of the TrackerPhysicsReader class. */ #include #include #include "TrackerReader.h" #include "event/physics/tracker/TrackerEvent.h" extern "C" { //Passo il path verso la il file temporaneo extern void trkeventpkt_(int*, char*); //Struct per il passaggio di dati da e verso la chiamata fortran extern struct { int DAQmode[12]; int DSPnumber[12]; int DATAlength[12]; int eventn[12]; int nclust[12]; int cutc[12]; int cutcl[12]; int addrcluster[12][3]; int signcluster[12][3]; int fc[12]; int compressiontime[12]; int fl5[12]; int fl4[12]; int fl3[12]; int fl2[12]; int fl1[12]; int fl6[12]; int checksum[12]; int pnum[12]; int cmdnum[12]; int bid[12]; int alarm[12]; int aswr[12]; int TOTDATAlength; int datatracker[49152]; } level0_; #include } using namespace pamela; using namespace pamela::tracker; static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.tracker.TrackerReader"); /** * Constructor. */ TrackerReader::TrackerReader(void): TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") { cat.debug("Constructor"); tracker = new TrackerEvent(); } /** * Get a string with the version info of the algorithm. */ std::string TrackerReader::GetVersionInfo(void) const { return "$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 1.2 2004/07/17 20:03:48 kusanagi Exp $"; } /** * Initialize the algorithm with a special run. This will initialize the * event reader routines for all packet types. */ void TrackerReader::Init(PamelaRun *run) { SetInputStream(run); run->WriteSubPacket(this, &tracker, tracker->Class()); } /** * Unpack the orbital event from an input file. */ void TrackerReader::RunEvent(int EventNumber) { } /** * Unpack the Tracker data event from the physical packet. */ void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) { int ERROR; //Scrivo un file temporaneo per passarlo alla routine //Speriamo di cambiare la routine per passargli un buffer..... DIR *dirp; std::string pathDir((char*)getenv("YODA_DATA")); pathDir = pathDir + "/todatemp.dat"; FILE *pfile; pfile = fopen((char*)pathDir.c_str(), "wb"); fwrite(subData, 1, length, pfile); fclose(pfile); //Call to the FORTRAN routin that unpack tracker events trkeventpkt_(&ERROR, (char*)pathDir.c_str()); remove((char*)pathDir.c_str()); //Store the unpacked data memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode)); memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber)); memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength)); memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn)); memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust)); memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc)); memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl)); memcpy(tracker->addrcluster, level0_.addrcluster, sizeof(tracker->addrcluster)); memcpy(tracker->signcluster, level0_.signcluster, sizeof(tracker->signcluster)); memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc)); memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime)); memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1)); memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2)); memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3)); memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4)); memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5)); memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6)); memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum)); memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum)); memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum)); memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid)); memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm)); memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr)); tracker->TOTDATAlength = level0_.TOTDATAlength; memcpy(tracker->datatracker, level0_.datatracker, sizeof(tracker->datatracker)); cat << log4cpp::Priority::ERROR << "Fortran77 function trkcalibpkt error code = " << ERROR << "\n " << log4cpp::CategoryStream::ENDLINE; }