AliPhysics  ed43440 (ed43440)
ExtractNG.C
Go to the documentation of this file.
1 #ifndef __CINT__
2 # include "AliFMDParameters.h"
3 # include "AliFMDCorrNoiseGain.h"
5 # include "AliForwardUtil.h"
6 # include "AliCDBManager.h"
7 # include "AliCDBEntry.h"
8 # include "AliCDBStorage.h"
9 # include "AliGRPObject.h"
10 # include "AliMagF.h"
11 # include "AliLog.h"
12 # include <TSystem.h>
13 # include <TROOT.h>
14 # include <TError.h>
15 # include <TString.h>
16 #endif
17 
23 void
25 {
26  // --- Figure out the year --------------------------------------
27  UShort_t year = 0;
28  if (runNo <= 99999) year = 2009;
29  else if (runNo <= 139667) year = 2010;
30  else if (runNo <= 170718) year = 2011;
31  else if (runNo <= 194306) year = 2012;
32  else if (runNo <= 197709) year = 2013;
33  if (year <= 0) {
34  Error("", "Couldn't deduce the year from the run number");
35  return;
36  }
37 
38  // --- Connect to OCDB ---------------------------------------------
39  AliCDBManager* cdb = AliCDBManager::Instance();
40  cdb->SetRun(runNo);
41  cdb->SetDefaultStorageFromRun(runNo);
42 
43 #if 0
44  // --- Get the general run parameters ------------------------------
45  // AliLog::SetModuleDebugLevel("STEER", 3);
46  AliCDBId grpId("GRP/GRP/Data", runNo + 100, runNo - 100);
47  AliCDBEntry* grpE = cdb->GetDefaultStorage()->GetEntry(grpId);
48  if (!grpE) {
49  Warning("ExtractForRun", "No GRP entry found for run %d", runNo);
50  return;
51  }
52  AliGRPObject* grp = static_cast<AliGRPObject*>(grpE->GetObject());
53  if (!grp) {
54  Warning("ExtractForRun", "No GRP object found for run %d", runNo);
55  return;
56  }
57  Float_t beamE = grp->GetBeamEnergy();
58  TString beamT = grp->GetBeamType();
59 #if 0
60  // This isn't really needed as the acceptance map is indifferent to
61  // the field settings.
62  Float_t l3cur = grp->GetL3Current(AliGRPObject::kMean);
63  Char_t l3pol = grp->GetL3Polarity();
64  Bool_t l3lhc = grp->IsPolarityConventionLHC();
65  Bool_t l3uni = grp->IsUniformBMap();
66  AliMagF* fldM =
67  AliMagF::CreateFieldMap(TMath::Abs(l3cur) * (l3pol ? -1:1), 0,
68  (l3lhc ? 0 : 1), l3uni, beamE, beamT.Data());
69  Float_t l3fld = fldM->SolenoidField();
70 #endif
71  Printf("=== From GRP: Beam: E=%f T=%s", beamE, beamT.Data());
72  if (beamE > 14000) beamE = 450;
73  if (beamT.IsNull()) beamT = "pp";
74 
77  Short_t fld = +999; // AliForwardUtil::ParseMagneticField(l3fld);
78  Printf("=== Run=%d, year=%d, sys=%d, sNN=%d, fld=%d",
79  runNo, year, sys, sNN, fld);
80 #endif
81  UShort_t sys = +999;
82  UShort_t sNN = +999;
83  Short_t fld = +999;
84 
85  // --- Get our parameters ------------------------------------------
86  AliFMDParameters* param = AliFMDParameters::Instance();
87  param->Init(true, AliFMDParameters::kPulseGain|AliFMDParameters::kPedestal);
88 
89  // --- Get the object to store -------------------------------------
91  Float_t konst = param->GetDACPerMIP();
92 
93  // --- Loop over all strips ----------------------------------------
94  for (UShort_t d = 1; d <= 3; d++) {
95  UShort_t nQ = (d == 1 ? 1 : 2);
96  for (UShort_t q = 0; q < nQ; q++) {
97  Char_t r = (q == 0 ? 'I' : 'O');
98  UShort_t nS = (q == 0 ? 20 : 40);
99  UShort_t nT = (q == 0 ? 512 : 256);
100  for (UShort_t s = 0; s < nS; s++) {
101  for (UShort_t t = 0; t < nT; t++) {
102  Float_t noise = param->GetPedestalWidth(d,r,s,t);
103  Float_t gain = param->GetPulseGain(d,r,s,t);
104  Float_t corr = 0;
105  if (noise > .5 && gain > .5) corr = noise / (gain * konst);
106  if (corr > 1 || corr < 0) {
107  Warning("", "FMD%d%c[%2d,%3d] corr= %f (=%f/(%f*%f))",
108  d, r, s, t, corr, noise, gain, konst);
109  corr = 0;
110  }
111  ret->Set(d,r,s,t,corr);
112  }
113  }
114  }
115  }
116 
117  // --- Write to a file ---------------------------------------------
118  Printf("=== Writing to disk");
120  if (!cm.Store(ret, runNo, sys, sNN, fld, false, false,
121  "fmd_corrections.root", "OLDER")) {
122  Error("", "Failed to store acceptance correction in local file");
123  return;
124  }
125 
126 }
127 
128 void ExtractAll() {
129  // We need to get a list of runs. We should make an entry for every
130  // pedestal and gain run.
131  //
132  // for y in `seq 2009 2013` ; do \
133  // for c in PulseGain Pedestal ; do \
134  // alien_ls /alice/data/${y}/OCDB/FMD/Calib/${c}/ | sed -e 's/Run//' -e 's/_.*//' ; \
135  // done ; \
136  // done | sort -u -n | grep -v ^0 | sed 's/\([0-9]*\)/ \1,/'
137  //
138  Int_t runs[] = {
139  // 58360,
140  // 61383,
141  // <-- Start of 2009
142  75201, 75238, 75311, 75330, 75383, 75384, 75630, 75631,
143  77901, 80649, 80650, 80738, 82055, 82301, 85947, 85948,
144  87560, 87561, 91794, 91795, 92436, 92441, 93271, 93273,
145  93587, 93588, 93595, 94793, 96747, 96945, 96947, 96949,
146  96956, 96962, 96963, 97226, 97228, 97593, 97996, 98780,
147  98782, 98974, 98980, 99033, 99084, 99085, 99414, 99726,
148  100075, 100273, 100594, 100595, 100868, 100967, 101808, 101809,
149  102034, 102036, 102043, 102238, 102240, 103639, 103641, 103984,
150  103989, 104108, 104109, 104167, 104169, 104526, 104529, 104901,
151  104904, 104914, 105111, 105112,
152  // <-- Start of 2010
153  105827, 105834, 105963, 107718, 110372, 110373, 113268, 113331,
154  113650, 113651, 114594, 114596, 115126, 115127, 115136, 115160,
155  115171, 115244, 115334, 115355, 115360, 115477, 115480, 115528,
156  115530, 115538, 115545, 115651, 115660, 116294, 116335, 116438,
157  116439, 116440, 116613, 116614, 116655, 117255, 117257, 117258,
158  117395, 117396, 117397, 117398, 117399, 117400, 117401, 117402,
159  117403, 117404, 117405, 117406, 117407, 117408, 117409, 117411,
160  117413, 117415, 117416, 117417, 117418, 117420, 117421, 117422,
161  117423, 117424, 117425, 117426, 117427, 117428, 117429, 117431,
162  117432, 117433, 117434, 117435, 117437, 117438, 117439, 117441,
163  117442, 117443, 117444, 117445, 117446, 117447, 117448, 117450,
164  117452, 117453, 117458, 117459, 117461, 117464, 117471, 117476,
165  117478, 117483, 117492, 117495, 117496, 117498, 117512, 117524,
166  117561, 117571, 117588, 117606, 117612, 117616, 117624, 117630,
167  117648, 117650, 117664, 117677, 117678, 117680, 117681, 117682,
168  117684, 117687, 117688, 117689, 117690, 117693, 117695, 117698,
169  117699, 117700, 117701, 117702, 117703, 117704, 117706, 117707,
170  117708, 117709, 117712, 117714, 117717, 117719, 117720, 117722,
171  117723, 117724, 117725, 117726, 117728, 117730, 117731, 117733,
172  117735, 117736, 117737, 117738, 117739, 117741, 117742, 117744,
173  117745, 117746, 117747, 117763, 117772, 117776, 117779, 117784,
174  119187, 119200, 120542, 120543, 121526, 121527, 121528, 121532,
175  121550, 121554, 121557, 121621, 121638, 121651, 121656, 121662,
176  121667, 121677, 121686, 121691, 121697, 121698, 121700, 121702,
177  121704, 121706, 121708, 121710, 121712, 121713, 121714, 121715,
178  121717, 121719, 121722, 121724, 121726, 121728, 121730, 121732,
179  121734, 121736, 121738, 121740, 121742, 121743, 121963, 121965,
180  121968, 121970, 121980, 121982, 121983, 121985, 121986, 121987,
181  121988, 121989, 121990, 121991, 121992, 121993, 121994, 121995,
182  121996, 121997, 121998, 121999, 122000, 122001, 122002, 122003,
183  122004, 122005, 122006, 122007, 122008, 122009, 122010, 122011,
184  122012, 122013, 124437, 124438, 125892, 125894, 125896, 125897,
185  126043, 126046, 126939, 126940, 128138, 128140, 128511, 128512,
186  129793, 129796, 129804, 130290, 130291, 131336, 131337, 131383,
187  131386, 131387, 131389, 131392, 131396, 131397, 131398, 131399,
188  131400, 132637, 132638, 132789, 132799, 135478, 135479, 136733,
189  136738, 136740, 138243, 138244, 138935,
190  // <-- Start of 2011
191  144429, 144751, 144837, 144856, 145167, 145169, 145170, 146647,
192  146650, 147281, 147285, 147289, 147299, 147301, 147307, 147318,
193  149252, 149256, 154053, 154054, 154057, 155422, 155424, 155430,
194  155933, 155934, 156030, 156032, 156037, 156038, 156201, 156202,
195  156204, 156207, 156217, 156222, 156778, 156780, 157800, 157801,
196  157802, 157804, 157805, 157808, 158993, 158994, 165623, 165636,
197  165637, 166817, 166819, 167219, 167221, 169438, 169443, 169446,
198  169448, 169449, 169450, 169451, 169484, 169486,
199  // <-- Start of 2012
200  172968, 172970, 175768, 175769, 176615, 176616, 176617, 177999,
201  178000, 178562, 178571, 179962, 179963, 182380, 182381, 183249,
202  183253, 183594, 183596, 184904, 184911, 184912, 185266, 185267,
203  185269, 185270, 185873, 186408, 186471, 187021, 187022, 187023,
204  187259, 187263, 187803, 187804, 188300, 188301, 188851, 188856,
205  189256, 189257, 191769, 191770,
206  // <-- Start of 2013
207  194507, 194522, 194523, 194526, 194589, 194590, 195027, 195030,
208  // <-- End marker
209  -1 };
210  Int_t* pRun = runs;
211  Int_t skipped = 0;
212  Int_t total = 0;
213  Int_t last = 0;
214  while (*pRun > 0) {
215  Int_t next = *(pRun+1);
216  Int_t dist = next - *pRun;
217  total++;
218  if (next > 0 && dist <= 20) {
219  skipped++;
220  pRun++;
221  continue;
222  }
223 #if 0
224  if (last > 0) {
225  dist = *pRun - last;
226  Printf("%-6d %s%d,%d,",dist, url,last,*pRun);
227  }
228 #endif
229  last = *pRun;
230  ExtractForRun(last);
231  pRun++;
232  }
233  Info("", "Skipped %d of %d", skipped, total);
234 }
235 //
236 // EOF
237 //
const char * url
static UShort_t ParseCenterOfMassEnergy(UShort_t sys, Float_t cms)
char Char_t
Definition: External.C:18
int Int_t
Definition: External.C:63
void Set(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t x)
virtual Bool_t Store(TObject *o, ULong_t runNo, UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc, Bool_t sat, const char *file, const char *meth="NEAR") const
float Float_t
Definition: External.C:68
Various utilities used in PWGLF/FORWARD.
short Short_t
Definition: External.C:23
static UShort_t ParseCollisionSystem(const char *sys)
GRPData * grp
Definition: GRP.C:361
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
void ExtractForRun(Int_t runNo)
Definition: ExtractNG.C:24
void ExtractAll()
Definition: ExtractNG.C:128
static AliForwardCorrectionManager & Instance()