| 1 | 
mocchiut | 
1.1 | 
 /** @file | 
| 2 | 
mocchiut | 
1.2 | 
 * $Source: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/PhysicsReader.cpp,v $ | 
| 3 | 
mocchiut | 
1.5 | 
 * $Id: PhysicsReader.cpp,v 1.4 2009/12/24 11:20:54 mocchiut Exp $ | 
| 4 | 
mocchiut | 
1.2 | 
 * $Author: mocchiut $ | 
| 5 | 
mocchiut | 
1.1 | 
 *  | 
| 6 | 
  | 
  | 
 * Implementation of the LogReader class. | 
| 7 | 
  | 
  | 
* ToBeDone: | 
| 8 | 
  | 
  | 
* Control the CRC for the entire data Packet not just for single records | 
| 9 | 
  | 
  | 
 */ | 
| 10 | 
  | 
  | 
 | 
| 11 | 
  | 
  | 
#define UINT unsigned int | 
| 12 | 
  | 
  | 
#define BYTE  unsigned char | 
| 13 | 
  | 
  | 
#include <string> | 
| 14 | 
  | 
  | 
 | 
| 15 | 
  | 
  | 
extern "C" { | 
| 16 | 
  | 
  | 
#include <sys/time.h> | 
| 17 | 
  | 
  | 
#include "CRC.h" | 
| 18 | 
  | 
  | 
} | 
| 19 | 
  | 
  | 
 | 
| 20 | 
  | 
  | 
#include <fstream> | 
| 21 | 
  | 
  | 
#include "stdio.h" | 
| 22 | 
  | 
  | 
#include "ReaderAlgorithms.h" | 
| 23 | 
  | 
  | 
 | 
| 24 | 
  | 
  | 
using namespace pamela; | 
| 25 | 
  | 
  | 
using namespace pamela::techmodel; | 
| 26 | 
  | 
  | 
using namespace pamela::tracker; | 
| 27 | 
  | 
  | 
using namespace pamela::anticounter; | 
| 28 | 
  | 
  | 
using namespace pamela::calorimeter; | 
| 29 | 
  | 
  | 
using namespace pamela::neutron; | 
| 30 | 
  | 
  | 
using namespace pamela::S4; | 
| 31 | 
  | 
  | 
using namespace pamela::tof; | 
| 32 | 
  | 
  | 
using namespace pamela::trigger; | 
| 33 | 
  | 
  | 
 | 
| 34 | 
  | 
  | 
/** | 
| 35 | 
  | 
  | 
 * Constructor.  | 
| 36 | 
  | 
  | 
 */ | 
| 37 | 
  | 
  | 
PhysicsReader::PhysicsReader(void):  | 
| 38 | 
  | 
  | 
    TechmodelAlgorithm(PacketType::Physics, "TechmodelPhysicsReader") {  | 
| 39 | 
  | 
  | 
    trackerReader     = new TrackerReader; | 
| 40 | 
  | 
  | 
    anticounterReader = new AnticounterReader; | 
| 41 | 
  | 
  | 
    calorimeterReader = new CalorimeterReader; | 
| 42 | 
  | 
  | 
    neutronReader     = new NeutronDetectorReader; | 
| 43 | 
  | 
  | 
    s4Reader          = new S4Reader; | 
| 44 | 
  | 
  | 
    tofReader         = new TofReader; | 
| 45 | 
  | 
  | 
    triggerReader     = new TriggerReader; | 
| 46 | 
  | 
  | 
} | 
| 47 | 
  | 
  | 
 | 
| 48 | 
  | 
  | 
/** | 
| 49 | 
  | 
  | 
 * Initialize the algorithm with a special run. This will initialize the | 
| 50 | 
  | 
  | 
 * event reader routines for all packet types. | 
| 51 | 
  | 
  | 
 */ | 
| 52 | 
  | 
  | 
void PhysicsReader::Init(PamelaRun *run)  | 
| 53 | 
  | 
  | 
{           | 
| 54 | 
mocchiut | 
1.5 | 
  //    printf(" physics reader in \n"); | 
| 55 | 
mocchiut | 
1.1 | 
        trackerReader->Init(run); | 
| 56 | 
  | 
  | 
    anticounterReader->Init(run); | 
| 57 | 
  | 
  | 
    calorimeterReader->Init(run); | 
| 58 | 
  | 
  | 
    neutronReader->Init(run); | 
| 59 | 
  | 
  | 
    s4Reader->Init(run); | 
| 60 | 
  | 
  | 
    tofReader->Init(run); | 
| 61 | 
  | 
  | 
    triggerReader->Init(run);    | 
| 62 | 
mocchiut | 
1.5 | 
    //  printf(" physics reader out \n"); | 
| 63 | 
mocchiut | 
1.1 | 
    ////run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class()); | 
| 64 | 
  | 
  | 
} | 
| 65 | 
  | 
  | 
 | 
| 66 | 
  | 
  | 
/** | 
| 67 | 
  | 
  | 
 * Unpack the Physics event from an input file. | 
| 68 | 
  | 
  | 
 */ | 
| 69 | 
  | 
  | 
void PhysicsReader::PKT_RunEvent(char* subData, long int dataLenght) throw (Exception) | 
| 70 | 
  | 
  | 
{ | 
| 71 | 
  | 
  | 
        int EventNumber = 0; | 
| 72 | 
  | 
  | 
    /*-----------------*/ | 
| 73 | 
  | 
  | 
    //passo packetData a tutti i reader dei vari rivelatori | 
| 74 | 
mocchiut | 
1.4 | 
        //      cout << " 1" << endl; | 
| 75 | 
mocchiut | 
1.1 | 
    triggerReader->RunEvent(EventNumber, subData, dataLenght);     | 
| 76 | 
mocchiut | 
1.4 | 
    //  cout << " 2" << endl; | 
| 77 | 
mocchiut | 
1.1 | 
    tofReader->RunEvent(EventNumber, subData, dataLenght); | 
| 78 | 
mocchiut | 
1.4 | 
    //  cout << " 3" << endl; | 
| 79 | 
mocchiut | 
1.1 | 
    trackerReader->RunEvent(EventNumber, subData, dataLenght); | 
| 80 | 
mocchiut | 
1.4 | 
    //  cout << " 4" << endl; | 
| 81 | 
mocchiut | 
1.1 | 
    anticounterReader->RunEvent(EventNumber, subData, dataLenght); | 
| 82 | 
mocchiut | 
1.4 | 
    //  cout << " 5" << endl; | 
| 83 | 
mocchiut | 
1.1 | 
    calorimeterReader->RunEvent(EventNumber, subData, dataLenght); | 
| 84 | 
mocchiut | 
1.4 | 
    //  cout << " 6" << endl; | 
| 85 | 
mocchiut | 
1.2 | 
    neutronReader->RunEvent(EventNumber, subData, dataLenght); // Emiliano! | 
| 86 | 
mocchiut | 
1.4 | 
    //  cout << " 7" << endl; | 
| 87 | 
mocchiut | 
1.1 | 
    s4Reader->RunEvent(EventNumber, subData, dataLenght); | 
| 88 | 
mocchiut | 
1.4 | 
    //  cout << " 8" << endl; | 
| 89 | 
mocchiut | 
1.1 | 
  //  if(...) | 
| 90 | 
  | 
  | 
   //   throw WrongCRCException_PKTUsed("asdsadas"); | 
| 91 | 
  | 
  | 
  | 
| 92 | 
  | 
  | 
} | 
| 93 | 
  | 
  | 
 | 
| 94 | 
  | 
  | 
/** | 
| 95 | 
  | 
  | 
 * Get a string with the version info of the algorithm. | 
| 96 | 
  | 
  | 
 */ | 
| 97 | 
  | 
  | 
std::string PhysicsReader::GetVersionInfo(void) const { | 
| 98 | 
  | 
  | 
  return  | 
| 99 | 
mocchiut | 
1.5 | 
    "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/PhysicsReader.cpp,v 1.4 2009/12/24 11:20:54 mocchiut Exp $\n"; | 
| 100 | 
mocchiut | 
1.1 | 
} | 
| 101 | 
  | 
  | 
 |