FairRoot/PandaRoot
Functions
lutmean.C File Reference

Go to the source code of this file.

Functions

int lutmean (TString baseFile="lut_all")
 

Function Documentation

int lutmean ( TString  baseFile = "lut_all")

Definition at line 1 of file lutmean.C.

References angle, At, Double_t, PndDrcLutNode::Entries(), f, PndDrcLutNode::GetDetectorId(), PndDrcLutNode::GetEntry(), PndDrcLutNode::GetPath(), PndDrcLutNode::GetPos(), PndDrcLutNode::GetTime(), i, inFile, max(), n, outFile, t, TString, and v.

2 {
3  gInterpreter->GenerateDictionary("vector<TVector3>","TVector3.h");
4 
5  TString inFile =baseFile+".root";
6  TString outFile =baseFile+"_avr.root";
7 
8  TFile* f = new TFile(inFile);
9  TTree *t=(TTree *) f->Get("dircsim") ;
10  TClonesArray* fLut[5];
11  for(Int_t l=0; l<5; l++){
12  fLut[l] = new TClonesArray("PndDrcLutNode");
13  t->SetBranchAddress(Form("LUT%d",l),&fLut[l]);
14  }
15  t->GetEntry(0);
16 
17 
18  TFile *fFileNew = TFile::Open(outFile, "RECREATE");
19  TClonesArray *fLutNew[5];
20 
21  TTree *fTreeNew = new TTree("dircsim","Look-up table for DIRC. Averaged");
22  for(Int_t l=0; l<5; l++){
23  fLutNew[l] = new TClonesArray("PndDrcLutNode");
24  fTreeNew->Branch(Form("LUT%d",l),&fLutNew[l],256000,0);
25  }
26 
27  Int_t Nnodes = 30000;
28  for(Int_t l=0; l<5; l++){
29  TClonesArray &fLutaNew = *fLutNew[l];
30  for (Long64_t n=0; n<Nnodes; n++) {
31  new((fLutaNew)[n]) PndDrcLutNode(-1);
32  }
33  }
34 
35  // TCanvas* c = new TCanvas("c","c",0,0,800,1200); c->Divide(1,2);
36  // TH1F * histNode = new TH1F("LutNode","Node vs Multiplicity",30000,0,150000);
37  // TH1F * hTime = new TH1F("hTime","Time",5000,0,10);
38  // TH1F * hDir = new TH1F("hDir","X component",1000,-1,1);
39 
40 
41  const Int_t max(100);
42  std::vector<TVector3> vArray[max];
43  std::vector<Double_t> tArray[max];
44  std::vector<Double_t> pArray;
45 
46  TVector3 dir, dir2, sum;
47  Double_t angle, minangle,pathid,time,sumt;
48  PndDrcLutNode *node;
49 
50  for(Int_t l=0; l<5; l++){
51  for (Int_t inode=0; inode<fLut[l]->GetEntriesFast(); inode++){
52  if(inode%1000==0) cout<<"Node # "<<inode<<endl;
53  node= (PndDrcLutNode*) fLut[l]->At(inode);
54  //histNode->Fill(node->GetNodeId(),node->Entries());
55  Int_t size = node->Entries();
56  if(size<1) continue;
57  for(int i=0; i<size; i++){
58  dir = node->GetEntry(i);
59  time = node->GetTime(i);
60  pathid = node->GetPath(i);
61 
62  // hDir->Fill(dir.X());
63  // hTime->Fill(time);
64 
65  bool newid = true;
66  for(int j=0; j<pArray.size(); j++){
67  if((Int_t)pathid == (Int_t)pArray[j]){
68  vArray[j].push_back(dir);
69  tArray[j].push_back(time);
70  newid= false;
71  }
72  }
73  if(newid){
74  vArray[pArray.size()].push_back(dir);
75  tArray[pArray.size()].push_back(time);
76  pArray.push_back(pathid);
77  }
78  }
79 
80  for(int j=0; j<pArray.size(); j++){
81  sum = TVector3(0,0,0);
82  sumt=0;
83  for(int v=0; v<vArray[j].size(); v++) {
84  sum += vArray[j][v];
85  sumt += tArray[j][v];
86 
87  // hDir->Fill(vArray[j][v].X());
88  // hTime->Fill(tArray[j][v]);
89  }
90 
91  // c->cd(1);
92  // hTime->Draw();
93  // c->cd(2);
94  // hDir->Draw();
95  // c->Update();
96  // c->WaitPrimitive();
97  // hDir->Reset();
98  // hTime->Reset();
99 
100  if(vArray[j].size()<5) continue;
101  sum *= 1/(Double_t)vArray[j].size();
102  sumt *= 1./(Double_t)tArray[j].size();
103 
104  ((PndDrcLutNode*)(fLutNew[l]->At(inode)))->AddEntry(node->GetDetectorId(), sum,pArray[j],j,sumt, node->GetPos());
105  }
106  for(int i=0; i<max; i++) {vArray[i].clear(); tArray[i].clear();}
107  pArray.clear();
108  }
109  }
110 
111  fTreeNew->Fill();
112  fTreeNew->Write();
113  fFileNew->Write();
114 
115  return 0;
116 }
Int_t i
Definition: run_full.C:25
TString outFile
Definition: hit_dirc.C:17
int n
Double_t GetDetectorId()
Definition: PndDrcLutNode.h:37
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
TString inFile
Definition: hit_dirc.C:8
Double_t GetPath(Int_t entry)
Definition: PndDrcLutNode.h:41
__m128 v
Definition: P4_F32vec4.h:4
cout<< "blue = Monte Carlo "<< endl;cout<< "red = Helix Hit "<< endl;cout<< "green = Center Of Tubes "<< endl;for(Int_t k=0;k< track->GetEntriesFast();k++){PndSttTrack *stttrack=(PndSttTrack *) track-> At(k)
Definition: checkhelixhit.C:56
Double_t
TFile * f
Definition: bump_analys.C:12
TVector3 GetEntry(Int_t entry)
Definition: PndDrcLutNode.h:39
Double_t GetTime(Int_t entry)
Definition: PndDrcLutNode.h:42
Int_t Entries()
Definition: PndDrcLutNode.h:36
TTree * t
Definition: bump_analys.C:13
TVector3 GetPos()
Definition: PndDrcLutNode.h:43
Double_t angle