4 // 0. Make a calibration
5 // 1. Make a laser scan list
6 // e.g in TPC workscape
7 find `pwd`/*/laserMean.root >laserScan.txt
8 // 2. Define a reference data
9 rrunA=84469/; for a in `cat laserScan.txt`; do echo `pwd`/$rrunA/laserMean.root; done >laserScanRefA.txt
10 rrunC=84469; for a in `cat laserScan.txt`; do echo `pwd`/$rrunC/laserMean.root; done >laserScanRefC.txt
11 rrun=84469; for a in `cat laserScan.txt`; do echo `pwd`/$rrun/laserMean.root; done >laserScanRef.txt
15 gSystem->Load("libANALYSIS");
16 gSystem->Load("libTPCcalib");
17 gSystem->Load("libSTAT");
19 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
20 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
21 .L $ALICE_ROOT/TPC/CalibMacros/CalibLaserVscan.C+
23 AliXRDPROOFtoolkit tool;
24 chain = tool.MakeChainRandom("laserScan.txt","Mean",0,10200);
26 chainRef = tool.MakeChain("laserScanRef.txt","Mean",0,10200);
27 chain->AddFriend(chainRef,"R")
28 chainRefA = tool.MakeChain("laserScanRefA.txt","Mean",0,10200);
29 chain->AddFriend(chainRefA,"RA")
30 chainRefC = tool.MakeChain("laserScanRefC.txt","Mean",0,10200);
31 chain->AddFriend(chainRefC,"RC")
40 TFile fbundle("scanDeltaBeam.root");
41 chain->Draw("mphi:GetValueBundle(id,1)","isOK&&GetValueBundle(id,0)>3&<r.fSide==0","")
52 #include "TObjArray.h"
58 #include "TTreeStream.h"
60 #include "AliTPCLaserTrack.h"
61 #include "AliTPCcalibDB.h"
62 #include "TStatToolkit.h"
65 TMatrixD matrixP4Corr(7,2); // P4 correction for P0 - y position and P2 -snp(phi)
66 TMatrixD matrixP2RMSIROC(7,5); // rms of second derivative IROC
67 TMatrixD matrixP2RMSOROC(7,5); // rms of second derivative OROC
69 // rod 5 means all rods
71 TMatrixD matrixMeanBundle(336,6); // mean position/delta per bundle
72 TMatrixD matrixRMSBundle(336,6); // rms of distribution
74 // 0 - number of entries
81 map<int,TVectorD*> mapRunVoltage; // run to voltage
82 // run# -0 ggA 1- ggC 2- coA 3-coC 4-skA 5-skC
83 map<int,int> mapRunVgg; // run to gating grid voltage
84 map<int,int> mapRunVskirt; //
85 map<int,int> mapRunVcover; //
86 TArrayI runlist(10000);
92 TCut tA="isOK&&RA.isOK";
93 TCut tC="isOK&&RC.isOK";
94 TCut cA="eY.fElements<0.01&&RA.eY.fElements<0.01&&X.fElements>10&&RA.X.fElements>10";
95 TCut cC="eY.fElements<0.01&&RA.eY.fElements<0.01&&X.fElements>10&&RA.X.fElements>10";
100 Double_t GetValueBundle(Int_t id, Int_t type){
103 return matrixMeanBundle(id,type);
106 Double_t GetP4Corr(Int_t id, Int_t value){
107 AliTPCLaserTrack *ltrack =(AliTPCLaserTrack *) AliTPCLaserTrack::GetTracks()->At(id);
108 Int_t beam = ltrack->GetBeam();
109 return matrixP4Corr(beam,value);
112 Double_t GetDyBundle(Int_t id){
113 Double_t dy = matrixMeanBundle(id,4);
114 Double_t dx = matrixMeanBundle(id,5);
115 AliTPCLaserTrack *ltrack =(AliTPCLaserTrack *) AliTPCLaserTrack::GetTracks()->At(id);
116 Double_t p2 = ltrack->GetParameter()[2];
117 Double_t delta = dy+dx*p2;
121 Double_t GetRMSBundle(Int_t id, Int_t type){
124 return matrixRMSBundle(id,type);
126 Int_t GetVoltage(Int_t run, Int_t type){
129 // run# -0 ggA 1- ggC 2- coA 3-coC 4-skA 5-skC
130 TVectorD *runVoltage = mapRunVoltage[run];
131 if (!runVoltage) return -1;
132 return (*runVoltage)[type];
138 TFile f("laserData.root","recreate");
139 matrixMeanBundle.Write("matrixMeanBundle");
140 matrixRMSBundle.Write("matrixRMSBundle");
141 matrixP4Corr.Write("matrixP4Corr");
142 matrixP2RMSIROC.Write("matrixP2RMSIROC");
143 matrixP2RMSOROC.Write("matrixP2RMSOROC");
147 AliTPCLaserTrack::LoadTracks();
148 TFile f("laserData.root");
149 matrixMeanBundle.Read("matrixMeanBundle");
150 matrixRMSBundle.Read("matrixRMSBundle");
151 matrixP4Corr.Read("matrixP4Corr");
152 matrixP2RMSIROC.Read("matrixP2RMSIROC");
153 matrixP2RMSOROC.Read("matrixP2RMSOROC");
159 in.open("runSetup.txt");
169 printf("%s\n",objfile.Data());
170 arr = objfile.Tokenize(" ");
172 if (arr->GetEntries()>=7){
173 Int_t run = atoi(arr->At(0)->GetName());
174 Int_t vcover = atoi(arr->At(0)->GetName());
175 Int_t vskirt = atoi(arr->At(1)->GetName());
176 Int_t vgg = atoi(arr->At(3)->GetName());
177 TVectorD * vsetup = new TVectorD(6);
178 for (Int_t iv=0; iv<6; iv++){
179 (*vsetup)[iv] = atoi(arr->At(iv+1)->GetName());
181 mapRunVoltage[run]=vsetup;
183 mapRunVskirt[run]=vskirt;
184 mapRunVcover[run]=vcover;
185 runlist[counter]=run;
197 void MakeAnalysisBeam(){
201 TTreeSRedirector *pcstream = new TTreeSRedirector("scanDeltaBeam.root");
202 TH1* phisP0=new TH1F("hhisP0","hhisP0",100,-5.,5.);
203 TH1* phisP0X=new TH1F("hhisP0X","hhisP0X",100,-5.,5.);
204 TH1* phisP2=new TH1F("hhisP2","hhisP2",100,-6,6);
205 TH1* phisP4=new TH1F("hhisP4","hhisP4",100,-0.05,0.05);
207 TH1* phisP2IROC=new TH1F("hhisP2IROC","hhisPIROC",100,-2.,2.);
208 TH1* phisP2OROC=new TH1F("hhisP2OROC","hhisPOROC",100,-2.,2.);
212 for (Int_t iside=0;iside<2;iside++){
213 for (Int_t ibeam=0; ibeam<8; ibeam++){
214 for (Int_t irun=0; irun<100; irun++){
215 Int_t run =runlist[irun];
217 if (run==0) continue;
218 Int_t vskirt = GetVoltage(run,1);
219 Int_t vcover = GetVoltage(run,2);
220 Int_t vgg = GetVoltage(run,0);
222 TCut cut = Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&<r.fBeam==%d&&run==%d", iside, ibeam,run);
224 cut = Form("isOK&&GetValueBundle(id,0)>3&<r.fSide==%d&&run==%d", iside,run);
226 Int_t entries = chain->Draw("gp41-GetValueBundle(id,3)>>hhisP4",cut,"goff");
227 if (entries==0) continue;
228 chain->Draw("10*(mphi-GetValueBundle(id,1)-GetP4Corr(id,0)*gp41)>>hhisP0",cut,"goff");
229 chain->Draw("10*(mphi-GetDyBundle(id)-GetP4Corr(id,0)*gp41)>>hhisP0X",cut,"goff");
230 chain->Draw("1000*(mphiP-GetValueBundle(id,2)-GetP4Corr(id,1)*gp41)>>hhisP2",cut,"goff");
232 printf("%d\t%d\t%d\t%f\t%f\t%d\n", iside, ibeam,run, phisP0X->GetMean(), phisP0X->GetRMS(), Int_t(phisP0X->GetEntries()));
234 chain->Draw("10*(mphi-GetValueBundle(id,1)-GetP4Corr(id,0)*gp41)>>hhisP0",cut,"goff");
236 chain->Draw("mPy2vP2In*100^2>>hhisP2IROC",cut,"goff");
237 chain->Draw("mPy2vP2Out*100^2>>hhisP2OROC",cut,"goff");
240 Double_t mp0 = phisP0->GetMean();
241 Double_t mp0X = phisP0X->GetMean();
242 Double_t mp2 = phisP2->GetMean();
243 Double_t mp4 = phisP4->GetMean();
244 Double_t mp2I = phisP2IROC->GetMean();
245 Double_t mp2O = phisP2OROC->GetMean();
246 Double_t sp0 = phisP0->GetRMS();
247 Double_t sp0X = phisP0X->GetRMS();
248 Double_t sp2 = phisP2->GetRMS();
249 Double_t sp4 = phisP4->GetRMS();
250 Double_t sp2I = phisP2IROC->GetRMS();
251 Double_t sp2O = phisP2OROC->GetRMS();
252 (*pcstream)<<"vScanBeam"<<
259 "entries="<<entries<<
282 void MakeMeanBundle(){
286 AliTPCLaserTrack::LoadTracks();
287 AliTPCLaserTrack *ltrack;
296 for (Int_t ibeam=0; ibeam<7; ibeam++){
297 Int_t entries0=chain->Draw("mphi:gp41",Form("isOK&<r.fBeam==%d",ibeam));
298 TGraph gr0(entries0,chain->GetV2(),chain->GetV1());
300 gr0.Fit("pol1","Q","Q");
301 fp1 = gr0.GetFunction("pol1");
302 matrixP4Corr(ibeam,0)=fp1->GetParameter(1);
303 Int_t entries2=chain->Draw("mphiP:gp41",Form("isOK&<r.fBeam==%d",ibeam));
304 TGraph gr2(entries2,chain->GetV2(),chain->GetV1());
306 gr2.Fit("pol1","Q","Q");
307 fp1 = gr2.GetFunction("pol1");
308 matrixP4Corr(ibeam,1)=fp1->GetParameter(1);
311 // get RMS of second derivative
313 phisP0= new TH1F("hisP0","hisP0",500,-1.,1.);
314 for (Int_t irod=0; irod<5;irod++)
315 for (Int_t ibeam=0; ibeam<7; ibeam++){
317 TCut cut=Form("isOK&<r.fBeam==%d&<r.fRod==%d",ibeam,irod);
318 if (irod==5) cut=Form("isOK&<r.fBeam==%d",ibeam);
319 chain->Draw("mPy2vP2In*100^2>>hisP0",cut);
320 matrixP2RMSIROC(ibeam,irod) = phisP0->GetRMS();
321 chain->Draw("mPy2vP2Out*100^2>>hisP0",cut);
322 matrixP2RMSOROC(ibeam,irod) = phisP0->GetRMS();
327 // Get mean bundle position
329 for (Int_t id=0; id<336; id+=7){
330 ltrack =(AliTPCLaserTrack *) AliTPCLaserTrack::GetTracks()->At(id);
331 Int_t side = ltrack->GetSide();
332 Int_t rod = ltrack->GetRod();
333 Int_t bundle = ltrack->GetBundle();
334 // Int_t beam = ltrack->GetBeam();
335 ccut = Form("isOK&<r.fSide==%d&<r.fBundle==%d&<r.fRod==%d",side,bundle,rod);
336 phisP0= new TH1F("hisP0","hisP0",500,-0.5,0.5);
337 phisP2= new TH1F("hisP2","hisP2",500,-0.02,0.02);
338 phisP4= new TH1F("hisP4","hisP4",500,-0.2,0.2);
339 Int_t entries =chain->Draw("mphi",Form("isOK&&id==%d",id),"goff");
340 chain->Draw("mphi-GetP4Corr(id,0)*gp41>>hisP0",ccut,"");
341 chain->Draw("mphiP-GetP4Corr(id,1)*gp41>>hisP2",ccut,"");
342 chain->Draw("gp41>>hisP4",ccut,"");
343 Int_t entriesG =chain->Draw("mphi-GetP4Corr(id,0)*gp41:tan(asin(LTr.fP[2]))",ccut,"");
344 if (entriesG<3) continue;
345 TGraph gr(entriesG,chain->GetV2(),chain->GetV1());
347 gr.Fit("pol1","Q","Q");
348 fp1 = gr.GetFunction("pol1");
349 for (Int_t id2=0;id2<6; id2++){
351 matrixMeanBundle(jd,0) = entries;
352 matrixMeanBundle(jd,1) =phisP0->GetMean();
353 matrixRMSBundle(jd,1) =phisP0->GetRMS();
354 matrixMeanBundle(jd,2) =phisP2->GetMean();
355 matrixRMSBundle(jd,2) =phisP2->GetRMS();
356 matrixMeanBundle(jd,3) =phisP4->GetMean();
357 matrixRMSBundle(jd,3) =phisP4->GetRMS();
358 matrixMeanBundle(jd,4) = fp1->GetParameter(0); // delta y
359 matrixMeanBundle(jd,5) = fp1->GetParameter(1); // delta x
362 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));
363 printf("%d\t%d\t%f\t%f\t%f\n",id,entries,matrixRMSBundle(id,1),matrixRMSBundle(id,2),matrixRMSBundle(id,3));
379 // Make delta Y pictures from voltage scan
381 TObjArray *aprofY = new TObjArray(14);
382 for (Int_t ib=0;ib<14;ib++){
383 TProfile *profY = new TProfile("py","py",100,0,150);
384 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");
385 profY->SetName(Form("#DeltaY side %d beam %d",ib/7,ib%7));
386 profY->SetTitle(Form("#DeltaY side %d beam %d",ib/7,ib%7));
387 aprofY->AddAt(profY,ib);
388 profY->SetMaximum(2.5);
389 profY->SetMinimum(-2.5);
390 profY->SetMarkerColor((ib%7)+1);
391 profY->SetMarkerStyle((ib%7)+22);
392 profY->SetMarkerSize(1.2);
393 profY->SetXTitle("U_{gg} (V)");
394 profY->SetYTitle("#Delta_{y} (mm)");
397 TCanvas *cY = new TCanvas("deltaY","deltaY",900,600);
401 for (Int_t ib=0;ib<14;ib++){
403 aprofY->At(ib)->Draw("p");
406 cY->SaveAs("pic/deltaYlaserVscna.eps");
407 cY->SaveAs("pic/deltaYlaserVscna.gif");
411 void MakeGraphsdP2(){
413 // Make delta Y pictures from voltage scan
415 TObjArray *aprofP2 = new TObjArray(14);
416 for (Int_t ib=0;ib<14;ib++){
417 TProfile *profP2 = new TProfile("pyP","pyP",100,0,150);
418 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");
419 profP2->SetName(Form("#Delta_{#phi} side %d beam %d",ib/7,ib%7));
420 profP2->SetTitle(Form("#Delta_{#phi} side %d beam %d",ib/7,ib%7));
421 aprofP2->AddAt(profP2,ib);
422 profP2->SetMaximum(0.005);
423 profP2->SetMinimum(-0.005);
424 profP2->SetMarkerColor((ib%7)+1);
425 profP2->SetMarkerStyle((ib%7)+22);
426 profP2->SetMarkerSize(1.2);
427 profP2->SetXTitle("U_{gg} (V)");
428 profP2->SetYTitle("#Delta_{#phi}");
431 TCanvas *cP2 = new TCanvas("deltaP2","deltaP2",900,600);
435 for (Int_t ib=0;ib<14;ib++){
437 aprofP2->At(ib)->Draw("p");
440 cP2->SaveAs("pic/deltaP2laserVscna.eps");
441 cP2->SaveAs("pic/deltaP2laserVscna.gif");
450 // Make delta Y pictures from voltage scan
452 TObjArray *aprofP4 = new TObjArray(14);
453 for (Int_t ib=0;ib<14;ib++){
454 TProfile *profP4 = new TProfile("pp4","pp4",100,0,150);
455 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");
456 profP4->SetName(Form("1/p_{t} side %d beam %d",ib/7,ib%7));
457 profP4->SetTitle(Form("1/p_{t} side %d beam %d",ib/7,ib%7));
458 aprofP4->AddAt(profP4,ib);
459 profP4->SetMaximum(0.025);
460 profP4->SetMinimum(-0.025);
461 profP4->SetMarkerColor((ib%7)+1);
462 profP4->SetMarkerStyle((ib%7)+22);
463 profP4->SetMarkerSize(1.2);
464 profP4->SetXTitle("U_{gg} (V)");
465 profP4->SetYTitle("1/p_{t} (GeV/c)");
468 TCanvas *cY = new TCanvas("P4","P4",900,600);
472 for (Int_t ib=0;ib<14;ib++){
474 aprofP4->At(ib)->Draw("p");
477 cY->SaveAs("pic/m1ptlaserVscna.eps");
478 cY->SaveAs("pic/m1ptlaserVscna.gif");
483 void MakePlotsP2GG(TCut ucut){
487 TFile fbundle("scanDeltaBeam.root");
488 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
490 Int_t mstyle[4]={22,23,24,25};
491 Int_t mcolor[4]={2,3,4,6};
493 entries = treeScan->Draw("10*sp2I/4:vgg","ibeam==7&&side==0"+ucut,"");
494 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
495 entries = treeScan->Draw("10*sp2O/4:vgg","ibeam==7&&side==0"+ucut,"");
496 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
497 entries = treeScan->Draw("10*sp2I/4:vgg","ibeam==7&&side==1"+ucut,"");
498 graph[2]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
499 entries = treeScan->Draw("10*sp2O/4:vgg","ibeam==7&&side==1"+ucut,"");
500 graph[3]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
502 for (Int_t i=0; i<4; i++){
503 graph[i]->GetXaxis()->SetTitle("U_{gg} (V)");
504 graph[i]->GetYaxis()->SetTitle("Sagita (mm)");
505 graph[i]->SetMinimum(0);
506 graph[i]->SetMaximum(2.5);
507 graph[i]->SetMarkerStyle(mstyle[i]);
508 graph[i]->SetMarkerSize(1);
509 graph[i]->SetMarkerColor(mcolor[i]);
510 if (i==0) graph[i]->Draw("ap");
513 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan - Sagita on 50 cm");
514 legend->AddEntry(graph[0],"IROC A side");
515 legend->AddEntry(graph[1],"OROC A side");
516 legend->AddEntry(graph[2],"IROC C side");
517 legend->AddEntry(graph[3],"OROC C side");
519 gPad->SaveAs("pic/scansagita_Vgg.eps");
520 gPad->SaveAs("pic/scansagita_Vgg.gif");
527 void MakePlotsP2Cover(TCut ucut){
531 TFile fbundle("scanDeltaBeam.root");
532 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
534 Int_t mstyle[4]={22,23,24,25};
535 Int_t mcolor[4]={2,3,4,6};
537 entries = treeScan->Draw("10*sp2I/4:vcover","ibeam==7&&side==0"+ucut,"");
538 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
539 entries = treeScan->Draw("10*sp2O/4:vcover","ibeam==7&&side==0"+ucut,"");
540 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
541 entries = treeScan->Draw("10*sp2I/4:vcover","ibeam==7&&side==1"+ucut,"");
542 graph[2]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
543 entries = treeScan->Draw("10*sp2O/4:vcover","ibeam==7&&side==1"+ucut,"");
544 graph[3]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
546 for (Int_t i=0; i<4; i++){
547 graph[i]->GetXaxis()->SetTitle("U_{cover} (V)");
548 graph[i]->GetYaxis()->SetTitle("Sagita (mm)");
549 graph[i]->SetMinimum(0.25);
550 graph[i]->SetMaximum(0.7);
551 graph[i]->SetMarkerStyle(mstyle[i]);
552 graph[i]->SetMarkerSize(1);
553 graph[i]->SetMarkerColor(mcolor[i]);
554 if (i==0) graph[i]->Draw("ap");
557 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan - Sagita on 50 cm");
558 legend->AddEntry(graph[0],"IROC A side");
559 legend->AddEntry(graph[1],"OROC A side");
560 legend->AddEntry(graph[2],"IROC C side");
561 legend->AddEntry(graph[3],"OROC C side");
563 gPad->SaveAs("pic/scansagita_Cover.eps");
564 gPad->SaveAs("pic/scansagita_Cover.gif");
567 void MakePlotsP2Skirt(TCut ucut){
571 TFile fbundle("scanDeltaBeam.root");
572 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
574 Int_t mstyle[4]={22,23,24,25};
575 Int_t mcolor[4]={2,3,4,6};
577 entries = treeScan->Draw("10*sp2I/4:vskirt","ibeam==7&&side==0"+ucut,"");
578 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
579 entries = treeScan->Draw("10*sp2O/4:vskirt","ibeam==7&&side==0"+ucut,"");
580 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
581 entries = treeScan->Draw("10*sp2I/4:vskirt","ibeam==7&&side==1"+ucut,"");
582 graph[2]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
583 entries = treeScan->Draw("10*sp2O/4:vskirt","ibeam==7&&side==1"+ucut,"");
584 graph[3]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
586 for (Int_t i=0; i<4; i++){
587 graph[i]->GetXaxis()->SetTitle("U_{skirt} (V)");
588 graph[i]->GetYaxis()->SetTitle("Sagita (mm)");
589 graph[i]->SetMinimum(0.25);
590 graph[i]->SetMaximum(0.7);
591 graph[i]->SetMarkerStyle(mstyle[i]);
592 graph[i]->SetMarkerSize(1);
593 graph[i]->SetMarkerColor(mcolor[i]);
594 if (i==0) graph[i]->Draw("ap");
597 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan - Sagita on 50 cm");
598 legend->AddEntry(graph[0],"IROC A side");
599 legend->AddEntry(graph[1],"OROC A side");
600 legend->AddEntry(graph[2],"IROC C side");
601 legend->AddEntry(graph[3],"OROC C side");
603 gPad->SaveAs("pic/scansagita_Skirt.eps");
604 gPad->SaveAs("pic/scansagita_Skirt.gif");
610 void MakePlotsdYGG(){
614 TFile fbundle("scanDeltaBeam.root");
615 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
617 Int_t mstyle[4]={22,23,24,25};
618 Int_t mcolor[4]={2,3,4,6};
620 entries = treeScan->Draw("sp0X:vgg","ibeam==7&&side==0","");
621 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
622 entries = treeScan->Draw("sp0X:vgg","ibeam==7&&side==1","");
623 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
625 for (Int_t i=0; i<2; i++){
626 graph[i]->GetXaxis()->SetTitle("U_{gg} (V)");
627 graph[i]->GetYaxis()->SetTitle("#sigma_{r#phi} (mm)");
628 graph[i]->SetMinimum(0);
629 graph[i]->SetMaximum(1);
630 graph[i]->SetMarkerStyle(mstyle[i]);
631 graph[i]->SetMarkerSize(1);
632 graph[i]->SetMarkerColor(mcolor[i]);
633 if (i==0) graph[i]->Draw("ap");
636 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan-#sigma_{r#phi}");
637 legend->AddEntry(graph[0],"A side");
638 legend->AddEntry(graph[1],"C side");
640 gPad->SaveAs("pic/scandy_Vgg.eps");
641 gPad->SaveAs("pic/scandy_Vgg.gif");
645 void MakePlotsdYCover(TCut ucut){
649 TFile fbundle("scanDeltaBeam.root");
650 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
652 Int_t mstyle[4]={22,23,24,25};
653 Int_t mcolor[4]={2,3,4,6};
655 entries = treeScan->Draw("sp0X:vcover","ibeam==7&&side==0"+ucut,"");
656 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
657 entries = treeScan->Draw("sp0X:vcover","ibeam==7&&side==1"+ucut,"");
658 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
660 for (Int_t i=0; i<2; i++){
661 graph[i]->GetXaxis()->SetTitle("U_{cover} (V)");
662 graph[i]->GetYaxis()->SetTitle("#sigma_{r#phi} (mm)");
663 graph[i]->SetMinimum(0);
664 graph[i]->SetMaximum(0.75);
665 graph[i]->SetMarkerStyle(mstyle[i]);
666 graph[i]->SetMarkerSize(1);
667 graph[i]->SetMarkerColor(mcolor[i]);
668 if (i==0) graph[i]->Draw("ap");
671 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan-#sigma_{r#phi}");
672 legend->AddEntry(graph[0],"A side");
673 legend->AddEntry(graph[1],"C side");
675 gPad->SaveAs("pic/scandy_Vcover.eps");
676 gPad->SaveAs("pic/scandy_Vcover.gif");
679 void MakePlotsdYSkirt(TCut ucut){
683 TFile fbundle("scanDeltaBeam.root");
684 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
686 Int_t mstyle[4]={22,23,24,25};
687 Int_t mcolor[4]={2,3,4,6};
689 entries = treeScan->Draw("sp0X:vskirt","ibeam==7&&side==0"+ucut,"");
690 graph[0]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
691 entries = treeScan->Draw("sp0X:vskirt","ibeam==7&&side==1"+ucut,"");
692 graph[1]= new TGraph(entries, treeScan->GetV2(), treeScan->GetV1());
694 for (Int_t i=0; i<2; i++){
695 graph[i]->GetXaxis()->SetTitle("U_{skirt} (V)");
696 graph[i]->GetYaxis()->SetTitle("#sigma_{r#phi} (mm)");
697 graph[i]->SetMinimum(0);
698 graph[i]->SetMaximum(0.75);
699 graph[i]->SetMarkerStyle(mstyle[i]);
700 graph[i]->SetMarkerSize(1);
701 graph[i]->SetMarkerColor(mcolor[i]);
702 if (i==0) graph[i]->Draw("ap");
705 TLegend *legend = new TLegend(0.45,0.70,0.9,0.9, "Voltage scan-#sigma_{r#phi}");
706 legend->AddEntry(graph[0],"A side");
707 legend->AddEntry(graph[1],"C side");
709 gPad->SaveAs("pic/scandy_Vskirt.eps");
710 gPad->SaveAs("pic/scandy_Vskirt.gif");
715 void GetOptimalSetting(){
719 TFile fbundle("scanDeltaBeam.root");
720 TTree * treeScan = (TTree*)fbundle.Get("vScanBeam");
725 TH1F * his = new TH1F("hisDelta","hisDelta",300,0,1);
726 treeScan->Draw("sp0X>>hisDelta","ibeam==7","");
727 meansp0X = his->GetMean();
728 treeScan->Draw("sp2I>>hisDelta","ibeam==7","");
729 meansp2I = his->GetMean();
730 treeScan->Draw("sp2O>>hisDelta","ibeam==7","");
731 meansp2O = his->GetMean();
735 Int_t indexes[10000];
736 for (Int_t iside=0;iside<2;iside++){
737 printf("*************************************\n");
738 printf("Side%d\tRun\tchi2\t\tVgg\tVskirt\tVcover\n",iside);
740 Int_t entries = treeScan->Draw(Form("sp0X/%f+sp2I/%f+sp2O/%f:run",meansp0X,meansp2I,meansp2O),Form("ibeam==7&&side==%d",iside));
741 TMath::Sort(entries,treeScan->GetV1(),indexes,kFALSE);
742 for (Int_t i=0; i<entries; i++){
743 Int_t index = indexes[i];
744 Int_t run = treeScan->GetV2()[index];
745 Float_t chi2=treeScan->GetV1()[index];
747 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));
751 for (Int_t iside=0;iside<2;iside++){
752 printf("***********************\n");
753 printf("Side%d\tRun\tchi2\t\tVgg\tVskirt\tVcover\n",iside);
755 Int_t entries = treeScan->Draw(Form("sp2I/%f+sp2O/%f:run",meansp0X,meansp2I,meansp2O),Form("ibeam==7&&side==%d",iside));
756 TMath::Sort(entries,treeScan->GetV1(),indexes,kFALSE);
757 for (Int_t i=0; i<entries; i++){
758 Int_t index = indexes[i];
759 Int_t run = treeScan->GetV2()[index];
760 Float_t chi2=treeScan->GetV1()[index];
762 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));
774 chain->SetAlias("VggA","GetVoltage(run,0)");
775 chain->SetAlias("VggC","GetVoltage(run,1)");
776 chain->SetAlias("VcoA","GetVoltage(run,2)");
777 chain->SetAlias("VcoC","GetVoltage(run,3)");
778 chain->SetAlias("VskA","GetVoltage(run,4)");
779 chain->SetAlias("VskC","GetVoltage(run,5)");
783 chain->SetAlias("TisOK","mdEdx>5&&entries>400");
784 chain->SetAlias("CisOK","nCl.fElements>entries*0.5&&eY.fElements<0.01");
785 chain->SetAlias("ATisOK","RA.mdEdx>5&&RA.entries>400");
786 chain->SetAlias("ACisOK","RA.nCl.fElements>RA.entries*0.5&&abs(RA.dY.fElements-dY.fElements)<0.3&&RA.eY.fElements<0.01");
790 chain->SetAlias("lX","X.fElements"); //
791 chain->SetAlias("tY","kY.fElements"); //
792 chain->SetAlias("dE","sign(Y.fElements)*(tan(10*pi/180.)*X.fElements-abs(Y.fElements))");
793 chain->SetAlias("RdY","(dY.fElements-RA.dY.fElements)");
795 chain->SetAlias("dIF","lX-85.2");
796 chain->SetAlias("dOF","245.8-lX");
797 chain->SetAlias("dUtY","((GetVoltage(run,0)-GetVoltage(RA.run,0))/400.*tY)");
799 chain->SetAlias("cIF","dUtY/(1+dIF/13.0)");
800 chain->SetAlias("cOF","dUtY/(1+dOF/22.0)");
801 chain->SetAlias("cIF2","(dUtY*dIF/13.0)/((1.+dIF/13.0)^2)");
802 chain->SetAlias("cOF2","(dUtY*dOF/22.0)/((1.+dOF/22.0)^2)");
804 chain->SetAlias("cE","(GetVoltage(run,0)-GetVoltage(RA.run,0))/400.*sign(dE)/(1+(abs(dE)-1.55)/1.4)");
805 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)");
810 void MakeAliasesBoth(){
812 // cuts - slect good tracks
814 chain->SetAlias("TisOK","mdEdx>5&&entries>400");
815 chain->SetAlias("ATisOK","(LTr.fSide==0)*(RA.mdEdx>5&&RA.entries>500)");
816 chain->SetAlias("CTisOK","(LTr.fSide==1)*(RC.mdEdx>5&&RC.entries>500)");
818 chain->Draw(">>run","TisOK&&(ATisOK||CTisOK)","entryList");
819 TEntryList *elist = (TEntryList*)gDirectory->Get("run");
820 chain->SetEntryList(elist);
823 chain->SetAlias("CisOK","(nCl.fElements>entries*0.5&&eY.fElements<0.01)");
824 chain->SetAlias("ACisOK","RA.nCl.fElements>RA.entries*0.5&&abs(RA.dY.fElements-dY.fElements)<0.3&&RA.eY.fElements<0.01");
825 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");
831 chain->SetAlias("Vgg","((LTr.fSide==0)*GetVoltage(run,0)+(LTr.fSide==1)*GetVoltage(run,1))");
832 chain->SetAlias("VcoA","((LTr.fSide==0)*GetVoltage(run,2)+(LTr.fSide==1)*GetVoltage(run,3))");
833 chain->SetAlias("VskA","((LTr.fSide==0)*GetVoltage(run,4)+(LTr.fSide==1)*GetVoltage(run,5))");
835 chain->SetAlias("dVgg","(((LTr.fSide==0)*(GetVoltage(run,0)-GetVoltage(RA.run,0))+((LTr.fSide==0)*(GetVoltage(run,0)-GetVoltage(RA.run,0))))/400.)");
839 chain->SetAlias("RdY","((LTr.fSide==0)*(dY.fElements-RA.dY.fElements)+(LTr.fSide==1)*(dY.fElements-RC.dY.fElements))");
841 chain->SetAlias("drift","(1.-abs(LTr.fP[1]+0.)/250)");
842 chain->SetAlias("lX","X.fElements"); //
843 chain->SetAlias("tY","kY.fElements"); //
844 chain->SetAlias("dE","sign(Y.fElements)*(tan(10*pi/180.)*X.fElements-abs(Y.fElements))");
846 chain->SetAlias("dIF","lX-85.2");
847 chain->SetAlias("dOF","245.8-lX");
848 chain->SetAlias("dUtY","dVgg*tY");
852 chain->SetAlias("cIF","dUtY/(1+dIF/13.0)");
853 chain->SetAlias("cOF","dUtY/(1+dOF/22.0)");
854 chain->SetAlias("cIF2","(dUtY*dIF/13.0)/((1.+dIF/13.0)^2)");
855 chain->SetAlias("cOF2","(dUtY*dOF/22.0)/((1.+dOF/22.0)^2)");
857 chain->SetAlias("cE","dVgg*sign(dE)/(1+(abs(dE)-1.5)/1.3)");
858 chain->SetAlias("cE2","dVgg*sign(dE)*((abs(dE)-1.5)/1.3)/((1+(abs(dE)-1.5)/1.3)^2)");
867 Int_t ntracks=3000000;
868 TStatToolkit toolkit;
880 TCut cutA="LTr.fBeam>-1&&CisOK&&(ACisOK||CCisOK)";
882 TString * strA = TStatToolkit::FitPlane(chain,"RdY", fstring.Data(),cutA, chi2,npoints,fitParam,covMatrix,-1.,0, ntracks);
883 chain->SetAlias("fdY",strA->Data());
885 printf("sqrt(Chi2/npoints)=%f\n",TMath::Sqrt(chi2/npoints));
886 chain->Draw("RdY-fdY",cutA);
889 TF1 fe("fe","[0]/(1+(x-[2])/[1])",2,10);
890 fe.SetParameters(0.4,1,1.5);
898 // 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)