FairRoot/PandaRoot
Functions
timeStructurePasta.C File Reference

Go to the source code of this file.

Functions

std::vector< TH1 * > CreateChannelHistos (int channelNr, TTree *t)
 
TH1 * CreateErrorHisto (TFile *f)
 
int timeStructurePasta (TString fileName)
 

Function Documentation

std::vector<TH1*> CreateChannelHistos ( int  channelNr,
TTree *  t 
)

Definition at line 8 of file timeStructurePasta.C.

References cut.

Referenced by timeStructurePasta().

8  {
9  std::vector<TH1*> histos;
10 
11  std::stringstream cutstream;
12  cutstream << "data.fTimeBranch.channelId == " << channelNr;
13  TCut cut = cutstream.str().c_str();
14  if (channelNr == -1) // -1 creates global histograms for all channels
15  cut = "";
16 // std::cout << "Cut: " << cutstream.str() << std::endl;
17 
18  std::stringstream hstream;
19  hstream << "hToT_" << channelNr;
20  TH1* tot = new TH1D(hstream.str().c_str(),"ToT Histogram ", 1025,-0.5,1024.5);
21  std::stringstream tstream;
22  tstream << "data.fToT >> " << hstream.str();
23  t->Draw(tstream.str().c_str(), cut, "goff");
24  histos.push_back(tot);
25 
26  std::stringstream hstream1;
27  hstream1 << "hECoarse_" << channelNr;
28  TH1* eCoarse = new TH1D(hstream1.str().c_str(),"Coarse Energy : EnergyBranch", 1025,-0.5,1024.5);
29  std::stringstream tstream1;
30  tstream1 << "data.fEnergyBranch.t_coarse >> " << hstream1.str();
31  t->Draw(tstream1.str().c_str(), cut, "goff");
32  histos.push_back(eCoarse);
33 
34  std::stringstream hstream2;
35  hstream2 << "hTCoarse_" << channelNr;
36  TH1* tCoarse = new TH1D(hstream2.str().c_str(),"Coarse Energy : TimeBranch", 1025,-0.5,1024.5);
37  std::stringstream tstream2;
38  tstream2 << "data.fTimeBranch.t_coarse >> " << hstream2.str();
39  t->Draw(tstream2.str().c_str(), cut, "goff");
40  histos.push_back(tCoarse);
41 
42  return histos;
43 }
double cut[MAX]
Definition: autocutx.C:36
TTree * t
Definition: bump_analys.C:13
TH1* CreateErrorHisto ( TFile *  f)

Definition at line 45 of file timeStructurePasta.C.

References RunSummary::fAllPartialResets, RunSummary::fCrcErrorCount, RunSummary::fCrcMatchCount, RunSummary::fMissingFrames, RunSummary::fSingleWordFrames, RunSummary::fSuperFrameCount, RunSummary::fWrongFrameCount, RunSummary::fWrongHitCount, and summary.

Referenced by timeStructurePasta().

45  {
46  RunSummary* summary = (RunSummary*)f->Get("RunSummary");
47  TH1D* histo = new TH1D("hOverview","Overview",9,-0.5,8.5);
48  histo->Fill((int)0, summary->fCrcMatchCount);
49  histo->Fill(1, summary->fCrcErrorCount);
50  histo->Fill(2, summary->fSingleWordFrames);
51  histo->Fill(3, summary->fAllPartialResets);
52  histo->Fill(4, summary->fWrongHitCount);
53  histo->Fill(5, summary->fWrongFrameCount);
54  histo->Fill(6, summary->fMissingFrames);
55  histo->Fill(7, summary->fSuperFrameCount);
56 
57  return histo;
58 }
int fWrongFrameCount
count of all frames where the expected frame ID did not match the frameID in the header ...
int fWrongHitCount
count of all frames where the hits in the header do not match the data
int fSingleWordFrames
count of all frames with just one word. This is an error a frame has at least two words ...
int fAllPartialResets
count of all partial resets detected
int fMissingFrames
count of all missing frames (not very reliable)
TFile * f
Definition: bump_analys.C:12
int fCrcErrorCount
count of all frames with wrong CRC
int fSuperFrameCount
count of frame counter overflow (should not happen because the frame counter is HUGE ...
RunSummary summary
int fCrcMatchCount
count of all frames with correct CRC
int timeStructurePasta ( TString  fileName)

Definition at line 60 of file timeStructurePasta.C.

References CreateChannelHistos(), CreateErrorHisto(), creator, digi, PndMvdPastaDigi::ENERGY, f, g, g2, PndMvdPastaDigi::GetChannelId(), PndMvdPastaDigi::GetTimeStamp(), i, n, output, and t.

61 {
62  TFile* f = new TFile(fileName, "READ");
63 
64  PndFileNameCreator creator(fileName.Data());
65  std::string output = creator.GetCustomFileName("histos");
66 
67  TFile* fOut = new TFile(output.c_str(),"RECREATE");
68 
69  TTree* t = (TTree*)f->Get("PastaTB");
70  TClonesArray* pastadata = new TClonesArray("PndMvdPastaDigi");
71  t->SetBranchAddress("data", &pastadata);
72 
73  TH1* hEvents = new TH1D("hEvents","Events per Channel", 65,-0.5,64.5);
74  t->Draw("data.fTimeBranch.channelId >> hEvents","","goff");
75 
76  std::vector<ULong64_t> times;
77  std::vector<int> stripNr;
78  for (int i = 0; i < t->GetEntriesFast(); i++){
79  t->GetEntry(i);
80  for (int j = 0; j < pastadata->GetEntries(); j++){
81  PndMvdPastaDigi* digi = (PndMvdPastaDigi*)pastadata->At(j);
82  times.push_back(digi->GetTimeStamp());
83  stripNr.push_back(digi->GetChannelId(PndMvdPastaDigi::ENERGY));
84 // std::cout << "TimeStamp: " << digi->GetTimeStamp() << std::endl;
85  }
86  }
87 
88  for(int i = -1; i < 64; i++){
89  std::stringstream channel;
90  std::vector<TH1*> channelResult = CreateChannelHistos(i, t);
91  for (int j = 0; j < channelResult.size(); j++){
92  channelResult[j]->Write();
93  }
94 
95  }
96 
97  TH1* errorHisto = CreateErrorHisto(f);
98  errorHisto->Write();
99 
100  const int sizeArray = times.size();
101 // std::cout << "SizeArray " << sizeArray << std::endl;
102 
103  TGraph* g = new TGraph(sizeArray);
104  g->SetName("GraphTimeVsIndex");
105  TGraph* g2 = new TGraph(sizeArray);
106  g2->SetName("GraphStripVsIndex");
107 // std::cout << "After creating graph" << std::endl;
108  for (int n = 0; n < sizeArray; n++){
109  g->SetPoint(n, n, times[n]);
110  g2->SetPoint(n,n,stripNr[n]);
111  }
112  hEvents->Write();
113  g->Write();
114  g2->Write();
115 
116 // TCanvas* c1 = new TCanvas();
117 // c1->Divide(2,1);
118 // c1->cd(1);
119 // g->Draw("AP");
120 
121 
122 // c1->cd(2);
123 // g2->Draw("AP");
124 // std::cout << "Writing Channel Structure" << std::endl;
125 
126 
127  f->Close();
128  fOut->Close();
129 
130  std::cout << "Finished conversion" << std::endl;
131 
132  return 0;
133 }
TClonesArray * digi
std::vector< TH1 * > CreateChannelHistos(int channelNr, TTree *t)
Int_t i
Definition: run_full.C:25
int n
TFile * g
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
A simple class which adds the corresponding file extensions to a given base class.
ULong64_t GetTimeStamp()
TFile * f
Definition: bump_analys.C:12
TF1 * g2
Definition: anaLmdReco.C:159
PndMvdCreateDefaultApvMap * creator
TTree * t
Definition: bump_analys.C:13
int GetChannelId(branchId id)
TH1 * CreateErrorHisto(TFile *f)