HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoPmm2AnalyseEvProp.cxx
Go to the documentation of this file.
1 //
2 // File HarpoPmm2AnalyseEvProp.cxx
3 //
12 #include "HarpoPmm2AnalyseEvProp.h"
13 #include "HarpoConfig.h"
14 #include "Pmm2Event.h"
15 
16 #include "TFile.h"
17 
18 #include <cstdlib>
19 #include <cstring>
20 #include <cassert>
21 #include <iostream>
22 
23 const int MaxTime = 16777216; // 2^24 Time Stamp overflow value
24 
25 ClassImp(HarpoPmm2AnalyseEvProp)
26 
27 void HarpoPmm2AnalyseEvProp::print()
28  {
29  //TODO
30  }
31 
33  {
34  if( verbose ) std::cout << " Processing Event " << nEvents<< std::endl;
35  int itdiff; // Difference between times stamps in events N and N -1
36  //fEvt->print();
37 
38  Pmm2Event *anaEvt; //pointer to PMM2 part
39  if (gHDetSet->isExist(PMM2))
40  {
41  anaEvt = static_cast<Pmm2Event *>(fEvt->GetDetEvent(PMM2));
42  anaEvt->print();
43  }
44  else
45  {
46  std::cout << "No PMM2 data for this event" << std::endl;
47  return;
48  }
49 
50  int imes;
51  int esize = anaEvt->GetHeader()->eventSize;
52  int ievnum = anaEvt->GetHeader()->eventNumb;
53 
54  helen->Fill(esize+0.5); // Number of hits
55  Pmm2MesVect * pm = anaEvt->GetMesurements();
56  //int esize = pm->Size(); // Also give number of Digi's
57 
58  if( verbose ) pm->print();
59 
60  for(imes=0;imes<esize;imes++) {
61  // i cann't use operator[] on pointer
62  Pmm2MesVect &m = *pm;
63 
64  // *** This to methos to get channels must be the same *********
65 
66  // access via local reference m
67  //int ch = m[imes].getChNum(); // channel
68 
69  // we can use at in plase of brackets
70  int ch = pm->at(imes).getChNum(); // channel
71 
72  heprof->Fill(ch + 0.5); // Channel profile
73 
74  int iadc = m[imes].getCharge(); // Charge in adc counts
75  int ig = m[imes].getGain(); // Adc Gain bit
76  hadc[ig]->Fill(iadc + 0.5); // All adc's values
77 
78  int ipps = m[imes].getPPS(); // PPS counter
79  int its = m[imes].getTimeStamp(); // Time stamp not corrected
80  //std::cout << "pps " << ipps << " ts " << its << std::endl;
81  hpps->Fill(ipps + 0.5, its + 0.5);
82 
83  htvse->Fill(ievnum + 0.5, its + 0.5);
84 
85  if ( (imes == 0) && (itsold != -1) )
86  {
87  itdiff = its - itsold;
88  if ( itdiff < 0 ) {
89  itdiff = MaxTime - itdiff;
90  }
91  // std::cout << "e " << nEvents << " diff " << itdiff << std::endl;
92  htdiff->Fill(itdiff + 0.5);
93  htdiff2->Fill(itdiff + 0.5);
94  }
95 
96  itsold = its;
97 
98  int iramp = m[imes].getTRamp(); // TDC Ramp bit
99  int iftime = m[imes].getFTime(); // Fine Time
100  hramp->Fill(iramp + 0.5, iftime + 0.5);
101 
102  } // Digi Loop
103  nEvents++;
104  }
105 
107  {
108  nEvents = 0;
109  itsold = -1;
111 
112  helen = new TH1F("hELen","Hist per Event",20,0.0,19.0);
113  heprof = new TH1F("hEProf","Hits per Chan",20,0.0,19.0);
114  hadc[0] = new TH1F("hAdcg0","All Adc counts Gain 0",256,0.0,1024.0);
115  hadc[1] = new TH1F("hAdcg1","All Adc counts Gain 1",256,0.0,1024.0);
116  hpps = new TH2F("hPps","Time Stamp vs PPS",20,0.0,19.0,256,0.0,0.0);
117  htvse = new TH2F("hTvsE","Time Stamp vs Ev Num",512,0.0,0.0,512,0.0,0.0);
118  hramp = new TH2F("hRamp","Fine Time vs TDC Ramp",4,0.0,3.0,256,0.0,0.0);
119  htdiff = new TH1F("hTDiff","Time Diff",1024,0.0,1000000.0);
120  htdiff2 = new TH1F("hTDiff2","Time Diff low",1024,0.0,15000.0);
121 }
122 
123 void HarpoPmm2AnalyseEvProp::Save(char * /* mode */)
124  {
125  TString * hstFile = gHConfig->GetHistFile();
126  if ( hstFile == NULL ) {
127  std::cout << gHConfig->GetProgramName() << " " <<
128  "No Hist File name gived, use default" << std::endl;
129  hstFile = new TString("pmm2evprop.root");
130  }
131 
132  TFile *hf = new TFile(hstFile->Data(),"RECREATE");
133  helen->Write();
134  heprof->Write();
135  hadc[0]->Write();
136  hadc[1]->Write();
137  hpps->Write();
138  htvse->Write();
139  hramp->Write();
140  htdiff->Write();
141  htdiff2->Write();
142  hf->Close();
143  }
144 
Dcc Plane Y.
Definition: HarpoDet.h:20
A symple class analyse base PMM2 events properties Event Analysis code.
int itsold
Time Stamp differens ( zoom on low val)
TString * GetProgramName()
Get Program Name.
Definition: HarpoConfig.h:105
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
Definition: HarpoDetSet.h:33
void print() const
Add new Digi to the event.
Definition: Pmm2Event.cxx:53
UInt_t eventSize
Raw Event size.
Definition: HarpoDetEvent.h:28
TH1F * htdiff
Fine Time vs TDC Ramp.
TH1F * hadc[2]
Hits per channel.
TH1F * htdiff2
Time Stamp differens.
HarpoDetEvent * GetDetEvent(Long_t plane=XDCC)
Definition: HarpoEvent.cxx:93
Pmm2MesVect * GetMesurements()
Return pointer to decoded data.
Definition: Pmm2Event.cxx:78
TH2F * htvse
Adc valuer for each gain.
void print() const
Definition: Pmm2MesList.cxx:34
TH2F * hpps
Time stamp vs Event number.
TH2F * hramp
Time stamp vs PPS counter.
TH1F * heprof
Number of Digi's in event.
A class store HARPO raw PMM2 event buffer and header. End provide access metods to the row data...
Definition: Pmm2Event.h:19
virtual const EventHeader_t * GetHeader() const
Definition: HarpoDetEvent.h:38
const int MaxTime
TH1F * helen
Redefine empty default.
HarpoEvent * fEvt
Definition: HarpoAnalyse.h:70
ULong_t nEvents
Definition: HarpoAnalyse.h:75
Int_t getChNum() const
Definition: Pmm2Mes.h:28
TString * GetHistFile()
Get Name of Histogram output file.
Definition: HarpoConfig.h:100
HarpoConfig * gHConfig
A list of all mesurements in one Event for Pmm2 v2 card The class is place holder for all unpacked me...
Definition: Pmm2MesList.h:19
Pmm2Mes at(ULong_t idx)
Definition: Pmm2MesList.h:37
R__EXTERN HarpoDetSet * gHDetSet
Definition: HarpoDetSet.h:71
UInt_t eventNumb
Event number in run.
Definition: HarpoDetEvent.h:29
Long64_t GetVerbose()
Get program verbosity level.
Definition: HarpoConfig.h:115