FairRoot/PandaRoot
Functions | Variables
NHitsPerEvent.C File Reference
#include <map>

Go to the source code of this file.

Functions

void Init ()
 
void SetEntryNr (Int_t nr)
 
void Next ()
 
void Draw ()
 
void ExtractData (TClonesArray *array, TGraph *g)
 
int NHitsPerEvent ()
 

Variables

Int_t gEntryNr = 0
 
TTree * t
 
TClonesArray * mvdHitArray = new TClonesArray("PndSdsHit")
 
TClonesArray * mvdProjectedArray = new TClonesArray("PndSdsHit")
 
TClonesArray * trackArray = new TClonesArray("PndTrack")
 
TGraph * gHitPoints = new TGraph(4)
 
TGraph * gProjections = new TGraph(4)
 
TMultiGraph * mg = new TMultiGraph()
 
TH1I * h1 = new TH1I("h1", "Hits per Event", 101, -0.5, 100.5)
 

Function Documentation

void Draw ( )

Definition at line 64 of file NHitsPerEvent.C.

Referenced by Next().

64  {
65 
66  std::cout << "mvdHitArray: " << mvdHitArray->GetEntries() << " projectedHitArray " << mvdProjectedArray->GetEntries() << std::endl;
67 
68 // gHitPoints->Clear();
71  //if (gHitPoints->GetN() != x.size()) gHitPoints->Expand(x.size());
72 
73  std::cout << "NHits: " << gHitPoints->GetN() << std::endl;
74  gHitPoints->Draw("apl");
75  gProjections->Draw("pl");
76 }
void ExtractData(TClonesArray *array, TGraph *g)
Definition: NHitsPerEvent.C:78
TGraph * gHitPoints
Definition: NHitsPerEvent.C:15
TClonesArray * mvdHitArray
Definition: NHitsPerEvent.C:12
TClonesArray * mvdProjectedArray
Definition: NHitsPerEvent.C:13
TGraph * gProjections
Definition: NHitsPerEvent.C:16
void ExtractData ( TClonesArray *  array,
TGraph *  g 
)

Definition at line 78 of file NHitsPerEvent.C.

References i, x, and y.

Referenced by Draw().

78  {
79  std::map<Double_t, Double_t> x;
80  std::map<Double_t, Double_t> y;
81  for (int i = 0; i < array->GetEntriesFast(); i++){
82  PndSdsHit* myHit = (PndSdsHit*)array->At(i);
83  x[myHit->GetZ()] = myHit->GetX();
84  y[myHit->GetZ()] = myHit->GetY();
85  std::cout << i << " : (" << myHit->GetX() << "/" << myHit->GetY() << "/" << myHit->GetZ() << ")" << std::endl;
86  }
87  for (int j = 0; j < g->GetN(); j++) g->RemovePoint(j);
88 
89  std::map<Double_t, Double_t >::iterator yit = y.begin();
90  int i = 0;
91  for (std::map<Double_t, Double_t >::iterator xit = x.begin() ; xit != x.end(); xit++, yit++, i++){
92  g->SetPoint(i, xit->second, yit->second);
93  }
94 }
Int_t i
Definition: run_full.C:25
TFile * g
Double_t x
Double_t y
void Init ( )

Initialize the session

Definition at line 20 of file NHitsPerEvent.C.

Referenced by NHitsPerEvent().

21 {
22  TFile* f = new TFile("2014-10-27-00-06-02_50_MHz_Filtered_PosCorrected_Event.root", "READ");
23  t = (TTree*)f->Get("pndsim");
24 // t->AddFriend("pndsim", "2014-10-27-00-06-02_50_MHz_Filtered_PosCorrected_Residuals.root");
25 // t->AddFriend("pndsim", "2014-10-27-00-06-02_50_MHz_Filtered_PosCorrected_Track.root");
26 // t->AddFriend("pndsim", "2014-10-27-00-06-02_50_MHz_Filtered_TimeCorrectedSorted_Event.root");
27  t->StartViewer();
28 
29  t->SetBranchAddress("MVDHitsPixelPosCorrected", &mvdHitArray);
30 // t->SetBranchAddress("MvdProjectedHit", &mvdProjectedArray);
31 // t->SetBranchAddress("MvdTrack", &trackArray);
32 
33  gHitPoints->SetLineColor(kRed);
34  gHitPoints->SetMarkerStyle(2);
35  gHitPoints->SetMarkerColor(kRed);
36 
37  gProjections->SetLineColor(kBlue);
38  gProjections->SetMarkerStyle(5);
39  gProjections->SetMarkerColor(kBlue);
40 
41 
42 // mg->Add(gProjections, "Projected");
43  mg->Add(gHitPoints, "Hits");
44  t->GetEntry(0);
45 }
TMultiGraph * mg
Definition: NHitsPerEvent.C:17
TGraph * gHitPoints
Definition: NHitsPerEvent.C:15
TClonesArray * mvdHitArray
Definition: NHitsPerEvent.C:12
TFile * f
Definition: bump_analys.C:12
TTree * t
Definition: NHitsPerEvent.C:11
TGraph * gProjections
Definition: NHitsPerEvent.C:16
void Next ( )

Definition at line 52 of file NHitsPerEvent.C.

References Bool_t, Draw(), gEntryNr, mvdProjectedArray, run, and t.

52  {
53  Bool_t run = kTRUE;
54  while(run){
55  t->GetEntry(++gEntryNr);
56  if (mvdProjectedArray->GetEntriesFast() > 0){
57  run = kFALSE;
58  }
59  }
60  std::cout << "NextEntry: " << gEntryNr << std::endl;
61  Draw();
62 }
Int_t run
Definition: autocutx.C:47
Int_t gEntryNr
Definition: NHitsPerEvent.C:10
void Draw()
Definition: NHitsPerEvent.C:64
TTree * t
Definition: NHitsPerEvent.C:11
TClonesArray * mvdProjectedArray
Definition: NHitsPerEvent.C:13
int NHitsPerEvent ( )

Definition at line 96 of file NHitsPerEvent.C.

References h1, i, Init(), mvdHitArray, and t.

97 {
98  Init();
99  for (int i = 0; i < t->GetEntries(); i++){
100  t->GetEntry(i);
101  h1->Fill(mvdHitArray->GetEntriesFast());
102  }
103  h1->Draw();
104  return 0;
105 }
Int_t i
Definition: run_full.C:25
TH1I * h1
Definition: NHitsPerEvent.C:18
TClonesArray * mvdHitArray
Definition: NHitsPerEvent.C:12
void Init()
Definition: NHitsPerEvent.C:20
TTree * t
Definition: NHitsPerEvent.C:11
void SetEntryNr ( Int_t  nr)

Definition at line 47 of file NHitsPerEvent.C.

References gEntryNr, and t.

47  {
48  gEntryNr = nr;
49  t->GetEntry(gEntryNr);
50 }
Int_t gEntryNr
Definition: NHitsPerEvent.C:10
TTree * t
Definition: NHitsPerEvent.C:11

Variable Documentation

Int_t gEntryNr = 0

Definition at line 10 of file NHitsPerEvent.C.

Referenced by Next(), and SetEntryNr().

TGraph* gHitPoints = new TGraph(4)

Definition at line 15 of file NHitsPerEvent.C.

Referenced by Draw(), and Init().

TGraph* gProjections = new TGraph(4)

Definition at line 16 of file NHitsPerEvent.C.

Referenced by Draw(), and Init().

TH1I* h1 = new TH1I("h1", "Hits per Event", 101, -0.5, 100.5)

Definition at line 18 of file NHitsPerEvent.C.

Referenced by NHitsPerEvent().

TMultiGraph* mg = new TMultiGraph()

Definition at line 17 of file NHitsPerEvent.C.

Referenced by Init(), and plot_hitpattern().

TClonesArray* mvdHitArray = new TClonesArray("PndSdsHit")

Definition at line 12 of file NHitsPerEvent.C.

Referenced by Draw(), Init(), and NHitsPerEvent().

TClonesArray* mvdProjectedArray = new TClonesArray("PndSdsHit")

Definition at line 13 of file NHitsPerEvent.C.

Referenced by Draw(), and Next().

TTree* t

Definition at line 11 of file NHitsPerEvent.C.

Referenced by Init(), Next(), NHitsPerEvent(), and SetEntryNr().

TClonesArray* trackArray = new TClonesArray("PndTrack")

Definition at line 14 of file NHitsPerEvent.C.

Referenced by OnlineDBuilderTask::Exec().