New reader for the pedestal run and vdrift (Julian) and some bug fixing (Raphaelle)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Jan 2010 08:49:19 +0000 (08:49 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Jan 2010 08:49:19 +0000 (08:49 +0000)
TRD/AliTRDCalibPadStatus.cxx
TRD/AliTRDCalibPadStatus.h
TRD/AliTRDCalibTask.cxx
TRD/AliTRDCalibraFillHisto.cxx
TRD/AliTRDCalibraFillHisto.h
TRD/AliTRDfeeParam.cxx
TRD/AliTRDfeeParam.h
TRD/TRDPEDESTALda.cxx
TRD/TRDVDRIFTda.cxx

index 5681315..2e2cc14 100644 (file)
 //  TH1F *histo = ped.GetHisto(31);                                       //
 //  histo->SetEntries(1);                                                 //
 //  histo->Draw();                                                        //
-//                                                                        //
+//
+// Authors:
+//   R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de)
+//   J. Book (jbook@ikf.uni-frankfurt.de)
+//                                                                                                    //
 ////////////////////////////////////////////////////////////////////////////
 
 
 #include "./Cal/AliTRDCalPad.h"
 #include "./Cal/AliTRDCalSingleChamberStatus.h"
 
+#include "AliTRDrawFastStream.h"
+#include "AliTRDdigitsManager.h"
+#include "AliTRDdigitsParam.h"
+#include "AliTRDSignalIndex.h"
+#include "AliTRDarraySignal.h"
+#include "AliTRDarrayADC.h"
+#include "AliTRDfeeParam.h"
+
 #ifdef ALI_DATE
 #include "event.h"
 #endif
@@ -219,10 +231,12 @@ Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
   // fast filling methode.
   // Attention: the entry counter of the histogram is not increased
   //            this means that e.g. the colz draw option gives an empty plot
+  
   Int_t bin = 0;
+  
   if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
     bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
-
+  
   //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
   
   GetHisto(icdet,kTRUE)->GetArray()[bin]++;
@@ -230,6 +244,45 @@ Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
   return 0;
 }
 //_____________________________________________________________________
+Int_t AliTRDCalibPadStatus::UpdateHisto2(const Int_t icdet, /*FOLD00*/
+                                        const Int_t icRow,
+                                        const Int_t icCol,
+                                        const Int_t csignal,
+                                        const Int_t crowMax,
+                                        const Int_t ccold,
+                                        const Int_t icMcm,
+                                        const Int_t icRob
+                                        )
+{
+  //
+  // Signal filling methode 
+  //
+  Int_t nbchannel = icRow+icCol*crowMax;
+  Int_t mCm = icMcm%4;
+  Int_t rOb = icRob%2;
+
+  // now the case of double read channel
+  if(ccold > 0){
+    nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax;
+    //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
+  }
+  
+  // fast filling methode.
+  // Attention: the entry counter of the histogram is not increased
+  //            this means that e.g. the colz draw option gives an empty plot
+  
+  Int_t bin = 0;
+  
+  if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
+    bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
+
+  //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
+
+  GetHisto(icdet,kTRUE)->GetArray()[bin]++;
+  
+  return 0;
+}
+//_____________________________________________________________________
 Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
 {
   //
@@ -237,6 +290,9 @@ Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t
   // 0 time bin problem or zero suppression
   // 1 no input
   // 2 input
+  // 
+
+  //
   // Raw version number: 
   // [3,31] non zero suppressed
   // 2,4 and [32,63] zero suppressed 
@@ -293,7 +349,7 @@ Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t
       fDetector         = idetector;      
 
       for(Int_t k = 0; k < fNumberOfTimeBins; k++){
-       if(signal[k]>0) UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
+       if(signal[k]>0 && iCol != -1) UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
       }
       
       withInput = 2;
@@ -328,7 +384,7 @@ Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t
       //printf("det %d, row %d, signal[0] %d, signal[1] %d, signal [2] %d\n", idetector, iRow, signal[0], signal[1], signal[2]);
  
       for(Int_t k = 0; k < nbtimebin; k++){
-       if(signal[k]>0) {
+       if(signal[k]>0 && iCol != -1) {
          UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
          //printf("Update with det %d, row %d, col %d, signal %d, rowmax %d, col %d, mcm %d\n",idetector,iRow,iCol,signal[n],iRowMax,col,mcm);
        }
@@ -388,6 +444,126 @@ Int_t AliTRDCalibPadStatus::ProcessEvent(
 }
 
 //_____________________________________________________________________
+Int_t AliTRDCalibPadStatus::ProcessEvent2(AliRawReader *rawReader)
+{
+  //
+  // Event Processing loop - AliTRDRawStreamCosmic
+  // 0 time bin problem or zero suppression
+  // 1 no input
+  // 2 input
+  // Raw version number: 
+  // [3,31] non zero suppressed
+  // 2,4 and [32,63] zero suppressed 
+  //
+  
+  Int_t withInput = 1;
+
+  AliTRDrawFastStream *rawStream = new AliTRDrawFastStream(rawReader);
+  rawStream->SetSharedPadReadout(kTRUE);
+
+  AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
+  digitsManager->CreateArrays();
+  
+  AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
+
+  Int_t det    = 0;
+  while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
+    if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
+      //       printf("there is ADC data on this chamber!\n");
+      
+       AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
+      if (digits->HasData()) { //array
+       
+       AliTRDSignalIndex   *indexes = digitsManager->GetIndexes(det);
+       if (indexes->IsAllocated() == kFALSE) {
+         AliError("Indexes do not exist!");
+         break;
+       }
+       Int_t iRow  = 0;
+       Int_t iCol  = 0;
+       indexes->ResetCounters();
+
+       while (indexes->NextRCIndex(iRow, iCol)) { //column,row
+         
+
+         AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
+         
+         Int_t mcm          = 0;     // MCM from AliTRDfeeParam
+         Int_t rob          = 0;     // ROB from AliTRDfeeParam
+         Int_t extCol       = 0;     // extended column from  AliTRDfeeParam  
+         mcm = feeParam->GetMCMfromPad(iRow,iCol);
+         rob = feeParam->GetROBfromPad(iRow,iCol);
+
+         Int_t idetector  = det;                            //  current detector
+         Int_t iRowMax    = rawStream->GetMaxRow();         //  current rowmax
+
+         Int_t adc        = 20 - (iCol%18) -1;                 //  current adc
+         Int_t col        = 0;                              //  col!=0 ->Shared Pad
+         extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);
+         //printf("  iCol %d  iRow %d  iRowMax %d  rob %d  mcm %d  adc %d  extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol);   
+         
+         // Signal for regular pads
+         Int_t nbtimebin  = digitParam->GetNTimeBins();     //  number of time bins read from data       
+         for(Int_t k = 0; k < nbtimebin; k++){
+           Short_t signal = 0;
+           signal = digits->GetData(iRow,iCol,k);
+           
+           if(signal>0) {
+             UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
+           }
+         }
+
+         
+         
+         if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) /* && fSharedPadsOn*/ ) { //SHARED PADS
+           
+             switch(adc) {
+             case 2:  
+               adc = 20;                                       //shared Pad adc 
+               mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm 
+               col =  1;
+               break;
+             case 19:  
+               adc = 1;                                        //shared Pad adc  
+               mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm  
+               col =  2;
+               break;
+             case 18: 
+               adc =  0;                                       //shared Pad adc  
+               mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm 
+               col =  3;
+               break;
+             }
+             rob = feeParam->GetROBfromSharedPad(iRow,iCol);     //shared Pad rob 
+             
+           
+           extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);     //extended pad col via the shared pad rob,mcm and adc
+           
+           //printf("SHARED PAD ---  iCol %d  iRow %d  rob %d  mcm %d  adc %d  extCol %d  col %d\n",iCol,iRow,rob,mcm,adc,extCol,col);
+           for(Int_t k = 0; k < nbtimebin; k++){
+             Short_t signal = 0;
+             signal = digits->GetDataByAdcCol(iRow,extCol,k);
+             
+             if(signal>0) {
+               UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
+             }
+           }
+         } //shared pads end
+           
+         
+         withInput = 2;
+       }//column,row
+
+      }//array
+    }//QA
+    digitsManager->ClearArrays(det);
+  }//idetector
+  delete digitsManager;
+  delete rawStream;
+  return withInput;
+}
+
+//_____________________________________________________________________
 Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm, Int_t ch) /*FOLD00*/
 {
   //
@@ -898,3 +1074,4 @@ Int_t AliTRDCalibPadStatus::GetSector(Int_t d) const
 
 }
 
+
index 7375b64..7486817 100644 (file)
@@ -23,6 +23,10 @@ class AliTRDCalPadStatus;
 class AliTRDrawStreamBase;
 class AliTRDgeometry;
 
+class AliTRDrawFastStream;
+class AliTRDdigitsManager;
+class AliTRDSignalIndex;
+
 struct eventHeaderStruct;
 
 class AliTRDCalibPadStatus : public TObject {
@@ -38,11 +42,15 @@ public:
   Int_t ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t nocheck = kFALSE);
   Int_t ProcessEvent(AliRawReader    *rawReader, Bool_t nocheck = kFALSE);
   Int_t ProcessEvent(const eventHeaderStruct   *event, Bool_t nocheck = kFALSE);
-
+  Int_t ProcessEvent2(AliRawReader    *rawReader);
   void  Destroy();
   Int_t UpdateHisto(const Int_t idet, const Int_t iRow, const Int_t iCol,
                    const Int_t signal, const Int_t crowMax, const Int_t ccold, const Int_t icMcm);
 
+  Int_t UpdateHisto2(const Int_t idet, const Int_t iRow, const Int_t iCol,
+                    const Int_t signal, const Int_t crowMax, const Int_t ccold, const Int_t icMcm, const Int_t icRob);
+
   void AnalyseHisto();
   AliTRDCalPadStatus *CreateCalPadStatus();
   AliTRDCalPad *CreateCalPad();
@@ -107,3 +115,4 @@ public:
 
 };
 #endif
+
index 830af7f..907e74a 100644 (file)
-
-/**************************************************************************
- * 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.                  *
- **************************************************************************/
-
-/////////////////////////////////////////////////////////////////////////////////
-//                                                                             
-// AliTRDCalibTask                                                               
-//                                                                             
-// Offline TRD calibration task                                
-//                        
-// Author:
-//   R. Bailhache (R.Bailhache@gsi.de)
-//                            
-//////////////////////////////////////////////////////////////////////////////////////
-
-
-
-#include "Riostream.h"
-#include "TChain.h"
-#include "TTree.h"
-#include "TFile.h"
-#include "TProfile2D.h"
-#include "TH2I.h"
-#include "TH1F.h"
-#include "TH2F.h"
-#include "TList.h"
-#include "TMath.h"
-#include "TObject.h"
-#include "TObjArray.h"
-#include "TString.h"
-#include "TCanvas.h"
-#include "TLegend.h"
-#include "TStyle.h"
-#include "TLine.h"
-
-#include "AliAnalysisTask.h"
-#include "AliAnalysisManager.h"
-
-#include "AliESDVertex.h"
-#include "AliESDEvent.h"
-#include "AliESDfriend.h"
-#include "AliESDInputHandler.h"
-#include "AliESDtrack.h"
-#include "AliESDfriendTrack.h"
-#include "AliTRDtrackV1.h"
-#include "AliTRDseedV1.h"
-#include "AliTRDcluster.h"
-#include "AliTRDgeometry.h"
-#include "AliESDtrackCuts.h"
-#include "AliESDVertex.h"
-#include "AliTRDCalDet.h"
-
-#include "AliTRDCalibraFillHisto.h"
-#include "AliTRDCalibraVdriftLinearFit.h" 
-
-#include "AliTRDcalibDB.h"
-
-
-#include "AliTRDCalibTask.h"
-
-
-ClassImp(AliTRDCalibTask)
-
-//________________________________________________________________________
-  AliTRDCalibTask::AliTRDCalibTask(const char *name) 
-    : AliAnalysisTask(name, ""), fESD(0), fESDfriend(0),
-      fkEsdTrack(0),
-      fFriendTrack(0),
-      fCalibObject(0),
-      fTrdTrack(0),
-      fCl(0),
-      fListHist(0),
-      fTRDCalibraFillHisto(0),
-      fNEvents(0),
-      fNbTRDTrack(0),
-      fNbTRDTrackOffline(0),
-      fNbTRDTrackStandalone(0),
-      fNbTPCTRDtrack(0),
-      fNbTimeBin(0),
-      fNbTimeBinOffline(0),
-      fNbTimeBinStandalone(0),
-      fNbClusters(0),
-      fNbClustersOffline(0),
-      fNbClustersStandalone(0),
-      fNbTracklets(0),
-      fNbTrackletsOffline(0),
-      fNbTrackletsStandalone(0),
-      fCH2dSum(0),
-      fPH2dSum(0),
-      fCH2dSM(0),
-      fPH2dSM(0),
-      fHisto2d(kTRUE),
-      fVector2d(kFALSE),
-      fVdriftLinear(kTRUE),
-      fNbTimeBins(0),
-      fSelectedTrigger(new TObjArray()),
-      fRejected(kTRUE),
-      fEsdTrackCuts(0),
-      fRequirePrimaryVertex(kFALSE),
-      fVtxTPC(kFALSE),
-      fVtxSPD(kFALSE),
-      fMinNbContributors(0),
-      fLow(0),
-      fHigh(30),
-      fFillZero(kFALSE),
-      fNormalizeNbOfCluster(kFALSE),
-      fRelativeScale(0.0),
-      fMaxCluster(100.0),
-      fNbMaxCluster(2),
-      fOfflineTracks(kFALSE),
-      fStandaloneTracks(kFALSE),
-      fCalDetGain(0x0),
-      fMaxEvent(0),
-      fCounter(0),
-      fDebug(0)
-{
-  //
-  // Default constructor
-  //
-
-  fNz[0] = 0;
-  fNz[1] = 0;
-  fNz[2] = 0;
-  
-  fNrphi[0] = 0;
-  fNrphi[1] = 0;
-  fNrphi[2] = 0;
-
-  // Define input and output slots here
-  // Input slot #0 works with a TChain
-  DefineInput(0, TChain::Class());
-    
-  // Output slot #0 writes into a TList container
-  DefineOutput(0, TList::Class());
-  
-   
-}
-//____________________________________________________________________________________
-AliTRDCalibTask::~AliTRDCalibTask()
-{
-  //
-  // AliTRDCalibTask destructor
-  //
-
-  // Pointeur
-  if(fNEvents) delete fNEvents;
-  if(fNbTRDTrack) delete fNbTRDTrack;
-  if(fNbTRDTrackOffline) delete fNbTRDTrackOffline;
-  if(fNbTRDTrackStandalone) delete fNbTRDTrackStandalone;
-  if(fNbTPCTRDtrack) delete fNbTPCTRDtrack;
-  if(fNbTimeBin) delete fNbTimeBin;
-  if(fNbTimeBinOffline) delete fNbTimeBinOffline;
-  if(fNbTimeBinStandalone) delete fNbTimeBinStandalone;
-  if(fNbClusters) delete fNbClusters;
-  if(fNbClustersOffline) delete fNbClustersOffline;
-  if(fNbClustersStandalone) delete fNbClustersStandalone;
-  if(fNbTracklets) delete fNbTracklets;
-  if(fNbTrackletsOffline) delete fNbTrackletsOffline;
-  if(fNbTrackletsStandalone) delete fNbTrackletsStandalone;
-  if(fCH2dSum) delete fCH2dSum;
-  if(fPH2dSum) delete fPH2dSum;
-  if(fCH2dSM) delete fCH2dSM;
-  if(fPH2dSM) delete fPH2dSM;
-  if(fCalDetGain) delete fCalDetGain;
-  
-  if(fSelectedTrigger) {
-    fSelectedTrigger->Delete();
-    delete fSelectedTrigger;
-  }
-  if(fEsdTrackCuts) {
-    delete fEsdTrackCuts;
-  }
-  
-}
-//________________________________________________________________________
-void AliTRDCalibTask::ConnectInputData(Option_t *) 
-{
-  // Connect ESD or AOD here
-  // Called once
-  
-  TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); //pointer wird "umgecastet" auf anderen Variablentyp
-  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();
-      esdH->SetActiveBranches("ESDfriend*");
-      //Printf("*** CONNECTED NEW EVENT ****");
-    }
-    
-  }
-}
-//________________________________________________________________________
-void AliTRDCalibTask::CreateOutputObjects() 
-{
-  //
-  // Create the histos
-  //
-
-  // Number of time bins
-  if(fNbTimeBins==0) {
-    AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
-    fNbTimeBins = cal->GetNumberOfTimeBinsDCS();
-    if(fNbTimeBins <= 0){ 
-      AliWarning(Form("No of TimeBins from DB [%d] use default [30]", fNbTimeBins));
-      fNbTimeBins = 30;
-    }
-  }
-  
-  // instance calibration 
-  fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();
-  fTRDCalibraFillHisto->SetHisto2d(fHisto2d); // choose to use histograms
-  fTRDCalibraFillHisto->SetVector2d(fVector2d); // choose to use vectors
-  fTRDCalibraFillHisto->SetCH2dOn();  // choose to calibrate the gain
-  fTRDCalibraFillHisto->SetPH2dOn();  // choose to calibrate the drift velocity
-  fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF
-  fTRDCalibraFillHisto->SetLinearFitterOn(fVdriftLinear); // Other possibility vdrift VDRIFT
-  fTRDCalibraFillHisto->SetLinearFitterDebugOn(fVdriftLinear); // Other possibility vdrift
-  for(Int_t k = 0; k < 3; k++){
-    if(((fNz[k] != 10) && (fNrphi[k] != 10)) && ((fNz[k] != 100) && (fNrphi[k] != 100))) {
-      fTRDCalibraFillHisto->SetNz(k,fNz[k]);                                    // Mode calibration
-      fTRDCalibraFillHisto->SetNrphi(k,fNrphi[k]);                             // Mode calibration
-    }
-    else {
-      if((fNz[k] == 100) && (fNrphi[k] == 100))  {
-       if(fVector2d) AliInfo("The mode all together is not supported by the vector method");
-       fTRDCalibraFillHisto->SetAllTogether(k);
-      }
-      if((fNz[k] == 10) && (fNrphi[k] == 10))  {
-       if(fVector2d) AliInfo("The mode per supermodule is not supported by the vector method");
-       fTRDCalibraFillHisto->SetPerSuperModule(k);
-      }
-    }
-  }
-  // Variables for how to fill
-  fTRDCalibraFillHisto->SetFillWithZero(fFillZero);
-  fTRDCalibraFillHisto->SetNormalizeNbOfCluster(fNormalizeNbOfCluster); 
-  fTRDCalibraFillHisto->SetMaxCluster(fMaxCluster);
-  fTRDCalibraFillHisto->SetNbMaxCluster(fNbMaxCluster);
-  
-  // Init with 30 timebins
-  fTRDCalibraFillHisto->Init2Dhistos(fNbTimeBins); // initialise the histos
-  fTRDCalibraFillHisto->SetNumberClusters(fLow); // At least 11 clusters
-  fTRDCalibraFillHisto->SetNumberClustersf(fHigh); // At least 11 clusters
-  fRelativeScale = fTRDCalibraFillHisto->GetRelativeScale(); // Get the relative scale for the gain
-  
-  // For testing only
-  if(fDebug > 2) fTRDCalibraFillHisto->SetDebugLevel(1); //debug stuff
-  
-  // output list
-  fListHist = new TList();
-  if(fHisto2d) {  
-    fListHist->Add(fTRDCalibraFillHisto->GetCH2d());
-    fListHist->Add(fTRDCalibraFillHisto->GetPH2d()); 
-    fListHist->Add(fTRDCalibraFillHisto->GetPRF2d());
-  } 
-  if(fVdriftLinear) fListHist->Add((TObject *) fTRDCalibraFillHisto->GetVdriftLinearFit());
-  if(fVector2d) fListHist->Add((TObject *) fTRDCalibraFillHisto->GetCalibraVector()); //calibra vector  
-  fNEvents = new TH1I("NEvents","NEvents", 2, 0, 2);
-  fListHist->Add(fNEvents);
-  
-  /////////////////////////////////////////
-  // First debug level
-  ///////////////////////////////////////
-  if(fDebug > 0) {
-    
-    fPH2dSM = new TProfile2D("PH2dSM","Nz10Nrphi10"
-                           ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
-                          ,18,0,18);
-    fPH2dSM->SetYTitle("Det/pad groups");
-    fPH2dSM->SetXTitle("time [#mus]");
-    fPH2dSM->SetZTitle("<PH> [a.u.]");
-    fPH2dSM->SetStats(0);
-    //
-    fCH2dSM = new TH2I("CH2dSM","Nz10Nrphi10",50,0,300,18,0,18);
-    fCH2dSM->SetYTitle("Det/pad groups");
-    fCH2dSM->SetXTitle("charge deposit [a.u]");
-    fCH2dSM->SetZTitle("counts");
-    fCH2dSM->SetStats(0);
-    fCH2dSM->Sumw2();
-    //
-    fPH2dSum = new TProfile2D("PH2dSum","Nz100Nrphi100"
-                           ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
-                           ,1,0,1);
-    fPH2dSum->SetYTitle("Det/pad groups");
-    fPH2dSum->SetXTitle("time [#mus]");
-    fPH2dSum->SetZTitle("<PH> [a.u.]");
-    fPH2dSum->SetStats(0);
-    //
-    fCH2dSum = new TH2I("CH2dSum","Nz100Nrphi100",50,0,300,1,0,1);
-    fCH2dSum->SetYTitle("Det/pad groups");
-    fCH2dSum->SetXTitle("charge deposit [a.u]");
-    fCH2dSum->SetZTitle("counts");
-    fCH2dSum->SetStats(0);
-    fCH2dSum->Sumw2();
-    
-    // Add them
-    fListHist->Add(fPH2dSM);
-    fListHist->Add(fCH2dSM);
-    fListHist->Add(fPH2dSum);
-    fListHist->Add(fCH2dSum);
-  }
-
-  /////////////////////////////////////////
-  // Second debug level
-  ///////////////////////////////////////
-  if(fDebug > 1) {
-
-    fNbTRDTrack = new TH1F("TRDTrack","TRDTrack",50,0,50);
-    fNbTRDTrack->Sumw2();
-    fNbTRDTrackOffline = new TH1F("TRDTrackOffline","TRDTrackOffline",50,0,50);
-    fNbTRDTrackOffline->Sumw2();
-    fNbTRDTrackStandalone = new TH1F("TRDTrackStandalone","TRDTrackStandalone",50,0,50);
-    fNbTRDTrackStandalone->Sumw2();
-    fNbTPCTRDtrack = new TH2F("NbTPCTRDtrack","NbTPCTRDtrack",100,0,100,100,0,100);
-    fNbTPCTRDtrack->Sumw2();
-    //
-    fNbTimeBin = new TH1F("NbTimeBin","NbTimeBin",35,0,35);
-    fNbTimeBin->Sumw2();
-    fNbTimeBinOffline = new TH1F("NbTimeBinOffline","NbTimeBinOffline",35,0,35);
-    fNbTimeBinOffline->Sumw2();
-    fNbTimeBinStandalone = new TH1F("NbTimeBinStandalone","NbTimeBinStandalone",35,0,35);
-    fNbTimeBinStandalone->Sumw2();
-    //
-    fNbClusters = new TH1F("NbClusters","",35,0,35);
-    fNbClusters->Sumw2();
-    fNbClustersOffline = new TH1F("NbClustersOffline","",35,0,35);
-    fNbClustersOffline->Sumw2();
-    fNbClustersStandalone = new TH1F("NbClustersStandalone","",35,0,35);
-    fNbClustersStandalone->Sumw2();
-    //
-    fNbTracklets = new TH1F("NbTracklets","NbTracklets",540,0.,540.);
-    fNbTracklets->Sumw2();
-    fNbTrackletsOffline = new TH1F("NbTrackletsOffline","NbTrackletsOffline",540,0.,540.);
-    fNbTrackletsOffline->Sumw2();
-    fNbTrackletsStandalone = new TH1F("NbTrackletsStandalone","NbTrackletsStandalone",540,0.,540.);
-    fNbTrackletsStandalone->Sumw2();
-   
-    fListHist->Add(fNbTRDTrack);
-    fListHist->Add(fNbTRDTrackOffline);
-    fListHist->Add(fNbTRDTrackStandalone);
-    fListHist->Add(fNbTPCTRDtrack);
-    
-    fListHist->Add(fNbTimeBin);
-    fListHist->Add(fNbTimeBinOffline);
-    fListHist->Add(fNbTimeBinStandalone);
-    fListHist->Add(fNbClusters);
-    fListHist->Add(fNbClustersOffline);
-    fListHist->Add(fNbClustersStandalone);
-    fListHist->Add(fNbTracklets);
-    fListHist->Add(fNbTrackletsOffline);
-    fListHist->Add(fNbTrackletsStandalone);
-    
-  }
-  
- }
- //________________________________________________________________________
- void AliTRDCalibTask::Exec(Option_t *) 
- {
-   //
-   // Filling of the histos
-   //
-
-   AliLog::SetGlobalLogLevel(AliLog::kError);
-
-   if (!fESD) {
-     //Printf("ERROR: fESD not available");
-     return;
-   }
-
-   //printf("Counter %d\n",fCounter);
-
-   fCounter++;
-   if((fMaxEvent != 0) && (fMaxEvent < fCounter)) return;
-
-   //printf("Counter %d\n",fCounter);
-
-   ///////////////////////////////
-   // Require a primary vertex
-   //////////////////////////////
-   if(fRequirePrimaryVertex) {
-     const AliESDVertex* vtxESD = 0x0;
-     if      (fVtxTPC) vtxESD = fESD->GetPrimaryVertexTPC() ;
-     else if (fVtxSPD) vtxESD = fESD->GetPrimaryVertexSPD() ;
-     else              vtxESD = fESD->GetPrimaryVertexTracks() ;
-     if(!vtxESD){
-       return;
-     }
-     Int_t nCtrb = vtxESD->GetNContributors();
-     if(nCtrb < fMinNbContributors) return;
-   }
-
-   //printf("Primary vertex passed\n");
-
-   ///////////////////
-   // Check trigger
-   ///////////////////
-   //printf("Class Fired %s\n",(const char*)fESD->GetFiredTriggerClasses());
-   Bool_t pass = kTRUE;
-   Int_t numberOfTriggerSelected = fSelectedTrigger->GetEntriesFast();
-   //printf("numberofTriggerSelected %d\n",numberOfTriggerSelected);
-   if(fRejected) {
-     pass = kTRUE;
-     for(Int_t k = 0; k < numberOfTriggerSelected; k++){
-       const TObjString *const obString=(TObjString*)fSelectedTrigger->At(k);
-       const TString tString=obString->GetString();
-       if(fESD->IsTriggerClassFired((const char*)tString)) {
-        pass = kFALSE;
-       }
-     }
-   }
-   else {
-     pass = kFALSE;
-     for(Int_t k = 0; k < numberOfTriggerSelected; k++){
-       const TObjString *const obString=(TObjString*)fSelectedTrigger->At(k);
-       const TString tString=obString->GetString();
-       if(fESD->IsTriggerClassFired((const char*)tString)) {
-        pass = kTRUE;
-       }
-     }
-   }
-   if(!pass) return;   
-
-   //printf("Trigger passed\n");
-  
-   fNEvents->Fill(1);
-
-   // In total
-   Int_t nbTrdTracks = 0;
-   // standalone
-   Int_t nbTrdTracksStandalone = 0;
-   // offline
-   Int_t nbTrdTracksOffline = 0;
-   // TPC
-   Int_t nbtrackTPC = 0;
-
-   Double_t nbTracks = fESD->GetNumberOfTracks();
-   //printf("Number of tracks %f\n",nbTracks);  
-
-   if (nbTracks <= 0.0) {
-     
-     if(fDebug > 1) {
-       fNbTRDTrack->Fill(nbTrdTracks);
-       fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);
-       fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
-     }
-     PostData(0, fListHist);
-     return;
-   }
-
-   fESDfriend = (AliESDfriend *)fESD->FindListObject("AliESDfriend");
-   fESD->SetESDfriend(fESDfriend);
-   if(!fESDfriend) return;   
-   
-   //printf("has friends\n");
-
-   ////////////////////////////////////
-   // Check the number of TPC tracks
-   ///////////////////////////////////
-   //printf("Nb of tracks %f\n",nbTracks);
-   for(Int_t itrk = 0; itrk < nbTracks; itrk++){
-     // Get ESD track
-     fkEsdTrack = fESD->GetTrack(itrk);
-     ULong_t status = fkEsdTrack->GetStatus(); 
-     if(status&(AliESDtrack::kTPCout)) nbtrackTPC++;
-     // Check that the calibration object is here
-     if(fESDfriend && (fESDfriend->GetTrack(itrk))) {
-       fFriendTrack = new AliESDfriendTrack(*(fESDfriend->GetTrack(itrk)));
-       Int_t counteer = 0;
-       Int_t icalib=0;
-       while((fCalibObject = (TObject *)(fFriendTrack->GetCalibObject(icalib++)))){
-        if(strcmp(fCalibObject->IsA()->GetName(), "AliTRDtrackV1") != 0) continue;
-        counteer++;
-       }
-       if(counteer > 0) {
-        nbTrdTracks++;
-        if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {
-          nbTrdTracksStandalone++;
-        }
-        if((status&(AliESDtrack::kTRDin))) {
-          nbTrdTracksOffline++;
-        }
-       }
-       if(fFriendTrack) delete fFriendTrack;
-     }
-   }
-   //printf("Number of TPC tracks %d, TRD %d\n",nbtrackTPC,nbTrdTracks);
-   if((nbtrackTPC>0) && (nbTrdTracks > (3.0*nbtrackTPC))) pass = kFALSE;
-   
-   if(fDebug > 1) {
-     
-     fNbTRDTrack->Fill(nbTrdTracks);
-     fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);
-     fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
-     fNbTPCTRDtrack->Fill(nbTrdTracks,nbtrackTPC);
-   
-   }
-
-   if(!pass) {
-     PostData(0, fListHist);
-     return;
-   }
-   //printf("Pass\n");  
-
-   /////////////////////////////////////
-   // Loop on AliESDtrack
-   ////////////////////////////////////
-   //printf("Nb of tracks %f\n",nbTracks);      
-   for(int itrk=0; itrk < nbTracks; itrk++){
-
-     // Get ESD track
-     fkEsdTrack = fESD->GetTrack(itrk);
-     if(!fkEsdTrack) continue;
-
-     // Quality cuts on the AliESDtrack
-     if((fEsdTrackCuts) && (!fEsdTrackCuts->IsSelected((AliVParticle *)fkEsdTrack))) {
-       //printf("Not a good track\n");
-       continue;
-     }
-     
-     // Other cuts
-     Bool_t good = kTRUE;
-     Bool_t standalonetrack = kFALSE;
-     Bool_t offlinetrack = kFALSE;
-     ULong_t status = fkEsdTrack->GetStatus();
-     
-     if(!(fESDfriend->GetTrack(itrk)))  continue;   
-     
-     fFriendTrack = new AliESDfriendTrack(*(fESDfriend->GetTrack(itrk)));
-     
-     //////////////////////////////////////
-     // Loop on calibration objects
-     //////////////////////////////////////
-     Int_t icalib=0;
-     while((fCalibObject = (TObject *)(fFriendTrack->GetCalibObject(icalib++)))){
-       if(strcmp(fCalibObject->IsA()->GetName(), "AliTRDtrackV1") != 0) continue;
-       //printf("Find the calibration object\n");
-
-       if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {
-        standalonetrack = kTRUE;
-       }
-       if((status&(AliESDtrack::kTRDin))) {
-        offlinetrack = kTRUE;
-       }
-       if(fOfflineTracks){
-        if(!offlinetrack){
-          good = kFALSE;
-        }
-       }
-       else if(fStandaloneTracks){
-        if(!standalonetrack){
-          good = kFALSE;
-        }
-       }
-       
-       fTrdTrack = (AliTRDtrackV1 *)fCalibObject;
-       if(good) {
-        fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack);
-        //printf("Fill fTRDCalibraFillHisto\n");
-       }
-       
-       //////////////////////////////////
-       // Debug 
-       ////////////////////////////////
-
-       if(fDebug > 0) {
-        
-        //printf("Enter debug\n");
-        
-        Int_t nbtracklets = 0;
-        
-        // Check some stuff
-        Bool_t standalonetracklet = kFALSE;  
-        const AliTRDseedV1 *tracklet = 0x0;
-        //////////////////////////////////////
-        // Loop tracklets
-        ///////////////////////////////////// 
-        for(Int_t itr = 0; itr < 6; itr++){
-          
-          if(!(tracklet = fTrdTrack->GetTracklet(itr))) continue;
-          if(!tracklet->IsOK()) continue;
-          nbtracklets++;
-          standalonetracklet = kFALSE; 
-          if(tracklet->IsStandAlone()) standalonetracklet = kTRUE;
-
-          Int_t nbclusters = 0;
-          Double_t phtb[AliTRDseedV1::kNtb];
-          memset(phtb, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
-          Double_t sum = 0.0;
-          Float_t normalisation = 6.67;
-          Int_t detector = 0;
-          Int_t sector = 0;
-          //Int_t crossrow = 0;
-          
-          // Check no shared clusters
-          //for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
-          //  if((fcl = tracklet->GetClusters(icc)))  crossrow = 1;
-          // }
-          
-          // Loop on clusters
-          for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
-            
-            if(!(fCl = tracklet->GetClusters(ic))) continue;
-            nbclusters++;
-            Int_t time = fCl->GetPadTime();
-            Float_t ch =  tracklet->GetdQdl(ic);
-            Float_t qcl = TMath::Abs(fCl->GetQ());
-            detector = fCl->GetDetector();       
-            if((time>-1) && (time<fNbTimeBins)) phtb[time]=qcl;
-            if((fCalDetGain) && (fCalDetGain->GetValue(detector) > 0.0)) sum += ch*fCalDetGain->GetValue(detector)/normalisation;      
-            else sum += ch/normalisation;
-            
-            if(fDebug > 1) {
-              fNbTimeBin->Fill(time);
-              if(tracklet->IsStandAlone()) fNbTimeBinStandalone->Fill(time);
-              else fNbTimeBinOffline->Fill(time);
-            }
-          }
-          sector = AliTRDgeometry::GetSector(detector);
-          
-          if(fDebug > 1) {
-            fNbTracklets->Fill(detector);
-            if(tracklet->IsStandAlone()) fNbTrackletsStandalone->Fill(detector);
-            else fNbTrackletsOffline->Fill(detector);
-          
-            fNbClusters->Fill(nbclusters);
-            if(tracklet->IsStandAlone())  fNbClustersStandalone->Fill(nbclusters);
-            else  fNbClustersOffline->Fill(nbclusters);
-          }       
-
-          if(fDebug > 0) {
-            if((nbclusters > fLow) && (nbclusters < fHigh)){
-              if(fRelativeScale > 0.0) sum = sum/fRelativeScale;              
-              fCH2dSM->Fill(sum,sector+0.5);
-              fCH2dSum->Fill(sum,0.5);
-              Bool_t checknoise = kTRUE;
-              if(fMaxCluster > 0) {
-                if(phtb[0] > fMaxCluster) checknoise = kFALSE;
-                if(fNbTimeBins > fNbMaxCluster) {
-                  for(Int_t k = (fNbTimeBins-fNbMaxCluster); k < fNbTimeBins; k++){
-                    if(phtb[k] > fMaxCluster) checknoise = kFALSE;
-                  }
-                }
-              }
-              if(checknoise) {        
-                for(int ic=0; ic<fNbTimeBins; ic++){
-                  if(fFillZero) {
-                    fPH2dSum->Fill((Double_t)(ic/10.0),0.5,(Double_t)phtb[ic]);
-                    fPH2dSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
-                  }
-                  else {
-                    if(phtb[ic] > 0.0) {
-                      fPH2dSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);
-                      fPH2dSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
-                    }
-                  }
-                }
-              }
-            }
-          }
-        } // loop on tracklets
-    
-       } // debug
-       
-     }// while calibration objects
-     
-     delete fFriendTrack;
-     
-   } // loop ESD track
-   
-   // Post output data
-   PostData(0, fListHist);
- }     
-//________________________________________________________________________
-void AliTRDCalibTask::Terminate(Option_t *) 
-{
-  //
-  // Terminate
-  //
-  
-  if(fTRDCalibraFillHisto) fTRDCalibraFillHisto->DestroyDebugStreamer();
-
-}
-//_______________________________________________________
-Bool_t AliTRDCalibTask::Load(const Char_t *filename)
-{
-  //
-  // Generic container loader
-  //
-
-  if(!TFile::Open(filename)){
-    //AliWarning(Form("Couldn't open file %s.", filename));
-    return kFALSE;
-  }
-  TList *o = 0x0;
-  if(!(o = (TList*)gFile->Get(GetName()))){
-    //AliWarning("Missing histogram container.");
-    return kFALSE;
-  }
-  fListHist = (TList*)o->Clone(GetName());
-  gFile->Close();
-  return kTRUE;
-}
-//________________________________________________________________________
-void AliTRDCalibTask::Plot() 
-{
-  //
-  // Plot the histos stored in the TList
-  //
-  if(!fListHist) return;
-
-  /////////////////////////////////////
-  // Take the debug stuff
-  /////////////////////////////////////
-
-  TH1I *nEvents  = (TH1I *) fListHist->FindObject("NEvents");
-
-  TH1F *trdTrack = (TH1F *) fListHist->FindObject("TRDTrack");
-  TH1F *trdTrackOffline = (TH1F *) fListHist->FindObject("TRDTrackOffline");
-  TH1F *trdTrackStandalone = (TH1F *) fListHist->FindObject("TRDTrackStandalone");
-
-  TH2F *tpctrdTrack = (TH2F *) fListHist->FindObject("NbTPCTRDtrack");
-
-  TH1F *nbTimeBin = (TH1F *) fListHist->FindObject("NbTimeBin");
-  TH1F *nbTimeBinOffline = (TH1F *) fListHist->FindObject("NbTimeBinOffline");
-  TH1F *nbTimeBinStandalone = (TH1F *) fListHist->FindObject("NbTimeBinStandalone");
-
-  TH1F *nbClusters = (TH1F *) fListHist->FindObject("NbClusters");
-  TH1F *nbClustersOffline = (TH1F *) fListHist->FindObject("NbClustersOffline");
-  TH1F *nbClustersStandalone = (TH1F *) fListHist->FindObject("NbClustersStandalone");
-
-  TH1F *nbTracklets = (TH1F *) fListHist->FindObject("NbTracklets");
-  TH1F *nbTrackletsOffline = (TH1F *) fListHist->FindObject("NbTrackletsOffline");
-  TH1F *nbTrackletsStandalone = (TH1F *) fListHist->FindObject("NbTrackletsStandalone");
-  
-  /////////////////////////////////////
-  // Take the calibration objects
-  /////////////////////////////////////
-
-  TH2I *ch2d = (TH2I *) fListHist->FindObject("CH2d");
-  TProfile2D *ph2d = (TProfile2D *) fListHist->FindObject("PH2d");
-
-  TH2I *ch2dSum = (TH2I *) fListHist->FindObject("CH2dSum");
-  TProfile2D *ph2dSum = (TProfile2D *) fListHist->FindObject("PH2dSum");
-
-  TH2I *ch2dSM = (TH2I *) fListHist->FindObject("CH2dSM");
-  TProfile2D *ph2dSM = (TProfile2D *) fListHist->FindObject("PH2dSM");
-  
-  AliTRDCalibraVdriftLinearFit *linearfit = (AliTRDCalibraVdriftLinearFit *) fListHist->FindObject("AliTRDCalibraVdriftLinearFit");
-  
-  ////////////////////////////////////////////////
-  // Add the AliTRDCalibraVdriftLinearFit
-  ///////////////////////////////////////////////
-  
-  Int_t first = 0;
-  TH2S *histolinearfitsum = 0x0;
-  
-  if(linearfit) {
-    for(Int_t det = 0; det < 540; det++) {
-      if(linearfit->GetLinearFitterHisto(det)){
-       if(TMath::Abs(first)<0.0001){
-         histolinearfitsum = linearfit->GetLinearFitterHisto(det);
-         first += 1;
-       }
-       else {
-         histolinearfitsum ->Add(linearfit->GetLinearFitterHisto(det));
-       }
-      }
-    }
-  }
-
-  ///////////////////////////
-  // Style
-  //////////////////////////
-
-  gStyle->SetPalette(1);
-  gStyle->SetOptStat(1111);
-  gStyle->SetOptFit(1111);
-  gStyle->SetPadBorderMode(0);
-  gStyle->SetCanvasColor(10);
-  gStyle->SetPadLeftMargin(0.13);
-  gStyle->SetPadRightMargin(0.13);
-
-  /////////////////////////
-  // Plot
-  ////////////////////////
-
- if(nEvents) {
-   
-    TCanvas *debugEvents = new TCanvas("cNEvents","cNEvents",10,10,510,510);
-    debugEvents->cd(1);
-    if(nEvents) nEvents->Draw();
-      
-  }
-
-  if(trdTrack || tpctrdTrack) {
-    
-    TCanvas *debugtrdtpcTrack = new TCanvas("TRDtracktpctrdtrack","TRDtracktpctrdtrack",10,10,510,510);
-    debugtrdtpcTrack->Divide(2,1);
-    debugtrdtpcTrack->cd(1);
-    if(trdTrack) trdTrack->Draw();
-    if(trdTrackOffline) trdTrackOffline->Draw("same");
-    if(trdTrackStandalone) trdTrackStandalone->Draw("same");
-    TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
-    if(trdTrack) leg->AddEntry(trdTrack,"All","p");
-    if(trdTrackOffline) leg->AddEntry(trdTrackOffline,"Offline","p");
-    if(trdTrackStandalone) leg->AddEntry(trdTrackStandalone,"Standalone","p");
-    leg->Draw("same");
-    debugtrdtpcTrack->cd(2);
-    if(tpctrdTrack) tpctrdTrack->Draw();
-    TLine *line = new TLine(0.0,0.0,100.0,100.0);
-    line->Draw("same");
-    
-  }
-  if(nbTimeBin || nbTracklets || nbClusters) {
-    
-    TCanvas *debugTracklets = new TCanvas("TRDtimebintrackletcluster","TRDtimebintrackletcluster",10,10,510,510);
-    debugTracklets->Divide(3,1);
-    debugTracklets->cd(1);
-    if(nbTimeBin) nbTimeBin->Draw();
-    if(nbTimeBinOffline) nbTimeBinOffline->Draw("same");
-    if(nbTimeBinStandalone) nbTimeBinStandalone->Draw("same");
-    TLegend *lega = new TLegend(0.4,0.6,0.89,0.89);
-    if(nbTimeBin) lega->AddEntry(nbTimeBin,"All","p");
-    if(nbTimeBinOffline) lega->AddEntry(nbTimeBinOffline,"Offline","p");
-    if(nbTimeBinStandalone) lega->AddEntry(nbTimeBinStandalone,"Standalone","p");
-    lega->Draw("same");
-    debugTracklets->cd(2);
-    if(nbTracklets) nbTracklets->Draw();
-    if(nbTrackletsOffline) nbTrackletsOffline->Draw("same");
-    if(nbTrackletsStandalone) nbTrackletsStandalone->Draw("same");
-    TLegend *legb = new TLegend(0.4,0.6,0.89,0.89);
-    if(nbTracklets) legb->AddEntry(nbTracklets,"All","p");
-    if(nbTrackletsOffline) legb->AddEntry(nbTrackletsOffline,"Offline","p");
-    if(nbTrackletsStandalone) legb->AddEntry(nbTrackletsStandalone,"Standalone","p");
-    legb->Draw("same");
-    debugTracklets->cd(3);
-    if(nbClusters) nbClusters->Draw();
-    if(nbClustersOffline) nbClustersOffline->Draw("same");
-    if(nbClustersStandalone) nbClustersStandalone->Draw("same");
-    TLegend *legc = new TLegend(0.4,0.6,0.89,0.89);
-    if(nbClusters) legc->AddEntry(nbClusters,"All","p");
-    if(nbClustersOffline) legc->AddEntry(nbClustersOffline,"Offline","p");
-    if(nbClustersStandalone) legc->AddEntry(nbClustersStandalone,"Standalone","p");
-    legc->Draw("same");
-  
-  }
-
-  if(ch2dSum || ph2dSum || histolinearfitsum) {
-    
-    TCanvas *debugSum = new TCanvas("SumCalibrationObjects","SumCalibrationObjects",10,10,510,510);
-    debugSum->Divide(3,1);
-    debugSum->cd(1);
-    if(ch2dSum) ch2dSum->Draw("lego");
-    debugSum->cd(2);
-    if(ph2dSum) ph2dSum->Draw("lego");
-    debugSum->cd(3);
-    if(histolinearfitsum) histolinearfitsum->Draw();
-  
-  }
-
-  if(ch2dSM || ph2dSM) {
-    
-    TCanvas *debugSM = new TCanvas("SMCalibrationObjects","SMCalibrationObjects",10,10,510,510);
-    debugSM->Divide(2,1);
-    debugSM->cd(1);
-    if(ch2dSM) ch2dSM->Draw("lego");
-    debugSM->cd(2);
-    if(ph2dSM) ph2dSM->Draw("lego");
-     
-  }
-
-  if(ch2d || ph2d) {
-    
-    TCanvas *debug = new TCanvas("CalibrationObjects","CalibrationObjects",10,10,510,510);
-    debug->Divide(2,1);
-    debug->cd(1);
-    if(ch2d) ch2d->Draw("lego");
-    debug->cd(2);
-    if(ph2d) ph2d->Draw("lego");
-     
-  }
-}
-
+\r
+/**************************************************************************\r
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ *                                                                        *\r
+ * Author: The ALICE Off-line Project.                                    *\r
+ * Contributors are mentioned in the code where appropriate.              *\r
+ *                                                                        *\r
+ * Permission to use, copy, modify and distribute this software and its   *\r
+ * documentation strictly for non-commercial purposes is hereby granted   *\r
+ * without fee, provided that the above copyright notice appears in all   *\r
+ * copies and that both the copyright notice and this permission notice   *\r
+ * appear in the supporting documentation. The authors make no claims     *\r
+ * about the suitability of this software for any purpose. It is          *\r
+ * provided "as is" without express or implied warranty.                  *\r
+ **************************************************************************/\r
+\r
+/////////////////////////////////////////////////////////////////////////////////\r
+//                                                                             \r
+// AliTRDCalibTask                                                               \r
+//                                                                             \r
+// Offline TRD calibration task                                \r
+//                        \r
+// Author:\r
+//   R. Bailhache (R.Bailhache@gsi.de)\r
+//                            \r
+//////////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+#include "Riostream.h"\r
+#include "TChain.h"\r
+#include "TTree.h"\r
+#include "TFile.h"\r
+#include "TProfile2D.h"\r
+#include "TH2I.h"\r
+#include "TH1F.h"\r
+#include "TH2F.h"\r
+#include "TList.h"\r
+#include "TMath.h"\r
+#include "TObject.h"\r
+#include "TObjArray.h"\r
+#include "TString.h"\r
+#include "TCanvas.h"\r
+#include "TLegend.h"\r
+#include "TStyle.h"\r
+#include "TLine.h"\r
+\r
+#include "AliAnalysisTask.h"\r
+#include "AliAnalysisManager.h"\r
+\r
+#include "AliESDVertex.h"\r
+#include "AliESDEvent.h"\r
+#include "AliESDfriend.h"\r
+#include "AliESDInputHandler.h"\r
+#include "AliESDtrack.h"\r
+#include "AliESDfriendTrack.h"\r
+#include "AliTRDtrackV1.h"\r
+#include "AliTRDseedV1.h"\r
+#include "AliTRDcluster.h"\r
+#include "AliTRDgeometry.h"\r
+#include "AliESDtrackCuts.h"\r
+#include "AliESDVertex.h"\r
+#include "AliTRDCalDet.h"\r
+\r
+#include "AliTRDCalibraFillHisto.h"\r
+#include "AliTRDCalibraVdriftLinearFit.h" \r
+\r
+#include "AliTRDcalibDB.h"\r
+\r
+\r
+#include "AliTRDCalibTask.h"\r
+\r
+\r
+ClassImp(AliTRDCalibTask)\r
+\r
+//________________________________________________________________________\r
+  AliTRDCalibTask::AliTRDCalibTask(const char *name) \r
+    : AliAnalysisTask(name, ""), fESD(0), fESDfriend(0),\r
+      fkEsdTrack(0),\r
+      fFriendTrack(0),\r
+      fCalibObject(0),\r
+      fTrdTrack(0),\r
+      fCl(0),\r
+      fListHist(0),\r
+      fTRDCalibraFillHisto(0),\r
+      fNEvents(0),\r
+      fNbTRDTrack(0),\r
+      fNbTRDTrackOffline(0),\r
+      fNbTRDTrackStandalone(0),\r
+      fNbTPCTRDtrack(0),\r
+      fNbTimeBin(0),\r
+      fNbTimeBinOffline(0),\r
+      fNbTimeBinStandalone(0),\r
+      fNbClusters(0),\r
+      fNbClustersOffline(0),\r
+      fNbClustersStandalone(0),\r
+      fNbTracklets(0),\r
+      fNbTrackletsOffline(0),\r
+      fNbTrackletsStandalone(0),\r
+      fCH2dSum(0),\r
+      fPH2dSum(0),\r
+      fCH2dSM(0),\r
+      fPH2dSM(0),\r
+      fHisto2d(kTRUE),\r
+      fVector2d(kFALSE),\r
+      fVdriftLinear(kTRUE),\r
+      fNbTimeBins(0),\r
+      fSelectedTrigger(new TObjArray()),\r
+      fRejected(kTRUE),\r
+      fEsdTrackCuts(0),\r
+      fRequirePrimaryVertex(kFALSE),\r
+      fVtxTPC(kFALSE),\r
+      fVtxSPD(kFALSE),\r
+      fMinNbContributors(0),\r
+      fLow(0),\r
+      fHigh(30),\r
+      fFillZero(kFALSE),\r
+      fNormalizeNbOfCluster(kFALSE),\r
+      fRelativeScale(0.0),\r
+      fMaxCluster(100.0),\r
+      fNbMaxCluster(2),\r
+      fOfflineTracks(kFALSE),\r
+      fStandaloneTracks(kFALSE),\r
+      fCalDetGain(0x0),\r
+      fMaxEvent(0),\r
+      fCounter(0),\r
+      fDebug(0)\r
+{\r
+  //\r
+  // Default constructor\r
+  //\r
+\r
+  fNz[0] = 0;\r
+  fNz[1] = 0;\r
+  fNz[2] = 0;\r
+  \r
+  fNrphi[0] = 0;\r
+  fNrphi[1] = 0;\r
+  fNrphi[2] = 0;\r
+\r
+  // Define input and output slots here\r
+  // Input slot #0 works with a TChain\r
+  DefineInput(0, TChain::Class());\r
+    \r
+  // Output slot #0 writes into a TList container\r
+  DefineOutput(0, TList::Class());\r
+  \r
+   \r
+}\r
+//____________________________________________________________________________________\r
+AliTRDCalibTask::~AliTRDCalibTask()\r
+{\r
+  //\r
+  // AliTRDCalibTask destructor\r
+  //\r
+\r
+  // Pointeur\r
+  if(fNEvents) delete fNEvents;\r
+  if(fNbTRDTrack) delete fNbTRDTrack;\r
+  if(fNbTRDTrackOffline) delete fNbTRDTrackOffline;\r
+  if(fNbTRDTrackStandalone) delete fNbTRDTrackStandalone;\r
+  if(fNbTPCTRDtrack) delete fNbTPCTRDtrack;\r
+  if(fNbTimeBin) delete fNbTimeBin;\r
+  if(fNbTimeBinOffline) delete fNbTimeBinOffline;\r
+  if(fNbTimeBinStandalone) delete fNbTimeBinStandalone;\r
+  if(fNbClusters) delete fNbClusters;\r
+  if(fNbClustersOffline) delete fNbClustersOffline;\r
+  if(fNbClustersStandalone) delete fNbClustersStandalone;\r
+  if(fNbTracklets) delete fNbTracklets;\r
+  if(fNbTrackletsOffline) delete fNbTrackletsOffline;\r
+  if(fNbTrackletsStandalone) delete fNbTrackletsStandalone;\r
+  if(fCH2dSum) delete fCH2dSum;\r
+  if(fPH2dSum) delete fPH2dSum;\r
+  if(fCH2dSM) delete fCH2dSM;\r
+  if(fPH2dSM) delete fPH2dSM;\r
+  if(fCalDetGain) delete fCalDetGain;\r
+  \r
+  if(fSelectedTrigger) {\r
+    fSelectedTrigger->Delete();\r
+    delete fSelectedTrigger;\r
+  }\r
+  if(fEsdTrackCuts) {\r
+    delete fEsdTrackCuts;\r
+  }\r
+  \r
+}\r
+//________________________________________________________________________\r
+void AliTRDCalibTask::ConnectInputData(Option_t *) \r
+{\r
+  // Connect ESD or AOD here\r
+  // Called once\r
+  \r
+  TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); //pointer wird "umgecastet" auf anderen Variablentyp\r
+  if (!tree) {\r
+    //Printf("ERROR: Could not read chain from input slot 0");\r
+  } else {\r
+    \r
+    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
+    \r
+    if (!esdH) {\r
+      //Printf("ERROR: Could not get ESDInputHandler");\r
+    } else {\r
+      fESD = esdH->GetEvent();\r
+      esdH->SetActiveBranches("ESDfriend*");\r
+      //Printf("*** CONNECTED NEW EVENT ****");\r
+    }\r
+    \r
+  }\r
+}\r
+//________________________________________________________________________\r
+void AliTRDCalibTask::CreateOutputObjects() \r
+{\r
+  //\r
+  // Create the histos\r
+  //\r
+\r
+  // Number of time bins\r
+  if(fNbTimeBins==0) {\r
+    AliTRDcalibDB *cal = AliTRDcalibDB::Instance();\r
+    fNbTimeBins = cal->GetNumberOfTimeBinsDCS();\r
+    if(fNbTimeBins <= 0){ \r
+      AliWarning(Form("No of TimeBins from DB [%d] use default [30]", fNbTimeBins));\r
+      fNbTimeBins = 30;\r
+    }\r
+  }\r
+  \r
+  // instance calibration \r
+  fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();\r
+  fTRDCalibraFillHisto->SetHisto2d(fHisto2d); // choose to use histograms\r
+  fTRDCalibraFillHisto->SetVector2d(fVector2d); // choose to use vectors\r
+  fTRDCalibraFillHisto->SetCH2dOn();  // choose to calibrate the gain\r
+  fTRDCalibraFillHisto->SetPH2dOn();  // choose to calibrate the drift velocity\r
+  fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF\r
+  fTRDCalibraFillHisto->SetLinearFitterOn(fVdriftLinear); // Other possibility vdrift VDRIFT\r
+  fTRDCalibraFillHisto->SetLinearFitterDebugOn(fVdriftLinear); // Other possibility vdrift\r
+  for(Int_t k = 0; k < 3; k++){\r
+    if(((fNz[k] != 10) && (fNrphi[k] != 10)) && ((fNz[k] != 100) && (fNrphi[k] != 100))) {\r
+      fTRDCalibraFillHisto->SetNz(k,fNz[k]);                                    // Mode calibration\r
+      fTRDCalibraFillHisto->SetNrphi(k,fNrphi[k]);                             // Mode calibration\r
+    }\r
+    else {\r
+      if((fNz[k] == 100) && (fNrphi[k] == 100))  {\r
+       if(fVector2d) AliInfo("The mode all together is not supported by the vector method");\r
+       fTRDCalibraFillHisto->SetAllTogether(k);\r
+      }\r
+      if((fNz[k] == 10) && (fNrphi[k] == 10))  {\r
+       if(fVector2d) AliInfo("The mode per supermodule is not supported by the vector method");\r
+       fTRDCalibraFillHisto->SetPerSuperModule(k);\r
+      }\r
+    }\r
+  }\r
+  // Variables for how to fill\r
+  fTRDCalibraFillHisto->SetFillWithZero(fFillZero);\r
+  fTRDCalibraFillHisto->SetNormalizeNbOfCluster(fNormalizeNbOfCluster); \r
+  fTRDCalibraFillHisto->SetMaxCluster(fMaxCluster);\r
+  fTRDCalibraFillHisto->SetNbMaxCluster(fNbMaxCluster);\r
+  \r
+  // Init with 30 timebins\r
+  fTRDCalibraFillHisto->Init2Dhistos(fNbTimeBins); // initialise the histos\r
+  fTRDCalibraFillHisto->SetNumberClusters(fLow); // At least 11 clusters\r
+  fTRDCalibraFillHisto->SetNumberClustersf(fHigh); // At least 11 clusters\r
+  fRelativeScale = fTRDCalibraFillHisto->GetRelativeScale(); // Get the relative scale for the gain\r
+  \r
+  // For testing only\r
+  if(fDebug > 2) fTRDCalibraFillHisto->SetDebugLevel(1); //debug stuff\r
+  \r
+  // output list\r
+  fListHist = new TList();\r
+  if(fHisto2d) {  \r
+    fListHist->Add(fTRDCalibraFillHisto->GetCH2d());\r
+    fListHist->Add(fTRDCalibraFillHisto->GetPH2d()); \r
+    fListHist->Add(fTRDCalibraFillHisto->GetPRF2d());\r
+  } \r
+  if(fVdriftLinear) fListHist->Add((TObject *) fTRDCalibraFillHisto->GetVdriftLinearFit());\r
+  if(fVector2d) fListHist->Add((TObject *) fTRDCalibraFillHisto->GetCalibraVector()); //calibra vector  \r
+  fNEvents = new TH1I("NEvents","NEvents", 2, 0, 2);\r
+  fListHist->Add(fNEvents);\r
+  \r
+  /////////////////////////////////////////\r
+  // First debug level\r
+  ///////////////////////////////////////\r
+  if(fDebug > 0) {\r
+    \r
+    fPH2dSM = new TProfile2D("PH2dSM","Nz10Nrphi10"\r
+                           ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)\r
+                          ,18,0,18);\r
+    fPH2dSM->SetYTitle("Det/pad groups");\r
+    fPH2dSM->SetXTitle("time [#mus]");\r
+    fPH2dSM->SetZTitle("<PH> [a.u.]");\r
+    fPH2dSM->SetStats(0);\r
+    //\r
+    fCH2dSM = new TH2I("CH2dSM","Nz10Nrphi10",50,0,300,18,0,18);\r
+    fCH2dSM->SetYTitle("Det/pad groups");\r
+    fCH2dSM->SetXTitle("charge deposit [a.u]");\r
+    fCH2dSM->SetZTitle("counts");\r
+    fCH2dSM->SetStats(0);\r
+    fCH2dSM->Sumw2();\r
+    //\r
+    fPH2dSum = new TProfile2D("PH2dSum","Nz100Nrphi100"\r
+                           ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)\r
+                           ,1,0,1);\r
+    fPH2dSum->SetYTitle("Det/pad groups");\r
+    fPH2dSum->SetXTitle("time [#mus]");\r
+    fPH2dSum->SetZTitle("<PH> [a.u.]");\r
+    fPH2dSum->SetStats(0);\r
+    //\r
+    fCH2dSum = new TH2I("CH2dSum","Nz100Nrphi100",50,0,300,1,0,1);\r
+    fCH2dSum->SetYTitle("Det/pad groups");\r
+    fCH2dSum->SetXTitle("charge deposit [a.u]");\r
+    fCH2dSum->SetZTitle("counts");\r
+    fCH2dSum->SetStats(0);\r
+    fCH2dSum->Sumw2();\r
+    \r
+    // Add them\r
+    fListHist->Add(fPH2dSM);\r
+    fListHist->Add(fCH2dSM);\r
+    fListHist->Add(fPH2dSum);\r
+    fListHist->Add(fCH2dSum);\r
+  }\r
+\r
+  /////////////////////////////////////////\r
+  // Second debug level\r
+  ///////////////////////////////////////\r
+  if(fDebug > 1) {\r
+\r
+    fNbTRDTrack = new TH1F("TRDTrack","TRDTrack",50,0,50);\r
+    fNbTRDTrack->Sumw2();\r
+    fNbTRDTrackOffline = new TH1F("TRDTrackOffline","TRDTrackOffline",50,0,50);\r
+    fNbTRDTrackOffline->Sumw2();\r
+    fNbTRDTrackStandalone = new TH1F("TRDTrackStandalone","TRDTrackStandalone",50,0,50);\r
+    fNbTRDTrackStandalone->Sumw2();\r
+    fNbTPCTRDtrack = new TH2F("NbTPCTRDtrack","NbTPCTRDtrack",100,0,100,100,0,100);\r
+    fNbTPCTRDtrack->Sumw2();\r
+    //\r
+    fNbTimeBin = new TH1F("NbTimeBin","NbTimeBin",35,0,35);\r
+    fNbTimeBin->Sumw2();\r
+    fNbTimeBinOffline = new TH1F("NbTimeBinOffline","NbTimeBinOffline",35,0,35);\r
+    fNbTimeBinOffline->Sumw2();\r
+    fNbTimeBinStandalone = new TH1F("NbTimeBinStandalone","NbTimeBinStandalone",35,0,35);\r
+    fNbTimeBinStandalone->Sumw2();\r
+    //\r
+    fNbClusters = new TH1F("NbClusters","",35,0,35);\r
+    fNbClusters->Sumw2();\r
+    fNbClustersOffline = new TH1F("NbClustersOffline","",35,0,35);\r
+    fNbClustersOffline->Sumw2();\r
+    fNbClustersStandalone = new TH1F("NbClustersStandalone","",35,0,35);\r
+    fNbClustersStandalone->Sumw2();\r
+    //\r
+    fNbTracklets = new TH1F("NbTracklets","NbTracklets",540,0.,540.);\r
+    fNbTracklets->Sumw2();\r
+    fNbTrackletsOffline = new TH1F("NbTrackletsOffline","NbTrackletsOffline",540,0.,540.);\r
+    fNbTrackletsOffline->Sumw2();\r
+    fNbTrackletsStandalone = new TH1F("NbTrackletsStandalone","NbTrackletsStandalone",540,0.,540.);\r
+    fNbTrackletsStandalone->Sumw2();\r
+   \r
+    fListHist->Add(fNbTRDTrack);\r
+    fListHist->Add(fNbTRDTrackOffline);\r
+    fListHist->Add(fNbTRDTrackStandalone);\r
+    fListHist->Add(fNbTPCTRDtrack);\r
+    \r
+    fListHist->Add(fNbTimeBin);\r
+    fListHist->Add(fNbTimeBinOffline);\r
+    fListHist->Add(fNbTimeBinStandalone);\r
+    fListHist->Add(fNbClusters);\r
+    fListHist->Add(fNbClustersOffline);\r
+    fListHist->Add(fNbClustersStandalone);\r
+    fListHist->Add(fNbTracklets);\r
+    fListHist->Add(fNbTrackletsOffline);\r
+    fListHist->Add(fNbTrackletsStandalone);\r
+    \r
+  }\r
+  \r
+ }\r
+ //________________________________________________________________________\r
+ void AliTRDCalibTask::Exec(Option_t *) \r
+ {\r
+   //\r
+   // Filling of the histos\r
+   //\r
+\r
+   AliLog::SetGlobalLogLevel(AliLog::kError);\r
+\r
+   if (!fESD) {\r
+     //Printf("ERROR: fESD not available");\r
+     return;\r
+   }\r
+\r
+   //printf("Counter %d\n",fCounter);\r
+\r
+   fCounter++;\r
+   if((fMaxEvent != 0) && (fMaxEvent < fCounter)) return;\r
+\r
+   //printf("Counter %d\n",fCounter);\r
+\r
+   ///////////////////////////////\r
+   // Require a primary vertex\r
+   //////////////////////////////\r
+   if(fRequirePrimaryVertex) {\r
+     const AliESDVertex* vtxESD = 0x0;\r
+     if      (fVtxTPC) vtxESD = fESD->GetPrimaryVertexTPC() ;\r
+     else if (fVtxSPD) vtxESD = fESD->GetPrimaryVertexSPD() ;\r
+     else              vtxESD = fESD->GetPrimaryVertexTracks() ;\r
+     if(!vtxESD){\r
+       return;\r
+     }\r
+     Int_t nCtrb = vtxESD->GetNContributors();\r
+     if(nCtrb < fMinNbContributors) return;\r
+   }\r
+\r
+   //printf("Primary vertex passed\n");\r
+\r
+   ///////////////////\r
+   // Check trigger\r
+   ///////////////////\r
+   //printf("Class Fired %s\n",(const char*)fESD->GetFiredTriggerClasses());\r
+   Bool_t pass = kTRUE;\r
+   Int_t numberOfTriggerSelected = fSelectedTrigger->GetEntriesFast();\r
+   //printf("numberofTriggerSelected %d\n",numberOfTriggerSelected);\r
+   if(fRejected) {\r
+     pass = kTRUE;\r
+     for(Int_t k = 0; k < numberOfTriggerSelected; k++){\r
+       const TObjString *const obString=(TObjString*)fSelectedTrigger->At(k);\r
+       const TString tString=obString->GetString();\r
+       if(fESD->IsTriggerClassFired((const char*)tString)) {\r
+        pass = kFALSE;\r
+       }\r
+     }\r
+   }\r
+   else {\r
+     pass = kFALSE;\r
+     for(Int_t k = 0; k < numberOfTriggerSelected; k++){\r
+       const TObjString *const obString=(TObjString*)fSelectedTrigger->At(k);\r
+       const TString tString=obString->GetString();\r
+       if(fESD->IsTriggerClassFired((const char*)tString)) {\r
+        pass = kTRUE;\r
+       }\r
+     }\r
+   }\r
+   if(!pass) return;   \r
+\r
+   //printf("Trigger passed\n");\r
+  \r
+   fNEvents->Fill(1);\r
+\r
+   // In total\r
+   Int_t nbTrdTracks = 0;\r
+   // standalone\r
+   Int_t nbTrdTracksStandalone = 0;\r
+   // offline\r
+   Int_t nbTrdTracksOffline = 0;\r
+   // TPC\r
+   Int_t nbtrackTPC = 0;\r
+\r
+   Double_t nbTracks = fESD->GetNumberOfTracks();\r
+   //printf("Number of tracks %f\n",nbTracks);  \r
+\r
+   if (nbTracks <= 0.0) {\r
+     \r
+     if(fDebug > 1) {\r
+       fNbTRDTrack->Fill(nbTrdTracks);\r
+       fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);\r
+       fNbTRDTrackOffline->Fill(nbTrdTracksOffline);\r
+     }\r
+     PostData(0, fListHist);\r
+     return;\r
+   }\r
+\r
+   fESDfriend = (AliESDfriend *)fESD->FindListObject("AliESDfriend");\r
+   fESD->SetESDfriend(fESDfriend);\r
+   if(!fESDfriend) return;   \r
+   \r
+   //printf("has friends\n");\r
+\r
+   ////////////////////////////////////\r
+   // Check the number of TPC tracks\r
+   ///////////////////////////////////\r
+   //printf("Nb of tracks %f\n",nbTracks);\r
+   for(Int_t itrk = 0; itrk < nbTracks; itrk++){\r
+     // Get ESD track\r
+     fkEsdTrack = fESD->GetTrack(itrk);\r
+     ULong_t status = fkEsdTrack->GetStatus(); \r
+     if(status&(AliESDtrack::kTPCout)) nbtrackTPC++;\r
+     // Check that the calibration object is here\r
+     if(fESDfriend && (fESDfriend->GetTrack(itrk))) {\r
+       fFriendTrack = new AliESDfriendTrack(*(fESDfriend->GetTrack(itrk)));\r
+       Int_t counteer = 0;\r
+       Int_t icalib=0;\r
+       while((fCalibObject = (TObject *)(fFriendTrack->GetCalibObject(icalib++)))){\r
+        if(strcmp(fCalibObject->IsA()->GetName(), "AliTRDtrackV1") != 0) continue;\r
+        counteer++;\r
+       }\r
+       if(counteer > 0) {\r
+        nbTrdTracks++;\r
+        if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {\r
+          nbTrdTracksStandalone++;\r
+        }\r
+        if((status&(AliESDtrack::kTRDin))) {\r
+          nbTrdTracksOffline++;\r
+        }\r
+       }\r
+       if(fFriendTrack) delete fFriendTrack;\r
+     }\r
+   }\r
+   //printf("Number of TPC tracks %d, TRD %d\n",nbtrackTPC,nbTrdTracks);\r
+   if((nbtrackTPC>0) && (nbTrdTracks > (3.0*nbtrackTPC))) pass = kFALSE;\r
+   \r
+   if(fDebug > 1) {\r
+     \r
+     fNbTRDTrack->Fill(nbTrdTracks);\r
+     fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);\r
+     fNbTRDTrackOffline->Fill(nbTrdTracksOffline);\r
+     fNbTPCTRDtrack->Fill(nbTrdTracks,nbtrackTPC);\r
+   \r
+   }\r
+\r
+   if(!pass) {\r
+     PostData(0, fListHist);\r
+     return;\r
+   }\r
+   //printf("Pass\n");  \r
+\r
+   /////////////////////////////////////\r
+   // Loop on AliESDtrack\r
+   ////////////////////////////////////\r
+   //printf("Nb of tracks %f\n",nbTracks);      \r
+   for(int itrk=0; itrk < nbTracks; itrk++){\r
+\r
+     // Get ESD track\r
+     fkEsdTrack = fESD->GetTrack(itrk);\r
+     if(!fkEsdTrack) continue;\r
+\r
+     // Quality cuts on the AliESDtrack\r
+     if((fEsdTrackCuts) && (!fEsdTrackCuts->IsSelected((AliVParticle *)fkEsdTrack))) {\r
+       //printf("Not a good track\n");\r
+       continue;\r
+     }\r
+     \r
+     // Other cuts\r
+     Bool_t good = kTRUE;\r
+     Bool_t standalonetrack = kFALSE;\r
+     Bool_t offlinetrack = kFALSE;\r
+     ULong_t status = fkEsdTrack->GetStatus();\r
+     \r
+     if(!(fESDfriend->GetTrack(itrk)))  continue;   \r
+     \r
+     fFriendTrack = new AliESDfriendTrack(*(fESDfriend->GetTrack(itrk)));\r
+     \r
+     //////////////////////////////////////\r
+     // Loop on calibration objects\r
+     //////////////////////////////////////\r
+     Int_t icalib=0;\r
+     while((fCalibObject = (TObject *)(fFriendTrack->GetCalibObject(icalib++)))){\r
+       if(strcmp(fCalibObject->IsA()->GetName(), "AliTRDtrackV1") != 0) continue;\r
+       //printf("Find the calibration object\n");\r
+\r
+       if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {\r
+        standalonetrack = kTRUE;\r
+       }\r
+       if((status&(AliESDtrack::kTRDin))) {\r
+        offlinetrack = kTRUE;\r
+       }\r
+       if(fOfflineTracks){\r
+        if(!offlinetrack){\r
+          good = kFALSE;\r
+        }\r
+       }\r
+       else if(fStandaloneTracks){\r
+        if(!standalonetrack){\r
+          good = kFALSE;\r
+        }\r
+       }\r
+       \r
+       fTrdTrack = (AliTRDtrackV1 *)fCalibObject;\r
+       if(good) {\r
+        fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack);\r
+        //printf("Fill fTRDCalibraFillHisto\n");\r
+       }\r
+       \r
+       //////////////////////////////////\r
+       // Debug \r
+       ////////////////////////////////\r
+\r
+       if(fDebug > 0) {\r
+        \r
+        //printf("Enter debug\n");\r
+        \r
+        Int_t nbtracklets = 0;\r
+        \r
+        // Check some stuff\r
+        Bool_t standalonetracklet = kFALSE;  \r
+        const AliTRDseedV1 *tracklet = 0x0;\r
+        //////////////////////////////////////\r
+        // Loop tracklets\r
+        ///////////////////////////////////// \r
+        for(Int_t itr = 0; itr < 6; itr++){\r
+          \r
+          if(!(tracklet = fTrdTrack->GetTracklet(itr))) continue;\r
+          if(!tracklet->IsOK()) continue;\r
+          nbtracklets++;\r
+          standalonetracklet = kFALSE; \r
+          if(tracklet->IsStandAlone()) standalonetracklet = kTRUE;\r
+\r
+          Int_t nbclusters = 0;\r
+          Double_t phtb[AliTRDseedV1::kNtb];\r
+          memset(phtb, 0, AliTRDseedV1::kNtb*sizeof(Double_t));\r
+          Double_t sum = 0.0;\r
+          Float_t normalisation = 6.67;\r
+          Int_t detector = 0;\r
+          Int_t sector = 0;\r
+          //Int_t crossrow = 0;\r
+          \r
+          // Check no shared clusters\r
+          //for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){\r
+          //  if((fcl = tracklet->GetClusters(icc)))  crossrow = 1;\r
+          // }\r
+          \r
+          // Loop on clusters\r
+          for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){\r
+            \r
+            if(!(fCl = tracklet->GetClusters(ic))) continue;\r
+            nbclusters++;\r
+            Int_t time = fCl->GetPadTime();\r
+            Float_t ch =  tracklet->GetdQdl(ic);\r
+            Float_t qcl = TMath::Abs(fCl->GetQ());\r
+            detector = fCl->GetDetector();       \r
+            // Add the charge if shared cluster\r
+            if((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) {\r
+              if((fCl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb))) {\r
+                qcl += TMath::Abs(fCl->GetQ());\r
+              }\r
+            }\r
+            if((time>-1) && (time<fNbTimeBins)) phtb[time]=qcl;\r
+            if((fCalDetGain) && (fCalDetGain->GetValue(detector) > 0.0)) sum += ch*fCalDetGain->GetValue(detector)/normalisation;      \r
+            else sum += ch/normalisation;\r
+            \r
+            if(fDebug > 1) {\r
+              fNbTimeBin->Fill(time);\r
+              if(tracklet->IsStandAlone()) fNbTimeBinStandalone->Fill(time);\r
+              else fNbTimeBinOffline->Fill(time);\r
+            }\r
+          }\r
+          sector = AliTRDgeometry::GetSector(detector);\r
+          \r
+          if(fDebug > 1) {\r
+            fNbTracklets->Fill(detector);\r
+            if(tracklet->IsStandAlone()) fNbTrackletsStandalone->Fill(detector);\r
+            else fNbTrackletsOffline->Fill(detector);\r
+          \r
+            fNbClusters->Fill(nbclusters);\r
+            if(tracklet->IsStandAlone())  fNbClustersStandalone->Fill(nbclusters);\r
+            else  fNbClustersOffline->Fill(nbclusters);\r
+          }       \r
+\r
+          if(fDebug > 0) {\r
+            if((nbclusters > fLow) && (nbclusters < fHigh)){\r
+              if(fRelativeScale > 0.0) sum = sum/fRelativeScale;              \r
+              fCH2dSM->Fill(sum,sector+0.5);\r
+              fCH2dSum->Fill(sum,0.5);\r
+              Bool_t checknoise = kTRUE;\r
+              if(fMaxCluster > 0) {\r
+                if(phtb[0] > fMaxCluster) checknoise = kFALSE;\r
+                if(fNbTimeBins > fNbMaxCluster) {\r
+                  for(Int_t k = (fNbTimeBins-fNbMaxCluster); k < fNbTimeBins; k++){\r
+                    if(phtb[k] > fMaxCluster) checknoise = kFALSE;\r
+                  }\r
+                }\r
+              }\r
+              if(checknoise) {        \r
+                for(int ic=0; ic<fNbTimeBins; ic++){\r
+                  if(fFillZero) {\r
+                    fPH2dSum->Fill((Double_t)(ic/10.0),0.5,(Double_t)phtb[ic]);\r
+                    fPH2dSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);\r
+                  }\r
+                  else {\r
+                    if(phtb[ic] > 0.0) {\r
+                      fPH2dSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);\r
+                      fPH2dSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);\r
+                    }\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+        } // loop on tracklets\r
+    \r
+       } // debug\r
+       \r
+     }// while calibration objects\r
+     \r
+     delete fFriendTrack;\r
+     \r
+   } // loop ESD track\r
+   \r
+   // Post output data\r
+   PostData(0, fListHist);\r
+ }     \r
+//________________________________________________________________________\r
+void AliTRDCalibTask::Terminate(Option_t *) \r
+{\r
+  //\r
+  // Terminate\r
+  //\r
+  \r
+  if(fTRDCalibraFillHisto) fTRDCalibraFillHisto->DestroyDebugStreamer();\r
+\r
\r
+}\r
+//_______________________________________________________\r
+Bool_t AliTRDCalibTask::Load(const Char_t *filename)\r
+{\r
+  //\r
+  // Generic container loader\r
+  //\r
+\r
+  if(!TFile::Open(filename)){\r
+    //AliWarning(Form("Couldn't open file %s.", filename));\r
+    return kFALSE;\r
+  }\r
+  TList *o = 0x0;\r
+  if(!(o = (TList*)gFile->Get(GetName()))){\r
+    //AliWarning("Missing histogram container.");\r
+    return kFALSE;\r
+  }\r
+  fListHist = (TList*)o->Clone(GetName());\r
+  gFile->Close();\r
+  return kTRUE;\r
+}\r
+//________________________________________________________________________\r
+void AliTRDCalibTask::Plot() \r
+{\r
+  //\r
+  // Plot the histos stored in the TList\r
+  //\r
\r
+  if(!fListHist) return;\r
+\r
+  /////////////////////////////////////\r
+  // Take the debug stuff\r
+  /////////////////////////////////////\r
+\r
+  TH1I *nEvents  = (TH1I *) fListHist->FindObject("NEvents");\r
+\r
+  TH1F *trdTrack = (TH1F *) fListHist->FindObject("TRDTrack");\r
+  TH1F *trdTrackOffline = (TH1F *) fListHist->FindObject("TRDTrackOffline");\r
+  TH1F *trdTrackStandalone = (TH1F *) fListHist->FindObject("TRDTrackStandalone");\r
+\r
+  TH2F *tpctrdTrack = (TH2F *) fListHist->FindObject("NbTPCTRDtrack");\r
+\r
+  TH1F *nbTimeBin = (TH1F *) fListHist->FindObject("NbTimeBin");\r
+  TH1F *nbTimeBinOffline = (TH1F *) fListHist->FindObject("NbTimeBinOffline");\r
+  TH1F *nbTimeBinStandalone = (TH1F *) fListHist->FindObject("NbTimeBinStandalone");\r
+\r
+  TH1F *nbClusters = (TH1F *) fListHist->FindObject("NbClusters");\r
+  TH1F *nbClustersOffline = (TH1F *) fListHist->FindObject("NbClustersOffline");\r
+  TH1F *nbClustersStandalone = (TH1F *) fListHist->FindObject("NbClustersStandalone");\r
+\r
+  TH1F *nbTracklets = (TH1F *) fListHist->FindObject("NbTracklets");\r
+  TH1F *nbTrackletsOffline = (TH1F *) fListHist->FindObject("NbTrackletsOffline");\r
+  TH1F *nbTrackletsStandalone = (TH1F *) fListHist->FindObject("NbTrackletsStandalone");\r
+  \r
+  /////////////////////////////////////\r
+  // Take the calibration objects\r
+  /////////////////////////////////////\r
+\r
+  TH2I *ch2d = (TH2I *) fListHist->FindObject("CH2d");\r
+  TProfile2D *ph2d = (TProfile2D *) fListHist->FindObject("PH2d");\r
+\r
+  TH2I *ch2dSum = (TH2I *) fListHist->FindObject("CH2dSum");\r
+  TProfile2D *ph2dSum = (TProfile2D *) fListHist->FindObject("PH2dSum");\r
+\r
+  TH2I *ch2dSM = (TH2I *) fListHist->FindObject("CH2dSM");\r
+  TProfile2D *ph2dSM = (TProfile2D *) fListHist->FindObject("PH2dSM");\r
+  \r
+  AliTRDCalibraVdriftLinearFit *linearfit = (AliTRDCalibraVdriftLinearFit *) fListHist->FindObject("AliTRDCalibraVdriftLinearFit");\r
+  \r
+  ////////////////////////////////////////////////\r
+  // Add the AliTRDCalibraVdriftLinearFit\r
+  ///////////////////////////////////////////////\r
+  \r
+  Int_t first = 0;\r
+  TH2S *histolinearfitsum = 0x0;\r
+  \r
+  if(linearfit) {\r
+    for(Int_t det = 0; det < 540; det++) {\r
+      if(linearfit->GetLinearFitterHisto(det)){\r
+       if(TMath::Abs(first)<0.0001){\r
+         histolinearfitsum = linearfit->GetLinearFitterHisto(det);\r
+         first += 1;\r
+       }\r
+       else {\r
+         histolinearfitsum ->Add(linearfit->GetLinearFitterHisto(det));\r
+       }\r
+      }\r
+    }\r
+  }\r
+\r
+  ///////////////////////////\r
+  // Style\r
+  //////////////////////////\r
+\r
+  gStyle->SetPalette(1);\r
+  gStyle->SetOptStat(1111);\r
+  gStyle->SetOptFit(1111);\r
+  gStyle->SetPadBorderMode(0);\r
+  gStyle->SetCanvasColor(10);\r
+  gStyle->SetPadLeftMargin(0.13);\r
+  gStyle->SetPadRightMargin(0.13);\r
+\r
+  /////////////////////////\r
+  // Plot\r
+  ////////////////////////\r
+\r
+ if(nEvents) {\r
+   \r
+    TCanvas *debugEvents = new TCanvas("cNEvents","cNEvents",10,10,510,510);\r
+    debugEvents->cd(1);\r
+    if(nEvents) nEvents->Draw();\r
+      \r
+  }\r
+\r
+  if(trdTrack || tpctrdTrack) {\r
+    \r
+    TCanvas *debugtrdtpcTrack = new TCanvas("TRDtracktpctrdtrack","TRDtracktpctrdtrack",10,10,510,510);\r
+    debugtrdtpcTrack->Divide(2,1);\r
+    debugtrdtpcTrack->cd(1);\r
+    if(trdTrack) trdTrack->Draw();\r
+    if(trdTrackOffline) trdTrackOffline->Draw("same");\r
+    if(trdTrackStandalone) trdTrackStandalone->Draw("same");\r
+    TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);\r
+    if(trdTrack) leg->AddEntry(trdTrack,"All","p");\r
+    if(trdTrackOffline) leg->AddEntry(trdTrackOffline,"Offline","p");\r
+    if(trdTrackStandalone) leg->AddEntry(trdTrackStandalone,"Standalone","p");\r
+    leg->Draw("same");\r
+    debugtrdtpcTrack->cd(2);\r
+    if(tpctrdTrack) tpctrdTrack->Draw();\r
+    TLine *line = new TLine(0.0,0.0,100.0,100.0);\r
+    line->Draw("same");\r
+    \r
+  }\r
\r
+  if(nbTimeBin || nbTracklets || nbClusters) {\r
+    \r
+    TCanvas *debugTracklets = new TCanvas("TRDtimebintrackletcluster","TRDtimebintrackletcluster",10,10,510,510);\r
+    debugTracklets->Divide(3,1);\r
+    debugTracklets->cd(1);\r
+    if(nbTimeBin) nbTimeBin->Draw();\r
+    if(nbTimeBinOffline) nbTimeBinOffline->Draw("same");\r
+    if(nbTimeBinStandalone) nbTimeBinStandalone->Draw("same");\r
+    TLegend *lega = new TLegend(0.4,0.6,0.89,0.89);\r
+    if(nbTimeBin) lega->AddEntry(nbTimeBin,"All","p");\r
+    if(nbTimeBinOffline) lega->AddEntry(nbTimeBinOffline,"Offline","p");\r
+    if(nbTimeBinStandalone) lega->AddEntry(nbTimeBinStandalone,"Standalone","p");\r
+    lega->Draw("same");\r
+    debugTracklets->cd(2);\r
+    if(nbTracklets) nbTracklets->Draw();\r
+    if(nbTrackletsOffline) nbTrackletsOffline->Draw("same");\r
+    if(nbTrackletsStandalone) nbTrackletsStandalone->Draw("same");\r
+    TLegend *legb = new TLegend(0.4,0.6,0.89,0.89);\r
+    if(nbTracklets) legb->AddEntry(nbTracklets,"All","p");\r
+    if(nbTrackletsOffline) legb->AddEntry(nbTrackletsOffline,"Offline","p");\r
+    if(nbTrackletsStandalone) legb->AddEntry(nbTrackletsStandalone,"Standalone","p");\r
+    legb->Draw("same");\r
+    debugTracklets->cd(3);\r
+    if(nbClusters) nbClusters->Draw();\r
+    if(nbClustersOffline) nbClustersOffline->Draw("same");\r
+    if(nbClustersStandalone) nbClustersStandalone->Draw("same");\r
+    TLegend *legc = new TLegend(0.4,0.6,0.89,0.89);\r
+    if(nbClusters) legc->AddEntry(nbClusters,"All","p");\r
+    if(nbClustersOffline) legc->AddEntry(nbClustersOffline,"Offline","p");\r
+    if(nbClustersStandalone) legc->AddEntry(nbClustersStandalone,"Standalone","p");\r
+    legc->Draw("same");\r
+  \r
+  }\r
+\r
+  if(ch2dSum || ph2dSum || histolinearfitsum) {\r
+    \r
+    TCanvas *debugSum = new TCanvas("SumCalibrationObjects","SumCalibrationObjects",10,10,510,510);\r
+    debugSum->Divide(3,1);\r
+    debugSum->cd(1);\r
+    if(ch2dSum) ch2dSum->Draw("lego");\r
+    debugSum->cd(2);\r
+    if(ph2dSum) ph2dSum->Draw("lego");\r
+    debugSum->cd(3);\r
+    if(histolinearfitsum) histolinearfitsum->Draw();\r
+  \r
+  }\r
+\r
+  if(ch2dSM || ph2dSM) {\r
+    \r
+    TCanvas *debugSM = new TCanvas("SMCalibrationObjects","SMCalibrationObjects",10,10,510,510);\r
+    debugSM->Divide(2,1);\r
+    debugSM->cd(1);\r
+    if(ch2dSM) ch2dSM->Draw("lego");\r
+    debugSM->cd(2);\r
+    if(ph2dSM) ph2dSM->Draw("lego");\r
+     \r
+  }\r
+\r
+  if(ch2d || ph2d) {\r
+    \r
+    TCanvas *debug = new TCanvas("CalibrationObjects","CalibrationObjects",10,10,510,510);\r
+    debug->Divide(2,1);\r
+    debug->cd(1);\r
+    if(ch2d) ch2d->Draw("lego");\r
+    debug->cd(2);\r
+    if(ph2d) ph2d->Draw("lego");\r
+     \r
+  }\r
\r
+}\r
+\r
index 82e0f72..7f4c352 100644 (file)
@@ -28,8 +28,9 @@
 // in the function "FollowBackProlongation" (AliTRDtracker)
 // Per default the functions to fill are off.                                   
 //                        
-// Author:
-//   R. Bailhache (R.Bailhache@gsi.de)
+// Authors:
+//   R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de)
+//   J. Book (jbook@ikf.uni-frankfurt.de)
 //                            
 //////////////////////////////////////////////////////////////////////////////////////
 
 #include "./Cal/AliTRDCalROC.h"
 #include "./Cal/AliTRDCalDet.h"
 
+#include "AliTRDrawFastStream.h"
+#include "AliTRDdigitsManager.h"
+#include "AliTRDdigitsParam.h"
+#include "AliTRDSignalIndex.h"
+#include "AliTRDarrayADC.h"
+
 #ifdef ALI_DATE
 #include "event.h"
 #endif
@@ -217,7 +224,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fNumberClustersProcent(c.fNumberClustersProcent)
   ,fThresholdClustersDAQ(c.fThresholdClustersDAQ)
   ,fNumberRowDAQ(c.fNumberRowDAQ)
-  ,fNumberColDAQ(c.fNumberColDAQ)  
+  ,fNumberColDAQ(c.fNumberColDAQ)
   ,fProcent(c.fProcent)
   ,fDifference(c.fDifference)
   ,fNumberTrack(c.fNumberTrack)
@@ -635,6 +642,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
   
   const AliTRDseedV1 *tracklet = 0x0;          // tracklet per plane
   AliTRDcluster *cl      = 0x0;                // cluster attached now to the tracklet
+  AliTRDcluster *cls     = 0x0;                // shared cluster attached now to the tracklet
   Bool_t         newtr   = kTRUE;              // new track
   
   // Get cal
@@ -700,7 +708,10 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
       Int_t     group[2] = {0,0};
       if(fCH2dOn)  group[0]  = CalculateCalibrationGroup(0,row,col);
       if(fPH2dOn)  group[1]  = CalculateCalibrationGroup(1,row,col);
-      StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col);
+      // Add the charge if shared cluster
+      cls = tracklet->GetClusters(jc+AliTRDseedV1::kNtb);
+      //
+      StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col,cls);
     }
     
     ////////////////////////////////////////
@@ -951,7 +962,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
     fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
     nbli++;  
 
-   
+    
   }
   
   ////////////////////////////////////
@@ -1914,16 +1925,18 @@ void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
 // Per tracklet: store or reset the info, fill the histos with the info
 //////////////////////////////////////////////////////////////////////////////////////////
 //_____________________________________________________________________________
-void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col)
+void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls)
 {
   //
   // Store the infos in fAmpTotal, fPHPlace and fPHValue
   // Correct from the gain correction before
+  // cls is shared cluster if any
   //
   
   // time bin of the cluster not corrected
   Int_t    time     = cl->GetPadTime();
   Float_t  charge   = TMath::Abs(cl->GetQ());  
+  if(cls) charge += TMath::Abs(cls->GetQ());
 
   //printf("Store::time %d, amplitude %f\n",time,dqdl);
   
@@ -2336,8 +2349,8 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo
   fROBPrevious           = -1;
   Int_t nbtimebin = 0;                                        
   Int_t baseline  = 10;  
-
-
+  //printf("------------Detector\n");
+  
   if(!nocheck){
   
     fTimeMax = 0;
@@ -2355,7 +2368,7 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo
        // Fill
        withInput = TMath::Max(FillDAQ(phvalue),withInput);
 
-
+       
        // reset
        for(Int_t k = 0; k < 36; k++){
          for(Int_t j = 0; j < 16; j++){
@@ -2385,7 +2398,7 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo
       Int_t row         = rawStream->GetRow();    
 
       
-      //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
+      // printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
      
                 
       for(Int_t itime = 0; itime < nbtimebin; itime++){
@@ -2412,7 +2425,7 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo
   }
   else{
 
-    while (rawStream->Next()) {
+    while (rawStream->Next()) { //iddetecte
 
       Int_t idetector = rawStream->GetDet();                            //  current detector
       Int_t imcm      = rawStream->GetMCM();                            //  current MCM
@@ -2453,6 +2466,14 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo
       
       for(Int_t itime = 0; itime < fTimeMax; itime++){
        phvalue[row][col][itime] = signal[itime]-baseline;
+       /*if(phvalue[row][col][itime] >= 20) {
+               printf("----------> phvalue[%d][%d][%d] %d  baseline %d \n",
+                      row,
+                      col,
+                      itime,
+                      signal[itime],
+                      baseline);
+                      }*/
       }
     }
     
@@ -2518,6 +2539,145 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(
 #endif
 
 }
+//_____________________________________________________________________
+Int_t AliTRDCalibraFillHisto::ProcessEventDAQ2(AliRawReader *rawReader)
+ { //main
+  //
+  // Event Processing loop - AliTRDrawFastStream
+  // 
+  // 0 timebin problem
+  // 1 no input
+  // 2 input
+  // Same algorithm as TestBeam but different reader
+  //
+
+   //  AliTRDrawFastStream *rawStream = AliTRDrawFastStream::GetRawStream(rawReader);
+  AliTRDrawFastStream *rawStream = new AliTRDrawFastStream(rawReader);
+  rawStream->SetSharedPadReadout(kFALSE);
+
+  AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
+  digitsManager->CreateArrays();
+    
+  Int_t withInput = 1;
+  
+  Double_t phvalue[16][144][36];
+  for(Int_t k = 0; k < 36; k++){
+    for(Int_t j = 0; j < 16; j++){
+      for(Int_t c = 0; c < 144; c++){
+       phvalue[j][c][k] = 0.0;
+      }
+    }
+  }
+  
+  fDetectorPreviousTrack = -1;
+  fMCMPrevious           = -1;
+  fROBPrevious           = -1;
+  
+  Int_t nbtimebin = 0;                                        
+  Int_t baseline  = 10;  
+
+  
+    fTimeMax = 0;
+       
+    Int_t det    = 0;
+    while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
+
+      if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
+       //      printf("there is ADC data on this chamber!\n");
+
+       AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
+       if (digits->HasData()) { //array
+         
+         AliTRDSignalIndex   *indexes = digitsManager->GetIndexes(det);
+         if (indexes->IsAllocated() == kFALSE) {
+           AliError("Indexes do not exist!");
+           break;
+         }
+         Int_t iRow  = 0;
+         Int_t iCol  = 0;
+         indexes->ResetCounters();
+         
+         while (indexes->NextRCIndex(iRow, iCol)) { //column,row
+           //printf(" det %d \t row %d \t col %d \t digit\n",det,iRow,iCol);
+           //while (rawStream->Next()) {
+           
+           Int_t idetector = det;                                             //  current detector
+           //Int_t imcm      = rawStream->GetMCM();                            //  current MCM
+           //Int_t irob      = rawStream->GetROB();                            //  current ROB
+           
+         
+           if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)) {
+             // Fill
+             withInput = TMath::Max(FillDAQ(phvalue),withInput);
+             
+             // reset
+             for(Int_t k = 0; k < 36; k++){
+               for(Int_t j = 0; j < 16; j++){
+                 for(Int_t c = 0; c < 144; c++){
+                   phvalue[j][c][k] = 0.0;
+                 }
+               }
+             }
+           }
+           
+           fDetectorPreviousTrack = idetector;
+           //fMCMPrevious           = imcm;
+           //fROBPrevious           = irob;
+           
+           //    nbtimebin              = rawStream->GetNumberOfTimeBins();              //  number of time bins read from data
+           AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
+           nbtimebin              = digitParam->GetNTimeBins();              //  number of time bins read from data
+           baseline               = digitParam->GetADCbaseline();            //  baseline
+           
+           if(nbtimebin == 0) return 0;
+           if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
+           fTimeMax          = nbtimebin;
+           
+           fNumberClustersf    = fTimeMax;
+           fNumberClusters     = (Int_t)(fNumberClustersProcent*fTimeMax);
+                 
+           
+           for(Int_t itime = 0; itime < nbtimebin; itime++) {
+             //            phvalue[row][col][itime] = signal[itime]-baseline;
+             phvalue[iRow][iCol][itime] = (Short_t)(digits->GetData(iRow,iCol,itime) - baseline);
+             /*if(phvalue[iRow][iCol][itime] >= 20) {
+                printf("----------> phvalue[%d][%d][%d] %d  baseline %d \n",
+                      iRow,
+                      iCol,
+                      itime,
+                      (Short_t)(digits->GetData(iRow,iCol,itime)),
+                      baseline);
+                      }*/
+           }
+           
+         }//column,row
+         
+         // fill the last one
+         if(fDetectorPreviousTrack != -1){
+           
+           // Fill
+           withInput = TMath::Max(FillDAQ(phvalue),withInput);
+           //      printf("\n ---> withinput %d\n\n",withInput);
+           // reset
+           for(Int_t k = 0; k < 36; k++){
+             for(Int_t j = 0; j < 16; j++){
+               for(Int_t c = 0; c < 144; c++){
+                 phvalue[j][c][k] = 0.0;
+               }
+             }
+           }
+         }
+         
+       }//array
+      }//QA
+      digitsManager->ClearArrays(det);
+    }//idetector
+    delete digitsManager;
+
+    delete rawStream;
+    return withInput;
+ }//main
+//_____________________________________________________________________
 //////////////////////////////////////////////////////////////////////////////
 // Routine inside the DAQ process
 /////////////////////////////////////////////////////////////////////////////
@@ -2570,23 +2730,22 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
                    } //addsignal
                } //shiftC
            } // shiftR
-         
          if (integralMax < integral)
            {
              imaxRow = ir;
              imaxCol = ic;
              integralMax = integral;
+             
            } // check max integral
        } //ic
     } // ir
 
-  //printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax);
-
+  //  printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax);
   //if((imaxRow == 0) || (imaxRow >= 15) || (imaxCol <= 3) || (imaxCol >= 140)) {
   //  used=1;
   //  return used;
   // }
-  
+
   if(((imaxRow + fNumberRowDAQ) > 16) || (imaxRow == 0) || ((imaxCol - fNumberColDAQ) <= 1) || ((imaxCol + fNumberColDAQ) >= 144)) {
     used=1;
     return used;
@@ -2599,6 +2758,7 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
   //  ////////////////////////////////////////////////////       
   
   
+  
   for (Int_t ishiftR = 0; ishiftR < fNumberRowDAQ; ishiftR++)
     {
       for (Int_t ishiftC = -fNumberColDAQ; ishiftC < fNumberColDAQ; ishiftC++)
@@ -2617,7 +2777,7 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
   Double_t sumcharge = 0.0;
   for(Int_t it = 0; it < fTimeMax; it++){
     sumcharge += sum[it];
-    if(sum[it] > fThresholdClustersDAQ) nbcl++;
+    if(sum[it] > fThresholdClustersDAQ)  nbcl++;
   }
 
 
@@ -2671,12 +2831,12 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
     for(Int_t it = 0; it < fTimeMax; it++){
       if(fFillWithZero) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); 
       else{
-       if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); 
+       if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); 
       } 
-      //if(fFillWithZero) UpdateDAQ(0,0,0,it,sum[it],fTimeMax); 
+      //if(fFillWithZero) UpdateDAQ(0,0,0,it,sum[it],fTimeMax);
       //else{
-      // if(sum[it] > 0.0) UpdateDAQ(0,0,0,it,sum[it],fTimeMax); 
-      //} 
+      // if(sum[it] > 0.0) UpdateDAQ(0,0,0,it,sum[it],fTimeMax);
+      //}
     }
     
    
@@ -3219,3 +3379,5 @@ void AliTRDCalibraFillHisto::AnalyseLinearFitter()
     }
   }
 }
+
+
index 4efadda..04354e6 100644 (file)
@@ -43,6 +43,9 @@ class AliTRDgeometry;
 class AliTRDCalDet;
 class AliTRDCalROC;
 
+class AliTRDrawFastStream;
+class AliTRDdigitsManager;
+class AliTRDSignalIndex;
 
 struct eventHeaderStruct;
 
@@ -69,6 +72,7 @@ class AliTRDCalibraFillHisto : public TObject {
          Int_t   ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bool_t nocheck = kFALSE);
          Int_t   ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck = kFALSE);
          Int_t   ProcessEventDAQ(const eventHeaderStruct *event, Bool_t nocheck = kFALSE);
+         Int_t   ProcessEventDAQ2(AliRawReader *rawReader);
 
   // Is Pad on
           Bool_t   IsPadOn(Int_t detector, Int_t row, Int_t col) const;
@@ -139,7 +143,7 @@ class AliTRDCalibraFillHisto : public TObject {
          void     SetThresholdClustersDAQ(Float_t thresholdClustersDAQ)     { fThresholdClustersDAQ = thresholdClustersDAQ;                         }
          void     SetNumberRowDAQ(Short_t numberRowDAQ)                     { fNumberRowDAQ         = numberRowDAQ;         }
          void     SetNumberColDAQ(Short_t numberColDAQ)                     { fNumberColDAQ         = numberColDAQ;         }
-          void     SetNumberBinCharge(Short_t numberBinCharge)               { fNumberBinCharge      = numberBinCharge;      }
+         void     SetNumberBinCharge(Short_t numberBinCharge)               { fNumberBinCharge      = numberBinCharge;      }
           void     SetNumberBinPRF(Short_t numberBinPRF)                     { fNumberBinPRF         = numberBinPRF;         }
          void     SetNumberGroupsPRF(Short_t numberGroupsPRF);
   
@@ -266,7 +270,7 @@ AliTRDCalibraVector *GetCalibraVector() const                                { r
          Bool_t   HandlePRFtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1);
          Bool_t   HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
          void     ResetfVariablestracklet();
-         void     StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col);
+         void     StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls=0x0);
          void     FillCH2d(Int_t x, Float_t y);
 
   // Calibration on DAQ
@@ -305,3 +309,4 @@ AliTRDCalibraVector *GetCalibraVector() const                                { r
 };
   
 #endif
+
index 4c0f7c6..ffcf834 100644 (file)
@@ -279,6 +279,28 @@ Int_t AliTRDfeeParam::GetMCMfromPad(Int_t irow, Int_t icol) const
 }
 
 //_____________________________________________________________________________
+Int_t AliTRDfeeParam::GetMCMfromSharedPad(Int_t irow, Int_t icol) const
+{
+  //
+  // Return on which MCM this pad is directry connected.
+  // Return -1 for error.
+  //
+  
+  if ( irow < 0 || icol < 0 || irow > fgkNrowC1 || icol > fgkNcol+8*3 ) return -1;
+
+  Int_t adc = 20 - (icol%18) -1;
+  switch(adc) {
+    case 2:  icol += 5; break;
+    case 18: icol -= 5; break;
+    case 19: icol -= 5; break;
+    default: icol += 0; break;
+  }
+
+  return (icol%(fgkNcol/2))/fgkNcolMcm + fgkNmcmRobInCol*(irow%fgkNmcmRobInRow);
+
+}
+
+//_____________________________________________________________________________
 Int_t AliTRDfeeParam::GetROBfromPad(Int_t irow, Int_t icol) const
 {
   //
@@ -290,6 +312,18 @@ Int_t AliTRDfeeParam::GetROBfromPad(Int_t irow, Int_t icol) const
 }
 
 //_____________________________________________________________________________
+Int_t AliTRDfeeParam::GetROBfromSharedPad(Int_t irow, Int_t icol) const
+{
+  //
+  // Return on which rob this pad is for shared pads
+  //
+
+  if(icol<72) return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol+5);
+  else return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol-5);
+
+}
+
+//_____________________________________________________________________________
 Int_t AliTRDfeeParam::GetRobSide(Int_t irob) const
 {
   //
index fffadb7..efeec15 100644 (file)
@@ -44,7 +44,9 @@ class AliTRDfeeParam : public TObject
   virtual Int_t    GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const;
   virtual Int_t    GetExtendedPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const;
   virtual Int_t    GetMCMfromPad(Int_t irow, Int_t icol) const;
+  virtual Int_t    GetMCMfromSharedPad(Int_t irow, Int_t icol) const;
   virtual Int_t    GetROBfromPad(Int_t irow, Int_t icol) const;
+  virtual Int_t    GetROBfromSharedPad(Int_t irow, Int_t icol) const;
   virtual Int_t    GetRobSide(Int_t irob) const;
   virtual Int_t    GetColSide(Int_t icol) const;
 
@@ -100,7 +102,7 @@ class AliTRDfeeParam : public TObject
          Bool_t   GetTracklet()         const { return fgTracklet; } 
   static  void     SetTracklet(Bool_t trackletSim = kTRUE) { fgTracklet = trackletSim; }
           Int_t    GetMaxNrOfTracklets() const { return fgkMaxNrOfTracklets; } 
-         Bool_t    GetMCTrackletOutput() const { return fgkMCTrackletOutput; }
+         Bool_t   GetMCTrackletOutput() const { return fgkMCTrackletOutput; }
 
   static  Float_t  GetTFattPar()          { return ((Float_t) fgkTFattPar1) / ((Float_t) fgkTFattPar2); }
           Float_t  GetTFf0()        const { return 1.0 + fgkTFon*(-1.0+GetTFattPar()); }   // 1 if TC off
@@ -227,3 +229,4 @@ class AliTRDfeeParam : public TObject
 
 };
 #endif
+
index 195a704..ddac68d 100644 (file)
@@ -39,11 +39,19 @@ extern "C" {
 #include "AliTRDrawStream.h"
 #include "AliTRDrawStreamBase.h"
 #include "AliCDBManager.h"
+
+//
+//AMORE
+//
+#include <AmoreDA.h>
+
 //
 // AliRoot TRD calib classes
 //
 #include "AliTRDCalibPadStatus.h"
 
+//functios, implementation below
+//void SendToAmoreDB(TObject *o, unsigned long32 runNb);
 
 /* Main routine
       Arguments: list of DATE raw data files
@@ -81,7 +89,7 @@ int main(int argc, char **argv) {
   
 
   /* init some counters */
-  int neventstotal=0;
+  int nevents_total=0;
   int nevents      =0;
  
   //Instance of AliCDBManager: needed by AliTRDRawStream
@@ -91,12 +99,12 @@ int main(int argc, char **argv) {
   // AliTRDCalibPadStatus object
   AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus();
   Bool_t passpadstatus = kTRUE;
+  //unsigned long32 runNb=0;      //run number
 
   // setting
   // AliTRDrawStream::SetNoDebug();
   AliTRDrawStream::DisableSkipData();
   AliTRDrawStream::SetNoErrorWarning();
-  //AliTRDrawStream::SetSubtractBaseline(0); 
   //AliTRDrawStream::SetForceCleanDataOnly();
   //AliTRDrawStream::AllowCorruptedData();
   //AliTRDrawStream::DisableStackNumberChecker();
@@ -147,17 +155,19 @@ int main(int argc, char **argv) {
 
        AliRawReader *rawReader = new AliRawReaderDate((void*)event);
        rawReader->Select("TRD");
-       AliTRDrawStream *trdRawStream = new AliTRDrawStream((AliRawReader *)rawReader);
-       Int_t result = calipad.ProcessEvent((AliTRDrawStreamBase *)trdRawStream,0);
+       
+       Int_t result = calipad.ProcessEvent2((AliTRDrawReader *)rawReader);
        // 0 error, 1 no input, 2 output
        if(result == 2) nevents++;
        if(result == 0) passpadstatus = kFALSE;
-       delete trdRawStream;
        delete rawReader;
       
       }
 
-      neventstotal++;
+      nevents_total++;
+
+      // get the run number
+      //runNb = event->eventRunNb;
 
       /* free resources */
       free(event);
@@ -166,7 +176,7 @@ int main(int argc, char **argv) {
 
 
   /* report progress */
-  printf("%d events processed and %d used\n",neventstotal,nevents);
+  printf("%d events processed and %d used\n",nevents_total,nevents);
 
   /* write file in any case to see what happens in case of problems*/
   TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
@@ -184,5 +194,80 @@ int main(int argc, char **argv) {
 
   
   return status;
+
+  /*
+
+  // send objects to AMORE
+  //SendToAmoreDB(calibpad,runNb);
+  
+  void SendToAmoreDB(TObject *calipad, unsigned long32 runNb)
+  {
+  //cheet a little -- temporary solution (hopefully)
+  //
+  //currently amoreDA uses the environment variable AMORE_DA_NAME to create the mysql
+  //table in which the calib objects are stored. This table is dropped each time AmoreDA
+  //is initialised. This of course makes a problem if we would like to store different
+  //calibration entries in the AMORE DB. Therefore in each DA which writes to the AMORE DB
+  //the AMORE_DA_NAME env variable is overwritten.
+  
+  
+  //
+  // The reference data are stored in:
+  // PadStatus1 for sm-00-01-02
+  // PadStatus2 for sm-03-04-05
+  // PadStatus3 for sm-06-07-08
+  // PadStatus4 for sm-09-10-11
+  // PadStatus5 for sm-12-13-14
+  // PadStatus6 for sm-15-16-17
+  // PadStatus0 if nothing found..means problems
+  //
+  
+  ///////////////////
+  // Find wich LDC
+  ///////////////////
+  Int_t ldcnumber = -1;
+  Int_t sm = -1;
+  for (Int_t idet=0; idet<540; idet++) {
+  AliTRDCalROC *rocMean  = calipad->GetCalRocMean(idet, kFALSE);
+    if ( rocMean )  {
+      sm  = AliTRDgeometry::GetSector(idet);  
+      if((sm==0) || (sm==1) || (sm==2)) ldcnumber = 1;
+      if((sm==3) || (sm==4) || (sm==5)) ldcnumber = 2;
+      if((sm==6) || (sm==7) || (sm==8)) ldcnumber = 3;
+      if((sm==9) || (sm==10) || (sm==11)) ldcnumber = 1;
+      if((sm==12) || (sm==13) || (sm==14)) ldcnumber = 2;
+      if((sm==15) || (sm==16) || (sm==17)) ldcnumber = 3;
+    }
+  }
+  const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
+  
+  gSystem->Setenv("AMORE_DA_NAME",Form("TRD-dataQA-%02d-%s",ldcnumber,FILE_ID));
+  /////////////////////
+  // Send the stuff
+  ////////////////////
+  if (ldcnumber>-1){
+  TDatime time;
+  TObjString info(Form("Run: %u; Date: %s",runNb,time.AsSQLString()));
+  
+  amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
+  Int_t statusDA=0;
+  statusDA+=amoreDA.Send("Pedestals",calibpad);
+  statusDA+=amoreDA.Send("Info",&info);
+  if ( statusDA )
+  printf("Waring: Failed to write one of the calib objects to the AMORE database\n");
+  }  else {
+  printf("Waring: No data found!\n");
+  }
+  
+  // reset env var
+  if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);
+  
+  }
+  
+  */
+
+
+
 }
 
index 03f77de..b7dd726 100644 (file)
@@ -45,13 +45,18 @@ extern "C" {
 #include "AliTRDrawStream.h"
 #include "AliTRDrawStreamBase.h"
 
+//
+//AMORE
+//
+#include <AmoreDA.h>
 
 //
 // TRD calibration algorithm includes
 //
 #include "AliTRDCalibraFillHisto.h"
 
-
+//functions, implementation below
+//void SendToAmoreDB(TObject *o, unsigned long32 runNb);
 
 
 /* Main routine
@@ -100,8 +105,9 @@ int main(int argc, char **argv) {
 
 
   /* init some counters */
-  int neventsphysics=0;
-  int neventstotal=0;
+  int nevents_physics=0;
+  int nevents_total=0;
+  //unsigned long32 runNb=0;      //run number
 
   //Instance of AliCDBManager: needed by AliTRDrawStream
   //AliCDBManager *man = AliCDBManager::Instance();
@@ -110,6 +116,7 @@ int main(int argc, char **argv) {
   //Instance of AliTRDCalibraFillHisto
   AliTRDCalibraFillHisto *calibra      = AliTRDCalibraFillHisto::Instance();
   calibra->SetNumberClustersProcent(0.9);
+
   // everythings are okey for vdrift
   Bool_t passvdrift  = kTRUE;    // if timebin okey
   Int_t  nbvdrift    = 0;     // number of events with entries for vdrift
@@ -118,7 +125,6 @@ int main(int argc, char **argv) {
   // AliTRDrawStream::SetNoDebug();
   AliTRDrawStream::DisableSkipData();
   AliTRDrawStream::SetNoErrorWarning();
-  //AliTRDrawStream::SetSubtractBaseline(0); 
   //AliTRDrawStream::SetForceCleanDataOnly();
   //AliTRDrawStream::AllowCorruptedData();
   //AliTRDrawStream::DisableStackNumberChecker();
@@ -156,7 +162,9 @@ int main(int argc, char **argv) {
       continue;
     }
 
-    if( ((Int_t)neventstotal)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) neventstotal,(Int_t) neventsphysics);  
+    if( ((Int_t)nevents_total)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);  
+
+
 
     /* use event - here, just write event id to result file */
     eventT=event->eventType;
@@ -168,23 +176,33 @@ int main(int argc, char **argv) {
       //if (eventT==PHYSICS_EVENT) {
       AliRawReader *rawReader = new AliRawReaderDate((void*)event);
       rawReader->Select("TRD");
-      AliTRDrawStream *trdRawStream = new AliTRDrawStream((AliRawReader *) rawReader);
-      Int_t result = calibra->ProcessEventDAQ((AliTRDrawStreamBase *) trdRawStream,(Bool_t)nbvdrift);
+
+      Int_t result = calibra->ProcessEventDAQ2((AliTRDrawReader *) rawReader);
       if(!result) passvdrift = kFALSE;
       else nbvdrift += (Int_t) result/2;
              
-      delete trdRawStream;
+
       delete rawReader;
     
     } 
+
+    // get the run number
+    //runNb = event->eventRunNb;
    
     if(eventT==PHYSICS_EVENT){
  
-      neventsphysics++;
+      nevents_physics++;
      
     }
     
-    neventstotal++;
+    /*
+      if( ((Int_t)nevents_physics)%100 == 0 ) {
+      SendToAmoreDB(&calibra);
+      }
+    */
+
+    
+    nevents_total++;
 
 
     /* free resources */
@@ -199,7 +217,7 @@ int main(int argc, char **argv) {
 
 
   /* report progress */
-  printf("%d events processed and %d used\n",neventstotal,nbvdrift);
+  printf("%d events processed and %d used\n",nevents_total,nbvdrift);
   
   //
   // Write a local file and put it on the FX 
@@ -221,5 +239,24 @@ int main(int argc, char **argv) {
   delete fileTRD;  
 
   return status;
+
+  /*
+    void SendToAmoreDB(TObject *o)
+    {
+    //AMORE
+    const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
+    gSystem->Setenv("AMORE_DA_NAME","TRD-dataQA");
+    
+    amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
+    Int_t statusDA=0;
+    statusDA+=amoreDA.Send("DataQA-VDRIFT",o);
+    if ( statusDA!=0 )
+    printf("Waring: Failed to write one of the calib objects to the AMORE database\n");
+    // reset env var
+    if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);
+    } 
+  */
+
 }
 
+