1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 // $Id: DisplaydHLTData.C 37070 2009-11-20 13:53:08Z aszostak $
21 * \file CreateCDBFieldIntegrals.C
22 * \brief Macro for creating and storing the magnetic field integrals in the CDB.
24 * This macro calculates the magnetic field integrals for the dipole magnet and
25 * writes them into the CDB under the HLT/ConfigMUON/FieldIntegrals path.
26 * These are then used by the online dHLT reconstruction components during
27 * momentum estimation of the tracks found.
28 * The simplest method to run this macro is with the following command:
30 * > aliroot -b -q -l CreateCDBFieldIntegrals.C
33 * \author Artur Szostak <artursz@iafrica.com>
36 #if !defined(__CINT__) || defined(__MAKECINT__)
37 #include "AliCDBManager.h"
38 #include "AliCDBStorage.h"
39 #include "AliCDBEntry.h"
40 #include "AliGRPManager.h"
41 #include "AliHLTMUONConstants.h"
45 #include "TObjString.h"
57 * Calculates the average magnetic field integral for the dipole magnet given the
58 * L3 solenoid current and dipole magnet current.
59 * \param [in] currentL3 The current in the L3 solenoid magnet.
60 * \param [in] currentDip The current in the dipole magnet.
61 * \param [out] result The magnetic field integral result.
62 * \param [in] sqrts The centre of mass energy for the beams.
63 * \param [in] beamtype The beam type as given the AliMagF, eg. p-p, A-A or none.
64 * \note The sign of the current indicates the polarity setting for the magnet.
65 * \returns true if the magnetic field was calculated successfully and false otherwise.
67 bool CalculateIntegral(
68 Float_t currentL3, Float_t currentDip, Float_t& result,
69 Float_t sqrts = 0, const char* beamtype = "none"
72 AliMagF* fld = AliMagF::CreateFieldMap(currentL3, currentDip, AliMagF::kConvLHC, kFALSE, sqrts, beamtype);
73 if (fld == NULL) return false;
76 for (int theta = 171; theta <= 179; ++theta)
77 for (int phi = 0; phi < 360; phi += 10)
80 dr.SetMagThetaPhi(1, theta*TMath::Pi()/180., phi*TMath::Pi()/180.);
81 Double_t dx = 1e-3 * dr.Mag();
86 while (r.Z() > -1700 && nsteps < 10000)
88 Double_t p[3] = {r.X(), r.Y(), r.Z()};
96 totals.Set(totals.GetSize()+1);
97 totals[totals.GetSize()-1] = total;
100 result = - TMath::Mean(totals.GetSize(), totals.GetArray());
101 Float_t rms = TMath::RMS(totals.GetSize(), totals.GetArray());
103 cout << "Integrated field value = " << result
105 << ", for L3 current = " << currentL3
106 << ", dipole current = " << currentDip << endl;
111 * Calculates the magnetic field integrals for the dipole magnet and stores them
113 * \param cdbPath The path to the local storage.
114 * \param version The version of the CDB entry.
115 * \param firstRun = The first run number for which the CDB entry is valid.
116 * \param lastRun = The last run number for which the CDB entry is valid.
117 * \param sqrts The centre of mass energy for the beams.
118 * \param beamtype The beam type as given the AliMagF, eg. p-p, A-A or none.
120 void CreateCDBFieldIntegrals(
121 const char* cdbPath = "local://$ALICE_ROOT/OCDB",
124 Int_t lastRun = AliCDBRunRange::Infinity(),
126 const char* beamtype = "none"
129 // Get the CDB manager and storage.
130 AliCDBManager* cdbManager = AliCDBManager::Instance();
131 if (cdbManager == NULL)
133 cerr << "ERROR: Global CDB manager object does not exist." << endl;
136 AliCDBStorage* storage = cdbManager->GetStorage(cdbPath);
139 cerr << "ERROR: Could not get storage for: " << cdbPath << endl;
143 const int nL3Current = 5;
144 const int nDipCurrent = 3;
145 Float_t currentL3[nL3Current] = {-30e3, -12e3, 0, 12e3, 30e3};
146 Float_t currentDip[nDipCurrent] = {-6e3, 0, 6e3};
148 // Create and store the configuration parameters for the trigger reconstructor.
149 TMap* params = new TMap;
150 params->SetOwner(kTRUE);
151 for (int i = 0; i < nL3Current; ++i)
152 for (int j = 0; j < nDipCurrent; ++j)
154 if (currentL3[i]*currentDip[j] < 0) continue; // Skip invalid combinations.
155 Float_t bfieldintegral;
156 if (! CalculateIntegral(currentL3[i], currentDip[j], bfieldintegral, sqrts, beamtype)) continue;
157 const char* paramName = Form("L3_current=%0.2e;Dipole_current=%0.2e", currentL3[i], currentDip[j]);
158 const char* paramValue = Form("%8.8f", bfieldintegral);
159 params->Add(new TObjString(paramName), new TObjString(paramValue));
162 const char* path = AliHLTMUONConstants::FieldIntegralsCDBPath();
163 AliCDBId id(path, firstRun, lastRun, version);
164 AliCDBMetaData* metaData = new AliCDBMetaData();
165 metaData->SetResponsible("dimuon HLT");
166 metaData->SetComment("Magnetic field integral parameters for dimuon HLT.");
167 storage->Put(params, id, metaData);