/[PAMELA software]/yoda/techmodel/physics/CalorimeterReader.cpp
ViewVC logotype

Diff of /yoda/techmodel/physics/CalorimeterReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by kusanagi, Sat Jul 17 20:03:48 2004 UTC revision 1.5 by kusanagi, Tue Sep 21 20:24:53 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v $
3   * $Id: TrackerReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $   * $Id: CalorimeterReader.cpp,v 1.4 2004/08/24 08:00:12 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the CalorimeterReader class.   * Implementation of the CalorimeterReader class.
7   */   */
8    
9    
10    #include <iostream>
11  #include <string>  #include <string>
12  #include <log4cpp/Category.hh>  #include <log4cxx/logger.h>
13  #include "CalorimeterReader.h"  #include "CalorimeterReader.h"
14    
15  extern "C" {  extern "C" {
16        
17   extern struct {   extern struct {
18          int IEV2;          int IEV2;
19          int dexy[96][22][2];          int stwerr;
20          int dexyc[96][22][2];          int perror;
21          int base[96][22][2];          int dexy[2][22][96];
22          int calselftrig[7][4];          int dexyc[2][22][96];
23            int base[2][22][96];
24            int calselftrig[4][7];
25          int calIItrig[4];          int calIItrig[4];
26          int calstripshift[4];          int calstripshift[4];
27          int calDSPtaberr[4];          int calDSPtaberr[4];
28          int calevnum[4];          int calevnum[4];
29      } evento_;      } evento_;
30    
31      int calunpack_(unsigned short[], long int*, int*);      void calunpack_(short[], long int*, int*);
32      //Struct per il passaggio di dati da e verso la chiamata fortran      //Struct per il passaggio di dati da e verso la chiamata fortran
33  }  }
34    
35  using namespace pamela;  using namespace pamela;
36  using namespace pamela::calorimeter;  using namespace pamela::calorimeter;
37    
38  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.calorimeter.CalorimeterReader");    static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.calorimeter.CalorimeterReader"));
39    
40  /**  /**
41   * Constructor.       * Constructor.    
42   */   */
43  CalorimeterReader::CalorimeterReader(void):  CalorimeterReader::CalorimeterReader(void):
44    TechmodelAlgorithm(PacketType::Physics, "TechmodelCalorimeterReader") {    TechmodelAlgorithm(PacketType::Physics, "TechmodelCalorimeterReader") {
45    cat.debug("Constructor");    logger->debug(_T("Construnctor"));
46    calorimeter = new CalorimeterEvent();    calorimeter = new CalorimeterEvent();
47  }  }
48    
# Line 47  CalorimeterReader::CalorimeterReader(voi Line 51  CalorimeterReader::CalorimeterReader(voi
51   */   */
52  std::string CalorimeterReader::GetVersionInfo(void) const {  std::string CalorimeterReader::GetVersionInfo(void) const {
53    return    return
54      "$Header: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $";      "$Header: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v 1.4 2004/08/24 08:00:12 kusanagi Exp $";
55  }  }
56    
57  /**  /**
# Line 55  std::string CalorimeterReader::GetVersio Line 59  std::string CalorimeterReader::GetVersio
59   * event reader routines for all packet types.   * event reader routines for all packet types.
60   */   */
61  void CalorimeterReader::Init(PamelaRun *run) {  void CalorimeterReader::Init(PamelaRun *run) {
62      logger->debug(_T("Initialize"));
63    SetInputStream(run);    SetInputStream(run);
64    run->WriteSubPacket(this, &calorimeter, calorimeter->Class());    run->WriteSubPacket(this, &calorimeter, calorimeter->Class());
65  }  }
# Line 70  void CalorimeterReader::RunEvent(int Eve Line 75  void CalorimeterReader::RunEvent(int Eve
75   * Unpack the Calorimeter data event from the physical packet.   * Unpack the Calorimeter data event from the physical packet.
76   */   */
77  void CalorimeterReader::RunEvent(int EventNumber, const char subData[], long int length) {  void CalorimeterReader::RunEvent(int EventNumber, const char subData[], long int length) {
78      char data[length];      std::stringstream oss;      
79        char *data = new char[length];
80      memcpy(data, subData, length);      memcpy(data, subData, length);
81      int  ERROR = 0;      int  ERROR = 0;
82            
# Line 78  void CalorimeterReader::RunEvent(int Eve Line 84  void CalorimeterReader::RunEvent(int Eve
84      for (int i = 0; i<length; i++){      for (int i = 0; i<length; i++){
85          convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF);          convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF);
86      }      }
       
       
     //Call to the routine that unpack calorimeter events  
     ERROR = calunpack_(convdata, &length, &ERROR);  
87                    
88      calorimeter->IEV2 = evento_.IEV2;      //Call to the routine that unpack calorimeter events
89      memcpy(calorimeter->dexy,           evento_.dexy,           sizeof(calorimeter->dexy));      calunpack_((short*)convdata, &length, &ERROR);
90      memcpy(calorimeter->dexyc,          evento_.dexyc,          sizeof(calorimeter->dexyc));  
91      memcpy(calorimeter->base,           evento_.base,           sizeof(calorimeter->base));      if (ERROR != 0) {
92      memcpy(calorimeter->calselftrig,    evento_.calselftrig,    sizeof(calorimeter->calselftrig));          char *errmsg;
93      memcpy(calorimeter->calIItrig,      evento_.calIItrig,      sizeof(calorimeter->calIItrig));          switch (ERROR){
94      memcpy(calorimeter->calstripshift,  evento_.calstripshift,  sizeof(calorimeter->calstripshift));              case 1: errmsg = "CALORIMETER NOT FOUND";
95      memcpy(calorimeter->calDSPtaberr,   evento_.calDSPtaberr,   sizeof(calorimeter->calDSPtaberr));          }
96      memcpy(calorimeter->calevnum,       evento_.calevnum,       sizeof(calorimeter->calevnum));          oss.flush();
97            oss << "Fortran77 function calunpack: " <<  errmsg;
98      cat <<  log4cpp::Priority::ERROR          logger->warn(oss.str().c_str());
99          <<  "Fortran77 function calunpack error code = " << ERROR      } else {
100          <<  "\n " << log4cpp::CategoryStream::ENDLINE;          calorimeter->IEV2   = evento_.IEV2;
101            calorimeter->stwerr = evento_.stwerr;
102            calorimeter->perror = evento_.perror;
103    
104        //--------have to invert array because of FORTRAN <-> C different management of the indexes
105            int tempDexy[96][22][2];
106            int tempDexyc[96][22][2];
107            int tempBase[96][22][2];
108            int tempCalselftrig[7][4];
109            memcpy(tempDexy,           evento_.dexy,           sizeof(tempDexy));
110            memcpy(tempDexyc,          evento_.dexyc,          sizeof(tempDexyc));
111            memcpy(tempBase,           evento_.base,           sizeof(tempBase));
112            memcpy(tempCalselftrig,    evento_.calselftrig,    sizeof(tempCalselftrig));
113    
114            for (int i = 0; i < 4; i++){
115                for (int j = 0; j < 7; j++){
116                    calorimeter->calselftrig[i][j] = tempCalselftrig[j][i];
117                }
118            }
119    
120            for (int i = 0; i < 2; i++){
121                for (int j = 0; j < 22; j++){
122                    for (int z = 0; z < 96; z++){
123                        calorimeter->dexy[i][j][z] = tempDexy[z][j][i];
124                        calorimeter->dexyc[i][j][z] = tempDexyc[z][j][i];
125                        calorimeter->base[i][j][z] = tempBase[z][j][i];
126                    }
127                }
128            }
129        //-----------------------------------------------------------------------------------------
130    
131            memcpy(calorimeter->calIItrig,      evento_.calIItrig,      sizeof(calorimeter->calIItrig));
132            memcpy(calorimeter->calstripshift,  evento_.calstripshift,  sizeof(calorimeter->calstripshift));
133            memcpy(calorimeter->calDSPtaberr,   evento_.calDSPtaberr,   sizeof(calorimeter->calDSPtaberr));
134            memcpy(calorimeter->calevnum,       evento_.calevnum,       sizeof(calorimeter->calevnum));
135        }
136        delete[] data;
137  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23