]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/TRD/AliTRDclusterResolution.cxx
Fixed compilation
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDclusterResolution.cxx
index fc6e308a922b9228c38ddf0c41738eb1b81a21ba..d4fe1de26a750e2b972c3f0c2a6374623939d1cb 100644 (file)
 #include "AliTRDclusterResolution.h"
 #include "info/AliTRDclusterInfo.h"
 #include "AliTRDgeometry.h"
+#include "AliTRDpadPlane.h"
 #include "AliTRDcluster.h"
 #include "AliTRDseedV1.h"
 #include "AliTRDcalibDB.h"
 #include "Cal/AliTRDCalDet.h"
 
 #include "AliLog.h"
-#include "AliTracker.h"
+#include "AliESDEvent.h"
 #include "AliCDBManager.h"
 
 #include "TROOT.h"
@@ -208,6 +209,8 @@ AliTRDclusterResolution::AliTRDclusterResolution()
   ,fResults(NULL)
   ,fStatus(0)
   ,fDet(-1)
+  ,fCol(-1)
+  ,fRow(-1)
   ,fExB(0.)
   ,fVdrift(0.)
   ,fT0(0.)
@@ -229,6 +232,8 @@ AliTRDclusterResolution::AliTRDclusterResolution(const char *name)
   ,fResults(NULL)
   ,fStatus(0)
   ,fDet(-1)
+  ,fCol(-1)
+  ,fRow(-1)
   ,fExB(0.)
   ,fVdrift(0.)
   ,fT0(0.)
@@ -267,6 +272,7 @@ AliTRDclusterResolution::~AliTRDclusterResolution()
 void AliTRDclusterResolution::UserCreateOutputObjects()
 {
   fContainer = Histos();
+  PostData(1, fContainer);
 }
 
 //_______________________________________________________
@@ -375,7 +381,7 @@ Bool_t AliTRDclusterResolution::GetRefFigure(Int_t ifig)
     ((TVirtualPad*)l->At(2))->cd();
     h1 = h2->ProjectionX("hdx_pxx"); h1->Scale(1.e4/kND); h1->SetMarkerStyle(24);
     h1->SetYTitle("<#deltax> [#mum]");
-    h1->SetXTitle("t_{drift} [#mus]");
+    h1->SetXTitle("t_{drift} [tb]");
     //h1->GetXaxis()->SetRange(2, AliTRDseedV1::kNtb-1); 
     h1->Draw("pc");
 
@@ -397,7 +403,7 @@ Bool_t AliTRDclusterResolution::GetRefFigure(Int_t ifig)
     ((TVirtualPad*)l->At(3))->cd();
     h1 = h2->ProjectionX("hdy_pxx"); h1->Scale(1.e4/kND); h1->SetMarkerStyle(24);
     h1->SetYTitle("<#deltay> [#mum]");
-    h1->SetXTitle("t_{drift} [#mus]");
+    h1->SetXTitle("t_{drift} [tb]");
     //h1->GetXaxis()->SetRange(2, AliTRDseedV1::kNtb-1); 
     h1->Draw("pc");
 
@@ -491,7 +497,13 @@ void AliTRDclusterResolution::UserExec(Option_t *)
 // Fill container histograms
 
   fInfo = dynamic_cast<TObjArray *>(GetInputData(1));
-  if(!HasExB()) AliWarning("ExB was not set. Call SetExB() before running the task.");
+  if(!HasExB()){ 
+    SetExB();
+    if(!HasExB()){ 
+      AliWarning("Magnetic field settings failed. Check OCDB access.");
+      return;
+    }
+  }
 
   Int_t det, t;
   Float_t x, y, z, q, dy, dydx, dzdx, cov[3], covcl[3];
@@ -508,10 +520,18 @@ void AliTRDclusterResolution::UserExec(Option_t *)
   TIterator *iter=fInfo->MakeIterator();
   while((cli=dynamic_cast<AliTRDclusterInfo*>((*iter)()))){
     cli->GetCluster(det, x, y, z, q, t, covcl);
-    dy = cli->GetResolution();
-    AliDebug(4, Form("det[%d] tb[%2d] q[%4.0f Log[%6.4f]] dy[%7.2f][um] ypull[%5.2f]", det, t, q, TMath::Log(q), 1.e4*dy, dy/TMath::Sqrt(covcl[0])));
 
+    // select cluster according to detector region if specified
     if(fDet>=0 && fDet!=det) continue;
+    if(fCol>=0 && fRow>=0){
+      Int_t c,r;
+      cli->GetCenterPad(c, r);
+      if(TMath::Abs(fCol-c) > 5) continue;
+      if(TMath::Abs(fRow-r) > 2) continue;
+    }
+
+    dy = cli->GetResolution();
+    AliDebug(4, Form("det[%d] tb[%2d] q[%4.0f Log[%6.4f]] dy[%7.2f][um] ypull[%5.2f]", det, t, q, TMath::Log(q), 1.e4*dy, dy/TMath::Sqrt(covcl[0])));
     
     cli->GetGlobalPosition(y, z, dydx, dzdx, &cov[0]);
 
@@ -546,7 +566,6 @@ void AliTRDclusterResolution::UserExec(Option_t *)
     // fill histo for systematic (mean)
     ((TH3S*)arr2->At(it-1))->Fill(10.*cli->GetAnisochronity(), dydx-cli->GetTilt()*dzdx, dy);  
   }
-  PostData(1, fContainer);
 }
 
 
@@ -629,34 +648,50 @@ Bool_t AliTRDclusterResolution::PostProcess()
 }
 
 //_______________________________________________________
-Bool_t AliTRDclusterResolution::SetExB(Int_t det, Int_t col, Int_t row)
+Bool_t AliTRDclusterResolution::SetExB()
 {
-  // check OCDB
-  AliCDBManager *cdb = AliCDBManager::Instance();
+// Retrieve calibration parameters from OCDB, drift velocity and t0 for the detector region specified by
+// a previous call to AliTRDclusterResolution::SetCalibrationRegion().
+
+  AliCDBManager *cdb = AliCDBManager::Instance(); // init OCDB
   if(cdb->GetRun() < 0){
     AliError("OCDB manager not properly initialized");
     return kFALSE;
   }
 
   // check magnetic field
-  if(TMath::Abs(AliTracker::GetBz()) < 1.e-10){
-    AliWarning("B=0. Magnetic field may not be initialized. Continue if you know what you are doing !");
+  AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
+  if(!esd){
+    AliError("Failed retrieving ESD event");
+    return kFALSE;
+  }
+  if(esd->InitMagneticField()){
+    AliError("Magnetic field failed initialization.");
+    return kFALSE;
   }
 
-  // set reference detector if any
-  fDet = -1;
-  if(det>=0 && det<AliTRDgeometry::kNdet) fDet = det;
-  else det=0;
+  // check pad for detector
+  if(fCol>=0 && fRow>=0){
+    AliTRDgeometry geo;
+    AliTRDpadPlane *pp(geo.GetPadPlane(fDet));
+    if(fCol>=pp->GetNcols() ||
+       fRow>=pp->GetNrows()){
+      AliWarning(Form("Pad coordinates col[%d] or row[%d] incorrect for det[%d].\nLimits are max col[%d] max row[%d]. Reset to default", fCol, fRow, fDet, pp->GetNcols(), pp->GetNrows()));
+      fCol = -1; fRow=-1;
+    }
+  }
 
   AliTRDcalibDB *fCalibration  = AliTRDcalibDB::Instance();
-  AliTRDCalROC  *fCalVdriftROC(fCalibration->GetVdriftROC(det))
-               ,*fCalT0ROC(fCalibration->GetT0ROC(det));
+  AliTRDCalROC  *fCalVdriftROC(fCalibration->GetVdriftROC(fDet>=0?fDet:0))
+               ,*fCalT0ROC(fCalibration->GetT0ROC(fDet>=0?fDet:0));
   const AliTRDCalDet  *fCalVdriftDet = fCalibration->GetVdriftDet();
   const AliTRDCalDet  *fCalT0Det = fCalibration->GetT0Det();
 
-  fVdrift = fCalVdriftDet->GetValue(det) * fCalVdriftROC->GetValue(col, row);
+  fVdrift = fCalVdriftDet->GetValue(fDet>=0?fDet:0);
+  if(fCol>=0 && fRow>=0) fVdrift*= fCalVdriftROC->GetValue(fCol, fRow);
   fExB    = AliTRDCommonParam::Instance()->GetOmegaTau(fVdrift);
-  fT0     = fCalT0Det->GetValue(det) * fCalT0ROC->GetValue(col, row);
+  fT0     = fCalT0Det->GetValue(fDet>=0?fDet:0);
+  if(fCol>=0 && fRow>=0) fT0 *= fCalT0ROC->GetValue(fCol, fRow);
   SetBit(kExB);
 
   AliDebug(1, Form("Calibrate for Det[%3d] t0[%5.3f] vd[%5.3f] ExB[%f]", fDet, fT0, fVdrift, fExB));
@@ -664,6 +699,23 @@ Bool_t AliTRDclusterResolution::SetExB(Int_t det, Int_t col, Int_t row)
   return kTRUE;
 }
 
+//_______________________________________________________
+void AliTRDclusterResolution::SetCalibrationRegion(Int_t det, Int_t col, Int_t row)
+{
+// Set calibration region in terms of detector and pad. 
+// By default detector 0 mean values are considered.
+
+  if(det>=0 && det<AliTRDgeometry::kNdet){ 
+    fDet = det;
+    if(col>=0 && row>=0){
+      fCol = col;
+      fRow = row;
+    }
+    return;
+  }
+  AliError(Form("Detector index outside range [0 %d].", AliTRDgeometry::kNdet));
+}
+
 //_______________________________________________________
 void AliTRDclusterResolution::SetVisual()
 {
@@ -849,7 +901,7 @@ void AliTRDclusterResolution::ProcessCenterPad()
         fP[0] = fp.GetParameter(1); fP[1] = fp.GetParError(1);
         fP[2] = fp.GetParameter(2); fP[3] = fp.GetParError(2);
 
-        AliDebug(4, Form("ly[%d] tb[%2d] y[%+5.2f] m[%5.3f] s[%5.3f] pm[%5.3f] ps[%5.3f]", fLy, fT, fY, fR[0], fR[2], fP[0], fP[2]));
+        AliDebug(4, Form("ly[%d] tb[%2d] y[%+5.2f] m[%5.3f] s[%5.3f] pm[%5.3f] ps[%5.3f]", fLy, (Int_t)fT, fY, fR[0], fR[2], fP[0], fP[2]));
         t->Fill();
       }
     }
@@ -1193,7 +1245,7 @@ void AliTRDclusterResolution::ProcessMean()
 
         h1 = (TH1D*)h3->Project3D("z");
         Int_t entries = (Int_t)h1->Integral();
-        if(entries < 150) continue;
+        if(entries < 50) continue;
         //Adjust(&f, h1);
         h1->Fit(&f, "QN");