]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
M AliTPCTransform.cxx - Eff C++ warning
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Oct 2009 22:56:40 +0000 (22:56 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Oct 2009 22:56:40 +0000 (22:56 +0000)
M      AliTPCcalibDB.cxx       - Drift correction - Use functionality of AliTPCcalibDButil
M      AliTPCcalibDButil.cxx   - Combining the TPC Laser and Cosmic to get corrections
M      AliTPCcalibDButil.h     -

M      AliTPCcalibTime.cxx     - Use AliRelAlignment for calculation of drift velocity correction - using the TPC-ITS and TPC-TOF matching
M      AliTPCcalibTime.h

Marian

TPC/AliTPCTransform.cxx
TPC/AliTPCcalibDB.cxx
TPC/AliTPCcalibDButil.cxx
TPC/AliTPCcalibDButil.h
TPC/AliTPCcalibTime.cxx
TPC/AliTPCcalibTime.h

index 6a9f4268afca51169ffbbc964e6357b11be92cd8..79f26740ec46e4f9c1ef3d5d1f2e34fd28abbcd6 100755 (executable)
@@ -251,7 +251,7 @@ void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
   static Double_t time0corrTime=0;
   static Int_t    lastStampT=-1;
   //
-  if (lastStampT!=fCurrentTimeStamp){
+  if (lastStampT!=(Int_t)fCurrentTimeStamp){
     lastStampT=fCurrentTimeStamp;
     if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionTime()>0) {
       vdcorrectionTime = (1+AliTPCcalibDB::Instance()->
index 9b38f2a8df7daf057f554a1f4c7117b044f936ba..bf348407fa506bdc436bbd092d087d25754b5555 100644 (file)
@@ -87,6 +87,7 @@
 #include <AliSplineFit.h>
 
 #include "AliTPCcalibDB.h"
+#include "AliTPCcalibDButil.h"
 #include "AliTPCAltroMapping.h"
 #include "AliTPCExB.h"
 
@@ -1556,7 +1557,7 @@ Bool_t AliTPCcalibDB::CreateRefFile(Int_t run, const char* filename)
 
 
 
-Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t side, Int_t /*mode*/){
+Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
   //
   // Get time dependent drift velocity correction
   // multiplication factor        vd = vdnom *(1+vdriftcorr)
@@ -1568,27 +1569,17 @@ Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_
   //
   // Notice - Extrapolation outside of calibration range  - using constant function
   //
-  if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
-  UpdateRunInformations(run,kFALSE);
-  TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
-  if (!array) return 0;
-  TGraphErrors *laserA= (TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_A");
-  TGraphErrors *laserC= (TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_C");
-  
-  Double_t result=0;
-  if (laserA && laserC){
-   result= (laserA->Eval(timeStamp)+laserC->Eval(timeStamp))*0.5;
-  }
-  if (laserA && side==0){
-    result = (laserA->Eval(timeStamp));
-  }
-  if (laserC &&side==1){
-    result = (laserC->Eval(timeStamp));
+  Double_t result;
+  // mode TPC crossing and laser 
+  if (mode==1) {
+    result=AliTPCcalibDButil::GetVDriftTPC(run,timeStamp);
+    
   }
+
   return result;
 }
 
-Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t side, Int_t /*mode*/){
+Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
   //
   // Get time dependent time 0 (trigger delay in cm) correction
   // additive correction        time0 = time0+ GetTime0CorrectionTime
@@ -1601,30 +1592,11 @@ Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t
   //
   // Notice - Extrapolation outside of calibration range  - using constant function
   //
-  if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
-  UpdateRunInformations(run,kFALSE);
-  TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
-  if (!array) return 0;
-  TGraphErrors *laserA= (TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_A");
-  TGraphErrors *laserC= (TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_C");
-  
-  Double_t lresult=0;
-  if (laserA && laserC){
-   lresult= (laserA->Eval(timeStamp)+laserC->Eval(timeStamp))*0.5;
-  }
-  if (laserA && side==0){
-    lresult = (laserA->Eval(timeStamp));
-  }
-  if (laserC &&side==1){
-    lresult = (laserC->Eval(timeStamp));
-  }
-  TGraphErrors *cosmic =(TGraphErrors*)array->FindObject("TGRAPHERRORS_MEAN_VDRIFT_COSMICS_ALL");
-  if (cosmic){
-    Double_t cresult =cosmic->Eval(timeStamp);
-    Double_t result  =(cresult-lresult)*fParam->GetZLength();
-    return result;
-  }
-  return 0;
+  Double_t result=0;
+  if (mode==1) result=AliTPCcalibDButil::GetTriggerOffsetTPC(run,timeStamp);    
+  result  *=fParam->GetZLength();
+
+  return result;
 
 }
 
index e85f195d70b9470d2f96dac799f8ed587c3b3512..26fc9be4a0a8c215e6904e4a662ef18e0b955851 100644 (file)
@@ -40,6 +40,7 @@
 #include "AliTPCmapper.h"
 #include "AliTPCParam.h"
 #include "AliTPCCalibRaw.h"
+#include "TGraphErrors.h"
 
 #include "AliTPCcalibDButil.h"
 #include "AliTPCPreprocessorOnline.h"
@@ -275,7 +276,7 @@ void AliTPCcalibDButil::ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMea
       values.ResizeTo(npoints);
       Int_t nused =0;
       for (Int_t ipoint=0; ipoint<npoints; ipoint++){
-        if (gr->GetY()[ipoint]>500 && gr->GetY()[ipoint]<1000 ){
+        if (gr->GetY()[ipoint]>10 && gr->GetY()[ipoint]<500 ){
           values[nused]=gr->GetY()[ipoint];
           nused++;
         }
@@ -1267,3 +1268,142 @@ AliTPCCalPad *AliTPCcalibDButil::CreatePadTime0CE(TVectorD &fitResultsA, TVector
   return padCE;
 }
 
+
+
+
+
+Int_t AliTPCcalibDButil::GetNearest(TGraph *graph, Double_t xref, Double_t &dx, Double_t &y){
+  //
+  // find the closest point to xref  in x  direction
+  // return dx and value 
+  Int_t index=0;
+  index = TMath::BinarySearch(graph->GetN(), graph->GetX(),xref);
+  if (index<0) index=0;
+  if (index>=graph->GetN()-1) index=graph->GetN()-2;
+  if (xref-graph->GetX()[index]>graph->GetX()[index]-xref) index++;
+  dx = xref-graph->GetX()[index];
+  y  = graph->GetY()[index];
+  return index;
+}
+
+
+Double_t  AliTPCcalibDButil::GetTriggerOffsetTPC(Int_t run, Int_t timeStamp, Double_t deltaT, Double_t deltaTLaser, Int_t valType){
+  //
+  // Get the correction of the trigger offset
+  // combining information from the laser track calibration 
+  // and from cosmic calibration
+  //
+  // run       - run number
+  // timeStamp - tim stamp in seconds
+  // deltaT    - integration period to calculate offset 
+  // deltaTLaser -max validity of laser data
+  // valType   - 0 - median, 1- mean
+  // 
+  // Integration vaues are just recomendation - if not possible to get points
+  // automatically increase the validity by factor 2  
+  // (recursive algorithm until one month of data taking)
+  //
+  //
+  const Float_t kLaserCut=0.0005;
+  const Int_t   kMaxPeriod=3600*24*30*3; // 3 month max
+  const Int_t   kMinPoints=20;
+  //
+  TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
+  if (!array) {
+    AliTPCcalibDB::Instance()->UpdateRunInformations(run,kFALSE); 
+  }
+  array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
+  if (!array) return 0;
+  //
+  TGraphErrors *laserA[3]={0,0,0};
+  TGraphErrors *laserC[3]={0,0,0};
+  TGraphErrors *cosmicAll=0;
+  laserA[1]=(TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_A");
+  laserC[1]=(TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_C");
+  cosmicAll =(TGraphErrors*)array->FindObject("TGRAPHERRORS_MEAN_VDRIFT_COSMICS_ALL");
+  //
+  //
+  if (!cosmicAll) return 0;
+  Int_t nmeasC=cosmicAll->GetN();
+  Float_t *tdelta = new Float_t[nmeasC];
+  Int_t nused=0;
+  for (Int_t i=0;i<nmeasC;i++){
+    if (TMath::Abs(cosmicAll->GetX()[i]-timeStamp)>deltaT) continue;
+    Float_t ccosmic=cosmicAll->GetY()[i];
+    Double_t yA=0,yC=0,dA=0,dC=0;
+    if (laserA[1]) GetNearest(laserA[1], cosmicAll->GetX()[i],dA,yA);
+    if (laserC[1]) GetNearest(laserC[1], cosmicAll->GetX()[i],dC,yC);
+    //yA=laserA[1]->Eval(cosmicAll->GetX()[i]);
+    //yC=laserC[1]->Eval(cosmicAll->GetX()[i]);
+    //
+    if (TMath::Sqrt(dA*dA+dC*dC)>deltaTLaser) continue;
+    Float_t claser=0;
+    if (TMath::Abs(yA-yC)<kLaserCut) {
+      claser=(yA-yC)*0.5;
+    }else{
+      if (i%2==0)  claser=yA;
+      if (i%2==1)  claser=yC;
+    }
+    tdelta[nused]=ccosmic-claser;
+    nused++;
+  }
+  if (nused<kMinPoints &&deltaT<kMaxPeriod) return  AliTPCcalibDButil::GetTriggerOffsetTPC(run, timeStamp, deltaT*2,deltaTLaser);
+  Double_t median = TMath::Median(nused,tdelta);
+  Double_t mean  = TMath::Mean(nused,tdelta);
+  delete tdelta;
+  return (valType==0) ? median:mean;
+}
+
+Double_t  AliTPCcalibDButil::GetVDriftTPC(Int_t run, Int_t timeStamp, Double_t deltaT, Double_t deltaTLaser, Int_t valType){
+  //
+  // Get the correction of the drift velocity
+  // combining information from the laser track calibration 
+  // and from cosmic calibration
+  //
+  // run       - run number
+  // timeStamp - tim stamp in seconds
+  // deltaT    - integration period to calculate time0 offset 
+  // deltaTLaser -max validity of laser data
+  // valType   - 0 - median, 1- mean
+  // 
+  // Integration vaues are just recomendation - if not possible to get points
+  // automatically increase the validity by factor 2  
+  // (recursive algorithm until one month of data taking)
+  //
+  //
+  //
+  TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
+  if (!array) {
+    AliTPCcalibDB::Instance()->UpdateRunInformations(run,kFALSE); 
+  }
+  array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
+  if (!array) return 0;
+  TGraphErrors *cosmicAll=0;
+  cosmicAll =(TGraphErrors*)array->FindObject("TGRAPHERRORS_MEAN_VDRIFT_COSMICS_ALL");
+  if (!cosmicAll) return 0;
+  Double_t t0= AliTPCcalibDButil::GetTriggerOffsetTPC(run,timeStamp, deltaT, deltaTLaser,valType);
+  Double_t vcosmic=  cosmicAll->Eval(timeStamp);
+  if (timeStamp>cosmicAll->GetX()[cosmicAll->GetN()-1])  vcosmic=timeStamp>cosmicAll->GetY()[cosmicAll->GetN()-1];
+  if (timeStamp<cosmicAll->GetX()[0])  vcosmic=cosmicAll->GetY()[0];
+  return  vcosmic+t0;
+
+  /*
+    Example usage:
+    
+    Int_t run=89000
+    TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
+    cosmicAll =(TGraphErrors*)array->FindObject("TGRAPHERRORS_MEAN_VDRIFT_COSMICS_ALL"); 
+    laserA=(TGraphErrors*)array->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_A");
+    //
+    Double_t *yvd= new Double_t[cosmicAll->GetN()];
+    Double_t *yt0= new Double_t[cosmicAll->GetN()];
+    for (Int_t i=0; i<cosmicAll->GetN();i++) yvd[i]=AliTPCcalibDButil::GetVDriftTPC(run,cosmicAll->GetX()[i]);
+    for (Int_t i=0; i<cosmicAll->GetN();i++) yt0[i]=AliTPCcalibDButil::GetTriggerOffsetTPC(run,cosmicAll->GetX()[i]);
+
+    TGraph *pcosmicVd=new TGraph(cosmicAll->GetN(), cosmicAll->GetX(), yvd);
+    TGraph *pcosmicT0=new TGraph(cosmicAll->GetN(), cosmicAll->GetX(), yt0);
+
+  */
+  
+}
+
index 3bcfd63aac3419b1be0002c622ce638eb5bc6bbb..315fd42815002b3060b2c3b909b0915d07bce227 100644 (file)
@@ -18,6 +18,7 @@ class AliTPCcalibDB;
 class AliTPCCalPad;
 class AliTPCmapper;
 class AliTPCCalibRaw;
+class TGraph;
 
 class AliTPCcalibDButil : public TObject
 {
@@ -81,6 +82,13 @@ public:
   void UpdatePulserOutlierMap();
   void UpdateRefPulserOutlierMap();
   void PulserOutlierMap(AliTPCCalPad *pulOut, const AliTPCCalPad *pulT, const AliTPCCalPad *pulQ);
+
+  //
+  // graph tools
+  //
+  static Double_t  GetTriggerOffsetTPC(Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0);
+  static Double_t  GetVDriftTPC(Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0);
+  static Int_t     GetNearest(TGraph *graph, Double_t xref, Double_t &dx, Double_t &y);
 private:
   AliTPCcalibDB *fCalibDB;            //pointer to calibDB object
   AliTPCCalPad  *fPadNoise;           //noise information
index d7f06c2863de70ce129417b2e72a4a0aa5146be7..0fc8d1cb3b269384c09be55bf4190715d10e2782 100644 (file)
@@ -1,4 +1,3 @@
-
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -52,9 +51,15 @@ Comments to be written here:
   gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
   gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
   AliXRDPROOFtoolkit tool;
-  TChain * chainTime = tool.MakeChain("time.txt","timeInfo",0,10200);
+  AliXRDPROOFtoolkit::FilterList("timeitstpc.txt","* itstpc",1) 
+  AliXRDPROOFtoolkit::FilterList("time.txt","* trackInfo",1) 
+  AliXRDPROOFtoolkit::FilterList("timelaser.txt","* laserInfo",1) 
+
+  TChain * chainTPCITS = tool.MakeChainRandom("timeitstpc.txt.Good","itstpc",0,10000); 
+  TChain * chainTPCTOF = tool.MakeChainRandom("time.txt","pointMatch",0,10000); 
+  TChain * chainTime = tool.MakeChainRandom("time.txt.Good","trackInfo",0,10000);
+  TChain * chainLaser = tool.MakeChainRandom("timelaser.txt.Good","laserInfo",0,10000);
   chainTime->Lookup();
-  TChain * chainLaser = tool.MakeChain("time.txt.Good","laserInfo",0,10200);
   chainLaser->Lookup();
 */
 
@@ -74,7 +79,6 @@ Comments to be written here:
 #include "TProfile.h"
 #include "TGraphErrors.h"
 #include "TCanvas.h"
-
 #include "AliTPCclusterMI.h"
 #include "AliTPCseed.h"
 #include "AliESDVertex.h"
@@ -90,6 +94,7 @@ Comments to be written here:
 #include "AliLog.h"
 
 #include "AliTPCcalibTime.h"
+#include "AliRelAlignerKalman.h"
 
 #include "TTreeStream.h"
 #include "AliTPCTracklet.h"
@@ -99,6 +104,9 @@ Comments to be written here:
 #include "AliDCSSensorArray.h"
 #include "AliDCSSensor.h"
 
+#include "TDatabasePDG.h"
+#include "AliTrackPointArray.h"
+
 ClassImp(AliTPCcalibTime)
 
 
@@ -112,6 +120,9 @@ AliTPCcalibTime::AliTPCcalibTime()
    fCutMinDir(-0.99),  // direction vector products
    fCutTracks(10),
    fArrayDz(0),          //NEW! Tmap of V drifts for different triggers
+   fAlignITSTPC(0),      //alignemnt array ITS TPC match
+   fAlignTRDTPC(0),      //alignemnt array TRD TPC match 
+   fAlignTOFTPC(0),      //alignemnt array TOF TPC match
    fTimeBins(0),
    fTimeStart(0),
    fTimeEnd(0),
@@ -148,6 +159,9 @@ AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t
    fCutMinDir(-0.99),    // direction vector products
    fCutTracks(10),
    fArrayDz(0),            //Tmap of V drifts for different triggers
+   fAlignITSTPC(0),      //alignemnt array ITS TPC match
+   fAlignTRDTPC(0),      //alignemnt array TRD TPC match 
+   fAlignTOFTPC(0),      //alignemnt array TOF TPC match
    fTimeBins(0),
    fTimeStart(0),
    fTimeEnd(0),
@@ -222,6 +236,10 @@ AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t
   fXmaxVdrift[3] = fRunEnd;
 
   fArrayDz=new TObjArray();
+  fAlignITSTPC = new TObjArray;      //alignemnt array ITS TPC match
+  fAlignTRDTPC = new TObjArray;      //alignemnt array ITS TPC match
+  fAlignTOFTPC = new TObjArray;      //alignemnt array ITS TPC match
+
   // fArrayDz->AddLast(fHistVdriftLaserA[0]);
 //   fArrayDz->AddLast(fHistVdriftLaserA[1]);
 //   fArrayDz->AddLast(fHistVdriftLaserA[2]);
@@ -273,6 +291,9 @@ AliTPCcalibTime::~AliTPCcalibTime(){
       fCosmiMatchingHisto[i]=NULL;
     }
   }
+  fAlignITSTPC->Delete();
+  fAlignTRDTPC->Delete();
+  fAlignTOFTPC->Delete();
 }
 
 Bool_t AliTPCcalibTime::IsLaser(AliESDEvent */*event*/){
@@ -377,7 +398,7 @@ void AliTPCcalibTime::ProcessLaser(AliESDEvent *event){
        "pt1="<<ptrelative1<<
        "temp0="<<temp0<<
        "temp1="<<temp1<<
-       "vecGoofie.=<<"<<&vecGoofie<<
+       "vecGoofie.="<<&vecGoofie<<
        //laser
        "rejectA="<<isReject[0]<<
        "rejectC="<<isReject[1]<<
@@ -497,6 +518,8 @@ void AliTPCcalibTime::ProcessCosmic(AliESDEvent *event){
     if (!trackOut) continue;
     
     AliESDfriendTrack *friendTrack = ESDfriend->GetTrack(i);
+    if (friendTrack) ProcessAlignITS(track,friendTrack);
+    if (friendTrack) ProcessAlignTOF(track,friendTrack);
     TObject *calibObject;
     AliTPCseed *seed = 0;
     for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
@@ -888,3 +911,204 @@ chainDrift->Draw("p1.fP[4]+p0.fP[4]>>his(100,-0.2,0.2)","isPair")
   RMS  ~ 0.036  ~ 0.03773  --> 0.2
 */
 
+
+void  AliTPCcalibTime::ProcessAlignITS(AliESDtrack* track, AliESDfriendTrack *friendTrack){
+  //
+  // Process track
+  // Update TPC-ITS alignment
+  //
+  const Int_t    kMinTPC  = 80;
+  const Int_t    kMinITS  = 3;
+  const Double_t kMinZ    = 10;
+  const Double_t kMaxDy   = 2;
+  const Double_t kMaxAngle= 0.02;
+  //
+  Int_t dummycl[1000];
+  if (track->GetITSclusters(dummycl)<kMinITS) return;  // minimal amount of clusters
+  if (track->GetTPCNcls()<kMinTPC) return;  // minimal amount of clusters cut
+  //
+  if (!friendTrack->GetITSOut()) return;
+  if (!track->GetInnerParam())   return;
+  if (!track->GetOuterParam())   return;
+  // exclude crossing track
+  if (track->GetOuterParam()->GetZ()*track->GetInnerParam()->GetZ()<0)   return;
+  if (TMath::Abs(track->GetInnerParam()->GetZ())<kMinZ)   return;
+  //
+  AliExternalTrackParam &pTPC=(AliExternalTrackParam &)(*(track->GetInnerParam()));
+  AliExternalTrackParam pITS(*(friendTrack->GetITSOut()));
+  //
+  //
+  //
+  Int_t htime = fTime/3600; //time in hours
+  if (fAlignITSTPC->GetEntries()<htime){
+    fAlignITSTPC->Expand(htime*2+20);
+  }
+  AliRelAlignerKalman* align =  (AliRelAlignerKalman*)fAlignITSTPC->At(htime);
+  if (!align){
+    align=new AliRelAlignerKalman(); 
+    align->SetOutRejSigma(2.);
+    //align->SetRejectOutliers(kFALSE);
+    align->SetMagField(fMagF); 
+    fAlignITSTPC->AddAt(align,htime);
+  }
+  pITS.Rotate(pTPC.GetAlpha());
+  pITS.PropagateTo(pTPC.GetX(),fMagF);
+  if (TMath::Abs(pITS.GetY()-pTPC.GetY())>kMaxDy) return;
+  if (TMath::Abs(pITS.GetSnp()-pTPC.GetSnp())>kMaxAngle) return;
+  if (TMath::Abs(pITS.GetTgl()-pTPC.GetTgl())>kMaxAngle) return;
+  align->AddTrackParams(&pITS,&pTPC);
+  align->SetTimeStamp(fTime);
+  Int_t nupdates=align->GetNUpdates();
+  //  align->SetRunNumber(fRun );
+  static Int_t entry=-1;
+  entry++;
+  align->SetOutRejSigma(1.+1./Double_t(nupdates));
+  TTreeSRedirector *cstream = GetDebugStreamer();  
+  if (cstream && align->GetState() && align->GetState()->GetNrows()>2 ){
+    TTimeStamp tstamp(fTime);
+    Float_t valuePressure0 = AliTPCcalibDB::GetPressure(tstamp,fRun,0);
+    Float_t valuePressure1 = AliTPCcalibDB::GetPressure(tstamp,fRun,1);
+    Double_t ptrelative0   = AliTPCcalibDB::GetPTRelative(tstamp,fRun,0);
+    Double_t ptrelative1   = AliTPCcalibDB::GetPTRelative(tstamp,fRun,1);
+    Double_t temp0         = AliTPCcalibDB::GetTemperature(tstamp,fRun,0);
+    Double_t temp1         = AliTPCcalibDB::GetTemperature(tstamp,fRun,1);
+    TVectorD vecGoofie(20);
+    AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(fRun);
+    if (goofieArray){
+      for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
+       AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
+       if (gsensor) vecGoofie[isensor]=gsensor->GetValue(tstamp);
+      }
+    }
+    TVectorD gpTPC(3), gdTPC(3);
+    TVectorD gpITS(3), gdITS(3);
+    pTPC.GetXYZ(gpTPC.GetMatrixArray());
+    pTPC.GetDirection(gdTPC.GetMatrixArray());
+    pITS.GetXYZ(gpITS.GetMatrixArray());
+    pITS.GetDirection(gdITS.GetMatrixArray());
+    (*cstream)<<"itstpc"<<
+      "run="<<fRun<<              //  run number
+      "event="<<fEvent<<          //  event number
+      "time="<<fTime<<            //  time stamp of event
+      "trigger="<<fTrigger<<      //  trigger
+      "mag="<<fMagF<<             //  magnetic field
+      // Environment values
+      "press0="<<valuePressure0<<
+      "press1="<<valuePressure1<<
+      "pt0="<<ptrelative0<<
+      "pt1="<<ptrelative1<<
+      "temp0="<<temp0<<
+      "temp1="<<temp1<<
+      "vecGoofie.="<<&vecGoofie<<
+      "entry="<<entry<<  // current entry
+      //
+      "a.="<<align<<     // current alignment
+      "pITS.="<<&pITS<<  // track param ITS
+      "pTPC.="<<&pTPC<<  // track param TPC
+      "gpTPC.="<<&gpTPC<<
+      "gdTPC.="<<&gdTPC<<
+      "gpITS.="<<&gpITS<<
+      "gdITS.="<<&gdITS<<
+      "\n";
+  }
+  
+}
+
+
+void  AliTPCcalibTime::ProcessAlignTOF(AliESDtrack* track, AliESDfriendTrack *friendTrack){
+  //
+  //process TOF-TPC  alignment
+  //
+  Int_t kminNcl=80;
+  Float_t kMaxDy=6;
+  Float_t kMaxDz=10;
+  if (track->GetTPCNcls()<kminNcl) return;
+  if (track->GetOuterParam()==0) return;
+  if (track->GetInnerParam()==0) return;
+  if (track->GetTOFsignal()<=0)  return;
+  //
+  AliExternalTrackParam *paramOut = new AliExternalTrackParam(*(track->GetOuterParam()));
+  AliExternalTrackParam *param=0;
+  const AliTrackPointArray *points=friendTrack->GetTrackPointArray();
+  if (!points) return;
+  Int_t npoints = points->GetNPoints();
+  AliTrackPoint point;
+  //Double_t alpha=
+  Double_t mass = TDatabasePDG::Instance()->GetParticle("mu+")->Mass();
+  TTreeSRedirector * cstream =  GetDebugStreamer();
+  //
+  //
+  //
+  for (Int_t ipoint=0;ipoint<npoints;ipoint++){
+    //
+    points->GetPoint(point,ipoint);
+    Float_t xyz[3];
+    point.GetXYZ(xyz);
+    Double_t r=TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
+    if (r<300)  continue;
+    if (r>400)  continue;
+    param=paramOut;
+    if (!param) continue;
+    AliTracker::PropagateTrackToBxByBz(param,r,mass,2.,kTRUE);
+    AliTracker::PropagateTrackToBxByBz(param,r,mass,0.1,kTRUE);    
+    AliTrackPoint lpoint = point.Rotate(param->GetAlpha());
+    param->PropagateTo(lpoint.GetX(),fMagF);
+    //
+    //
+    // this is ugly - we need AliCluster constructor
+    //
+    AliExternalTrackParam &pTPC=*param;
+    AliExternalTrackParam pTOF(*param);
+    ((Double_t*)pTOF.GetParameter())[0] =lpoint.GetY();
+    ((Double_t*)pTOF.GetParameter())[1] =lpoint.GetZ();
+    pTOF.ResetCovariance(20);
+    ((Double_t*)pTOF.GetCovariance())[0]+=3.*3.;
+    ((Double_t*)pTOF.GetCovariance())[2]+=3.*3.;
+    if (TMath::Abs(pTOF.GetY()-pTPC.GetY())>kMaxDy) continue;
+    if (TMath::Abs(pTOF.GetZ()-pTPC.GetZ())>kMaxDz) continue;
+    //
+    Int_t htime = fTime/3600; //time in hours
+      
+    if (fAlignTOFTPC->GetEntries()<htime){
+      fAlignTOFTPC->Expand(htime*2+20);
+    }
+    AliRelAlignerKalman* align =  (AliRelAlignerKalman*)fAlignTOFTPC->At(htime);
+    if (!align){
+      align=new AliRelAlignerKalman(); 
+      align->SetOutRejSigma(2.);
+      //align->SetRejectOutliers(kFALSE);
+      align->SetMagField(fMagF); 
+      fAlignTOFTPC->AddAt(align,htime);
+    }
+    pTOF.Rotate(pTPC.GetAlpha());
+    pTOF.PropagateTo(pTPC.GetX(),fMagF);
+    align->AddTrackParams(&pTOF,&pTPC);
+    align->SetTimeStamp(fTime);
+    Int_t nupdates=align->GetNUpdates();
+    static Int_t entry=-1;
+    entry++;
+    align->SetOutRejSigma(1.+1./Double_t(nupdates));
+    
+    //
+    //
+    if (cstream) {
+      (*cstream) << "pointMatch" <<
+       "run="<<fRun<<              //  run number
+       "event="<<fEvent<<          //  event number
+       "time="<<fTime<<            //  time stamp of event
+       "trigger="<<fTrigger<<      //  trigger
+       "mag="<<fMagF<<             //  magnetic field
+       //
+       "a.="<<align<<     // current alignment 
+       "p.="<<&point<<
+       "lp.="<<&lpoint<<
+       "pTPC.="<<&pTPC<<
+       "pTOF.="<<&pTOF<<
+       "\n";
+    }
+
+
+
+  }
+  delete paramOut;
+}
index c9387f7f8b64cd58d2a8cbba39e25b0e84ef3a64..5ef6257ba9adf2150dc7dc1c5e47fb0c0df69ea1 100644 (file)
@@ -42,6 +42,8 @@ public:
   Bool_t                 IsPair(AliExternalTrackParam *tr0, AliExternalTrackParam *tr1);
   Bool_t                 IsCross(AliESDtrack *tr0, AliESDtrack *tr1);
   Bool_t                 IsSame (AliESDtrack *tr0, AliESDtrack *tr1);
+  void                   ProcessAlignITS(AliESDtrack* track, AliESDfriendTrack *friendTrack);
+  void                   ProcessAlignTOF(AliESDtrack* track, AliESDfriendTrack *friendTrack);
 
   THnSparse*    GetHistVdriftLaserA(Int_t index=1){return fHistVdriftLaserA[index];};
   THnSparse*    GetHistVdriftLaserC(Int_t index=1){return fHistVdriftLaserC[index];};
@@ -83,7 +85,9 @@ private:
   // DELTA Z histo
 //  TMap*      fMapDz;                 //Tmap of V drifts for different triggers
   TObjArray* fArrayDz;                  // array of DZ histograms for different triggers
-
+  TObjArray* fAlignITSTPC;              // alignemnt array ITS TPC match
+  TObjArray* fAlignTRDTPC;              // alignemnt array TRD TPC match
+  TObjArray* fAlignTOFTPC;              // alignemnt array TOF TPC match
   Int_t    fTimeBins;                  //Bins time
   Double_t fTimeStart;                 //Start time
   Double_t fTimeEnd;                   //End time