Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gen_roadset.C
Go to the documentation of this file.
1 void gen_roadset()
2 {
3  TFile* fp = new TFile("roads.root");
4  TTree* tr[3];
5  tr[0] = (TTree*)fp->Get("tr_new");
6  tr[1] = (TTree*)fp->Get("tr_tgt");
7  tr[2] = (TTree*)fp->Get("tr_old");
8 
9  // dimuon truth
10  int nDimuon;
11  float mass;
12  float xf;
13  float x1;
14  float x2;
15  float px[2];
16  int track_id[2];
17  int charge[2];
18  // digitized hit
19  int nHit;
20  int tb[2]; // 0 for not-all-4-stations hit at top/bottom
21  int unique_id[2][4]; // unique ID = 1000*detectorID + elementID
22  int detector_id[2][4];
23  float detector_zpos[2][4];
24  int element_id[2][4];
25  float element_xpos[2][4];
26  // road
27  int road_id[2]; // 0 for out-of-accentance track
28  int road_freq[2]; // roads frequency for roadset67, 1 for new roadset in this step
29 
30  for(int itr=0; itr<3; itr++)
31  {
32  char name[255];
33  sprintf(name,"roads_%d.txt",itr);
34 
35  FILE* fo = fopen(name, "w");
36 
37  tr[itr] -> SetBranchAddress("nDimuon",&nDimuon);
38  tr[itr] -> SetBranchAddress("mass",&mass);
39  tr[itr] -> SetBranchAddress("xf",&xf);
40  tr[itr] -> SetBranchAddress("x1",&x1);
41  tr[itr] -> SetBranchAddress("x2",&x2);
42  tr[itr] -> SetBranchAddress("px",px);
43  tr[itr] -> SetBranchAddress("track_id",track_id);
44  tr[itr] -> SetBranchAddress("charge",charge);
45  tr[itr] -> SetBranchAddress("nHit",&nHit);
46  tr[itr] -> SetBranchAddress("tb",tb);
47  tr[itr] -> SetBranchAddress("unique_id",unique_id);
48  tr[itr] -> SetBranchAddress("detector_id",detector_id);
49  tr[itr] -> SetBranchAddress("detector_zpos",detector_zpos);
50  tr[itr] -> SetBranchAddress("element_id",element_id);
51  tr[itr] -> SetBranchAddress("element_xpos",element_xpos);
52  tr[itr] -> SetBranchAddress("road_id",road_id);
53  tr[itr] -> SetBranchAddress("road_freq",road_freq);
54 
55 
56  const int nevt = tr[itr]->GetEntries();
57  for(int ievt=0; ievt<nevt; ievt++)
58  {
59  tr[itr]->GetEntry(ievt);
60 
61  if( itr<2 )
62  {
63  if( nDimuon!=1 ) continue;
64 
65  if( (road_id[0]*road_id[1])==0 ) continue;
66  }
67 
68  for(int icharge=0; icharge<2; icharge++)
69  {
70  int rid = road_id[icharge];
71  int uid[4];
72  for(int i=0; i<4; i++){ uid[i] = unique_id[icharge][i]; }
73 
74  it[icharge] = find(comp_id[icharge].begin(), comp_id[icharge].end(), rid);
75 
76  if( (it[icharge] == comp_id.end()) || (comp_id[icharge].size()==0) )
77  {
78  comp_id[icharge].push_back(rid);
79  }
80 
81 
82 
83  fprintf(fo, "%d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t \n",charge, rid, uid[0], uid[1], uid[2], uid[3], 0, 0, 0);
84  }
85  }
86  fclose(fo);
87 
88  cout<<"Done for loop "<<itr<<endl;
89  }
90 }
91 
92 
93 
void gen_roadset()
Definition: gen_roadset.C:1