5 gSystem->Load("libANALYSIS");
6 gSystem->Load("libTPCcalib");
7 gSystem->Load("libSTAT.so");
9 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
10 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
11 .L $ALICE_ROOT/TPC/CalibMacros/CalibLaserVscan.C+
13 AliXRDPROOFtoolkit tool;
14 chain = tool.MakeChainRandom("laserScan.txt","Mean",0,10200);
16 chainRef = tool.MakeChain("laserScanRef.txt","Mean",0,10200);
17 chain->AddFriend(chainRef,"R")
18 chainRefA = tool.MakeChain("laserScanRefA.txt","Mean",0,10200);
19 chain->AddFriend(chainRefA,"RA")
20 chainRefC = tool.MakeChain("laserScanRefC.txt","Mean",0,10200);
21 chain->AddFriend(chainRefC,"RC")
30 TFile fbundle("scanDeltaBeam.root");
31 chain->Draw("mphi:GetValueBundle(id,1)","isOK&&GetValueBundle(id,0)>3&<r.fSide==0","")
42 #include "TObjArray.h"
48 #include "TTreeStream.h"
50 #include "AliTPCLaserTrack.h"
51 #include "AliTPCcalibDB.h"
52 #include "TStatToolkit.h"
55 TMatrixD matrixP4Corr(7,2); // P4 correction for P0 - y position and P2 -snp(phi)
56 TMatrixD matrixP2RMSIROC(7,5); // rms of second derivative IROC
57 TMatrixD matrixP2RMSOROC(7,5); // rms of second derivative OROC
59 // rod 5 means all rods
61 TMatrixD matrixMeanBundle(336,6); // mean position/delta per bundle
62 TMatrixD matrixRMSBundle(336,6); // rms of distribution
64 // 0 - number of entries
71 map<int,TVectorD*> mapRunVoltage; // run to voltage
72 // run# -0 ggA 1- ggC 2- coA 3-coC 4-skA 5-skC
73 map<int,int> mapRunVgg; // run to gating grid voltage
74 map<int,int> mapRunVskirt; //
75 map<int,int> mapRunVcover; //
76 TArrayI runlist(10000);
82 TCut tA="isOK&&RA.isOK";
83 TCut tC="isOK&&RC.isOK";
84 TCut cA="eY.fElements<0.01&&RA.eY.fElements<0.01&&X.fElements>10&&RA.X.fElements>10";
85 TCut cC="eY.fElements<0.01&&RA.eY.fElements<0.01&&X.fElements>10&&RA.X.fElements>10";
90 Double_t GetValueBundle(Int_t id, Int_t type){
93 return matrixMeanBundle(id,type);
96 Double_t GetP4Corr(Int_t id, Int_t value){
97 AliTPCLaserTrack *ltrack =(AliTPCLaserTrack *) AliTPCLaserTrack::GetTracks()->At(id);
98 Int_t beam = ltrack->GetBeam();
99 return matrixP4Corr(beam,value);
102 Double_t GetDyBundle(Int_t id){
103 Double_t dy = matrixMeanBundle(id,4);
104 Double_t dx = matrixMeanBundle(id,5);
105 AliTPCLaserTrack *ltrack =(AliTPCLaserTrack *) AliTPCLaserTrack::GetTracks()->At(id);
106 Double_t p2 = ltrack->GetParameter()[2];
107 Double_t delta = dy+dx*p2;
111 Double_t GetRMSBundle(Int_t id, Int_t type){
114 return matrixRMSBundle(id,type);
116 Int_t GetVoltage(Int_t run, Int_t type){
119 // run# -0 ggA 1- ggC 2- coA 3-coC 4-skA 5-skC
120 TVectorD *runVoltage = mapRunVoltage[run];
121 if (!runVoltage) return -1;
122 return (*runVoltage)[type];
128 TFile f("laserData.root","recreate");
129 matrixMeanBundle.Write("matrixMeanBundle");
130 matrixRMSBundle.Write("matrixRMSBundle");
131 matrixP4Corr.Write("matrixP4Corr");
132 matrixP2RMSIROC.Write("matrixP2RMSIROC");
133 matrixP2RMSOROC.Write("matrixP2RMSOROC");
137 AliTPCLaserTrack::LoadTracks();
138 TFile f("laserData.root");
139 matrixMeanBundle.Read("matrixMeanBundle");
140 matrixRMSBundle.Read("matrixRMSBundle");
141 matrixP4Corr.Read("matrixP4Corr");
142 matrixP2RMSIROC.Read("matrixP2RMSIROC");
143 matrixP2RMSOROC.Read("matrixP2RMSOROC");
149 in.open("runSetup.txt");
159 printf("%s\n",objfile.Data());
160 arr = objfile.Tokenize(" ");
162 if (arr->GetEntries()>=7){
163 Int_t run = atoi(arr->At(0)->GetName());
164 Int_t vcover = atoi(arr->At(0)->GetName());
165 Int_t vskirt = atoi(arr->At(1)->GetName());
166 Int_t vgg = atoi(arr->At(3)->GetName());
167 TVectorD * vsetup = new TVectorD(6);
168 for (Int_t iv=0; iv<6; iv++){
169 (*vsetup)[iv] = atoi(arr->At(iv+1)->GetName());
171 mapRunVoltage[run]=vsetup;
173 mapRunVskirt[run]=vskirt;
174 mapRunVcover[run]=vcover;
175 runlist[counter]=run;
187 void MakeAnalysisBeam(){
191 TTreeSRedirector *pcstream = new TTreeSRedirector("scanDeltaBeam.root");
192 TH1* phisP0=new TH1F("hhisP0","hhisP0",100,-5.,5.);
193 TH1* phisP0X=new TH1F("hhisP0X","hhisP0X",100,-5.,5.);
194 TH1* phisP2=new TH1F("hhisP2","hhisP2",100,-6,6);
195 TH1* phisP4=new TH1F("hhisP4","hhisP4",100,-0.05,0.05);
197 TH1* phisP2IROC=new TH1F("hhisP2IROC","hhisPIROC",100,-2.,2.);
198 TH1* phisP2OROC=new TH1F("hhisP2OROC","hhisPOROC",100,-2.,2.);
202 for (Int_t iside=0;iside<2;iside++){
203 for (Int_t ibeam=0; ibeam<8; ibeam++){
204 for (Int_t irun=0; irun<100; irun++){
205 Int_t run =runlist[irun];
207 if (run==0) continue;
208 Int_t vskirt = GetVoltage(run,1);
209 Int_t vcover = GetVoltage(run,2);
210 Int_t vgg = GetVoltage(run,0);
212 TCut cut = Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&<r.fBeam==%d&&run==%d", iside, ibeam,run);
214 cut = Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&&run==%d", iside,run);
216 Int_t entries = chain->Draw("gp41-GetValueBundle(id,3)>>hhisP4",cut,"goff");
217 if (entries==0) continue;
218 chain->Draw("10*(mphi-GetValueBundle(id,1)-GetP4Corr(id,0)*gp41)>>hhisP0",cut,"goff");
219 chain->Draw("10*(mphi-GetDyBundle(id)-GetP4Corr(id,0)*gp41)>>hhisP0X",cut,"goff");
220 chain->Draw("1000*(mphiP-GetValueBundle(id,2)-GetP4Corr(id,1)*gp41)>>hhisP2",cut,"goff");
222 printf("%d\t%d\t%d\t%f\t%f\t%d\n", iside, ibeam,run, phisP0X->GetMean(), phisP0X->GetRMS(), Int_t(phisP0X->GetEntries()));
224 chain->Draw("10*(mphi-GetValueBundle(id,1)-GetP4Corr(id,0)*gp41)>>hhisP0",cut,"goff");
226 chain->Draw("mPy2vP2In*100^2>>hhisP2IROC",cut,"goff");
227 chain->Draw("mPy2vP2Out*100^2>>hhisP2OROC",cut,"goff");
230 Double_t mp0 = phisP0->GetMean();
231 Double_t mp0X = phisP0X->GetMean();
232 Double_t mp2 = phisP2->GetMean();
233 Double_t mp4 = phisP4->GetMean();
234 Double_t mp2I = phisP2IROC->GetMean();
235 Double_t mp2O = phisP2OROC->GetMean();
236 Double_t sp0 = phisP0->GetRMS();
237 Double_t sp0X = phisP0X->GetRMS();
238 Double_t sp2 = phisP2->GetRMS();
239 Double_t sp4 = phisP4->GetRMS();
240 Double_t sp2I = phisP2IROC->GetRMS();
241 Double_t sp2O = phisP2OROC->GetRMS();
242 (*pcstream)<<"vScanBeam"<<
249 "entries="<<entries<<
272 void MakeMeanBundle(){
276 AliTPCLaserTrack::LoadTracks();
277 AliTPCLaserTrack *ltrack;
286 for (Int_t ibeam=0; ibeam<7; ibeam++){
287 Int_t entries0=chain->Draw("mphi:gp41",Form("isOK&<r.fBeam==%d",ibeam));
288 TGraph gr0(entries0,chain->GetV2(),chain->GetV1());
290 gr0.Fit("pol1","Q","Q");
291 fp1 = gr0.GetFunction("pol1");
292 matrixP4Corr(ibeam,0)=fp1->GetParameter(1);
293 Int_t entries2=chain->Draw("mphiP:gp41",Form("isOK&<r.fBeam==%d",ibeam));
294 TGraph gr2(entries2,chain->GetV2(),chain->GetV1());
296 gr2.Fit("pol1","Q","Q");
297 fp1 = gr2.GetFunction("pol1");
298 matrixP4Corr(ibeam,1)=fp1->GetParameter(1);
301 // get RMS of second derivative
303 phisP0= new TH1F("hisP0","hisP0",500,-1.,1.);
304 for (Int_t irod=0; irod<5;irod++)
305 for (Int_t ibeam=0; ibeam<7; ibeam++){
307 TCut cut=Form("isOK&<r.fBeam==%d&<r.fRod==%d",ibeam,irod);
308 if (irod==5) cut=Form("isOK&<r.fBeam==%d",ibeam);
309 chain->Draw("mPy2vP2In*100^2>>hisP0",cut);
310 matrixP2RMSIROC(ibeam,irod) = phisP0->GetRMS();
311 chain->Draw("mPy2vP2Out*100^2>>hisP0",cut);
312 matrixP2RMSOROC(ibeam,irod) = phisP0->GetRMS();
317 // Get mean bundle position
319 for (Int_t id=0; id<336; id+=7){
320 ltrack =(AliTPCLaserTrack *) AliTPCLaserTrack::GetTracks()->At(id);
321 Int_t side = ltrack->GetSide();
322 Int_t rod = ltrack->GetRod();
323 Int_t bundle = ltrack->GetBundle();
324 // Int_t beam = ltrack->GetBeam();
325 ccut = Form("isOK&<r.fSide==%d&<r.fBundle==%d&<r.fRod==%d",side,bundle,rod);
326 phisP0= new TH1F("hisP0","hisP0",500,-0.5,0.5);
327 phisP2= new TH1F("hisP2","hisP2",500,-0.02,0.02);
328 phisP4= new TH1F("hisP4","hisP4",500,-0.2,0.2);
329 Int_t entries =chain->Draw("mphi",Form("isOK&&id==%d",id),"goff");
330 chain->Draw("mphi-GetP4Corr(id,0)*gp41>>hisP0",ccut,"");
331 chain->Draw("mphiP-GetP4Corr(id,1)*gp41>>hisP2",ccut,"");
332 chain->Draw("gp41>>hisP4",ccut,"");
333 Int_t entriesG =chain->Draw("mphi-GetP4Corr(id,0)*gp41:tan(asin(LTr.fP[2]))",ccut,"");
334 if (entriesG<3) continue;
335 TGraph gr(entriesG,chain->GetV2(),chain->GetV1());
337 gr.Fit("pol1","Q","Q");
338 fp1 = gr.GetFunction("pol1");
339 for (Int_t id2=0;id2<6; id2++){
341 matrixMeanBundle(jd,0) = entries;
342 matrixMeanBundle(jd,1) =phisP0->GetMean();
343 matrixRMSBundle(jd,1) =phisP0->GetRMS();
344 matrixMeanBundle(jd,2) =phisP2->GetMean();
345 matrixRMSBundle(jd,2) =phisP2->GetRMS();
346 matrixMeanBundle(jd,3) =phisP4->GetMean();
347 matrixRMSBundle(jd,3) =phisP4->GetRMS();
348 matrixMeanBundle(jd,4) = fp1->GetParameter(0); // delta y
349 matrixMeanBundle(jd,5) = fp1->GetParameter(1); // delta x
352 printf("%d\t%d\t%f\t%f\t%f\t%f\t%f\n",id,entries,matrixMeanBundle(id,1),matrixMeanBundle(id,2),matrixMeanBundle(id,3),matrixMeanBundle(id,4),matrixMeanBundle(id,5));
353 printf("%d\t%d\t%f\t%f\t%f\n",id,entries,matrixRMSBundle(id,1),matrixRMSBundle(id,2),matrixRMSBundle(id,3));
369 // Make delta Y pictures from voltage scan
371 TObjArray *aprofY = new TObjArray(14);
372 for (Int_t ib=0;ib<14;ib++){
373 TProfile *profY = new TProfile("py","py",100,0,150);
374 chain->Draw("10*(mphi-GetValueBundle(id,1)):bz>>py",Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&<r.fBeam==%d",ib/7,ib%7),"prof");
375 profY->SetName(Form("#DeltaY side %d beam %d",ib/7,ib%7));
376 profY->SetTitle(Form("#DeltaY side %d beam %d",ib/7,ib%7));
377 aprofY->AddAt(profY,ib);
378 profY->SetMaximum(2.5);
379 profY->SetMinimum(-2.5);
380 profY->SetMarkerColor((ib%7)+1);
381 profY->SetMarkerStyle((ib%7)+22);
382 profY->SetMarkerSize(1.2);
383 profY->SetXTitle("U_{gg} (V)");
384 profY->SetYTitle("#Delta_{y} (mm)");
387 TCanvas *cY = new TCanvas("deltaY","deltaY",900,600);
391 for (Int_t ib=0;ib<14;ib++){
393 aprofY->At(ib)->Draw("p");
396 cY->SaveAs("pic/deltaYlaserVscna.eps");
397 cY->SaveAs("pic/deltaYlaserVscna.gif");
401 void MakeGraphsdP2(){
403 // Make delta Y pictures from voltage scan
405 TObjArray *aprofP2 = new TObjArray(14);
406 for (Int_t ib=0;ib<14;ib++){
407 TProfile *profP2 = new TProfile("pyP","pyP",100,0,150);
408 chain->Draw("(mphiP-GetValueBundle(id,2)):bz>>pyP",Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&<r.fBeam==%d",ib/7,ib%7),"prof");
409 profP2->SetName(Form("#Delta_{#phi} side %d beam %d",ib/7,ib%7));
410 profP2->SetTitle(Form("#Delta_{#phi} side %d beam %d",ib/7,ib%7));
411 aprofP2->AddAt(profP2,ib);
412 profP2->SetMaximum(0.005);
413 profP2->SetMinimum(-0.005);
414 profP2->SetMarkerColor((ib%7)+1);
415 profP2->SetMarkerStyle((ib%7)+22);
416 profP2->SetMarkerSize(1.2);
417 profP2->SetXTitle("U_{gg} (V)");
418 profP2->SetYTitle("#Delta_{#phi}");
421 TCanvas *cP2 = new TCanvas("deltaP2","deltaP2",900,600);
425 for (Int_t ib=0;ib<14;ib++){
427 aprofP2->At(ib)->Draw("p");
430 cP2->SaveAs("pic/deltaP2laserVscna.eps");
431 cP2->SaveAs("pic/deltaP2laserVscna.gif");
440 // Make delta Y pictures from voltage scan
442 TObjArray *aprofP4 = new TObjArray(14);
443 for (Int_t ib=0;ib<14;ib++){
444 TProfile *profP4 = new TProfile("pp4","pp4",100,0,150);
445 chain->Draw("(gp41-GetValueBundle(id,3)):bz>>pp4",Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&<r.fBeam==%d",ib/7,ib%7),"prof");
446 profP4->SetName(Form("1/p_{t} side %d beam %d",ib/7,ib%7));
447 profP4->SetTitle(Form("1/p_{t} side %d beam %d",ib/7,ib%7));
448 aprofP4->AddAt(profP4,ib);
449 profP4->SetMaximum(0.025);
450 profP4->SetMinimum(-0.025);
451 profP4->SetMarkerColor((ib%7)+1);
452 profP4->SetMarkerStyle((ib%7)+22);
453 profP4->SetMarkerSize(1.2);
454 profP4->SetXTitle("U_{gg} (V)");
455 profP4->SetYTitle("1/p_{t} (GeV/c)");
458 TCanvas *cY = new TCanvas("P4","P4",900,600);
462 for (Int_t ib=0;ib<14;ib++){
464 aprofP4->At(ib)->Draw("p");
467 cY->SaveAs("pic/m1ptlaserVscna.eps");
468 cY->SaveAs("pic/m1ptlaserVscna.gif");
473 void MakePlotsP2GG(TCut ucut){
477 TFile fbundle("scanDeltaBeam.root");
478 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
480 Int_t mstyle[4]={22,23,24,25};
481 Int_t mcolor[4]={2,3,4,6};
483 entries = treeScan->Draw("10*sp2I/4:vgg","ibeam==7&&side==0"+ucut,"");
484 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
485 entries = treeScan->Draw("10*sp2O/4:vgg","ibeam==7&&side==0"+ucut,"");
486 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
487 entries = treeScan->Draw("10*sp2I/4:vgg","ibeam==7&&side==1"+ucut,"");
488 graph[2]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
489 entries = treeScan->Draw("10*sp2O/4:vgg","ibeam==7&&side==1"+ucut,"");
490 graph[3]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
492 for (Int_t i=0; i<4; i++){
493 graph[i]->GetXaxis()->SetTitle("U_{gg} (V)");
494 graph[i]->GetYaxis()->SetTitle("Sagita (mm)");
495 graph[i]->SetMinimum(0);
496 graph[i]->SetMaximum(2.5);
497 graph[i]->SetMarkerStyle(mstyle[i]);
498 graph[i]->SetMarkerSize(1);
499 graph[i]->SetMarkerColor(mcolor[i]);
500 if (i==0) graph[i]->Draw("ap");
503 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan - Sagita on 50 cm");
504 legend->AddEntry(graph[0],"IROC A side");
505 legend->AddEntry(graph[1],"OROC A side");
506 legend->AddEntry(graph[2],"IROC C side");
507 legend->AddEntry(graph[3],"OROC C side");
509 gPad->SaveAs("pic/scansagita_Vgg.eps");
510 gPad->SaveAs("pic/scansagita_Vgg.gif");
517 void MakePlotsP2Cover(TCut ucut){
521 TFile fbundle("scanDeltaBeam.root");
522 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
524 Int_t mstyle[4]={22,23,24,25};
525 Int_t mcolor[4]={2,3,4,6};
527 entries = treeScan->Draw("10*sp2I/4:vcover","ibeam==7&&side==0"+ucut,"");
528 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
529 entries = treeScan->Draw("10*sp2O/4:vcover","ibeam==7&&side==0"+ucut,"");
530 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
531 entries = treeScan->Draw("10*sp2I/4:vcover","ibeam==7&&side==1"+ucut,"");
532 graph[2]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
533 entries = treeScan->Draw("10*sp2O/4:vcover","ibeam==7&&side==1"+ucut,"");
534 graph[3]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
536 for (Int_t i=0; i<4; i++){
537 graph[i]->GetXaxis()->SetTitle("U_{cover} (V)");
538 graph[i]->GetYaxis()->SetTitle("Sagita (mm)");
539 graph[i]->SetMinimum(0.25);
540 graph[i]->SetMaximum(0.7);
541 graph[i]->SetMarkerStyle(mstyle[i]);
542 graph[i]->SetMarkerSize(1);
543 graph[i]->SetMarkerColor(mcolor[i]);
544 if (i==0) graph[i]->Draw("ap");
547 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan - Sagita on 50 cm");
548 legend->AddEntry(graph[0],"IROC A side");
549 legend->AddEntry(graph[1],"OROC A side");
550 legend->AddEntry(graph[2],"IROC C side");
551 legend->AddEntry(graph[3],"OROC C side");
553 gPad->SaveAs("pic/scansagita_Cover.eps");
554 gPad->SaveAs("pic/scansagita_Cover.gif");
557 void MakePlotsP2Skirt(TCut ucut){
561 TFile fbundle("scanDeltaBeam.root");
562 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
564 Int_t mstyle[4]={22,23,24,25};
565 Int_t mcolor[4]={2,3,4,6};
567 entries = treeScan->Draw("10*sp2I/4:vskirt","ibeam==7&&side==0"+ucut,"");
568 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
569 entries = treeScan->Draw("10*sp2O/4:vskirt","ibeam==7&&side==0"+ucut,"");
570 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
571 entries = treeScan->Draw("10*sp2I/4:vskirt","ibeam==7&&side==1"+ucut,"");
572 graph[2]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
573 entries = treeScan->Draw("10*sp2O/4:vskirt","ibeam==7&&side==1"+ucut,"");
574 graph[3]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
576 for (Int_t i=0; i<4; i++){
577 graph[i]->GetXaxis()->SetTitle("U_{skirt} (V)");
578 graph[i]->GetYaxis()->SetTitle("Sagita (mm)");
579 graph[i]->SetMinimum(0.25);
580 graph[i]->SetMaximum(0.7);
581 graph[i]->SetMarkerStyle(mstyle[i]);
582 graph[i]->SetMarkerSize(1);
583 graph[i]->SetMarkerColor(mcolor[i]);
584 if (i==0) graph[i]->Draw("ap");
587 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan - Sagita on 50 cm");
588 legend->AddEntry(graph[0],"IROC A side");
589 legend->AddEntry(graph[1],"OROC A side");
590 legend->AddEntry(graph[2],"IROC C side");
591 legend->AddEntry(graph[3],"OROC C side");
593 gPad->SaveAs("pic/scansagita_Skirt.eps");
594 gPad->SaveAs("pic/scansagita_Skirt.gif");
600 void MakePlotsdYGG(){
604 TFile fbundle("scanDeltaBeam.root");
605 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
607 Int_t mstyle[4]={22,23,24,25};
608 Int_t mcolor[4]={2,3,4,6};
610 entries = treeScan->Draw("sp0X:vgg","ibeam==7&&side==0","");
611 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
612 entries = treeScan->Draw("sp0X:vgg","ibeam==7&&side==1","");
613 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
615 for (Int_t i=0; i<2; i++){
616 graph[i]->GetXaxis()->SetTitle("U_{gg} (V)");
617 graph[i]->GetYaxis()->SetTitle("#sigma_{r#phi} (mm)");
618 graph[i]->SetMinimum(0);
619 graph[i]->SetMaximum(1);
620 graph[i]->SetMarkerStyle(mstyle[i]);
621 graph[i]->SetMarkerSize(1);
622 graph[i]->SetMarkerColor(mcolor[i]);
623 if (i==0) graph[i]->Draw("ap");
626 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan-#sigma_{r#phi}");
627 legend->AddEntry(graph[0],"A side");
628 legend->AddEntry(graph[1],"C side");
630 gPad->SaveAs("pic/scandy_Vgg.eps");
631 gPad->SaveAs("pic/scandy_Vgg.gif");
635 void MakePlotsdYCover(TCut ucut){
639 TFile fbundle("scanDeltaBeam.root");
640 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
642 Int_t mstyle[4]={22,23,24,25};
643 Int_t mcolor[4]={2,3,4,6};
645 entries = treeScan->Draw("sp0X:vcover","ibeam==7&&side==0"+ucut,"");
646 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
647 entries = treeScan->Draw("sp0X:vcover","ibeam==7&&side==1"+ucut,"");
648 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
650 for (Int_t i=0; i<2; i++){
651 graph[i]->GetXaxis()->SetTitle("U_{cover} (V)");
652 graph[i]->GetYaxis()->SetTitle("#sigma_{r#phi} (mm)");
653 graph[i]->SetMinimum(0);
654 graph[i]->SetMaximum(0.75);
655 graph[i]->SetMarkerStyle(mstyle[i]);
656 graph[i]->SetMarkerSize(1);
657 graph[i]->SetMarkerColor(mcolor[i]);
658 if (i==0) graph[i]->Draw("ap");
661 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan-#sigma_{r#phi}");
662 legend->AddEntry(graph[0],"A side");
663 legend->AddEntry(graph[1],"C side");
665 gPad->SaveAs("pic/scandy_Vcover.eps");
666 gPad->SaveAs("pic/scandy_Vcover.gif");
669 void MakePlotsdYSkirt(TCut ucut){
673 TFile fbundle("scanDeltaBeam.root");
674 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
676 Int_t mstyle[4]={22,23,24,25};
677 Int_t mcolor[4]={2,3,4,6};
679 entries = treeScan->Draw("sp0X:vskirt","ibeam==7&&side==0"+ucut,"");
680 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
681 entries = treeScan->Draw("sp0X:vskirt","ibeam==7&&side==1"+ucut,"");
682 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
684 for (Int_t i=0; i<2; i++){
685 graph[i]->GetXaxis()->SetTitle("U_{skirt} (V)");
686 graph[i]->GetYaxis()->SetTitle("#sigma_{r#phi} (mm)");
687 graph[i]->SetMinimum(0);
688 graph[i]->SetMaximum(0.75);
689 graph[i]->SetMarkerStyle(mstyle[i]);
690 graph[i]->SetMarkerSize(1);
691 graph[i]->SetMarkerColor(mcolor[i]);
692 if (i==0) graph[i]->Draw("ap");
695 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan-#sigma_{r#phi}");
696 legend->AddEntry(graph[0],"A side");
697 legend->AddEntry(graph[1],"C side");
699 gPad->SaveAs("pic/scandy_Vskirt.eps");
700 gPad->SaveAs("pic/scandy_Vskirt.gif");
705 void GetOptimalSetting(){
709 TFile fbundle("scanDeltaBeam.root");
710 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
715 TH1F * his = new TH1F("hisDelta","hisDelta",300,0,1);
716 treeScan->Draw("sp0X>>hisDelta","ibeam==7","");
717 meansp0X = his->GetMean();
718 treeScan->Draw("sp2I>>hisDelta","ibeam==7","");
719 meansp2I = his->GetMean();
720 treeScan->Draw("sp2O>>hisDelta","ibeam==7","");
721 meansp2O = his->GetMean();
725 Int_t indexes[10000];
726 for (Int_t iside=0;iside<2;iside++){
727 printf("*************************************\n");
728 printf("Side%d\tRun\tchi2\t\tVgg\tVskirt\tVcover\n",iside);
730 Int_t entries = treeScan->Draw(Form("sp0X/%f+sp2I/%f+sp2O/%f:run",meansp0X,meansp2I,meansp2O),Form("ibeam==7&&side==%d",iside));
731 TMath::Sort(entries,treeScan->GetV1(),indexes,kFALSE);
732 for (Int_t i=0; i<entries; i++){
733 Int_t index = indexes[i];
734 Int_t run = treeScan->GetV2()[index];
735 Float_t chi2=treeScan->GetV1()[index];
737 printf("%d\t%d\t%f\t%d\t%d\t%d\n",iside,run, chi2,GetVoltage(run,0), GetVoltage(run,1),GetVoltage(run,2));
741 for (Int_t iside=0;iside<2;iside++){
742 printf("***********************\n");
743 printf("Side%d\tRun\tchi2\t\tVgg\tVskirt\tVcover\n",iside);
745 Int_t entries = treeScan->Draw(Form("sp2I/%f+sp2O/%f:run",meansp0X,meansp2I,meansp2O),Form("ibeam==7&&side==%d",iside));
746 TMath::Sort(entries,treeScan->GetV1(),indexes,kFALSE);
747 for (Int_t i=0; i<entries; i++){
748 Int_t index = indexes[i];
749 Int_t run = treeScan->GetV2()[index];
750 Float_t chi2=treeScan->GetV1()[index];
752 printf("%d\t%d\t%f\t%d\t%d\t%d\n",iside,run, chi2,GetVoltage(run,0), GetVoltage(run,1),GetVoltage(run,2));
764 chain->SetAlias("VggA","GetVoltage(run,0)");
765 chain->SetAlias("VggC","GetVoltage(run,1)");
766 chain->SetAlias("VcoA","GetVoltage(run,2)");
767 chain->SetAlias("VcoC","GetVoltage(run,3)");
768 chain->SetAlias("VskA","GetVoltage(run,4)");
769 chain->SetAlias("VskC","GetVoltage(run,5)");
773 chain->SetAlias("TisOK","mdEdx>5&&entries>400");
774 chain->SetAlias("CisOK","nCl.fElements>entries*0.5&&eY.fElements<0.01");
775 chain->SetAlias("ATisOK","RA.mdEdx>5&&RA.entries>400");
776 chain->SetAlias("ACisOK","RA.nCl.fElements>RA.entries*0.5&&abs(RA.dY.fElements-dY.fElements)<0.3&&RA.eY.fElements<0.01");
780 chain->SetAlias("lX","X.fElements"); //
781 chain->SetAlias("tY","kY.fElements"); //
782 chain->SetAlias("dE","sign(Y.fElements)*(tan(10*pi/180.)*X.fElements-abs(Y.fElements))");
783 chain->SetAlias("RdY","(dY.fElements-RA.dY.fElements)");
785 chain->SetAlias("dIF","lX-85.2");
786 chain->SetAlias("dOF","245.8-lX");
787 chain->SetAlias("dUtY","((GetVoltage(run,0)-GetVoltage(RA.run,0))/400.*tY)");
789 chain->SetAlias("cIF","dUtY/(1+dIF/13.0)");
790 chain->SetAlias("cOF","dUtY/(1+dOF/22.0)");
791 chain->SetAlias("cIF2","(dUtY*dIF/13.0)/((1.+dIF/13.0)^2)");
792 chain->SetAlias("cOF2","(dUtY*dOF/22.0)/((1.+dOF/22.0)^2)");
794 chain->SetAlias("cE","(GetVoltage(run,0)-GetVoltage(RA.run,0))/400.*sign(dE)/(1+(abs(dE)-1.55)/1.4)");
795 chain->SetAlias("cE2","(GetVoltage(run,0)-GetVoltage(RA.run,0))/400.*sign(dE)*((abs(dE)-1.55)/1.4)/((1+(abs(dE)-1.55)/1.4)^2)");
800 void MakeAliasesBoth(){
802 // cuts - slect good tracks
804 chain->SetAlias("TisOK","mdEdx>5&&entries>400");
805 chain->SetAlias("ATisOK","(LTr.fSide==0)*(RA.mdEdx>5&&RA.entries>500)");
806 chain->SetAlias("CTisOK","(LTr.fSide==1)*(RC.mdEdx>5&&RC.entries>500)");
808 chain->Draw(">>run","TisOK&&(ATisOK||CTisOK)","entryList");
809 TEntryList *elist = (TEntryList*)gDirectory->Get("run");
810 chain->SetEntryList(elist);
813 chain->SetAlias("CisOK","(nCl.fElements>entries*0.5&&eY.fElements<0.01)");
814 chain->SetAlias("ACisOK","RA.nCl.fElements>RA.entries*0.5&&abs(RA.dY.fElements-dY.fElements)<0.3&&RA.eY.fElements<0.01");
815 chain->SetAlias("CCisOK","RC.nCl.fElements>RC.entries*0.5&&abs(RC.dY.fElements-dY.fElements)<0.3&&abs(RC.dZ.fElements-dZ.fElements)<0.3&&RC.eY.fElements<0.01");
821 chain->SetAlias("Vgg","((LTr.fSide==0)*GetVoltage(run,0)+(LTr.fSide==1)*GetVoltage(run,1))");
822 chain->SetAlias("VcoA","((LTr.fSide==0)*GetVoltage(run,2)+(LTr.fSide==1)*GetVoltage(run,3))");
823 chain->SetAlias("VskA","((LTr.fSide==0)*GetVoltage(run,4)+(LTr.fSide==1)*GetVoltage(run,5))");
825 chain->SetAlias("dVgg","(((LTr.fSide==0)*(GetVoltage(run,0)-GetVoltage(RA.run,0))+((LTr.fSide==0)*(GetVoltage(run,0)-GetVoltage(RA.run,0))))/400.)");
829 chain->SetAlias("RdY","((LTr.fSide==0)*(dY.fElements-RA.dY.fElements)+(LTr.fSide==1)*(dY.fElements-RC.dY.fElements))");
831 chain->SetAlias("drift","(1.-abs(LTr.fP[1]+0.)/250)");
832 chain->SetAlias("lX","X.fElements"); //
833 chain->SetAlias("tY","kY.fElements"); //
834 chain->SetAlias("dE","sign(Y.fElements)*(tan(10*pi/180.)*X.fElements-abs(Y.fElements))");
836 chain->SetAlias("dIF","lX-85.2");
837 chain->SetAlias("dOF","245.8-lX");
838 chain->SetAlias("dUtY","dVgg*tY");
842 chain->SetAlias("cIF","dUtY/(1+dIF/13.0)");
843 chain->SetAlias("cOF","dUtY/(1+dOF/22.0)");
844 chain->SetAlias("cIF2","(dUtY*dIF/13.0)/((1.+dIF/13.0)^2)");
845 chain->SetAlias("cOF2","(dUtY*dOF/22.0)/((1.+dOF/22.0)^2)");
847 chain->SetAlias("cE","dVgg*sign(dE)/(1+(abs(dE)-1.5)/1.3)");
848 chain->SetAlias("cE2","dVgg*sign(dE)*((abs(dE)-1.5)/1.3)/((1+(abs(dE)-1.5)/1.3)^2)");
857 Int_t ntracks=3000000;
858 TStatToolkit toolkit;
870 TCut cutA="LTr.fBeam>-1&&CisOK&&(ACisOK||CCisOK)";
872 TString * strA = TStatToolkit::FitPlane(chain,"RdY", fstring.Data(),cutA, chi2,npoints,fitParam,covMatrix,-1.,0, ntracks);
873 chain->SetAlias("fdY",strA->Data());
875 printf("sqrt(Chi2/npoints)=%f\n",TMath::Sqrt(chi2/npoints));
876 chain->Draw("RdY-fdY",cutA);
879 TF1 fe("fe","[0]/(1+(x-[2])/[1])",2,10);
880 fe.SetParameters(0.4,1,1.5);
888 // chain->Draw("RdY:(GetVoltage(run,0)-GetVoltage(RA.run,0))*tY/(1+dIF/10.)","TisOK&&ATisOK&&CisOK&&ACisOK&<r.fBundle>0&<r.fBeam!=3&&dIF<30","",10000)