16 double deltaX, deltaY, deltaZ,
deltaR, deltaPhi;
20 const char * inputpattern=
"/sphenix/u/skurdi/CMCalibration/cmDistHitsTree_Event*.root";
23 TFileCollection *filelist=
new TFileCollection();
24 filelist->Add(inputpattern);
25 TString sourcefilename;
29 nEvents=filelist->GetNFiles();
30 }
else if(nMaxEvents<filelist->GetNFiles()){
33 nEvents= filelist->GetNFiles();
36 TCanvas *canvas1=
new TCanvas(
"canvas1",
"CMDistortionReco1",1200,800);
40 TCanvas *canvas=
new TCanvas(
"canvas",
"CMDistortionReco2",400,400);
43 position =
new TVector3(1.,1.,1.);
44 newposition =
new TVector3(1.,1.,1.);
47 TH1F *hTimePerEvent =
new TH1F(
"hTimePerEvent",
"Time Per Event; time (ms)",20,0,10000);
49 for (
int ifile=0;ifile <
nEvents;ifile++){
53 unsigned long before = now;
56 sourcefilename=((TFileInfo*)(filelist->GetList()->At(ifile)))->GetCurrentUrl()->GetFile();
58 char const *treename=
"cmDistHitsTree";
59 TFile *input=TFile::Open(sourcefilename,
"READ");
60 TTree *inTree=(TTree*)input->Get(
"tree");
62 inTree->SetBranchAddress(
"position",&position);
63 inTree->SetBranchAddress(
"newposition",&newposition);
67 double lowphi = -0.078539819;
68 double highphi = 6.3617253;
75 TH2F *hStripesPerBinPhiR =
new TH2F(
"hStripesPerBinPhiR",
"CM Stripes Per Bin (z in stripes); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
77 TH2F *hCartesianForwardPhiR[3];
78 hCartesianForwardPhiR[0] =
new TH2F(
"hForwardX_PhiR",
"X Shift Forward of Stripe Centers, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
79 hCartesianForwardPhiR[1] =
new TH2F(
"hForwardY_PhiR",
"Y Shift Forward of Stripe Centers, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
80 hCartesianForwardPhiR[2] =
new TH2F(
"hForwardZ_PhiR",
"Z Shift Forward of Stripe Centers, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
82 TH2F *hCylindricalForwardPhiR[2];
83 hCylindricalForwardPhiR[0] =
new TH2F(
"hForwardR_PhiR",
"Radial Shift Forward of Stripe Centers, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
84 hCylindricalForwardPhiR[1] =
new TH2F(
"hForwardPhi_PhiR",
"Phi Shift Forward of Stripe Centers, Phi,R binning (rad); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
86 for (
int i=0;i<inTree->GetEntries();i++){
89 double r = position->Perp();
90 double phi = position->Phi();
92 if(position->Phi() < 0.0){
93 phi = position->Phi() + 2.0*TMath::Pi();
96 hStripesPerBinPhiR->Fill(phi,r,1);
98 deltaX = (newposition->X() - position->X())*(1
e4);
99 deltaY = (newposition->Y() - position->Y())*(1
e4);
100 deltaZ = (newposition->Z() - position->Z())*(1
e4);
102 deltaR = (newposition->Perp() - position->Perp())*(1
e4);
103 deltaPhi = newposition->DeltaPhi(*position);
105 hCartesianForwardPhiR[0]->Fill(phi,r,deltaX);
106 hCartesianForwardPhiR[1]->Fill(phi,r,deltaY);
107 hCartesianForwardPhiR[2]->Fill(phi,r,deltaZ);
109 hCylindricalForwardPhiR[0]->Fill(phi,r,deltaR);
110 hCylindricalForwardPhiR[1]->Fill(phi,r,deltaPhi);
113 TH2F *hCartesianAveShiftPhiR[3];
114 hCartesianAveShiftPhiR[0] =
new TH2F(
"AveShiftX_PhiR",
"Average of CM Model X over Stripes per Bin, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
115 hCartesianAveShiftPhiR[1] =
new TH2F(
"AveShiftY_PhiR",
"Average of CM Model Y over Stripes per Bin, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
116 hCartesianAveShiftPhiR[2] =
new TH2F(
"AveShiftZ_PhiR",
"Average of CM Model Z over Stripes per Bin, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
118 TH2F *hCylindricalAveShiftPhiR[2];
119 hCylindricalAveShiftPhiR[0] =
new TH2F(
"AveShiftR_PhiR",
"Average of CM Model R over Stripes per Bin, Phi,R binning (#mum); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
120 hCylindricalAveShiftPhiR[1] =
new TH2F(
"AveShiftPhi_PhiR",
"Average of CM Model Phi over Stripes per Bin, Phi,R binning (rad); phi (rad); r (cm)",nbinsphi,lowphi,highphi,nbinsr,lowr,highr);
122 for (
int i = 0; i < 3; i ++){
123 hCartesianAveShiftPhiR[i]->Divide(hCartesianForwardPhiR[i],hStripesPerBinPhiR);
126 hCylindricalAveShiftPhiR[0]->Divide(hCylindricalForwardPhiR[0],hStripesPerBinPhiR);
127 hCylindricalAveShiftPhiR[1]->Divide(hCylindricalForwardPhiR[1],hStripesPerBinPhiR);
135 double minphi = -0.078539819;
136 double minr = 18.884615;
137 double minz = -1.3187500;
139 double maxphi = 6.3617253;
140 double maxr = 79.115387;
141 double maxz = 106.81875;
143 TH3F *hCartesianCMModelPhiR[3];
144 hCartesianCMModelPhiR[0]=
new TH3F(
"hCMModelX_PhiR",
"CM Model: X Shift Forward of Stripe Centers, Phi,R binning", nphi,minphi,maxphi, nr,minr,maxr, nz,minz,maxz);
145 hCartesianCMModelPhiR[1]=
new TH3F(
"hCMModelY_PhiR",
"CM Model: Y Shift Forward of Stripe Centers, Phi,R binning", nphi,minphi,maxphi, nr,minr,maxr, nz,minz,maxz);
146 hCartesianCMModelPhiR[2]=
new TH3F(
"hCMModelZ_PhiR",
"CM Model: Z Shift Forward of Stripe Centers, Phi,R binning", nphi,minphi,maxphi, nr,minr,maxr, nz,minz,maxz);
148 TH3F *hCylindricalCMModelPhiR[2];
149 hCylindricalCMModelPhiR[0]=
new TH3F(
"hCMModelR_PhiR",
"CM Model: Radial Shift Forward of Stripe Centers, Phi,R binning", nphi,minphi,maxphi, nr,minr,maxr, nz,minz,maxz);
150 hCylindricalCMModelPhiR[1]=
new TH3F(
"hCMModelPhi_PhiR",
"CM Model: Phi Shift Forward of Stripe Centers, Phi,R binning", nphi,minphi,maxphi, nr,minr,maxr, nz,minz,maxz);
152 double xshiftPhiR, yshiftPhiR, zshiftPhiR, rshiftcartPhiR, phishiftcartPhiR;
154 for(
int i = 0; i < nphi; i++){
155 double phi = minphi + ((maxphi - minphi)/(1.0*nphi))*(i+0.5);
157 for(
int j = 0; j < nr; j++){
158 double r = minr + ((maxr - minr)/(1.0*nr))*(j+0.5);
160 for(
int k = 0;
k < nz;
k++){
161 double z = minz + ((maxz -
minz)/(1.0*nz))*(
k+0.5);
163 xshiftPhiR=(hCartesianAveShiftPhiR[0]->Interpolate(phi,r))*(1
e-4);
164 yshiftPhiR=(hCartesianAveShiftPhiR[1]->Interpolate(phi,r))*(1
e-4);
165 zshiftPhiR=(hCartesianAveShiftPhiR[2]->Interpolate(phi,r))*(1
e-4);
167 rshiftcartPhiR=(hCylindricalAveShiftPhiR[0]->Interpolate(phi,r))*(1
e-4);
168 phishiftcartPhiR=hCylindricalAveShiftPhiR[1]->Interpolate(phi,r);
170 hCartesianCMModelPhiR[0]->Fill(phi,r,z,xshiftPhiR*(1-z/105.5));
171 hCartesianCMModelPhiR[1]->Fill(phi,r,z,yshiftPhiR*(1-z/105.5));
172 hCartesianCMModelPhiR[2]->Fill(phi,r,z,zshiftPhiR*(1-z/105.5));
174 hCylindricalCMModelPhiR[0]->Fill(phi,r,z,rshiftcartPhiR*(1-z/105.5));
175 hCylindricalCMModelPhiR[1]->Fill(phi,r,z,phishiftcartPhiR*(1-z/105.5));
182 plots=TFile::Open(Form(
"CMModelsPhiR_Event%d.root",ifile),
"RECREATE");
184 for(
int i = 0; i < 3; i++){
185 hCartesianForwardPhiR[i]->Write();
186 hCartesianAveShiftPhiR[i]->Write();
187 hCartesianCMModelPhiR[i]->Write();
190 for(
int i = 0; i < 2; i++){
191 hCylindricalForwardPhiR[i]->Write();
192 hCylindricalAveShiftPhiR[i]->Write();
193 hCylindricalCMModelPhiR[i]->Write();
201 unsigned long after = now;
203 hTimePerEvent->Fill(after-before);
206 for (
int i = 0; i < 3; i++){
207 hCartesianForwardPhiR[i]->SetStats(0);
211 hStripesPerBinPhiR->Draw(
"colz");
212 canvas1->cd(2)->Clear();
213 canvas1->cd(3)->Clear();
215 hCartesianForwardPhiR[0]->Draw(
"colz");
217 hCartesianForwardPhiR[1]->Draw(
"colz");
219 hCartesianForwardPhiR[2]->Draw(
"colz");
222 canvas1->Print(
"CMDistortionReco1.pdf(",
"pdf");
223 }
else if (ifile == nEvents - 1){
224 canvas1->Print(
"CMDistortionReco1.pdf)",
"pdf");
226 canvas1->Print(
"CMDistortionReco1.pdf",
"pdf");
232 hTimePerEvent->Draw();
233 canvas->Print(
"CMDistortionReco2.pdf",
"pdf");