StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
listPadOcc.C
1 // List pad occupancy for all clusters in all sectors which pass the
2 // cuts (3<=padlength<=6 and 4<=timelength<=8) for a "good" cluster
3 
4 // structures definitions
5 
6 struct HIT
7 {
8  Float_t x,y,z;
9  Float_t rad,phi;
10  Float_t raderror,phierror;
11 };
12 
13 struct CLUSTER
14 {
15  Float_t timepos,padpos,timesigma,padsigma;
16  Float_t peakheight, charge;
17  Int_t timebin,pad;
18  Int_t padlength,timelength;
19  Int_t row,sec;
20  Int_t flag;
21  Int_t numpeaks;
22 };
23 
24 struct EVENT
25 {
26  Float_t run;
27  Int_t nevent;
28  Float_t temperature,pressure;
29 };
30 
31 // =====================================
32 
33 void listPadOcc(const Char_t *fileName="filelist.txt")
34 {
35 
36  CLUSTER cluster;
37  HIT hit;
38  EVENT event;
39 
40  // plain Style
41  gROOT->Reset();
42  gStyle->SetTitleOffset(1.25);
43  gStyle->SetCanvasBorderMode(0);
44  gStyle->SetPadBorderMode(0);
45  gStyle->SetPadColor(0);
46  gStyle->SetCanvasColor(0);
47  gStyle->SetTitleColor(0);
48  gStyle->SetStatColor(0);
49  gStyle->SetPalette(1);
50  gStyle->SetOptStat(1111);
51  gStyle->SetOptFit();
52 
53  Int_t maxentries;
54  Int_t nevents=0;
55 
56  Int_t PadEntries[2][60][160];
57 
58  // Clear pad entries
59  for (int isec=0;isec<60;isec++){
60  for (int irow=0;irow<2;irow++){
61  for (int ipad=0;ipad<160;ipad++){
62  PadEntries[irow][isec][ipad]=0;
63  }
64  }
65  }
66 // input
67 
68 //++++++++++++++++++++++++++++++++++++++++++++++++++
69 // read file list from text file (maximum of 200 files)
70  char **fList = new char[200][256];
71  int nfile=0;
72  ifstream fin(fileName);
73  if (fin) {
74  int j=0;
75  cout << "Input file " << fileName << " found." << endl;
76  for (Int_t i=0;i<200;i++){
77  char *line = new char[256];
78  fin >> line;
79  if (fin.eof()) break;
80  fList[j] = line;
81  cout << " Added file : " << fList[j] << endl;
82  j++;
83  }
84  nfile = j;
85  }
86  fin.close();
87 
88 //++++++++++++++++++++++++++++++++++++++++++++++++++
89 
90  for (Int_t ifile=0;ifile<nfile;ifile++) {
91  TString eingabe = fList[ifile];
92  TFile f(eingabe);
93 
94  // read in ntuple
95  // ==============
96 
97  TTree *dtree=(TTree*) f.Get("cl");
98  TBranch *bcluster=dtree->GetBranch("cluster");
99  bcluster->SetAddress(&cluster);
100  TBranch *bevent=dtree->GetBranch("event");
101  bevent->SetAddress(&event);
102 
103  bevent->GetEntry(0);
104 // cout<<"Event number "<<event.nevent<<endl;
105  Int_t CurrentEvent = event.nevent;
106  nevents++;
107  maxentries=bcluster->GetEntries();
108  //cout<<"maxentries "<<maxentries<<endl;
109 
110  for (int i=0;i<=maxentries;i++) {
111  bevent->GetEntry(i);
112  if (event.nevent != CurrentEvent){
113 // cout<<"Event number "<<event.nevent<<endl;
114  CurrentEvent = event.nevent;
115  nevents++;
116  }
117  bcluster->GetEntry(i);
118  // Cut on #pad and #timebins for "good" clusters
119  if ((cluster.padlength>=3&&cluster.padlength<=6) &&
120  (cluster.timelength>=4&&cluster.timelength<=8)){
121 //cout<<"cluster.row "<<cluster.row<<" cluster.sec "<<cluster.sec<<" cluster.pad"<<endl;
122  PadEntries[cluster.row-1][cluster.sec-1][cluster.pad-1]++;
123  }
124  }
125  }
126 
127  cout<<nevents<<" Events analyzed"<<endl;
128 
129  cout<<endl;
130  cout<<" Pad occupancy for all clusters in all sectors which passed the cuts (3<=padlength<=6 and 4<=timelength<=8) for a 'good' cluster:"<<endl;
131  cout<<endl;
132 
133  Int_t npad;
134 
135  // Padrows 1 & 2
136  for (int irow=0;irow<2;irow++){
137  cout<<"Padrow "<<irow+1<<endl;
138  npad=0;
139  for (int isec=0;isec<6;isec++){
140  for (int ipad=0;ipad<160;ipad++){
141  // write out all entries
142  cout<<irow+1<<" "<<isec+1<<" "<<npad<<" ("<<ipad+1<<") "<<PadEntries[irow][isec][ipad]<<endl;
143  npad++;
144  }
145  }
146  }
147 
148  // Padrows 3 & 4
149  for (int irow=0;irow<2;irow++){
150  cout<<"Padrow "<<irow+3<<endl;
151  npad=0;
152  for (int isec=6;isec<12;isec++){
153  for (int ipad=0;ipad<160;ipad++){
154  // write out all entries
155  cout<<irow+1<<" "<<isec+1<<" "<<npad<<" ("<<ipad+1<<") "<<PadEntries[irow][isec][ipad]<<endl;
156  npad++;
157  }
158  }
159  }
160 
161  // Padrows 5 & 6
162  for (int irow=0;irow<2;irow++){
163  cout<<"Padrow "<<irow+5<<endl;
164  npad=0;
165  for (int isec=12;isec<18;isec++){
166  for (int ipad=0;ipad<160;ipad++){
167  // write out all entries
168  cout<<irow+1<<" "<<isec+1<<" "<<npad<<" ("<<ipad+1<<") "<<PadEntries[irow][isec][ipad]<<endl;
169  npad++;
170  }
171  }
172  }
173 
174  // Padrows 7 & 8
175  for (int irow=0;irow<2;irow++){
176  cout<<"Padrow "<<irow+7<<endl;
177  npad=0;
178  for (int isec=18;isec<24;isec++){
179  for (int ipad=0;ipad<160;ipad++){
180  // write out all entries
181  cout<<irow+1<<" "<<isec+1<<" "<<npad<<" ("<<ipad+1<<") "<<PadEntries[irow][isec][ipad]<<endl;
182  npad++;
183  }
184  }
185  }
186 
187  // Padrows 9 & 10
188  for (int irow=0;irow<2;irow++){
189  cout<<"Padrow "<<irow+9<<endl;
190  npad=0;
191  for (int isec=24;isec<30;isec++){
192  for (int ipad=0;ipad<160;ipad++){
193  // write out all entries
194  cout<<irow+1<<" "<<isec+1<<" "<<npad<<" ("<<ipad+1<<") "<<PadEntries[irow][isec][ipad]<<endl;
195  npad++;
196  }
197  }
198  }
199 
200 }
201