19 std::ostream* deadScript)
21 AliFMDGeometry* geom = AliFMDGeometry::Instance();
22 AliFMDParameters* pars = AliFMDParameters::Instance();
23 Float_t konst = pars->GetDACPerMIP();
25 UShort_t nS = (r ==
'I' || r ==
'i' ? 20 : 40);
26 UShort_t nT = (r ==
'I' || r ==
'i' ? 512 : 256);
29 TH2D* hAll =
new TH2D(
"all",
"All",200,-4,6,nS,0,2*TMath::Pi());
30 hAll->SetXTitle(
"#eta");
31 hAll->SetYTitle(
"#phi");
33 hAll->SetDirectory(0);
34 TH2D* hOK =
static_cast<TH2D*
>(hAll->Clone());
38 *deadScript <<
"\n // === FMD" << d << r <<
" === " << std::endl;
42 Int_t nPhi = hAll->GetNbinsY();
49 geom->Detector2XYZ(d, r, s, t, x, y, z);
52 AliFMDGeometry::XYZ2REtaPhiTheta(x, y, z, q, eta, phi, theta);
53 if (phi < 0) phi += 2*TMath::Pi();
57 Bool_t isDead = pars->IsDead(d, r, s, t);
60 Warning(
"",
"FMD%d%c[%2d,%3d] is dead because OCDB says so");
65 Double_t ped = pars->GetPedestal (d, r, s, t);
66 Double_t noise = pars->GetPedestalWidth(d, r, s, t);
67 Double_t gain = pars->GetPulseGain (d, r, s, t);
69 if (!isDead && deadScript) {
70 reason =
"Low pedestal";
71 Warning(
"",
"FMD%d%c[%2d,%3d] is dead because pedestal %f < 10",
77 if (noise > .5 && gain > .5) corr = noise / (gain * konst);
78 if (corr > 0.05 || corr <= 0) {
79 if (!isDead && deadScript) {
80 reason =
"high noise/low gain";
81 Warning(
"",
"FMD%d%c[%2d,%3d] is dead because %f/(%f*%f)=%f > 0.05 or negative",
82 d, r, s, t, noise, gain, konst, corr);
95 if(d==2 && r==
'I' && VA>1 && (s==16 || s==17)) {
96 if (!isDead && deadScript) {
98 Warning(
"",
"FMD%d%c[%2d,%3d] is dead because I say so", d, r, s, t);
105 Int_t etaBin = hAll->GetXaxis()->FindBin(eta);
106 Int_t ovrBin = hAll->GetBin(etaBin, nPhi+1);
109 hAll->Fill(eta, phi);
110 hAll->AddBinContent(ovrBin);
116 hOK->AddBinContent(ovrBin);
122 *deadScript <<
" filter->AddDead(" << d <<
",'" << r <<
"'," 123 << std::setw(2) << s <<
',' 124 << std::setw(3) << t <<
"); // " 125 << reason << std::endl;
132 hOK->Divide(hOK,hAll,1,1,
"B");
135 for (
Int_t etaBin = 1; etaBin <= hOK->GetNbinsX(); etaBin++) {
136 Double_t ovr = hOK->GetBinContent(etaBin, nPhi+1);
137 Double_t novr = (ovr < 1e-12 ? 0 : 1./ovr);
138 hOK->SetBinContent(etaBin, nPhi+1, novr);
140 if (ovr > 0 && ovr != 1)
141 Info(
"",
"Setting overflow bin (%3d,%3d) to 1/%f=%f", etaBin, nPhi+1,
142 ovr, hOK->GetBinContent(etaBin, nPhi+1));
148 Printf(
"=== FMD%d%c at vz=%+5.1f - %d/%d=%3d%% OK (w/overflow)",
149 d, r, vz, nOK, nAll, (100*nOK)/nAll);
171 const char*
fwd =
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
172 gSystem->AddIncludePath(Form(
"-I%s", fwd));
173 gROOT->Macro(Form(
"%s/scripts/LoadLibs.C", fwd));
180 Bool_t gridOnline = kTRUE;
181 if(!(TGrid::Connect(
"alien://",0,0,
"t")))
186 if (runNo <= 99999) year = 2009;
187 else if (runNo <= 139667) year = 2010;
188 else if (runNo <= 170718) year = 2011;
189 else if (runNo <= 194306) year = 2012;
190 else if (runNo <= 197709) year = 2013;
191 else if (runNo <= 208364) year = 2014;
194 Warning(
"",
"Couldn't deduce the year from the run number");
200 Printf(
"=== Setting up OCDB");
202 AliCDBManager* cdb = AliCDBManager::Instance();
204 cdb->SetDefaultStorageFromRun(runNo);
208 cdb->SetDefaultStorage(
"local://$(ALICE_PHYSICS)/OCDB");
212 Printf(
"=== Loading geometry");
213 AliGeomManager::LoadGeometry();
216 Printf(
"=== Intialising parameters");
217 AliFMDParameters* pars = AliFMDParameters::Instance();
221 Printf(
"=== Initialising geomtry");
222 AliFMDGeometry* geom = AliFMDGeometry::Instance();
224 geom->InitTransformations();
227 AliCDBEntry* grpE = cdb->Get(
"GRP/GRP/Data");
229 AliWarningF(
"No GRP entry found for run %d", runNo);
232 AliGRPObject*
grp =
static_cast<AliGRPObject*
>(grpE->GetObject());
234 AliWarningF(
"No GRP object found for run %d", runNo);
237 Float_t beamE = grp->GetBeamEnergy();
238 TString beamT = grp->GetBeamType();
242 Float_t l3cur = grp->GetL3Current(AliGRPObject::kMean);
243 Char_t l3pol = grp->GetL3Polarity();
244 Bool_t l3lhc = grp->IsPolarityConventionLHC();
245 Bool_t l3uni = grp->IsUniformBMap();
247 AliMagF::CreateFieldMap(TMath::Abs(l3cur) * (l3pol ? -1:1), 0,
248 (l3lhc ? 0 : 1), l3uni, beamE, beamT.Data());
249 Float_t l3fld = fldM->SolenoidField();
255 Printf(
"=== Run=%d, year=%d, sys=%d, sNN=%d, fld=%d",
256 runNo, year, sys, sNN, fld);
264 std::ofstream deadScript(
"deadstrips.C");
265 deadScript <<
"// Automatically generaeted by ExtractAcceptance.C\n" 266 <<
"// Add additional dead strips to sharing filter\n" 267 <<
"// Information taken from OCDB entry for\n" 269 <<
"// run = " << runNo <<
"\n" 270 <<
"// year = " << year <<
"\n" 271 <<
"// system = " << sys <<
"\n" 272 <<
"// sqrt{sNN} = " << sNN <<
"GeV\n" 273 <<
"// L3 field = " << fld <<
"kG\n" 274 <<
"void deadstrips(AliFMDESDFixer* filter)\n" 280 Float_t dV = (vtxHigh - vtxLow) / nVtxBins;
281 Printf(
"=== Looping over vertices: %d bins from %+6.2f to %+6.2f " 282 "in steps of %+6.2f",
283 nVtxBins, vtxLow, vtxHigh, dV);
284 for (
Double_t v = vtxLow+dV/2; v < vtxHigh; v += dV) {
288 Char_t r = (q == 0 ?
'I' :
'O');
293 !gotDead ? &deadScript : 0);
296 Warning(
"ExtractAcceptance",
"Didn't get correction from " 297 "FMD%d%c @ vz=%+6.2fcm", d, r, v);
313 <<
"// EOF" << std::endl;
317 Printf(
"=== Writing to disk");
319 if (!cm.
Store(corr, runNo, sys, sNN, fld,
false,
false,
320 "fmd_corrections.root")) {
321 Error(
"",
"Failed to store acceptance correction in local file");
325 std::ofstream f(
"Upload.C");
326 f <<
"// Generated by ExtractELoss.C\n" 327 <<
"TString MakeDest(const TString& dest, const TString& fname)\n" 329 <<
" TString tmp(dest);\n" 330 <<
" if (!tmp.IsNull()) {\n" 331 <<
" if (!tmp.EndsWith(\"/\")) tmp.Append(\"/\");\n" 332 <<
" tmp.Append(fname);\n" 336 <<
"void Upload(const TString& dest=\"\")\n" 338 <<
" gROOT->Macro(\"" << fwd <<
"/scripts/LoadLibs.C\");\n" 340 <<
" const char* fmdFile = \"fmd_corrections.root\";\n" 341 <<
" TString fdest = MakeDest(dest, fmdFile);\n" 343 <<
" AliForwardCorrectionManager::Instance().Append(fmdFile, fdest);\n" 349 Info(
"ExtracAcceptance",
350 "Run generated Upload.C(DEST) script to copy files in place");
TH2D * MakeOneRing(UShort_t d, Char_t r, Double_t vz, Int_t &nDead, std::ostream *deadScript)
static UShort_t ParseCenterOfMassEnergy(UShort_t sys, Float_t cms)
void SetVertexAxis(const TAxis &axis)
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
void SetHasOverflow(Bool_t present=true)
void ExtractAcceptance(Int_t runNo=121526, Int_t nVtxBins=10, Float_t vtxLow=-10, Float_t vtxHigh=10)
static UShort_t ParseCollisionSystem(const char *sys)
void Print(Option_t *option="R") const
Bool_t SetCorrection(UShort_t d, Char_t r, Double_t v, TH2D *h)
static AliForwardCorrectionManager & Instance()