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

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

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

revision 1.4 by kusanagi, Thu Aug 19 15:24:58 2004 UTC revision 2.2 by kusanagi, Wed Dec 22 11:39:16 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $
3   * $Id: TrackerReader.cpp,v 1.3 2004/07/26 23:09:47 kusanagi Exp $   * $Id: TrackerReader.cpp,v 2.1 2004/10/17 12:28:46 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the TrackerPhysicsReader class.   * Implementation of the TrackerPhysicsReader class.
7   */   */
8    
9  #include <string>  #include <string>
10  #include <log4cpp/Category.hh>  #include <log4cxx/logger.h>
11  #include "TrackerReader.h"  #include "TrackerReader.h"
12  #include "event/physics/tracker/TrackerEvent.h"  #include "event/physics/tracker/TrackerEvent.h"
13    
# Line 43  extern "C" { Line 43  extern "C" {
43        int TOTDATAlength;        int TOTDATAlength;
44        int datatracker[49152];        int datatracker[49152];
45      } level0_;      } level0_;
   
46  #include <dirent.h>  #include <dirent.h>
47  }  }
48    
49  using namespace pamela;  using namespace pamela;
50  using namespace pamela::tracker;  using namespace pamela::tracker;
51    
52  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.tracker.TrackerReader");    static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.tracker.TrackerReader"));
53    
54  /**  /**
55   * Constructor.   * Constructor.
56   */   */
57  TrackerReader::TrackerReader(void):  TrackerReader::TrackerReader(void):
58    TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {    TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {
59    cat.debug("Constructor");    logger->debug(_T("Constructor"));
60    tracker = new TrackerEvent();    tracker = new TrackerEvent();
61  }  }
62    
# Line 66  TrackerReader::TrackerReader(void): Line 65  TrackerReader::TrackerReader(void):
65   */   */
66  std::string TrackerReader::GetVersionInfo(void) const {  std::string TrackerReader::GetVersionInfo(void) const {
67    return    return
68      "$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 1.3 2004/07/26 23:09:47 kusanagi Exp $";      "$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 2.1 2004/10/17 12:28:46 kusanagi Exp $";
69  }  }
70    
71  /**  /**
# Line 74  std::string TrackerReader::GetVersionInf Line 73  std::string TrackerReader::GetVersionInf
73   * event reader routines for all packet types.   * event reader routines for all packet types.
74   */   */
75  void TrackerReader::Init(PamelaRun *run) {  void TrackerReader::Init(PamelaRun *run) {
76      logger->debug(_T("Initialize"));
77    SetInputStream(run);    SetInputStream(run);
78    run->WriteSubPacket(this, &tracker, tracker->Class());    run->WriteSubPacket(this, &tracker, tracker->Class());
79  }  }
# Line 93  void TrackerReader::RunEvent(int EventNu Line 93  void TrackerReader::RunEvent(int EventNu
93            
94      //Scrivo un file temporaneo per passarlo alla routine      //Scrivo un file temporaneo per passarlo alla routine
95      //Speriamo di cambiare la routine per passargli un buffer.....      //Speriamo di cambiare la routine per passargli un buffer.....
96          DIR *dirp;      //DIR *dirp;
97      std::string pathDir((char*)getenv("YODA_DATA"));      
98      pathDir = pathDir + "/todatemp.dat";      //std::string pathDir((char*)getenv("YODA_DATA"));
99        
100        //pathDir = pathDir + "/todatemp.dat";
101        stringstream oss;
102        oss.str("");
103        oss << getenv("YODA_DATA") << "/" << time(NULL) << "trev.dat";
104      FILE *pfile;      FILE *pfile;
105      pfile = fopen((char*)pathDir.c_str(), "wb");      pfile = fopen(oss.str().c_str(), "wb");
106      fwrite(subData, 1, length, pfile);      fwrite(subData, 1, length, pfile);
107      fclose(pfile);      fclose(pfile);
108            
109      //Call to the FORTRAN routin that unpack tracker events      //Call to the FORTRAN routin that unpack tracker events
110      trkeventpkt_(&ERROR, (char*)pathDir.c_str());      trkeventpkt_(&ERROR, (char*)oss.str().c_str());
111            
112      remove((char*)pathDir.c_str());      remove(oss.str().c_str());
113    
114            /*if (ERROR != 0) {
115            char *errmsg;
116            switch (ERROR){
117                case 1: errmsg = "---------------------";
118            }
119        } else {*/
120      //Store the unpacked data      //Store the unpacked data
121      memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));      memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));
122      memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));      memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));
# Line 115  void TrackerReader::RunEvent(int EventNu Line 125  void TrackerReader::RunEvent(int EventNu
125      memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));      memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));
126      memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));      memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));
127      memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));      memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));
128    //    memcpy(tracker->addrcluster, (level0_.addrcluster), sizeof(tracker->addrcluster));
129    //    memcpy(tracker->signcluster, (level0_.signcluster), sizeof(tracker->signcluster));
130  //--------have to invert array because of FORTRAN <-> C different management of the indexes  //--------have to invert array because of FORTRAN <-> C different management of the indexes
131      int tempAddr[3][12];      int tempAddr[3][12];
132      int tempSign[3][12];      int tempSign[3][12];
133      memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));      memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
134      memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));      memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
135      for (int j = 0; j < 12; j++){      for (int j = 0; j < 11; j++){
136          for (int i = 0; i < 3; i++){          for (int i = 0; i < 2; i++){
137              tracker->addrcluster[j][i] = tempAddr[i][j];              tracker->addrcluster[j][i] = tempAddr[i][j];
138              tracker->signcluster[j][i] = tempSign[i][j];              tracker->signcluster[j][i] = tempSign[i][j];
139          }          }
# Line 144  void TrackerReader::RunEvent(int EventNu Line 155  void TrackerReader::RunEvent(int EventNu
155      memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));                memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));          
156      tracker->TOTDATAlength = level0_.TOTDATAlength;      tracker->TOTDATAlength = level0_.TOTDATAlength;
157      memcpy(tracker->datatracker, level0_.datatracker, sizeof(tracker->datatracker));                memcpy(tracker->datatracker, level0_.datatracker, sizeof(tracker->datatracker));          
158        //}
159            
     cat <<  log4cpp::Priority::ERROR  
         <<  "Fortran77 function trkcalibpkt error code = " << ERROR  
         <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
160  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.2.2

  ViewVC Help
Powered by ViewVC 1.1.23