From dd162229ba248f085030dfbbfdd91ed7c663870a Mon Sep 17 00:00:00 2001 From: alla Date: Sun, 27 Feb 2011 22:08:58 +0000 Subject: [PATCH] 1st draft for pass0 --- T0/AddTaskT0Calib.C | 48 +++++++++ T0/AliT0CalibOffsetChannelsTask.cxx | 150 ++++++++++++++++++++++++++++ T0/AliT0CalibOffsetChannelsTask.h | 41 ++++++++ T0/AliT0PreprocessorOffline.cxx | 89 +++++++++++++++++ T0/AliT0PreprocessorOffline.h | 28 ++++++ T0/CMakelibT0calib.pkg | 40 ++++++++ T0/T0calibLinkDef.h | 14 +++ 7 files changed, 410 insertions(+) create mode 100644 T0/AddTaskT0Calib.C create mode 100644 T0/AliT0CalibOffsetChannelsTask.cxx create mode 100644 T0/AliT0CalibOffsetChannelsTask.h create mode 100644 T0/AliT0PreprocessorOffline.cxx create mode 100644 T0/AliT0PreprocessorOffline.h create mode 100644 T0/CMakelibT0calib.pkg create mode 100644 T0/T0calibLinkDef.h diff --git a/T0/AddTaskT0Calib.C b/T0/AddTaskT0Calib.C new file mode 100644 index 00000000000..0a2317fe70f --- /dev/null +++ b/T0/AddTaskT0Calib.C @@ -0,0 +1,48 @@ +/* + + This macros setup the TPC calibration task AddTaskTPCCalib + for Pass0. + - the run number is required to config TPC OCDB + + The following calibration components are added to the AliTPCAnalysisTaskcalib task: + 1. AliTPCcalibCalib - redo reconstruction with current calibration + 2. AliTPCcalibTimeGain - TPC time dependent gain calibration + 3. AliTPCcalibTime - TPC time dependent drift time calibration + 4. AliTPCcalibLaser - laser track calibration + +*/ +//_____________________________________________________________________________ +AliAnalysisTask *AddTaskT0Calib(Int_t runNumber) +{ + // + // add calibration task + // + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + ::Error("AddTaskT0Calib", "No analysis manager to connect to."); + return NULL; + } + + // check the input handler + if (!mgr->GetInputEventHandler()) { + ::Error("AddTaskT0Calib", "This task requires an input event handler"); + return NULL; + } + + // set TPC OCDB parameters + //ConfigOCDB(runNumber); + + // setup task + AliT0CalibOffsetChannelsTask *task1=new AliT0CalibOffsetChannelsTask("CalibObjectsTrain1"); + // SetupCalibTaskTrain1(task1); + mgr->AddTask(task1); + + AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer(); + if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(), + AliAnalysisManager::kInputContainer); + AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("T0Calib",TObjArray::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root"); + + mgr->ConnectInput(task1,0,cinput1); + mgr->ConnectOutput(task1,1,coutput1); + return task1; +} diff --git a/T0/AliT0CalibOffsetChannelsTask.cxx b/T0/AliT0CalibOffsetChannelsTask.cxx new file mode 100644 index 00000000000..0cb352f9dac --- /dev/null +++ b/T0/AliT0CalibOffsetChannelsTask.cxx @@ -0,0 +1,150 @@ +#include "TChain.h" +#include "TTree.h" +#include "TH1D.h" +#include "TF1.h" +#include "TCanvas.h" +#include "TObjArray.h" + +#include "AliAnalysisTask.h" +#include "AliAnalysisManager.h" + +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" + +#include "AliT0CalibSeasonTimeShift.h" +#include "AliT0CalibOffsetChannelsTask.h" + +#include "AliCDBMetaData.h" +#include "AliCDBId.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliCDBStorage.h" + +// Task should calculate channels offset +// Authors: Alla + +ClassImp(AliT0CalibOffsetChannelsTask) +//________________________________________________________________________ +AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask() + : AliAnalysisTaskSE(), fESD(0), fTzeroObject(0),fRunNumber(0) +{ + // Constructor + + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + DefineOutput(1, TObjArray::Class()); + fTzeroObject = new TObjArray(0); + fTzeroObject->SetOwner(kTRUE); + // Output slot #0 id reserved by the base class for AOD + // Output slot #1 writes into a TH1 container + // DefineOutput(1, TList::Class()); +} + + +//________________________________________________________________________ +AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask(const char *name) + : AliAnalysisTaskSE(name), fESD(0), fTzeroObject(0),fRunNumber(0) +{ + // Constructor + + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + DefineOutput(1, TObjArray::Class()); + // Output slot #0 id reserved by the base class for AOD + // Output slot #1 writes into a TH1 container + // DefineOutput(1, TList::Class()); +} + +//________________________________________________________________________ +AliT0CalibOffsetChannelsTask::~AliT0CalibOffsetChannelsTask() +{ + // Destructor + printf("AliT0CalibOffsetChannels~AliT0CalibOffsetChannels() "); + if( fTzeroObject )fTzeroObject->Delete(); +} + +//________________________________________________________________________ +void AliT0CalibOffsetChannelsTask::ConnectInputData(Option_t *) { + // + // + // + TTree* tree=dynamic_cast(GetInputData(0)); + if (!tree) { + printf("ERROR: Could not read chain from input slot 0"); + } + else { + AliESDInputHandler *esdH = dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); + if (!esdH) { + printf ("ERROR: Could not get ESDInputHandler"); + } + else { + fESD = esdH->GetEvent(); + printf ("*** CONNECTED NEW EVENT ****"); + } + } +} + +//________________________________________________________________________ +void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects() +{ + // Create histograms + for (Int_t i=0; i<24; i++) { + fTimeDiff[i] = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",300, -300, 300); + fCFD[i] = new TH1F("CFD","CFD",500, 6000, 7000); + } + fTzeroObject = new TObjArray(0); + fTzeroObject->SetOwner(kTRUE); + + PostData(1, fTzeroObject); + + // Called once +} + +//________________________________________________________________________ +void AliT0CalibOffsetChannelsTask::UserExec(Option_t *) +{ + // Main loop + // Called for each event + + // Post output data. + fESD = dynamic_cast(InputEvent()); + if (!fESD) { + printf("ERROR: fESD not available\n"); + return; + } + + const Double32_t* time = fESD->GetT0time(); + for (Int_t i=0; i<12; i++) { + if( time[i]>1 ){ + fCFD[i]->Fill( time[i]); + if( time[0]>1 ) + fTimeDiff[i]->Fill( time[i]-time[0]); + } + } + for (Int_t i=12; i<24; i++) { + if( time[i]>1) { + fCFD[i]->Fill( time[i]); + if( time[12]>1 ) + fTimeDiff[i]->Fill( time[i]-time[12]); + } + } + fRunNumber = fESD->GetRunNumber() ; + + // printf("%lf %lf %lf\n",orA,orC,time); + PostData(1, fTzeroObject); +} + //________________________________________________________________________ +void AliT0CalibOffsetChannelsTask::Terminate(Option_t *) +{ + + // Called once at the end of the query + for (Int_t i=0; i<24; i++) + fTzeroObject->AddAtAndExpand(fTimeDiff[i],i); + + for (Int_t i=24; i<48; i++) + fTzeroObject->AddAtAndExpand(fCFD[i],i); + +} + diff --git a/T0/AliT0CalibOffsetChannelsTask.h b/T0/AliT0CalibOffsetChannelsTask.h new file mode 100644 index 00000000000..8ff1504cf1f --- /dev/null +++ b/T0/AliT0CalibOffsetChannelsTask.h @@ -0,0 +1,41 @@ +#ifndef AliT0CalibOffsetChannelsTask_cxx +#define AliT0CalibOffsetChannelsTask_cxx + +// task determines mean and sigma of T0 signals ORA, ORC, ORA-ORC, ORA+ORC/2 +// Authors: FK + +class TH1F; +class AliESDEvent; +class AliT0CalibSeasonTimeShift; + +#include "AliAnalysisTaskSE.h" + +class AliT0CalibOffsetChannelsTask : public AliAnalysisTaskSE { + public: + AliT0CalibOffsetChannelsTask(); + AliT0CalibOffsetChannelsTask(const char *name); + virtual ~AliT0CalibOffsetChannelsTask(); + + virtual void ConnectInputData(Option_t *option); + virtual void UserCreateOutputObjects(); + // virtual void Process(AliESDEvent *event); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + TObjArray* GetOffsetHistos() {return fTzeroObject;} + + private: + AliESDEvent *fESD; //! ESD object + TObjArray *fTzeroObject; //array with CFDi-CFD1 and CFDi + TH1F *fTimeDiff[24]; //! CFDi-CFD1 vs Npmt + TH1F *fCFD[24]; //! CFDi vs Npmt + int fRunNumber; + + // AliT0CalibSeasonTimeShift *fTzeroObject; + + AliT0CalibOffsetChannelsTask(const AliT0CalibOffsetChannelsTask&); // not implemented + AliT0CalibOffsetChannelsTask& operator=(const AliT0CalibOffsetChannelsTask&); // not implemented + + ClassDef(AliT0CalibOffsetChannelsTask, 1); // example of analysis +}; + +#endif diff --git a/T0/AliT0PreprocessorOffline.cxx b/T0/AliT0PreprocessorOffline.cxx new file mode 100644 index 00000000000..0a0e40b0fab --- /dev/null +++ b/T0/AliT0PreprocessorOffline.cxx @@ -0,0 +1,89 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +/* + +*/ +// T0 preprocessor: +// 2) takes data after pass0 , +// processes it, and stores either to OCDB . + + +#include "AliT0PreprocessorOffline.h" +#include "AliT0CalibTimeEq.h" +#include "AliCDBStorage.h" +#include "AliCDBMetaData.h" +#include "AliCDBManager.h" + +#include "AliCDBEntry.h" +#include "AliLog.h" + +#include +#include +#include +#include +#include "TClass.h" + + +ClassImp(AliT0PreprocessorOffline) + +//____________________________________________________ +AliT0PreprocessorOffline::AliT0PreprocessorOffline(): +TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline") +{ + //constructor +} +//____________________________________________________ + +AliT0PreprocessorOffline::~AliT0PreprocessorOffline() +{ + //destructor + +} +//____________________________________________________ +//____________________________________________________ + +void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString ocdbStorage) +{ + + + //Processing data from DAQ Physics run + AliInfo("Processing Time Offset between channels"); + if (filePhysName) + { + AliT0CalibTimeEq *offline = new AliT0CalibTimeEq(); + offline->Reset(); + Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data()); + AliCDBMetaData metaData; + metaData.SetBeamPeriod(1); + metaData.SetResponsible("Alla Maevskaya"); + metaData.SetComment("Time equalizing result with slew"); + + if (writeok) { + AliCDBId* id1=NULL; + id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun); + AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage); + gStorage->Put(offline, (*id1), &metaData); + } + else { + + AliWarning(Form("writeok = %d not enough data for equalizing",writeok)); + } + + delete offline; + } + + +} diff --git a/T0/AliT0PreprocessorOffline.h b/T0/AliT0PreprocessorOffline.h new file mode 100644 index 00000000000..2fa3f82883c --- /dev/null +++ b/T0/AliT0PreprocessorOffline.h @@ -0,0 +1,28 @@ +#ifndef ALI_T0_PREPROCESSOROFFLINE_H +#define ALI_T0_PREPRECESSOROFFLINE_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliT0Preprocessor.h 39249 2010-02-28 19:09:52Z alla $ */ + + +// T0 preprocessor. +#include "TNamed.h" + +class AliT0PreprocessorOffline: public TNamed +{ + public: + AliT0PreprocessorOffline(); + virtual ~AliT0PreprocessorOffline(); + void CalibOffsetChannels(TString FileName, Int_t ustartRun, Int_t uendRun, TString ocdbStorage); + + private: + AliT0PreprocessorOffline(const AliT0PreprocessorOffline & proc); // copy constructor + AliT0PreprocessorOffline& operator=(const AliT0PreprocessorOffline&); //operator + + ClassDef(AliT0PreprocessorOffline, 1) +}; + + +#endif diff --git a/T0/CMakelibT0calib.pkg b/T0/CMakelibT0calib.pkg new file mode 100644 index 00000000000..249f8d30f08 --- /dev/null +++ b/T0/CMakelibT0calib.pkg @@ -0,0 +1,40 @@ +#--------------------------------------------------------------------------------# +# Package File for T0 calib # +# Author : Johny Jose (johny.jose@cern.ch) # +# Variables Defined : # +# # +# SRCS - C++ source files # +# HDRS - C++ header files # +# DHDR - ROOT Dictionary Linkdef header file # +# CSRCS - C source files # +# CHDRS - C header files # +# EINCLUDE - Include directories # +# EDEFINE - Compiler definitions # +# ELIBS - Extra libraries to link # +# ELIBSDIR - Extra library directories # +# PACKFFLAGS - Fortran compiler flags for package # +# PACKCXXFLAGS - C++ compiler flags for package # +# PACKCFLAGS - C compiler flags for package # +# PACKSOFLAGS - Shared library linking flags # +# PACKLDFLAGS - Module linker flags # +# PACKBLIBS - Libraries to link (Executables only) # +# EXPORT - Header files to be exported # +# CINTHDRS - Dictionary header files # +# CINTAUTOLINK - Set automatic dictionary generation # +# ARLIBS - Archive Libraries and objects for linking (Executables only) # +# SHLIBS - Shared Libraries and objects for linking (Executables only) # +#--------------------------------------------------------------------------------# + +set ( SRCS AliT0CalibOffsetChannelsTask.cxx AliT0PreprocessorOffline.cxx) + +string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) + +set ( DHDR T0calibLinkDef.h) + +set ( EINCLUDE RAW) + +if( ALICE_TARGET STREQUAL "win32gcc") + + set ( PACKSOFLAGS ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lT0base -lSTEER -lCDB -lSTEERBase -lRAWDatarec -L${ROOTLIBDIR} -lGui) + +endif( ALICE_TARGET STREQUAL "win32gcc") diff --git a/T0/T0calibLinkDef.h b/T0/T0calibLinkDef.h new file mode 100644 index 00000000000..90b115835df --- /dev/null +++ b/T0/T0calibLinkDef.h @@ -0,0 +1,14 @@ +#ifdef __CINT__ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: T0calibLinkDef.h 40168 2010-04-06 09:37:48Z alla $ */ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliT0PreprocessorOffline+; +#pragma link C++ class AliT0CalibOffsetChannelsTask+; + +#endif -- 2.43.0