/** @file * $Source: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v $ * $Id: CalorimeterReader.cpp,v 1.5 2004/09/21 20:24:53 kusanagi Exp $ * $Author: kusanagi $ * * Implementation of the CalorimeterReader class. */ #include #include #include #include "CalorimeterReader.h" extern "C" { extern struct { int IEV2; int stwerr; int perror; int dexy[2][22][96]; int dexyc[2][22][96]; int base[2][22][96]; int calselftrig[4][7]; int calIItrig[4]; int calstripshift[4]; int calDSPtaberr[4]; int calevnum[4]; } evento_; void calunpack_(short[], long int*, int*); //Struct per il passaggio di dati da e verso la chiamata fortran } using namespace pamela; using namespace pamela::calorimeter; static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.calorimeter.CalorimeterReader")); /** * Constructor. */ CalorimeterReader::CalorimeterReader(void): TechmodelAlgorithm(PacketType::Physics, "TechmodelCalorimeterReader") { logger->debug(_T("Construnctor")); calorimeter = new CalorimeterEvent(); } /** * Get a string with the version info of the algorithm. */ std::string CalorimeterReader::GetVersionInfo(void) const { return "$Header: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v 1.5 2004/09/21 20:24:53 kusanagi Exp $"; } /** * Initialize the algorithm with a special run. This will initialize the * event reader routines for all packet types. */ void CalorimeterReader::Init(PamelaRun *run) { logger->debug(_T("Initialize")); SetInputStream(run); run->WriteSubPacket(this, &calorimeter, calorimeter->Class()); } /** * Unpack the calorimeter event from an input file. */ void CalorimeterReader::RunEvent(int EventNumber) { } /** * Unpack the Calorimeter data event from the physical packet. */ void CalorimeterReader::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()); } else { calorimeter->IEV2 = evento_.IEV2; calorimeter->stwerr = evento_.stwerr; calorimeter->perror = evento_.perror; //--------have to invert array because of FORTRAN <-> C different management of the indexes int tempDexy[96][22][2]; int tempDexyc[96][22][2]; int tempBase[96][22][2]; int tempCalselftrig[7][4]; memcpy(tempDexy, evento_.dexy, sizeof(tempDexy)); memcpy(tempDexyc, evento_.dexyc, sizeof(tempDexyc)); memcpy(tempBase, evento_.base, sizeof(tempBase)); memcpy(tempCalselftrig, evento_.calselftrig, sizeof(tempCalselftrig)); for (int i = 0; i < 4; i++){ for (int j = 0; j < 7; j++){ calorimeter->calselftrig[i][j] = tempCalselftrig[j][i]; } } for (int i = 0; i < 2; i++){ for (int j = 0; j < 22; j++){ for (int z = 0; z < 96; z++){ calorimeter->dexy[i][j][z] = tempDexy[z][j][i]; calorimeter->dexyc[i][j][z] = tempDexyc[z][j][i]; calorimeter->base[i][j][z] = tempBase[z][j][i]; } } } //----------------------------------------------------------------------------------------- memcpy(calorimeter->calIItrig, evento_.calIItrig, sizeof(calorimeter->calIItrig)); memcpy(calorimeter->calstripshift, evento_.calstripshift, sizeof(calorimeter->calstripshift)); memcpy(calorimeter->calDSPtaberr, evento_.calDSPtaberr, sizeof(calorimeter->calDSPtaberr)); memcpy(calorimeter->calevnum, evento_.calevnum, sizeof(calorimeter->calevnum)); } delete[] data; }