]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/CalibMacros/MergeCalibration/ConfigCalibTrain.C
Keep also the events with cosmic tracks (Marian)
[u/mrichter/AliRoot.git] / ANALYSIS / CalibMacros / MergeCalibration / ConfigCalibTrain.C
1 //
2 // Macro to initialize: 
3 // - the OCDB (run number required as input argument)
4 // - the geometry (expected to be in the current directory)
5 // to run the Calibration train.
6 // 
7
8 void ConfigCalibTrain(Int_t run, const char *ocdb="raw://"){
9
10   // OCDB
11  
12   printf("setting run to %d\n",run);
13   AliCDBManager::Instance()->SetDefaultStorage(ocdb);
14   AliCDBManager::Instance()->SetRun(run); 
15
16   // geometry
17   AliGeomManager::LoadGeometry();
18   AliGeomManager::ApplyAlignObjsFromCDB("GRP ITS TPC");
19
20
21
22   AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
23   AliGRPObject* grpData = (AliGRPObject*)entry->GetObject();
24
25   Bool_t ok=kTRUE;
26   Float_t l3Current = grpData->GetL3Current((AliGRPObject::Stats)0);
27   if (l3Current == AliGRPObject::GetInvalidFloat()) {
28     printf("GRP/GRP/Data entry:  missing value for the L3 current !");
29     ok = kFALSE;
30   }
31   
32   Char_t l3Polarity = grpData->GetL3Polarity();
33   if (l3Polarity == AliGRPObject::GetInvalidChar()) {
34     printf("GRP/GRP/Data entry:  missing value for the L3 polarity !");
35     ok = kFALSE;
36   }
37   
38   // Dipole
39   Float_t diCurrent = grpData->GetDipoleCurrent((AliGRPObject::Stats)0);
40   if (diCurrent == AliGRPObject::GetInvalidFloat()) {
41     printf("GRP/GRP/Data entry:  missing value for the dipole current !");
42     ok = kFALSE;
43   }
44   
45   Char_t diPolarity = grpData->GetDipolePolarity();
46   if (diPolarity == AliGRPObject::GetInvalidChar()) {
47     printf("GRP/GRP/Data entry:  missing value for the dipole polarity !");
48     ok = kFALSE;
49   }
50
51   TString beamType = grpData->GetBeamType();
52   if (beamType==AliGRPObject::GetInvalidString()) {
53     printf("GRP/GRP/Data entry:  missing value for the beam type ! Using UNKNOWN");
54     beamType = "UNKNOWN";
55   }
56
57   Float_t beamEnergy = grpData->GetBeamEnergy();
58   if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
59     printf("GRP/GRP/Data entry:  missing value for the beam energy ! Using 0");
60     beamEnergy = 0;
61   }
62
63   // read special bits for the polarity convention and map type
64   //Int_t  polConvention = grpData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
65   Int_t  polConvention = grpData->IsPolarityConventionLHC() ? 0 : 1;
66   Bool_t uniformB = grpData->IsUniformBMap();
67   
68   if (ok) {
69     AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
70                                            TMath::Abs(diCurrent) * (diPolarity ? -1:1),
71                                            polConvention,uniformB,beamEnergy, beamType.Data());
72     if (fld) {
73       TGeoGlobalMagField::Instance()->SetField( fld );
74       TGeoGlobalMagField::Instance()->Lock();
75       printf("Running with the B field constructed out of GRP !");
76     }
77   }
78   printf("Problem with magnetic field setup\n");
79 }