]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding a task for the relative TPC-ITS alignment (M. Krzewicki)
authorbelikov <belikov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Oct 2009 16:43:00 +0000 (16:43 +0000)
committerbelikov <belikov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Oct 2009 16:43:00 +0000 (16:43 +0000)
PWG1/AliAnalysisTaskITSTPCalignment.cxx [new file with mode: 0644]
PWG1/AliAnalysisTaskITSTPCalignment.h [new file with mode: 0644]
PWG1/AliRelAlignerKalmanArray.cxx [new file with mode: 0644]
PWG1/AliRelAlignerKalmanArray.h [new file with mode: 0644]
PWG1/CMake_libPWG1.txt
PWG1/PWG1LinkDef.h
PWG1/libPWG1.pkg
PWG1/runITSTPCalignment.C [new file with mode: 0644]

diff --git a/PWG1/AliAnalysisTaskITSTPCalignment.cxx b/PWG1/AliAnalysisTaskITSTPCalignment.cxx
new file mode 100644 (file)
index 0000000..7119a06
--- /dev/null
@@ -0,0 +1,180 @@
+////////////////////////////////////////////////////////////////////////////////
+//  AliAnalysisTaskITSTPCalignment
+//  Runs the relative ITS TPC alignment procedure and TPC vdrift calib
+//  Origin: Mikolaj Krzewicki, mikolaj.krzewicki@cern.ch
+////////////////////////////////////////////////////////////////////////////////
+
+#include "TChain.h"
+#include "TTree.h"
+#include "TH2.h"
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliRelAlignerKalman.h"
+#include "AliRelAlignerKalmanArray.h"
+#include "AliAnalysisTaskITSTPCalignment.h"
+
+ClassImp(AliAnalysisTaskITSTPCalignment)
+
+//________________________________________________________________________
+AliAnalysisTaskITSTPCalignment::AliAnalysisTaskITSTPCalignment():
+    AliAnalysisTask(),
+    fESD(0),
+    fArray(0),
+    fYZResidualsHist(0),
+    fPLResidualsHist(0),
+    fListOfHistos(0),
+    fSaveInterval(600),
+    fTimeMatchingTolerance(20),
+    fDoQA(kFALSE)
+{
+  //dummy ctor
+}
+
+//________________________________________________________________________
+AliAnalysisTaskITSTPCalignment::AliAnalysisTaskITSTPCalignment(const char *name):
+    AliAnalysisTask(name,name),
+    fESD(0),
+    fArray(0),
+    fYZResidualsHist(0),
+    fPLResidualsHist(0),
+    fListOfHistos(0),
+    fSaveInterval(600),
+    fTimeMatchingTolerance(20),
+    fDoQA(kFALSE)
+{
+  // Constructor
+
+  // Define input and output slots here
+  // Input slot #0 works with a TChain
+  DefineInput(0, TChain::Class());
+  DefineOutput(0, AliRelAlignerKalmanArray::Class());
+  DefineOutput(1, TList::Class());
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskITSTPCalignment::ConnectInputData(Option_t *)
+{
+  // Called once
+  TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
+  if (!tree)
+  {
+    Printf("ERROR: Could not read chain from input slot 0");
+  }
+  else
+  {
+    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+    if (!esdH)
+    {
+      Printf("ERROR: Could not get ESDInputHandler");
+    }
+    else
+      fESD = esdH->GetEvent();
+  }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskITSTPCalignment::CreateOutputObjects()
+{
+  // Create output objects
+  // Called once
+
+  fArray = new AliRelAlignerKalmanArray("ITSTPCalignmentArray");
+  fArray->SetSaveInterval(fSaveInterval);
+  fArray->SetTimeMatchingTolerance(fTimeMatchingTolerance);
+
+  fYZResidualsHist = new TH2F("fYZResidualsHist", "YZ residuals", 50, -0.5, 0.5, 50, -2., 2. );
+  fPLResidualsHist = new TH2F("fPLResidualsHist", "sin(phi) tan(lambda) residuals", 50, -.05, 0.05, 50, -0.05, 0.05 );
+
+  fListOfHistos = new TList();
+  fListOfHistos->Add(fYZResidualsHist);
+  fListOfHistos->Add(fPLResidualsHist);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskITSTPCalignment::Exec(Option_t *)
+{
+  // Main loop
+  // Called for each event
+  if (!fESD)
+  {
+    Printf("ERROR: fESD not available");
+    return;
+  }
+
+  AliRelAlignerKalman* aligner = fArray->GetAligner();
+
+  Int_t lastrunnumber = aligner->GetRunNumber();
+  UInt_t currentTimeStamp = fESD->GetTimeStamp();
+
+  //for a new run reset TPC errors
+  if (lastrunnumber != fESD->GetRunNumber())
+  {
+    aligner->ResetTPCparamsCovariance();
+    fArray->SetCurrentTimeBin(currentTimeStamp);
+  }
+
+  //if time jumps back reset all
+  if (currentTimeStamp < aligner->GetTimeStamp())
+  {
+    aligner->Reset();
+    fArray->SetCurrentTimeBin(currentTimeStamp);
+  }
+
+  //Update the parmeters
+  if (fArray->AddCosmicEvent(fESD))
+    if (fDoQA)
+    {
+      //fill the QA histograms
+      TArrayI trackTArrITS(1);
+      TArrayI trackTArrTPC(1);
+      if (aligner->FindCosmicTrackletNumbersInEvent(
+            trackTArrITS, trackTArrTPC, fESD ))
+      {
+        AliESDtrack* ptrack;
+        const AliExternalTrackParam* pconstparams1;
+        const AliExternalTrackParam* pconstparams2;
+        AliExternalTrackParam params1;
+        AliExternalTrackParam params2;
+
+        ////////////////////////////////
+        for (Int_t i=0;i<trackTArrITS.GetSize();i++)
+        {
+          //ITS track
+          ptrack = fESD->GetTrack(trackTArrITS[i]);
+          pconstparams1 = ptrack->GetOuterParam();
+          if (!pconstparams1) continue;
+          params1 = *pconstparams1; //make copy to be safe
+
+          //TPC track
+          ptrack = fESD->GetTrack(trackTArrTPC[i]);
+          pconstparams2 = ptrack->GetInnerParam();
+          if (!pconstparams2) continue;
+          params2 = *pconstparams2; //make copy
+          params2.Rotate(params1.GetAlpha());
+          params2.PropagateTo( params1.GetX(), aligner->GetMagField() );
+
+          Float_t resy = params2.GetY() - params1.GetY();
+          Float_t resz = params2.GetZ() - params1.GetZ();
+          Float_t ressnp = params2.GetSnp() - params1.GetSnp();
+          Float_t restgl = params2.GetTgl() - params1.GetTgl();
+          fYZResidualsHist->Fill(resy,resz);
+          fPLResidualsHist->Fill(ressnp,restgl);
+        }
+      }//if DoQA
+
+    }//if AddEvent
+
+  // Post output data.
+  PostData(0, fArray);
+  PostData(1, fListOfHistos);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskITSTPCalignment::Terminate(Option_t *)
+{
+  // Called once at the end of the query
+  fArray->Merge(new TList()); //final cleanup
+}
+
diff --git a/PWG1/AliAnalysisTaskITSTPCalignment.h b/PWG1/AliAnalysisTaskITSTPCalignment.h
new file mode 100644 (file)
index 0000000..122447f
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALIANALYSISTASKITSTPCALIGNMENT_H
+#define ALIANALYSISTASKITSTPCALIGNMENT_H
+
+///////////////////////////////////////////////////////////////////////////
+//  Class AliAnalysisTaskITSTPCalignment
+//  runs ITS-TPC alignment with TPC vdrift calibration
+//
+//    Origin: Mikolaj Krzewicki, mikolaj.krzewicki@cern.ch
+///////////////////////////////////////////////////////////////////////////
+
+class AliAnalysisTask;
+class TTree;
+class AliESDEvent;
+class AliRelAlignerKalman;
+class TH2F;
+
+class AliAnalysisTaskITSTPCalignment : public AliAnalysisTask
+{
+public:
+  AliAnalysisTaskITSTPCalignment();
+  AliAnalysisTaskITSTPCalignment(const char *name);
+  virtual ~AliAnalysisTaskITSTPCalignment() {}
+
+  void SetSaveInterval( const UInt_t si ) {fSaveInterval = si;}
+  void SetTimeMatchingTolerance( const UInt_t tol ) {fTimeMatchingTolerance = tol; }
+  void SetDoQA( const Bool_t qa ) {fDoQA=qa;}
+  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+
+private:
+  AliESDEvent* fESD;    //ESD object
+  AliRelAlignerKalmanArray* fArray; //array of aligners
+  TH2F* fYZResidualsHist; //2D histogram with the yz residuals
+  TH2F* fPLResidualsHist; //2D histogram with the phi lambda residuals
+  TList* fListOfHistos;   //list with QA histograms
+  UInt_t fSaveInterval;   //save interveal
+  UInt_t fTimeMatchingTolerance; //time matching tolerance
+
+  Bool_t fDoQA; //whether to fill QA histograms
+
+  AliAnalysisTaskITSTPCalignment(const AliAnalysisTaskITSTPCalignment&); // not implemented
+  AliAnalysisTaskITSTPCalignment& operator=(const AliAnalysisTaskITSTPCalignment&); // not implemented
+
+  ClassDef(AliAnalysisTaskITSTPCalignment, 1);
+};
+
+#endif
diff --git a/PWG1/AliRelAlignerKalmanArray.cxx b/PWG1/AliRelAlignerKalmanArray.cxx
new file mode 100644 (file)
index 0000000..fc563d6
--- /dev/null
@@ -0,0 +1,274 @@
+/**************************************************************************
+  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+  *                                                                        *
+  * Author: The ALICE Off-line Project.                                    *
+  * Contributors are mentioned in the code where appropriate.              *
+  *                                                                        *
+  * Permission to use, copy, modify and distribute this software and its   *
+  * documentation strictly for non-commercial purposes is hereby granted   *
+  * without fee, provided that the above copyright notice appears in all   *
+  * copies and that both the copyright notice and this permission notice   *
+  * appear in the supporting documentation. The authors make no claims     *
+  * about the suitability of this software for any purpose. It is          *
+  * provided "as is" without express or implied warranty.                  *
+  **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//     Data container for relative ITS-TPC alignment analysis
+//     Holds an array of AliRelAlignerKalman objects
+//     and takes care of merging when processing data in parallel
+//
+//     Origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <TNamed.h>
+#include <TMath.h>
+#include <TObjArray.h>
+#include <TCollection.h>
+#include "AliESDEvent.h"
+#include "AliRelAlignerKalman.h"
+#include "AliRelAlignerKalmanArray.h"
+
+ClassImp(AliRelAlignerKalmanArray)
+
+//______________________________________________________________________________
+AliRelAlignerKalmanArray::AliRelAlignerKalmanArray():
+    TNamed(),
+    fArray(new TObjArray()),
+    fSaveInterval(600), //default every 10minutes
+    fTimeMatchingTolerance(20),
+    fCurrentTimeBin(0),
+    fAligner(new AliRelAlignerKalman())
+{
+  //ctor
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalmanArray::AliRelAlignerKalmanArray(const char* name):
+    TNamed(name, name),
+    fArray(new TObjArray()),
+    fSaveInterval(600), //default every 10 minutes
+    fTimeMatchingTolerance(60),
+    fCurrentTimeBin(0),
+    fAligner(new AliRelAlignerKalman())
+{
+  //ctor
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalmanArray::~AliRelAlignerKalmanArray()
+{
+  //dtor
+  fArray->SetOwner();
+  delete fArray;
+  delete fAligner;
+}
+
+//______________________________________________________________________________
+Long64_t AliRelAlignerKalmanArray::Merge( TCollection* list )
+{
+  //Merge all the arrays
+  //the merge is vertical, meaning matching entries in tree are merged
+
+  AliRelAlignerKalmanArray *arrayFromList;
+  if (!list) return 0;
+  TIter next(list);
+  while ( arrayFromList = dynamic_cast<AliRelAlignerKalmanArray*>(next()) )
+  {
+    if (arrayFromList==this) continue;
+
+    fArray->AddAll(arrayFromList->fArray); //put all objects in one array
+
+    //do the merge
+    fArray->Sort();
+    TObjArray* tmpArray = SortedMerge(fArray);
+    tmpArray->SetOwner(kTRUE);
+
+    TObjArray* newArray = dynamic_cast<TObjArray*>(tmpArray->Clone());
+    delete fArray; //takes care of all loaded objects
+    fArray = newArray;
+
+    fArray->AddLast(arrayFromList->fAligner); //add the endofrun aligner
+  }
+
+  //TODO: this can be done better!
+  //Add own endofrun aligner and clean up
+  fArray->AddLast(fAligner);
+  fArray->Sort();
+  //TObjArray* tmpArray = SortedMerge(fArray);
+  //tmpArray->SetOwner(kTRUE);
+  //TObjArray* newArray = dynamic_cast<TObjArray*>(tmpArray->Clone());
+  //delete fArray; //takes care of all loaded objects
+  //fArray = newArray;
+
+  return fArray->GetEntriesFast();
+}
+
+//______________________________________________________________________________
+TObjArray* AliRelAlignerKalmanArray::SortedMerge( TObjArray* input )
+{
+  //Merges the adjacent aligners if close enough
+  //input needs to be already sorted
+
+  UInt_t timeStampIn;
+  AliRelAlignerKalman* alignerIn;
+  AliRelAlignerKalman* alignerOut = dynamic_cast<AliRelAlignerKalman*>(input->At(0));
+  TObjArray* output = new TObjArray();  //empty array
+  output->AddLast(alignerOut);        //first object in: copy of first input element
+
+  timeStampIn = alignerOut->GetTimeStamp();
+  SetCurrentTimeBin( timeStampIn );
+  TIter next(input);
+  while ( alignerIn = dynamic_cast<AliRelAlignerKalman*>(next()) )
+  {
+    timeStampIn = alignerIn->GetTimeStamp();
+    if ( IsInCurrentTimeBin(timeStampIn) )
+    {
+      alignerOut->Merge(alignerIn);
+    }
+    else
+    {
+      alignerOut = alignerIn;
+      output->AddLast(alignerOut);
+    }//if
+    SetCurrentTimeBin( timeStampIn );
+  }
+  return output;
+}
+
+//______________________________________________________________________________
+void AliRelAlignerKalmanArray::SetCurrentTimeBin( UInt_t timestamp )
+{
+  //set the current timebin
+  fCurrentTimeBin = TimeBin(timestamp);
+}
+
+//______________________________________________________________________________
+UInt_t AliRelAlignerKalmanArray::TimeBin( UInt_t timestamp ) const
+{
+  return (timestamp+(fSaveInterval/2))/fSaveInterval*fSaveInterval; //it's all integers!
+}
+
+//______________________________________________________________________________
+Bool_t AliRelAlignerKalmanArray::IsInCurrentTimeBin( UInt_t timestamp ) const
+{
+  //check if timestamp is within the current timebin
+  UInt_t timeDiff = (timestamp>=fCurrentTimeBin)?timestamp-fCurrentTimeBin:
+                    fCurrentTimeBin-timestamp;
+  return (timeDiff < fTimeMatchingTolerance);
+}
+
+////______________________________________________________________________________
+//void AliRelAlignerKalmanArray::AddESDEvent( AliESDEvent* event )
+//{
+//  //add an AliESDEvent, take care of bookkeeping
+//  if (!fAligner) return;
+//  if (event->GetRunNumber() != fAligner->GetRunNumber())
+//  {
+//    //what to do when a new run starts
+//  }
+//
+//}
+//
+////______________________________________________________________________________
+Bool_t AliRelAlignerKalmanArray::AddCosmicEvent( AliESDEvent* event )
+{
+  if (!fAligner->AddCosmicEvent(event)) return kFALSE;
+
+  UInt_t currentTimeStamp = event->GetTimeStamp();
+  UInt_t timeFromLastBinCentre = currentTimeStamp - fCurrentTimeBin;
+  UInt_t binCentre = TimeBin(currentTimeStamp);
+  UInt_t timeFromBinCentre = currentTimeStamp-binCentre;
+  UInt_t nIntervals = timeFromLastBinCentre/fSaveInterval;
+
+  //////////////////////////////////////////////////////////////////////////////
+  //only ONE SAVE PER TIMEBIN!!!!, as close as possible to the bin center
+  //////////////////////////////////////////////////////////////////////////////
+  if ( (nIntervals == 1) &&                      //is in next time bin passed centre
+       (timeFromBinCentre < fTimeMatchingTolerance) )     //and close to it
+  {
+    AddLast(new AliRelAlignerKalman(*fAligner));
+  }
+  else if ( (nIntervals > 2) ) //TODO: don't hardwire stuff!
+  {
+    //if missed a few windows save anyway at current bin centre
+    fAligner->SetTimeStamp(binCentre);
+    AddLast(new AliRelAlignerKalman(*fAligner));
+  }
+  //////////////////////////////////////////////////////////////////////////////
+
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalmanArray::AliRelAlignerKalmanArray( const AliRelAlignerKalmanArray& in):
+    TNamed(in.GetName(), in.GetTitle()),
+    fArray(NULL),
+    fSaveInterval(in.fSaveInterval),
+    fTimeMatchingTolerance(in.fTimeMatchingTolerance),
+    fCurrentTimeBin(in.fCurrentTimeBin),
+    fAligner(new AliRelAlignerKalman(*in.fAligner))
+{
+  //copy ctor
+  fArray = static_cast<TObjArray*>(in.Clone());
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalmanArray& AliRelAlignerKalmanArray::operator=(const AliRelAlignerKalmanArray& in)
+{
+  //assignment operator
+  fArray = static_cast<TObjArray*>(in.Clone());
+  fSaveInterval = in.fSaveInterval;
+  fTimeMatchingTolerance = in.fTimeMatchingTolerance;
+  return *this;
+}
+
+//______________________________________________________________________________
+Bool_t AliRelAlignerKalmanArray::SetSaveInterval( const UInt_t s )
+{
+  //only set if array empty
+  if (fArray->GetEntriesFast()) return kFALSE;
+  fSaveInterval = s;
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+Bool_t AliRelAlignerKalmanArray::SetTimeMatchingTolerance( const UInt_t m )
+{
+  //only set if array empty
+  if (fArray->GetEntriesFast()) return kFALSE;
+  fTimeMatchingTolerance = m;
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalman* AliRelAlignerKalmanArray::At( Int_t i ) const
+{
+  //mimic TObjArray::At( Int_t i )
+  return dynamic_cast<AliRelAlignerKalman*>(fArray->At(i));
+}
+
+//______________________________________________________________________________
+void AliRelAlignerKalmanArray::AddLast( AliRelAlignerKalman* al )
+{
+  //mimic TObjArray::AddLast( TObject* obj )
+  fArray->AddLast( al );
+  SetCurrentTimeBin(al->GetTimeStamp());
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalman* AliRelAlignerKalmanArray::Last() const
+{
+  //mimic TObjArray::Last()
+  return dynamic_cast<AliRelAlignerKalman*>(fArray->Last());
+}
+
+//______________________________________________________________________________
+AliRelAlignerKalman* AliRelAlignerKalmanArray::operator[](Int_t i) const
+{
+  //mimic TObjArray::operator[](Int_t)
+  return dynamic_cast<AliRelAlignerKalman*>(fArray->At(i));
+}
+
diff --git a/PWG1/AliRelAlignerKalmanArray.h b/PWG1/AliRelAlignerKalmanArray.h
new file mode 100644 (file)
index 0000000..e3e19ab
--- /dev/null
@@ -0,0 +1,67 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//     Data container for relative ITS-TPC alignment analysis
+//     see info in the implementation file
+//
+//     Origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef AliRelAlignerKalmanArray_h
+#define AliRelAlignerKalmanArray_h
+
+
+class TString;
+class TCollection;
+class AliESDEvent;
+class TObjArray;
+class AliRelAlignerKalman;
+class TNamed;
+
+class AliRelAlignerKalmanArray:public TNamed
+{
+public:
+  AliRelAlignerKalmanArray();
+  AliRelAlignerKalmanArray(const char* name);
+  virtual ~AliRelAlignerKalmanArray();
+  AliRelAlignerKalmanArray& operator=(const AliRelAlignerKalmanArray& a );
+  AliRelAlignerKalmanArray(const AliRelAlignerKalmanArray& a);
+  
+  Long64_t Merge( TCollection* list );
+  //Bool_t AddESDEvent( AliESDEvent* event );
+  Bool_t AddCosmicEvent( AliESDEvent* event );
+  void AddLast( AliRelAlignerKalman* al );
+  AliRelAlignerKalman* At( Int_t i ) const;
+  AliRelAlignerKalman* Last() const;
+  Int_t GetEntries() const {return fArray->GetEntriesFast();}
+  AliRelAlignerKalman* operator[](Int_t i) const;
+  Bool_t SetTimeMatchingTolerance( const UInt_t m );
+  Bool_t SetSaveInterval( const UInt_t s );
+  UInt_t GetTimeMatchingTolerance() const {return fTimeMatchingTolerance;}
+  UInt_t GetSaveInterval() const {return fSaveInterval;}
+  UInt_t TimeBin( UInt_t timebin ) const;
+  void SetCurrentTimeBin( UInt_t timestamp );
+  UInt_t GetCurrentTimeBin() const {return fCurrentTimeBin;}
+  Bool_t IsInCurrentTimeBin( UInt_t timestamp ) const;
+  AliRelAlignerKalman* GetAligner() const {return fAligner;}
+  TObjArray* SortedMerge ( TObjArray* input ); 
+  //void SetResetAllAtNewRun( Bool_t s ) {fResetAllAtNewRun = s;}
+  //void SetResetTPCAtNewRun( Bool_t s ) {fResetTPCAtNewRun = s;}
+
+private:
+  TObjArray* fArray; //an array of aligners
+  UInt_t fSaveInterval; //how often to save (in seconds)
+  UInt_t fTimeMatchingTolerance; //tolerance for matching timestamps
+  UInt_t fCurrentTimeBin; //current timebin
+  AliRelAlignerKalman* fAligner;  //aligner object
+  //Bool_t fResetAllAtNewRun;
+  //Bool_t fResetTPCAtNewRun;
+  
+  ClassDef(AliRelAlignerKalmanArray,1)     //AliRelAlignerKalman class
+};
+
+#endif
+
index a9575bf8730c672cf93b392c3044ca8dfdd31487..72ee7eb43cecbb2f9a7bef76266c3deddbbe922f 100644 (file)
@@ -32,6 +32,8 @@ set(SRCS
        AliPerformanceTPC.cxx
        AliAlignmentDataFilterITS.cxx
        AliTrackMatchingTPCITSCosmics.cxx
+        AliRelAlignerKalmanArray.cxx
+        AliAnalysisTaskITSTPCalignment.cxx
 )
 
 # fill list of header files from list of source files
index cd1e1cf4171c8e27f2f43c123a6f15be6c2c7ea2..ea752fa9db00783155dada822f82e75578884be2 100644 (file)
@@ -48,6 +48,7 @@
 #pragma link C++ class AliAnalysisTaskV0QA+;
 #pragma link C++ class AliMaterialBudget+;
 
-
+#pragma link C++ class AliRelAlignerKalmanArray+;
+#pragma link C++ class AliAnalysisTaskITSTPCalignment+;
 
 #endif
index c0e8d977a6dfda6599959d724cf09e7419d1088d..8960ee38236e320d05e34c9c49ccade82b51f825 100644 (file)
@@ -34,7 +34,9 @@ SRCS:=        AliTreeDraw.cxx \
         AliTrackMatchingTPCITSCosmics.cxx \
        AliAnalysisTaskV0QA.cxx \
        AliMaterialBudget.cxx \
-       AliPerformanceMatch.cxx
+       AliPerformanceMatch.cxx \
+        AliRelAlignerKalmanArray.cxx\
+        AliAnalysisTaskITSTPCalignment.cxx
 
 HDRS:= $(SRCS:.cxx=.h)
 
diff --git a/PWG1/runITSTPCalignment.C b/PWG1/runITSTPCalignment.C
new file mode 100644 (file)
index 0000000..929b4b8
--- /dev/null
@@ -0,0 +1,211 @@
+void runITSTPCalignment( UInt_t saveinterval = 1000000 )
+{
+  TStopwatch timer;
+  timer.Start();
+
+  //runProof("/COMMON/COMMON/LHC09a4_run8100X#esdTree");
+  runLocal("AliESDs.root");
+
+  timer.Stop();
+  timer.Print();
+}
+
+//_________________________________________________//
+void runLocal(const char* filenamestr = "AliESDs.root" ) {
+
+  TString inputFilename(filenamestr);
+  TString outputArrayFilename = "ITSTPCalignmentArray.root";
+  TString outputHistFilename = "ITSTPCalignmentHist.root";
+
+  //____________________________________________________//
+  //_____________Setting up the par files_______________//
+  //____________________________________________________//
+  setupPar("STEERBase");
+  gSystem->Load("libSTEERBase.so");
+  setupPar("ESD");
+  gSystem->Load("libVMC.so");
+  gSystem->Load("libESD.so");
+  setupPar("AOD");
+  gSystem->Load("libAOD.so");
+  setupPar("ANALYSIS");
+  gSystem->Load("libANALYSIS.so");
+  setupPar("ANALYSISalice");
+  gSystem->Load("libANALYSISalice.so");
+  //____________________________________________________//  
+
+  //add input files from dirs
+  TChain* chain = new TChain("esdTree");
+  chain->SetBranchStatus("*ESDfriend*",0);
+  TString workingDir = gSystem->pwd();
+  void* dirhandle = gSystem->OpenDirectory(workingDir.Data());
+  if (!dirhandle) return;
+  const char* filenamestr;
+  while ((filenamestr = gSystem->GetDirEntry(dirhandle)))
+  {
+    TString filename(filenamestr);
+    if (filename=="." || filename=="..") continue;
+    if (gSystem->cd(filename.Data()))
+    {
+      if (!gSystem->AccessPathName(inputFilename.Data()))//return value is here inverted!
+      {
+        TString inputESDfile(workingDir);
+        inputESDfile += "/";
+        inputESDfile += filename;
+        inputESDfile += "/";
+        inputESDfile += inputFilename;
+        chain->Add(inputESDfile.Data());
+        printf("found file: %s\n", inputESDfile.Data());
+      }
+      gSystem->cd(workingDir.Data());
+    }
+  }
+
+  //____________________________________________//
+  gROOT->LoadMacro("AliRelAlignerKalman.cxx++");
+  gROOT->LoadMacro("AliRelAlignerKalmanArray.cxx++");
+  gROOT->LoadMacro("AliAnalysisTaskITSTPCalignment.cxx++");
+
+  // analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
+  AliVEventHandler* esdH = new AliESDInputHandler;
+  mgr->SetInputEventHandler(esdH);
+
+  //create the task
+  AliAnalysisTaskITSTPCalignment *taskITSTPCalignment = 
+                        new AliAnalysisTaskITSTPCalignment("TaskITSTPCalignment");
+  taskITSTPCalignment->SetDoQA(kTRUE);
+
+  mgr->AddTask(taskITSTPCalignment);
+
+  AliAnalysisDataContainer* cinput0 = mgr->GetCommonInputContainer();
+  AliAnalysisDataContainer* coutput0 = mgr->CreateContainer("outputArray",
+                                       AliRelAlignerKalmanArray::Class(),
+                                       AliAnalysisManager::kOutputContainer,
+                                       outputArrayFilename.Data());
+  AliAnalysisDataContainer* coutput1 = mgr->CreateContainer("outputList",
+                                       TList::Class(),
+                                       AliAnalysisManager::kOutputContainer,
+                                       outputHistFilename.Data());
+
+  mgr->ConnectInput(taskITSTPCalignment,0,cinput0);
+  mgr->ConnectOutput(taskITSTPCalignment,0,coutput0);
+  mgr->ConnectOutput(taskITSTPCalignment,1,coutput1);
+  if (!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+
+  mgr->StartAnalysis("local",chain);
+}
+
+//_________________________________________________//
+void runInteractive(const char* collectionName = "tag.xml") {
+  gSystem->Load("libProofPlayer.so");
+
+  TString outputArrayFilename = "ITSTPCalignmentArray.root";
+  TString outputHistFilename = "ITSTPCalignmentHist.root";
+
+  printf("*** Connect to AliEn ***\n");
+  TGrid::Connect("alien://");
+  //____________________________________________________//
+  //_____________Setting up the par files_______________//
+  //____________________________________________________//
+  setupPar("STEERBase");
+  gSystem->Load("libSTEERBase.so");
+  setupPar("ESD");
+  gSystem->Load("libVMC.so");
+  gSystem->Load("libESD.so");
+  setupPar("AOD");
+  gSystem->Load("libAOD.so");
+  setupPar("ANALYSIS");
+  gSystem->Load("libANALYSIS.so");
+  setupPar("ANALYSISalice");
+  gSystem->Load("libANALYSISalice.so");
+  //____________________________________________________//  
+  
+  //____________________________________________//
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
+  AliRunTagCuts *runCuts = new AliRunTagCuts();
+  AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
+  AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
+  AliEventTagCuts *evCuts = new AliEventTagCuts();
+  //grid tags
+  TAlienCollection* coll = TAlienCollection::Open(collectionName);
+  TGridResult* TagResult = coll->GetGridResult("",0,0);
+  tagAnalysis->ChainGridTags(TagResult);
+  TChain* chain = 0x0;
+  chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
+  chain->SetBranchStatus("*Calo*",0);
+  
+  //____________________________________________//
+  gROOT->LoadMacro("AliRelAlignerKalman.cxx++");
+  gROOT->LoadMacro("AliRelAlignerKalmanArray.cxx++");
+  gROOT->LoadMacro("AliAnalysisTaskITSTPCalignment.cxx++");
+
+  // analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("ITSTPCalignmentAnalysisManager");
+  AliVEventHandler* esdH = new AliESDInputHandler;
+  mgr->SetInputEventHandler(esdH);
+
+  //create the task
+  AliAnalysisTaskITSTPCalignment *taskITSTPCalignment = 
+                        new AliAnalysisTaskITSTPCalignment("TaskITSTPCalignment");
+  taskITSTPCalignment->SetDoQA(kTRUE);
+
+  mgr->AddTask(taskITSTPCalignment);
+
+  AliAnalysisDataContainer* cinput0 = mgr->GetCommonInputContainer();
+  AliAnalysisDataContainer* coutput0 = mgr->CreateContainer("outputArray",
+                                       AliRelAlignerKalmanArray::Class(),
+                                       AliAnalysisManager::kOutputContainer,
+                                       outputArrayFilename.Data());
+  AliAnalysisDataContainer* coutput1 = mgr->CreateContainer("outputList",
+                                       TList::Class(),
+                                       AliAnalysisManager::kOutputContainer,
+                                       outputHistFilename.Data());
+
+  mgr->ConnectInput(taskITSTPCalignment,0,cinput0);
+  mgr->ConnectOutput(taskITSTPCalignment,0,coutput0);
+  mgr->ConnectOutput(taskITSTPCalignment,1,coutput1);
+  if (!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+
+  mgr->StartAnalysis("local",chain);
+}
+
+//______________________________________________________________________________
+Int_t setupPar(const char* pararchivename) {
+  ///////////////////
+  // Setup PAR File//
+  ///////////////////
+  if (pararchivename) {
+    char processline[1024];
+    sprintf(processline,".! tar xvzf %s.par",pararchivename);
+    gROOT->ProcessLine(processline);
+    const char* ocwd = gSystem->WorkingDirectory();
+    gSystem->ChangeDirectory(pararchivename);
+    
+    // check for BUILD.sh and execute
+    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
+      printf("*******************************\n");
+      printf("*** Building PAR archive    ***\n");
+      printf("*******************************\n");
+      
+      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
+        Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
+        return -1;
+      }
+    }
+    // check for SETUP.C and execute
+    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
+      printf("*******************************\n");
+      printf("*** Setup PAR archive       ***\n");
+      printf("*******************************\n");
+      gROOT->Macro("PROOF-INF/SETUP.C");
+    }
+    
+    gSystem->ChangeDirectory("../");
+  } 
+  return 1;
+}