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