/[PAMELA software]/yoda/techmodel/PhysicsReader.cpp
ViewVC logotype

Diff of /yoda/techmodel/PhysicsReader.cpp

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

revision 2.3 by kusanagi, Thu Dec 16 17:32:57 2004 UTC revision 6.1 by kusanagi, Wed Aug 16 13:15:23 2006 UTC
# Line 1  Line 1 
1      /** @file      /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $
3   * $Id: PhysicsReader.cpp,v 2.2 2004/12/09 08:48:41 kusanagi Exp $   * $Id: PhysicsReader.cpp,v 6.0 2006/02/07 17:11:10 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the LogReader class.   * Implementation of the LogReader class.
# Line 19  extern "C" { Line 19  extern "C" {
19    
20  #include <fstream>  #include <fstream>
21  #include "stdio.h"  #include "stdio.h"
22    #include <sys/wait.h>
23  #include "ReaderAlgorithms.h"  #include "ReaderAlgorithms.h"
24    
25    
# Line 29  using namespace pamela::anticounter; Line 30  using namespace pamela::anticounter;
30  using namespace pamela::calorimeter;  using namespace pamela::calorimeter;
31  using namespace pamela::neutron;  using namespace pamela::neutron;
32  using namespace pamela::S4;  using namespace pamela::S4;
33    using namespace pamela::tof;
34    using namespace pamela::trigger;
35    
36  static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.PhysicsReader"));  static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.PhysicsReader"));
37    
# Line 36  static log4cxx::LoggerPtr logger = log4c Line 39  static log4cxx::LoggerPtr logger = log4c
39   * Constructor.   * Constructor.
40   */   */
41  PhysicsReader::PhysicsReader(void):  PhysicsReader::PhysicsReader(void):
42    TechmodelAlgorithm(PacketType::Physics, "TechmodelPhysicsReader") {      TechmodelAlgorithm(PacketType::Physics, "TechmodelPhysicsReader") {
43    logger->debug(_T("Constructor"));      logger->debug(_T("Constructor"));
44    trackerReader     = new TrackerReader;      trackerReader     = new TrackerReader;
45    anticounterReader = new AnticounterReader;      anticounterReader = new AnticounterReader;
46    calorimeterReader = new CalorimeterReader;      calorimeterReader = new CalorimeterReader;
47    neutronReader     = new NeutronDetectorReader;      neutronReader     = new NeutronDetectorReader;
48    s4Reader          = new S4Reader;      s4Reader          = new S4Reader;
49        tofReader         = new TofReader;
50        triggerReader     = new TriggerReader;
51  }  }
52    
53  /**  /**
# Line 50  PhysicsReader::PhysicsReader(void): Line 55  PhysicsReader::PhysicsReader(void):
55   */   */
56  std::string PhysicsReader::GetVersionInfo(void) const {  std::string PhysicsReader::GetVersionInfo(void) const {
57    return    return
58      "$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 2.2 2004/12/09 08:48:41 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 6.0 2006/02/07 17:11:10 kusanagi Exp $\n";
59  }  }
60    
61  /**  /**
# Line 58  std::string PhysicsReader::GetVersionInf Line 63  std::string PhysicsReader::GetVersionInf
63   * event reader routines for all packet types.   * event reader routines for all packet types.
64   */   */
65  void PhysicsReader::Init(PamelaRun *run) {  void PhysicsReader::Init(PamelaRun *run) {
66    SetInputStream(run);      SetInputStream(run);
67    trackerReader->Init(run);      trackerReader->Init(run);
68    anticounterReader->Init(run);      anticounterReader->Init(run);
69    calorimeterReader->Init(run);      calorimeterReader->Init(run);
70    neutronReader->Init(run);      neutronReader->Init(run);
71    s4Reader->Init(run);      s4Reader->Init(run);
72        tofReader->Init(run);
73        triggerReader->Init(run);
74    //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class());    //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class());
75    logger->debug(_T("Initialize"));    logger->debug(_T("Initialize"));
76  }  }
# Line 75  void PhysicsReader::RunEvent(int EventNu Line 82  void PhysicsReader::RunEvent(int EventNu
82      char *subData = new char[dataLenght];      char *subData = new char[dataLenght];
83      InputFile->read(subData, sizeof(unsigned char)*dataLenght);      InputFile->read(subData, sizeof(unsigned char)*dataLenght);
84    
85          /*-----------------*/      /*-----------------*/
86          //passo packetData a tutti i reader dei vari rivelatori      /*
87          trackerReader->RunEvent(EventNumber, subData, dataLenght);      //passo packetData a tutti i reader dei vari rivelatori
88          anticounterReader->RunEvent(EventNumber, subData, dataLenght);      int childtrk, childac, childcalo, childnd, childs4, childtof, childtrig, Status;
89          calorimeterReader->RunEvent(EventNumber, subData, dataLenght);      int retctrk, retcac, retccalo, retcnd, retcs4, retctof, retctrig;
90          neutronReader->RunEvent(EventNumber, subData, dataLenght);      
91          s4Reader->RunEvent(EventNumber, subData, dataLenght);      if ((childtrk = fork()) > 0) {
92          /*-----------------*/          trackerReader->RunEvent(EventNumber, subData, dataLenght);
93      delete[] subData;      }
94        if ((childac = fork()) > 0) {
95            anticounterReader->RunEvent(EventNumber, subData, dataLenght);
96        }
97        if ((childcalo = fork()) > 0) {
98            calorimeterReader->RunEvent(EventNumber, subData, dataLenght);
99        }
100        if ((childnd = fork()) > 0) {
101            neutronReader->RunEvent(EventNumber, subData, dataLenght);
102        }
103        if ((childs4 = fork()) > 0) {
104            s4Reader->RunEvent(EventNumber, subData, dataLenght);
105        }
106        if ((childtof = fork()) > 0) {
107            tofReader->RunEvent(EventNumber, subData, dataLenght);
108        }
109        if ((childtrig = fork()) > 0) {
110            triggerReader->RunEvent(EventNumber, subData, dataLenght);
111        }
112        
113        do {
114            retctrk  = waitpid(childtrk, &Status, 0);
115            retcac   = waitpid(childac, &Status, 0);
116            retccalo = waitpid(childcalo, &Status, 0);
117            retcnd   = waitpid(childnd, &Status, 0);
118            retcs4   = waitpid(childs4, &Status, 0);
119            retctof  = waitpid(childtof, &Status, 0);
120            retctrig = waitpid(childtrig, &Status, 0);
121        } while(    (retctrk > 0  || (retctrk == -1))   &&
122                    (retcac > 0   || (retcac == -1))    &&
123                    (retccalo > 0 || (retccalo == -1))  &&
124                    (retcnd > 0   || (retcnd == -1))    &&
125                    (retcs4 > 0   || (retcs4 == -1))    &&
126                    (retctof > 0  || (retctof == -1))   &&
127                    (retctrig > 0 || (retctrig == -1)) );
128    */  
129      
130        trackerReader->RunEvent(EventNumber, subData, dataLenght);
131        anticounterReader->RunEvent(EventNumber, subData, dataLenght);
132        calorimeterReader->RunEvent(EventNumber, subData, dataLenght);
133        neutronReader->RunEvent(EventNumber, subData, dataLenght);
134        s4Reader->RunEvent(EventNumber, subData, dataLenght);
135        tofReader->RunEvent(EventNumber, subData, dataLenght);
136        triggerReader->RunEvent(EventNumber, subData, dataLenght);
137        
138        /*-----------------*/
139        delete [] subData;
140  }  }
141    

Legend:
Removed from v.2.3  
changed lines
  Added in v.6.1

  ViewVC Help
Powered by ViewVC 1.1.23