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

Annotation of /yoda/techmodel/physics/NeutronDetectorReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Wed Aug 16 08:20:29 2006 UTC (18 years, 3 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA6_3/19, YODA6_3/18, YODA6_3/13, YODA6_3/12, YODA6_3/11, YODA6_3/10, YODA6_3/17, YODA6_3/16, YODA6_3/15, YODA6_3/14, YODA6_3/06, YODA6_3/20, YODA6_3/07, YODA6_3/08, YODA6_3/09, HEAD
Changes since 6.0: +2 -3 lines
Hardware bug in the Neutron Detector.
Volodia wrote:
"There is a bug in ND hardwer. Because of this
the patter of ND sometimes could be changed from '00 00 00 0F'
to '00 00 01 0F'. You can see this in files 915, 917 for 99% events.
I saw also '00 00 16 0F' in several cases.
At the same time S4 QL was also crushed for this files. Why?

I am afraid that it is neseccary to make some correction in
YODA to take into account this problem.
May be , it would be better to check '?? ?? ?? 0F ?? ?? ?? 0F ?? ?? ?? OF'"

1 kusanagi 1.1
2     #include <string>
3 kusanagi 1.2 #include <log4cxx/logger.h>
4 kusanagi 1.1 #include "NeutronDetectorReader.h"
5    
6     using namespace pamela;
7     using namespace pamela::neutron;
8    
9 kusanagi 1.2 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.neutron.NeutronDetectorReader"));
10 kusanagi 1.1
11     /**
12     * Constructor.
13     */
14     NeutronDetectorReader::NeutronDetectorReader(void):
15     TechmodelAlgorithm(PacketType::Physics, "TechmodelNeutronDetectorReader") {
16 kusanagi 1.2 logger->debug(_T("Constructor"));
17 kusanagi 1.1 neutronEvent = new NeutronEvent();
18     }
19    
20     /**
21     * Get a string with the version info of the algorithm.
22     */
23     std::string NeutronDetectorReader::GetVersionInfo(void) const {
24     return
25 kusanagi 6.1 "$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 6.0 2006/02/07 17:11:11 kusanagi Exp $";
26 kusanagi 1.1 }
27    
28     /**
29     * Initialize the algorithm with a special run. This will initialize the
30     * event reader routines for all packet types.
31 kusanagi 2.4 * For definition the definition for Neutron detector data is located in the
32     * end of the physics packet.
33     * More explicitely the neutronData is composed by 4 bytes;
34     * a pattern 00 0F TR BK
35     * where:
36     * 00 0f is a fixed pattern
37     * TR is the NeutronCounter for a trigger event
38     * BK is the NeutronCounter beetween two trigger events
39 kusanagi 1.1 */
40     void NeutronDetectorReader::Init(PamelaRun *run) {
41 kusanagi 1.2 logger->debug(_T("Initialize"));
42 kusanagi 1.1 SetInputStream(run);
43     run->WriteSubPacket(this, &neutronEvent, neutronEvent->Class());
44     }
45    
46     /**
47     * Unpack the anticounter event from an input file.
48     */
49     void NeutronDetectorReader::RunEvent(int EventNumber) {
50    
51     }
52    
53     /**
54     * Unpack the NeutronDetector data event from the physical packet.
55     */
56 kusanagi 4.1 void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int length) {
57 kusanagi 2.2 NeutronRecord *rec;
58     const int lenNeutronData = 12;
59 kusanagi 4.1 //char *data = new char[lenght];
60     //memcpy(data, subData, lenght);
61 kusanagi 1.1 neutronEvent->Records->Clear();
62     TClonesArray &recs = *(neutronEvent->Records);
63 kusanagi 2.1 int offset;
64 kusanagi 4.1 if (haveData(&*subData, length)){
65 kusanagi 1.1 for (int i = 0; i < 3; i++){
66 kusanagi 2.1 offset = lenNeutronData - 4*i;
67 kusanagi 1.1 rec = new(recs[i]) NeutronRecord(); //aggiungo un nuovo NeutronRecord all'evento
68 kusanagi 4.1 rec->trigPhysics = (UINT8)subData[length-offset];
69     rec->upperBack = (((UINT8)subData[length-offset+1])>>4);
70     rec->bottomBack = (((UINT8)subData[length-offset+1])&0x0F);
71 kusanagi 1.1 }
72 kusanagi 2.3 neutronEvent->unpackError = 0;
73     } else {
74     neutronEvent->unpackError = 1;
75 kusanagi 1.1 }
76     }
77    
78 kusanagi 2.4
79 kusanagi 4.1 bool NeutronDetectorReader::haveData(const char data[], long int length){
80 kusanagi 1.1 bool ret = false;
81 kusanagi 6.1 if (((UINT8)data[length - 1] == 0x0F)&&((UINT8)data[length - 5] == 0x0F)&&((UINT8)data[length - 9] == 0x0F)) ret = true;
82 kusanagi 1.1 return ret;
83     }

  ViewVC Help
Powered by ViewVC 1.1.23