99#include <TNtuple.h>
1010#include <TString.h>
1111#include <TTree.h>
12+ #include <TROOT.h>
13+ #include <TStyle.h>
1214
1315#include "DetectorsCommonDataFormats/DetID.h"
1416#include "ITSMFTBase/SegmentationAlpide.h"
2628#include "DetectorsCommonDataFormats/DetectorNameConf.h"
2729#endif
2830
29- void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hitfile = "o2sim_HitsIT3.root",
30- std::string inputGeom = "", std::string dictfile = "")
31+ void CheckClustersITS3 (int nITS3layers = 3 , std ::string clusfile = "o2clus_it3.root" , std ::string hitfile = "o2sim_HitsIT3.root" ,
32+ std ::string inputGeom = "" , std ::string dictfile = "" , bool batch = true )
3133{
34+ gROOT -> SetBatch (batch );
35+
36+ // we assume that we have 2 chips per layer
37+ const int nChipsPerLayer = 2 ;
38+
3239 const int QEDSourceID = 99 ; // Clusters from this MC source correspond to QED electrons
3340
3441 using namespace o2 ::base ;
@@ -158,21 +165,24 @@ void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hit
158165 auto pattID = cluster .getPatternID ();
159166 o2 ::math_utils ::Point3D < float > locC ;
160167 auto chipID = cluster .getSensorID ();
161- if (pattID == o2::itsmft ::CompCluster::InvalidPatternID || dict.isGroup(pattID)) {
168+ if (pattID == o2 ::its3 ::CompCluster ::InvalidPatternID || dict .isGroup (pattID )) {
162169 o2 ::itsmft ::ClusterPattern patt (pattIt );
163170 locC = dict .getClusterCoordinates (chipID , cluster , patt , false);
164171 } else {
165172 locC = dict .getClusterCoordinates (chipID , cluster );
166173 errX = dict .getErrX (pattID );
167174 errZ = dict .getErrZ (pattID );
168175 npix = dict .getNpixels (pattID );
176+ LOGP (info , "I am invalid and I am on chip {}" , chipID );
169177 }
170178 // Transformation to the local --> global
171- auto gloC = gman->getMatrixL2G(chipID) * locC;
172- if (chipID < o2::its3::SegmentationSuperAlpide::NLayers) {
173- double radius = SegmentationSuperAlpide::Radii[chipID];
174- double phi = locC.X() / radius;
175- gloC.SetXYZ(radius * std::cos(phi), radius * std::sin(phi), locC.Z());
179+ auto gloC = gman -> getMatrixL2G (chipID )(locC );
180+ if (chipID / nChipsPerLayer < nITS3layers ) {
181+ double radius = SegmentationSuperAlpide ::Radii [chipID / nChipsPerLayer ];
182+
183+ bool isTop = !(chipID % nChipsPerLayer );
184+ double phi = locC .X () / radius + (isTop ? -0.5 : +0.5 ) * (float )TMath ::Pi ();
185+ gloC .SetXYZ (- radius * std ::cos (phi ), - (isTop ? radius * std ::sin (phi ) - 0.1 / 2 : radius * std ::sin (phi ) + 0.1 / 2 ), locC .Z ());
176186 }
177187
178188 const auto& lab = (clusLabArr -> getLabels (clEntry ))[0 ];
@@ -195,24 +205,34 @@ void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hit
195205 float dx = 0 , dz = 0 ;
196206 int ievH = lab .getEventID ();
197207 o2 ::math_utils ::Point3D < float > locH , locHsta ;
208+ o2 ::math_utils ::Point3D < float > gloH , gloHsta ;
198209
199210 // mean local position of the hit
200211 locH = gman -> getMatrixL2G (chipID ) ^ (hit .GetPos ()); // inverse conversion from global to local
201212 locHsta = gman -> getMatrixL2G (chipID ) ^ (hit .GetPosStart ());
202213
203- if (chipID < 4) {
204- float startPhi{std::atan2(-hit.GetPosStart().Y(), -hit.GetPosStart().X())};
205- float endPhi{std::atan2(-hit.GetPos().Y(), -hit.GetPos().X())};
206- locH.SetXYZ(SegmentationSuperAlpide::Radii[chipID] * endPhi, 0.f, hit.GetPos().Z());
207- locHsta.SetXYZ(SegmentationSuperAlpide::Radii[chipID] * startPhi, 0.f, hit.GetPosStart().Z());
214+ if (chipID / nChipsPerLayer < nITS3layers ) {
215+ bool isTop = !(chipID % nChipsPerLayer );
216+ float reShiftedY = isTop ? hit .GetPosStart ().Y () - 0.1 / 2 : hit .GetPosStart ().Y () + 0.1 / 2 ;
217+ float startPhi {std ::atan2 (- reShiftedY , - hit .GetPosStart ().X ()) + (isTop ? (float )TMath ::Pi () / 2 : - (float )TMath ::Pi () / 2 )};
218+ float reShiftedEndY = isTop ? hit .GetPos ().Y () - 0.1 / 2 : hit .GetPos ().Y () + 0.1 / 2 ;
219+ float endPhi {std ::atan2 (- reShiftedEndY , - hit .GetPos ().X ()) + (isTop ? (float )TMath ::Pi () / 2 : - (float )TMath ::Pi () / 2 )};
220+ float deltaY = reShiftedEndY - reShiftedY ;
221+ locH .SetXYZ (SegmentationSuperAlpide ::Radii [chipID / nChipsPerLayer ] * endPhi , 0.f , hit .GetPos ().Z ());
222+ locHsta .SetXYZ (SegmentationSuperAlpide ::Radii [chipID / nChipsPerLayer ] * startPhi , deltaY , hit .GetPosStart ().Z ());
208223 }
209-
210224 auto x0 = locHsta .X (), dltx = locH .X () - x0 ;
211225 auto y0 = locHsta .Y (), dlty = locH .Y () - y0 ;
212226 auto z0 = locHsta .Z (), dltz = locH .Z () - z0 ;
213- auto r = (0.5 * (Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff) - y0) / dlty;
214- locH.SetXYZ(x0 + r * dltx, y0 + r * dlty, z0 + r * dltz);
215- //locH.SetXYZ(0.5 * (locH.X() + locHsta.X()), 0.5 * (locH.Y() + locHsta.Y()), 0.5 * (locH.Z() + locHsta.Z()));
227+
228+ if (chipID / nChipsPerLayer >= nITS3layers ) {
229+ auto r = (0.5 * (Segmentation ::SensorLayerThickness - Segmentation ::SensorLayerThicknessEff ) - y0 ) / dlty ;
230+ locH .SetXYZ (x0 + r * dltx , y0 + r * dlty , z0 + r * dltz );
231+ } else {
232+ // not really precise, but okish
233+ locH .SetXYZ (0.5 * (locH .X () + locHsta .X ()), 0.5 * (locH .Y () + locHsta .Y ()), 0.5 * (locH .Z () + locHsta .Z ()));
234+ }
235+
216236 std ::array < float , 18 > data = {(float )lab .getEventID (), (float )trID ,
217237 locH .X (), locH .Z (), dltx / dlty , dltz / dlty ,
218238 gloC .X (), gloC .Y (), gloC .Z (),
@@ -223,30 +243,34 @@ void CheckClustersITS3(std::string clusfile = "o2clus_it3.root", std::string hit
223243 }
224244 }
225245
226- new TCanvas;
227- nt.Draw("cgy:cgx");
228- new TCanvas;
229- nt.Draw("dz:dx", "abs(dz)<0.01 && abs(dx)<0.01");
230- new TCanvas;
231- nt.Draw("dz:tz", "abs(dz)<0.005 && abs(tz)<2");
232-
233- auto c1 = new TCanvas("p1", "pullX");
234- c1->cd();
235- c1->SetLogy();
236- nt.Draw("dx/ex", "abs(dx/ex)<10&&patid<10");
237- auto c2 = new TCanvas("p2", "pullZ");
238- c2->cd();
239- c2->SetLogy();
240- nt.Draw("dz/ez", "abs(dz/ez)<10&&patid<10");
241-
242- auto d1 = new TCanvas("d1", "deltaX");
243- d1->cd();
244- d1->SetLogy();
245- nt.Draw("dx", "abs(dx)<5");
246- auto d2 = new TCanvas("d2", "deltaZ");
247- d2->cd();
248- d2->SetLogy();
249- nt.Draw("dz", "abs(dz)<5");
246+ auto canvCgXCgY = new TCanvas ("canvCgXCgY" , "" , 1600 , 1600 );
247+ canvCgXCgY -> Divide (2 , 2 );
248+ canvCgXCgY -> cd (1 );
249+ nt .Draw ("cgy:cgx>>h_cgy_vs_cgx_IB(1000, -10, 10, 1000, -10, 10)" , "id < 6" , "colz" );
250+ canvCgXCgY -> cd (2 );
251+ nt .Draw ("cgy:cgz>>h_cgy_vs_cgz_IB(1000, -15, 15, 1000, -10, 10)" , "id < 6" , "colz" );
252+ canvCgXCgY -> cd (3 );
253+ nt .Draw ("cgy:cgx>>h_cgy_vs_cgx_OB(1000, -50, 50, 1000, -50, 50)" , "id >= 6" , "colz" );
254+ canvCgXCgY -> cd (4 );
255+ nt .Draw ("cgy:cgz>>h_cgy_vs_cgz_OB(1000, -100, 100, 1000, -50, 50)" , "id >= 6" , "colz" );
256+ canvCgXCgY -> SaveAs ("it3clusters_y_vs_x_vs_z.pdf" );
257+
258+ auto canvdXdZ = new TCanvas ("canvdXdZ" , "" , 1600 , 800 );
259+ canvdXdZ -> Divide (2 , 1 );
260+ canvdXdZ -> cd (1 );
261+ nt .Draw ("dx:dz>>h_dx_vs_dz_IB(1000, -0.025, 0.025, 1000, -0.025, 0.025)" , "id < 6" , "colz" );
262+ canvdXdZ -> cd (2 );
263+ nt .Draw ("dx:dz>>h_dx_vs_dz_OB(1000, -0.025, 0.025, 1000, -0.025, 0.025)" , "id >= 6" , "colz" );
264+ canvdXdZ -> SaveAs ("it3clusters_dx_vs_dz.pdf" );
265+
266+ // auto c1 = new TCanvas("p1", "pullX");
267+ // c1->cd();
268+ // c1->SetLogy();
269+ // nt.Draw("dx/ex", "abs(dx/ex)<10&&patid<10");
270+ // auto c2 = new TCanvas("p2", "pullZ");
271+ // c2->cd();
272+ // c2->SetLogy();
273+ // nt.Draw("dz/ez", "abs(dz/ez)<10&&patid<10");
250274
251275 fout .cd ();
252276 nt .Write ();
0 commit comments