1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliTaskCDBconnect.h"
20 #include <TGeoGlobalMagField.h>
21 #include "TGeoManager.h"
23 #include "AliAnalysisManager.h"
24 #include "AliGeomManager.h"
25 #include "AliCDBManager.h"
26 #include "AliGRPManager.h"
27 #include "AliVEvent.h"
28 #include "AliInputEventHandler.h"
31 ClassImp(AliTaskCDBconnect)
33 //______________________________________________________________________________
34 AliTaskCDBconnect::AliTaskCDBconnect():
42 //______________________________________________________________________________
43 AliTaskCDBconnect::AliTaskCDBconnect(const char* name, const char *storage, Int_t run)
44 :AliAnalysisTask(name, "ESD analysis tender car"),
48 // Default constructor
49 AliCDBManager *cdb = AliCDBManager::Instance();
50 cdb->SetDefaultStorage(storage);
51 DefineInput (0, TChain::Class());
55 //______________________________________________________________________________
56 AliTaskCDBconnect::~AliTaskCDBconnect()
62 //______________________________________________________________________________
63 void AliTaskCDBconnect::InitGRP()
65 // Initialize geometry and mag. field
66 AliCDBManager *cdb = AliCDBManager::Instance();
67 if (!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("raw://");
69 if (!fGRPManager) fGRPManager = new AliGRPManager();
70 AliInfo("AliCDBconnect: #### Loading GRP to init B-field...");
71 if(!fGRPManager->ReadGRPEntry()) AliFatal("Cannot get GRP entry");
72 if(!fGRPManager->SetMagField()) AliFatal("Problem with magnetic field setup");
76 AliInfo("AliCDBconnect: #### Loading geometry...");
77 AliGeomManager::LoadGeometry("geometry.root");
78 if(!AliGeomManager::ApplyAlignObjsFromCDB("GRP ITS TPC TRD")) AliWarning("Problem with align objects");
82 //______________________________________________________________________________
83 void AliTaskCDBconnect::CreateOutputObjects()
85 // Init CDB locally if run number is defined.
87 // try to init before the analysis set
88 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
89 if (!mgr) AliFatal("No analysis manager");
90 if ( fRun>0 && mgr->IsProofMode() ) {
91 // in the proof mode the initialization done in the constructor is not available
95 AliInfo("Run number is not available at this stage, InitGRP will be called in the execution loop");
100 //______________________________________________________________________________
101 void AliTaskCDBconnect::Exec(Option_t* /*option*/)
104 // Execute all supplied analysis of one event. Notify run change via RunChanged().
105 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
106 if (!mgr) AliFatal("No analysis manager");
107 AliInputEventHandler* inp = (AliInputEventHandler*)mgr->GetInputEventHandler();
108 if (!inp) AliFatal("No input event handler connected");
110 AliVEvent* ev = inp->GetEvent();
111 if (!ev) AliFatal("No event returned");
112 int run = ev->GetRunNumber();
113 // Intercept when the run number changed
120 //______________________________________________________________________________
121 void AliTaskCDBconnect::SetSpecificStorage(const char* calibType, const char* dbString)
123 AliCDBManager *cdb = AliCDBManager::Instance();
124 cdb->SetSpecificStorage(calibType,dbString);