/[PAMELA software]/chewbacca/PamOffLineSW/techmodel/EventReader.cpp
ViewVC logotype

Diff of /chewbacca/PamOffLineSW/techmodel/EventReader.cpp

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

revision 1.2 by mocchiut, Tue Nov 4 09:44:36 2008 UTC revision 1.5 by mocchiut, Thu Feb 11 09:02:11 2010 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: messineo $   * $Author: mocchiut $
3   * $Date: 2008-06-13 11:58:58 $   * $Date: 2009/08/04 13:58:12 $
4   * $Revision: 1.22 $   * $Revision: 1.4 $
5   *   *
6   * Implementation of the functions of a sample Algorithm class.   * Implementation of the functions of a sample Algorithm class.
7   * This file can be used as a templace to develop your own algorithm.   * This file can be used as a templace to develop your own algorithm.
# Line 9  Line 9 
9    
10  #include "EventReader.h"  #include "EventReader.h"
11  #include "ReaderAlgorithms.h"  #include "ReaderAlgorithms.h"
12    #include <TObjectTable.h>
13    
14  extern "C" {  extern "C" {
15      #include "CRC.h"      #include "CRC.h"
# Line 85  EventReader::EventReader(): Line 86  EventReader::EventReader():
86   * Initialize the algorithm with a special run. This will initialize the   * Initialize the algorithm with a special run. This will initialize the
87   * event reader routines for all packet types.   * event reader routines for all packet types.
88   */   */
89  void EventReader::Init(PamelaRun *run) {          TObject *EventReader::GetPtr(TString name){    
90          //Create the structure of directories and create xxx.Header.root files    for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin(); i != TechmodelAlgorithmMap.end(); i++) {
91            run->WriteHeaders(this, &Header);        if ( !strcmp(i->second->GetAlgorithmName(),name.Data()) ){
92      //Create the xxx.root in it's specific directory        //      cout << " Retrieving pointer of " << i->second->GetAlgorithmName()<<endl;
93      for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin();        TechmodelAlgorithm* EventAlgorithm(i->second);
94         i != TechmodelAlgorithmMap.end(); i++) {        return(EventAlgorithm->GetPtr(""));
95         // cout << " Initializing algo " << i->second->GetAlgorithmName()<<endl;      };
96         i->second->Init(run);    };
97      }    return(NULL);
98    }
99    
     if ( Header ) { delete Header; Header = new EventHeader(); };  // EMILIANO, reset Counter when opening a new file  
100    
101      Run=run;  void EventReader::Init(PamelaRun *run) {        
102      //Create the structure of directories and create xxx.Header.root files
103      //  printf(" init er \n");
104      run->WriteHeaders(this, &Header);  
105      //  printf(" init er wrote \n");
106      //Create the xxx.root in it's specific directory
107      //  gObjectTable->Print();
108      //  Int_t yy = 0;
109      for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin();
110           i != TechmodelAlgorithmMap.end(); i++) {
111        //    cout << " Initializing algo " << i->second->GetAlgorithmName()<<endl;
112        i->second->Init(run);
113        //    printf(" algo %i \n",yy);
114        //    yy++;
115      }
116      //  printf(" init er header  \n");
117      if ( Header ) { delete Header; Header = new EventHeader(); };  // EMILIANO, reset Counter when opening a new file
118      //  printf(" init er header done %p  \n",run);
119      
120      Run=run;
121  }  }
122    
123    
# Line 184  int EventReader::PKT_RunEvent(char* head Line 204  int EventReader::PKT_RunEvent(char* head
204                  // catch (NotExistingAlgorithmException exc) {}                  // catch (NotExistingAlgorithmException exc) {}
205    
206                  Run->FillTrees(type);                  Run->FillTrees(type);
207                    //              cout << Header->GetCounter()->Get(type) << endl;
208                  Header->GetCounter()->Increment(type);                  Header->GetCounter()->Increment(type);
209                    //              cout << Header->GetCounter()->Get(type) << endl;
210          }          }
211          else          else
212          {          {
213                  ret=-3;                  ret=-3;
214                  oss.str("");                  oss.str("");
215                  oss << " No way to read events of type  " << type->GetName().c_str()<<". The Packet is skipped ";                    //              oss << " No way to read events of type  " << type->GetName().c_str()<<". The Packet is skipped ";  
216                    oss << " No way to read events of type  " << type->GetName()<<". The Packet is skipped ";  
217                  oss << " Return "<<ret;                  oss << " Return "<<ret;
218                  msg=oss.str();                  msg=oss.str();
219                  PamOffLineSW::mainLogUtil->logWarning(msg);                    PamOffLineSW::mainLogUtil->logWarning(msg);  
# Line 211  void EventReader::PKT_UnpackPscuHeader(c Line 234  void EventReader::PKT_UnpackPscuHeader(c
234    unsigned int  OrbitalTime  = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) +  (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF);    unsigned int  OrbitalTime  = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) +  (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF);
235    unsigned int  PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) +  (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF);    unsigned int  PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) +  (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF);
236    unsigned char CRC          = buff[15];    unsigned char CRC          = buff[15];
237    unsigned char FileOffset   = 0;// ??    //  unsigned char FileOffset   = 0;// ??
238    
239    Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2);    Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2);
240    Header->GetPscuHeader()->SetCounter(Counter);    Header->GetPscuHeader()->SetCounter(Counter);
# Line 231  void EventReader::PKT_UnpackPscuHeader(c Line 254  void EventReader::PKT_UnpackPscuHeader(c
254   */   */
255  std::string EventReader::GetVersionInfo(void) const {  std::string EventReader::GetVersionInfo(void) const {
256          return          return
257      "$Header: /repository/PamOffLineSW/techmodel/EventReader.cpp,v 1.22 2008-06-13 11:58:58 messineo Exp $\n";      "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/EventReader.cpp,v 1.4 2009/08/04 13:58:12 mocchiut Exp $\n";
258  }  }
259    
260    

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

  ViewVC Help
Powered by ViewVC 1.1.23