15 printf(
"Hello Create\n");
19 void TT() { printf(
"Hello Van\n"); TreeClass::Create(); printf(
"bye Van\n");}
23 TreeClass::TreeClass() :
TBase() {}
27 TreeClass::TreeClass(TFile *f) :
TBase() {
28 fOutFileName =
"Out.root";
30 cout << f->GetName() <<
" file has been found" << endl;
31 fOutFileName = f->GetName();
32 fOutFileName.ReplaceAll(
"/",
"_");
33 fOutFileName.ReplaceAll(
".root",
"");
34 fOutFileName +=
"Out.root";
35 TTree *tree = (TTree*) f->Get(
"T");
36 if (tree) { MyInit(tree); }
37 else cout <<
"no TTree found" << endl;
43 TreeClass::TreeClass(TTree *tree) :
TBase(tree) {
47 TCollection *files = gROOT->GetListOfFiles();
48 if (! files) { cout <<
"no root files" << endl;
return; }
55 while ( (f = (TFile *) next()) ) {
56 tree = (TTree*) f->Get(
"T");
58 cout << f->GetName() <<
" file hase been found" << endl;
59 fOutFileName = f->GetName();
60 fOutFileName.ReplaceAll(
"/",
"_");
61 fOutFileName.ReplaceAll(
".root",
"");
62 fOutFileName +=
"Out.root";
64 Events = tree->GetEntries();
66 cout <<
"#\t" << Files <<
"\t" << f->GetName() <<
"\t" << Events << endl;
72 if (tree) {MyInit(tree);}
76 void TreeClass::Loop(Int_t Nevents) {
84 const Int_t NSvtLayers = 6;
108 {
"timeB",
"time for 80 anodes", 256, 3, 0.,128., 0.,3. };
111 {
"uP",
"track u", 320, 3, -5.,5., 0.,3. };
114 {
"Du",
"Du before cut", 250, 3, -2.,2., 0.,3. };
117 {
"Du",
"Du cuts", 200, 3, -1.,1., 0.,3. };
119 TFile *fOut =
new TFile(fOutFileName,
"recreate");
134 TH1F *LocPlots[NB][NL][NW][NH][NA];
135 TH1F * uPlots[NB][NL];
136 TH1F * uPlBLW[NB][NL][NW];
137 TH1F * hpT =
new TH1F(
"Pt",
"pt", 200, -2., 2.);
138 TH1F * hpM =
new TH1F(
"Ptot",
"ptot", 200, 0., 5.);
139 TH1F * LocAll =
new TH1F(
"All",
"all", plotTB.nx, plotTB.xmin, plotTB.xmax);
140 TH1F * uPAll =
new TH1F(
"UPall",
"uPall", plotUP.nx, plotUP.xmin, plotUP.xmax);
141 TH1F * uAll =
new TH1F(
"Uall",
"ua", plotUP.nx, plotUP.xmin, plotUP.xmax);
144 TH1F * uCuts[NB][NL];
145 TH1F * xCuts[NB][NL];
146 TH1F * uCut =
new TH1F(
"Ucut",
"uc", plotDu.nx, plotDu.xmin, plotDu.xmax);
147 TH1F * vCut =
new TH1F(
"Vcut",
"vc", 200, -3., 3.);
148 TH2F * dMin =
new TH2F(
"DMin",
"vumin",100,-0.75,0.75,100,-0.75,0.75);
149 TH1F * vMin =
new TH1F(
"VMin",
"vmin", plotDuv.nx, plotDuv.xmin, plotDuv.xmax);
150 TH1F * uMin =
new TH1F(
"UMin",
"umin", plotDuv.nx, plotDuv.xmin, plotDuv.xmax);
151 TH1F * uMinC =
new TH1F(
"UMinC",
"umC", plotDuv.nx, plotDuv.xmin, plotDuv.xmax);
152 memset(LocPlots,0,NB*NL*NW*NH*
sizeof(TH1F *));
153 memset( uPlots,0,NB*NL*
sizeof(TH1F *));
154 for (
int B = 0; B < 3; B++) {
155 uName = Form(
"UBarrel%i", B+1);
156 uTitle = Form(
"du for B%i", B+1);
157 duB[B][0] =
new TH1F(uName, uTitle, plotDuv.nx, plotDuv.xmin, plotDuv.xmax );
158 uName = Form(
"VBarrel%i", B+1);
159 uTitle = Form(
"dv for B%i", B+1);
160 dvB[B] =
new TH1F(uName, uTitle, plotDuv.nx, plotDuv.xmin, plotDuv.xmax );
161 uName = Form(
"UBarrel%iVcut", B+1);
162 uTitle = Form(
"du for B%i after Vcut", B+1);
163 duB[B][1] =
new TH1F(uName, uTitle, plotDuv.nx, plotDuv.xmin, plotDuv.xmax );
165 for (Int_t L = 0; L < NSvtLayers; L++) {
166 Int_t barrel = SvtSsdConfig[L].Barrel;
167 Int_t layer = SvtSsdConfig[L].Layer;
168 Int_t NoLadders = SvtSsdConfig[L].NoLadders;
169 Int_t NoWafers = SvtSsdConfig[L].NoWafers;
170 for (Int_t ladder = 1; ladder <= NoLadders; ladder++) {
171 if (barrel <= 3 && (ladder-1)%2 != layer%2)
continue;
173 uName += Form(
"L%02iB%i", ladder, barrel);
174 uTitle = Form(
"uP for layer %i B %i L %i", layer, barrel, ladder);
175 uPlots[barrel-1][ladder-1] =
176 new TH1F(uName, uTitle, plotUP.nx, plotUP.xmin, plotUP.xmax );
178 uName = Form(
"%sL%02iB%i", plotDu.Name, ladder, barrel);
179 uTitle = Form(
"u-uP for B %i L %i", barrel, ladder);
180 uCuts[barrel-1][ladder-1]=
181 new TH1F(uName, uTitle, plotDu.nx, plotDu.xmin, plotDu.xmax );
182 uName = Form(
"%sxL%02iB%i", plotDu.Name, ladder, barrel);
183 uTitle = Form(
"u-uP corr B %i L %i", barrel, ladder);
184 xCuts[barrel-1][ladder-1]=
185 new TH1F(uName, uTitle, plotDu.nx, plotDu.xmin, plotDu.xmax );
186 for (Int_t wafer = 1; wafer <= NoWafers; wafer++) {
188 uName += Form(
"L%02iB%iW%i", ladder, barrel, wafer);
189 uTitle = Form(
"uP for layer %i B %i L %i W %i", layer, barrel, ladder, wafer);
190 uPlBLW[barrel-1][ladder-1][wafer-1] =
191 new TH1F(uName, uTitle, plotUP.nx, plotUP.xmin, plotUP.xmax );
192 for (Int_t hybrid = 1; hybrid <= 2; hybrid++) {
193 for (Int_t anode =1; anode <=3; anode++) {
195 Name += Form(
"L%02iB%iW%02iH%iA%i", ladder, barrel, wafer, hybrid, anode);
196 Title = Form(
"%s for layer %i B %i L %i W %i H %i G %i",
197 plotTB.Title, layer, barrel, ladder, wafer, hybrid, anode);
198 LocPlots[barrel-1][ladder-1][wafer-1][hybrid-1][anode-1] =
199 new TH1F(Name, Title, plotTB.nx, plotTB.xmin, plotTB.xmax );
205 Long64_t nentries = fChain->GetEntriesFast();
206 if (Nevents > 0 && nentries > Nevents) nentries = Nevents;
207 Long64_t nbytes = 0, nb = 0;
209 TString currentFile(
"");
211 for (Long64_t jentry=0; jentry<nentries;jentry++) {
212 Long64_t ientry = LoadTree(jentry);
213 if (ientry < 0)
break;
214 nb = fChain->GetEntry(jentry); nbytes += nb;
215 if (! jentry%1000 || TreeNo != fChain->GetTreeNumber()) {
216 cout <<
"Read event \t" << jentry
217 <<
" so far, switch to file " << fChain->GetCurrentFile()->GetName()
219 cout <<
" current TreeNo: " << TreeNo
220 <<
" new TreeNo: " << fChain->GetTreeNumber() << endl;
221 TreeNo = fChain->GetTreeNumber();
224 UInt_t Ntrack = fNPTracks;
226 for (UInt_t trk = 0; trk < Ntrack; trk++) {
227 int hitFlag[3][16][7] = { { { 0 } } };
228 Int_t Npoints = fTracks_fNpoint[trk];
229 if (minNoFitPoints > 0 && Npoints%100 < minNoFitPoints)
continue;
230 if (UseSsd && Npoints < 1000)
continue;
231 if (UseSvt && Npoints < 100)
continue;
232 Int_t Nsp = fTracks_fNsp[trk];
233 double dvmin = 1000.;
234 double dumin = 1000.;
237 Int_t k = fTracks_fIdHitT[trk][
hit] - 1;
239 if ( k < 0) cout <<
" k <0:"<<k<<
" hit="<<
hit<<
" Nsp="<<Nsp<< endl;
240 if ( k < 0)
continue;
241 Int_t layer = fHits_layer[k];
242 if (layer <= NSvtLayers ){
243 Int_t barrel = fHits_barrel[k];
244 Int_t ladder = fHits_ladder[k];
245 Int_t wafer = fHits_wafer[k];
246 Int_t hybrid = fHits_hybrid[k];
248 Double32_t u = fHits_u[k];
249 Double32_t v = fHits_v[k];
250 Double32_t uP = fHits_uP[k];
251 Double32_t vP = fHits_vP[k];
252 Double32_t du = u - uP;
253 Double32_t dv = v - vP;
254 Double32_t anode = fHits_anode[k];
255 Double32_t timeb = fHits_timeb[k];
257 hpT->Fill(fHits_pT[k]);
258 hpM->Fill(fHits_pMom[k]);
259 if (TMath::Abs(fHits_pT[k]) < 0.2)
continue;
260 if ( TMath::Abs(dv) < TMath::Abs(dvmin) ) {dvmin = dv; dumin= du; kmin = k;}
262 if ( hitFlag[barrel-1][ladder-1][wafer-1] == 0) {
263 hitFlag[barrel-1][ladder-1][wafer-1] = 1;
265 uPlots[barrel-1][ladder-1]->Fill( uP );
266 uPlBLW[barrel-1][ladder-1][wafer-1] ->Fill( uP );
269 duB[barrel-1][0]->Fill(du);
270 dvB[barrel-1]->Fill(dv);
272 if (TMath::Abs(dv) > rCut )
continue;
274 uCuts[barrel-1][ladder-1]->Fill(du);
276 int hid = X1.GetHid (barrel, ladder, wafer, hybrid);
277 double dux = uP - X1.Sptr[hid]->Coord( timeb );
278 xCuts[barrel-1][ladder-1]->Fill(dux);
280 duB[barrel-1][1]->Fill(du);
281 if (TMath::Abs(du) > 2.*rCut)
continue;
283 Int_t group = ((Int_t)anode)/80;
284 if (group >= 3) group = 2;
285 if (group < 0) group = 0;
286 LocPlots[barrel-1][ladder-1][wafer-1][hybrid-1][group]->Fill( timeb );
287 LocAll->Fill( timeb );
289 X1.Sptr[hid]->addStat( timeb, u, uP);
293 if (TMath::Abs(dvmin) < 1000.) {
294 dMin->Fill(dvmin,dumin);
297 if (TMath::Abs(dvmin) < rCut ) uMinC->Fill(dumin);