8 #if !defined(__CINT__) || defined(__MAKECINT__) 12 #include <TStopwatch.h> 13 #include <TMultiGraph.h> 16 #include <TGraphErrors.h> 25 #include <THashList.h> 26 #include <TFileCollection.h> 27 #include <TAlienCollection.h> 28 #include <TGridCollection.h> 29 #include <TGridResult.h> 33 #include "AliCDBManager.h" 34 #include "AliAnalysisManager.h" 35 #include "AliESDInputHandler.h" 36 #include "AliTagAnalysis.h" 37 #include "AliRunTagCuts.h" 38 #include "AliLHCTagCuts.h" 39 #include "AliDetectorTagCuts.h" 40 #include "AliEventTagCuts.h" 41 #include "AliAnalysisDataContainer.h" 42 #include "AliAnalysisAlien.h" 45 #include "AliPhysicsSelectionTask.h" 46 #include "AliPhysicsSelection.h" 47 #include "AliMultSelectionTask.h" 52 #include "AliMpDetElement.h" 53 #include "AliMpDDLStore.h" 54 #include "AliMUONCalibParamND.h" 55 #include "AliMUON2DMap.h" 56 #include "AliMUONTrackerData.h" 57 #include "AliMUONPainterDataRegistry.h" 58 #include "AliMUONTrackerDataWrapper.h" 60 #include "AliMuonEventCuts.h" 61 #include "AliMuonTrackCuts.h" 114 nSteps = TMath::Max(nSteps,1);
115 if (extrapMode != 0 && extrapMode != 1) {
116 Error(
"MuonResolution",
"incorrect extrapolation mode!");
123 Error(
"MuonResolution",
"Please provide either an ESD root file, a list of ESDs, a collection of ESDs or a dataset.");
128 Double_t clusterResNB[10] = {-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.};
129 Double_t clusterResB[10] = {-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.};
130 Double_t clusterResNBErr[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
131 Double_t clusterResBErr[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
132 Double_t halfChShiftNB[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
133 Double_t halfChShiftB[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
134 Double_t halfChShiftNBErr[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
135 Double_t halfChShiftBErr[20] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
138 for (
Int_t i=0; i<200; i++) {
144 TMultiGraph* mgClusterResXVsStep =
new TMultiGraph(
"mgClusterResXVsStep",
"cluster X-resolution versus step;step;#sigma_{X} (cm)");
145 TMultiGraph* mgClusterResYVsStep =
new TMultiGraph(
"mgClusterResYVsStep",
"cluster Y-resolution versus step;step;#sigma_{Y} (cm)");
148 for (
Int_t i = 0; i < 10; i++) {
150 clusterResXVsStep[i]->SetName(Form(
"gResX_ch%d",i+1));
151 clusterResXVsStep[i]->SetMarkerStyle(kFullDotMedium);
152 clusterResXVsStep[i]->SetMarkerColor(i+1+i/9);
153 mgClusterResXVsStep->Add(clusterResXVsStep[i],
"lp");
156 clusterResYVsStep[i]->SetName(Form(
"gResY_ch%d",i+1));
157 clusterResYVsStep[i]->SetMarkerStyle(kFullDotMedium);
158 clusterResYVsStep[i]->SetMarkerColor(i+1+i/9);
159 mgClusterResYVsStep->Add(clusterResYVsStep[i],
"lp");
161 TMultiGraph* mgHalfChShiftXVsStep =
new TMultiGraph(
"mgHalfChShiftXVsStep",
"half-chamber displacement in X direction versus step;step;#Delta_{X} (cm)");
162 TMultiGraph* mgHalfChShiftYVsStep =
new TMultiGraph(
"mgHalfChShiftYVsStep",
"half-chamber displacement in Y direction versus step;step;#Delta_{Y} (cm)");
165 for (
Int_t i = 0; i < 20; i++) {
167 halfChShiftXVsStep[i]->SetName(Form(
"gShiftX_hch%d",i+1));
168 halfChShiftXVsStep[i]->SetMarkerStyle(kFullDotMedium);
169 halfChShiftXVsStep[i]->SetMarkerColor(i+1+i/9+i/18);
170 mgHalfChShiftXVsStep->Add(halfChShiftXVsStep[i],
"lp");
171 halfChShiftXVsStep[i]->SetPoint(0, 0, halfChShiftNB[i]);
172 halfChShiftXVsStep[i]->SetPointError(0, 0., halfChShiftNBErr[i]);
175 halfChShiftYVsStep[i]->SetName(Form(
"gShiftY_hch%d",i+1));
176 halfChShiftYVsStep[i]->SetMarkerStyle(kFullDotMedium);
177 halfChShiftYVsStep[i]->SetMarkerColor(i+1+i/9+i/18);
178 mgHalfChShiftYVsStep->Add(halfChShiftYVsStep[i],
"lp");
179 halfChShiftYVsStep[i]->SetPoint(0, 0, halfChShiftB[i]);
180 halfChShiftYVsStep[i]->SetPointError(0, 0., halfChShiftBErr[i]);
186 if (!
gSystem->Exec(
"ls chamberResolution_step*[0-9].root")) {
187 cout<<
"Above files already exist in the current directory. [d=delete, r=resume, e=exit] "<<flush;
188 while (
remove !=
'd' &&
remove !=
'r' &&
remove !=
'e') cin>>
remove;
189 if (
remove ==
'y')
gSystem->Exec(
"rm -f chamberResolution_step*[0-9].root");
190 else if (
remove ==
'r' && !
Resume(mode, firstStep, clusterResNB, clusterResB, clusterResNBErr, clusterResBErr,
191 shiftHalfCh, halfChShiftNB, halfChShiftB, halfChShiftNBErr, halfChShiftBErr,
192 shiftDE, deShiftNB, deShiftB, clusterResXVsStep, clusterResYVsStep,
193 halfChShiftXVsStep, halfChShiftYVsStep))
return;
194 else if (
remove ==
'e')
return;
201 if (inputFileName.EndsWith(
".root")) {
202 TFile *inFile = TFile::Open(inputFileName.Data(),
"READ");
203 if (inFile && inFile->IsOpen()) {
204 inputObj =
dynamic_cast<TFileCollection*
>(inFile->FindObjectAny(
"dataset"));
207 }
else inputObj =
new TObjString(inputFileName);
208 }
else inputObj =
CreateChain(mode, inputFileName);
209 if (!inputObj)
return;
213 for (
Int_t iStep = firstStep; iStep < nSteps; iStep++) {
214 cout<<
"step "<<iStep+1<<
"/"<<nSteps<<endl;
218 applyAccCut, applyPDCACut, minMomentum, minPt, isMC,
219 correctForSystematics, extrapMode, clusterResNB, clusterResB,
220 shiftHalfCh, halfChShiftNB, halfChShiftB, shiftDE, deShiftNB, deShiftB);
221 if (!muonResolution)
return;
226 if (!gGrid) TGrid::Connect(
"alien://");
227 TString resultDir = Form(
"%s/%s/step%d", gGrid->GetHomeDirectory(), outDir.Data(), iStep);
228 if ((smode ==
"submit" || smode ==
"full") && AliAnalysisAlien::DirectoryExists(resultDir.Data())) {
229 cout << endl <<
"Output directory alien://" << resultDir <<
" already exist." << endl;
230 cout <<
"Do you want to continue? [Y/n] " << endl;
232 reply.Gets(stdin,kTRUE);
234 if (reply.BeginsWith(
"n"))
return;
236 CreateAlienHandler(smode, aliphysicsVersion, inputFileName, dataDir, dataPattern, outDir, iStep,
237 runFormat, maxFilesPerJob, maxMergeFiles, maxMergeStages);
242 if (mgr->InitAnalysis()) {
245 mgr->StartAnalysis(
"grid");
246 if (smode !=
"terminate")
return;
247 }
else if (mode ==
kTerminate) mgr->StartAnalysis(
"grid terminate");
248 else if (mode ==
kProof) {
249 if (inputObj->IsA() == TFileCollection::Class())
250 mgr->StartAnalysis(
"proof", static_cast<TFileCollection*>(inputObj), nevents);
251 else mgr->StartAnalysis(
"proof", static_cast<TObjString*>(inputObj)->GetName(), nevents);
252 }
else mgr->StartAnalysis(
"local", static_cast<TChain*>(inputObj), nevents);
257 TFile* outFile = TFile::Open(Form(
"chamberResolution_step%d.root", iStep),
"UPDATE");
258 if (outFile && outFile->IsOpen()) {
270 for (
Int_t i = 0; i < 10; i++) {
271 clusterResXVsStep[i]->SetPoint(0, 0, clusterResNB[i]);
272 clusterResXVsStep[i]->SetPointError(0, 0., clusterResNBErr[i]);
273 clusterResYVsStep[i]->SetPoint(0, 0, clusterResB[i]);
274 clusterResYVsStep[i]->SetPointError(0, 0., clusterResBErr[i]);
279 if (!
GetChamberResolution(iStep, clusterResNB, clusterResB, clusterResNBErr, clusterResBErr))
return;
282 for (
Int_t i = 0; i < 10; i++) {
283 clusterResXVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResNB[i]);
284 clusterResXVsStep[i]->SetPointError(iStep+1, 0., clusterResNBErr[i]);
285 clusterResYVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResB[i]);
286 clusterResYVsStep[i]->SetPointError(iStep+1, 0., clusterResBErr[i]);
291 if (!
AddHalfChShift(iStep, halfChShiftNB, halfChShiftB, halfChShiftNBErr, halfChShiftBErr))
return;
294 for (
Int_t i = 0; i < 20; i++) {
295 halfChShiftXVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftNB[i]);
296 halfChShiftXVsStep[i]->SetPointError(iStep+1, 0., halfChShiftNBErr[i]);
297 halfChShiftYVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftB[i]);
298 halfChShiftYVsStep[i]->SetPointError(iStep+1, 0., halfChShiftBErr[i]);
302 muonResolution->
GetDEShift(deShiftNB, deShiftB);
303 if (!
AddDEShift(iStep, deShiftNB, deShiftB))
return;
306 mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis);
308 TObject::SetObjectStat(kFALSE);
311 if ((mode ==
kGrid || mode ==
kTerminate) && iStep != nSteps-1)
return;
316 gSystem->Exec(Form(
"cp chamberResolution_step%d.root results.root", nSteps-1));
319 TCanvas* convergence1 =
new TCanvas(
"convergenceRes",
"convergence of cluster resolution");
320 convergence1->Divide(1,2);
322 mgClusterResXVsStep->Draw(
"ap");
324 mgClusterResYVsStep->Draw(
"ap");
327 TCanvas* convergence2 =
new TCanvas(
"convergenceShift",
"convergence of half-chamber displacements");
328 convergence2->Divide(1,2);
330 mgHalfChShiftXVsStep->Draw(
"ap");
332 mgHalfChShiftYVsStep->Draw(
"ap");
335 TFile* outFile = TFile::Open(
"results.root",
"UPDATE");
336 if (!outFile || !outFile->IsOpen())
return;
338 mgClusterResXVsStep->Write();
339 mgClusterResYVsStep->Write();
340 convergence1->Write();
341 mgHalfChShiftXVsStep->Write();
342 mgHalfChShiftYVsStep->Write();
343 convergence2->Write();
348 printf(
"\nhalf-chamber total displacements:\n");
349 printf(
" - non-bending:");
350 for (
Int_t i = 0; i < 20; i++) printf((i==0)?
" %6.4f":
", %6.4f", halfChShiftNB[i]);
351 printf(
"\n - bending:");
352 for (
Int_t i = 0; i < 20; i++) printf((i==0)?
" %6.4f":
", %6.4f", halfChShiftB[i]);
356 printf(
"\nDE total displacements:\n");
357 printf(
" - non-bending:");
358 for (
Int_t i = 0; i <
nDE; i++) printf((i==0)?
" %6.4f":
", %6.4f", deShiftNB[i]);
359 printf(
"\n - bending:");
360 for (
Int_t i = 0; i <
nDE; i++) printf((i==0)?
" %6.4f":
", %6.4f", deShiftB[i]);
385 cout<<
"From which step (included) you want to resume? [#, e=exit] "<<flush;
387 do {step.Gets(stdin,kTRUE);}
while (!step.IsDigit() && step !=
"e");
388 if (step ==
"e")
return kFALSE;
389 firstStep = step.Atoi();
393 gSystem->Exec(
"rm -f chamberResolution_step*[0-9].root");
398 if (firstStep != 0 &&
gSystem->AccessPathName(Form(
"chamberResolution_step%d.root", firstStep-1))) {
399 cout<<
"No result found from the previous step ("<<firstStep-1<<
"). Unable to resume from step "<<firstStep<<endl;
404 for (
Int_t i = 0; i < 10; i++) {
405 clusterResXVsStep[i]->SetPoint(0, 0, clusterResNB[i]);
406 clusterResXVsStep[i]->SetPointError(0, 0., clusterResNBErr[i]);
407 clusterResYVsStep[i]->SetPoint(0, 0, clusterResB[i]);
408 clusterResYVsStep[i]->SetPointError(0, 0., clusterResBErr[i]);
412 Bool_t missingInfo = kFALSE;
413 for (
Int_t iStep = 0; iStep < firstStep; iStep++) {
416 if (!
GetChamberResolution(iStep, clusterResNB, clusterResB, clusterResNBErr, clusterResBErr) && iStep == firstStep-1) {
422 for (
Int_t i = 0; i < 10; i++) {
423 clusterResXVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResNB[i]);
424 clusterResXVsStep[i]->SetPointError(iStep+1, 0., clusterResNBErr[i]);
425 clusterResYVsStep[i]->SetPoint(iStep+1, iStep+1, clusterResB[i]);
426 clusterResYVsStep[i]->SetPointError(iStep+1, 0., clusterResBErr[i]);
430 if (!shiftHalfCh)
for (
Int_t i=0; i<20; i++) {
431 halfChShiftNB[i] = 0.; halfChShiftB[i] = 0.;
432 halfChShiftNBErr[i] = 0.; halfChShiftBErr[i] = 0.;
434 if (!
AddHalfChShift(iStep, halfChShiftNB, halfChShiftB, halfChShiftNBErr, halfChShiftBErr) && shiftHalfCh) {
440 for (
Int_t i = 0; i < 20; i++) {
441 halfChShiftXVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftNB[i]);
442 halfChShiftXVsStep[i]->SetPointError(iStep+1, 0., halfChShiftNBErr[i]);
443 halfChShiftYVsStep[i]->SetPoint(iStep+1, iStep+1, halfChShiftB[i]);
444 halfChShiftYVsStep[i]->SetPointError(iStep+1, 0., halfChShiftBErr[i]);
448 if (shiftDE && !
AddDEShift(iStep, deShiftNB, deShiftB)) {
456 if (missingInfo)
continue;
460 gSystem->Exec(
"mkdir __TMP__");
461 for (
Int_t iStep = 0; iStep < firstStep; iStep++)
462 if (!
gSystem->AccessPathName(Form(
"chamberResolution_step%d.root", iStep)))
463 gSystem->Exec(Form(
"mv chamberResolution_step%d.root __TMP__", iStep));
464 gSystem->Exec(
"rm -f chamberResolution_step*[0-9].root");
465 gSystem->Exec(
"mv __TMP__/chamberResolution_step*[0-9].root .");
466 gSystem->Exec(
"rm -rf __TMP__");
480 if (iStep == 0) gEnv->SetValue(
"XSec.GSI.DelegProxy",
"2");
481 else gProof->Close(
"s");
484 if (aaf ==
"saf3") TProof::Open(
"pod://");
486 TString location = (aaf ==
"caf") ?
"alice-caf.cern.ch" :
"nansafmaster2.in2p3.fr";
487 TString nWorkers = (aaf ==
"caf") ?
"workers=80" :
"";
488 TString user = (
gSystem->Getenv(
"alien_API_USER") == NULL) ?
"" : Form(
"%s@",
gSystem->Getenv(
"alien_API_USER"));
489 TProof::Mgr(Form(
"%s%s",user.Data(), location.Data()))->SetROOTVersion(Form(
"VO_ALICE@ROOT::%s",rootVersion.Data()));
490 TProof::Open(Form(
"%s%s/?N",user.Data(), location.Data()), nWorkers.Data());
496 list->Add(
new TNamed(
"ALIROOT_MODE",
"base"));
497 list->Add(
new TNamed(
"ALIROOT_ENABLE_ALIEN",
"1"));
500 gProof->UploadPackage(Form(
"%s/AliceVaf.par", home.Data()));
501 gProof->EnablePackage(Form(
"%s/AliceVaf.par", home.Data()), list, (iStep!=0));
502 }
else gProof->EnablePackage(Form(
"VO_ALICE@AliPhysics::%s",aliphysicsVersion.Data()), list, kTRUE);
521 if (runMode.Contains(
"terminate")) merge = kFALSE;
522 else if (runMode ==
"merge") runMode =
"terminate";
525 plugin->SetRunMode(runMode.Data());
528 plugin->SetNtestFiles(2);
531 plugin->SetAPIVersion(
"V1.1x");
532 if (!aliphysicsVersion.IsNull()) plugin->SetAliPhysicsVersion(aliphysicsVersion.Data());
535 plugin->SetGridDataDir(dataDir.Data());
536 plugin->SetDataPattern(dataPattern.Data());
537 ifstream inFile(runListName.Data());
539 if (inFile.is_open())
541 while (! inFile.eof() )
543 currRun.ReadLine(inFile,kTRUE);
544 if(currRun.IsNull())
continue;
545 plugin->AddRunNumber(Form(runFormat.Data(), currRun.Atoi()));
551 plugin->SetGridWorkingDir(outDir.Data());
554 plugin->SetGridOutputDir(Form(
"step%d",iStep));
557 plugin->SetOutputToRunNo();
560 plugin->SetAdditionalRootLibs(
"libGui.so libProofPlayer.so libXMLParser.so");
563 plugin->AddIncludePath(
"-I$ALICE_ROOT/include");
564 plugin->AddIncludePath(
"-I$ALICE_PHYSICS/include");
565 plugin->AddIncludePath(
"-I.");
571 plugin->SetAnalysisMacro(
"Resolution.C");
572 plugin->SetExecutable(
"Resolution.sh");
575 plugin->SetTTL(30000);
578 plugin->SetInputFormat(
"xml-single");
581 plugin->SetJDLName(
"Resolution.jdl");
587 plugin->SetSplitMode(
"se");
590 plugin->SetSplitMaxInputFileNumber(maxFilesPerJob);
593 if (merge) plugin->SetMergeViaJDL(kTRUE);
596 plugin->SetMaxMergeFiles(maxMergeFiles);
599 plugin->SetMaxMergeStages(maxMergeStages);
602 plugin->SetRegisterExcludes(
"AnalysisResults.root EventStat_temp.root");
605 plugin->SetKeepLogs();
607 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(plugin);
626 AliESDInputHandler* esdH =
new AliESDInputHandler();
627 esdH->SetReadFriends(kFALSE);
628 esdH->SetInactiveBranches(
"*");
629 esdH->SetActiveBranches(
"MuonTracks MuonClusters MuonPads AliESDRun. AliESDHeader. AliMultiplicity. AliESDFMD. AliESDVZERO. SPDVertex. PrimaryVertex. AliESDZDC.");
630 mgr->SetInputEventHandler(esdH);
633 UInt_t eventSelectionMask = 0;
635 gROOT->LoadMacro(
"$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
636 AliPhysicsSelectionTask* physicsSelection =
reinterpret_cast<AliPhysicsSelectionTask*
>(gROOT->ProcessLineSync(TString::Format(
"AddTaskPhysicsSelection(%d)", isMC)));
637 if (!physicsSelection) {
638 Error(
"CreateAnalysisTrain",
"AliPhysicsSelectionTask not created!");
642 eventSelectionMask |= AliMuonEventCuts::kPhysicsSelected;
644 if (selectTrigger) eventSelectionMask |= AliMuonEventCuts::kSelectedTrig;
647 gROOT->LoadMacro(
"$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C");
648 AliMultSelectionTask *mult =
reinterpret_cast<AliMultSelectionTask*
>(gROOT->ProcessLineSync(
"AddTaskMultSelection()"));
650 Error(
"CreateAnalysisTrain",
"AliMultSelectionTask not created!");
656 TString outputFileName = Form(
"chamberResolution_step%d.root", iStep);
657 AliAnalysisManager::SetCommonFileName(outputFileName.Data());
659 if (!muonResolution) {
660 Error(
"CreateAnalysisTrain",
"AliAnalysisTaskMuonResolution not created!");
665 muonResolution->SetDefaultStorage(
"raw://");
667 if (mode !=
kProof) muonResolution->ShowProgressBar();
668 muonResolution->PrintClusterRes(kTRUE, kTRUE);
669 muonResolution->SetStartingResolution(clusterResNB, clusterResB);
670 muonResolution->RemoveMonoCathodClusters(kTRUE, kFALSE);
680 muonResolution->SetHalfChShift(halfChShiftNB, halfChShiftB);
681 muonResolution->ShiftHalfCh();
682 muonResolution->PrintHalfChShift();
685 muonResolution->SetDEShift(deShiftNB, deShiftB);
686 muonResolution->ShiftDE();
687 muonResolution->PrintDEShift();
690 if (eventSelectionMask != 0) {
691 AliMuonEventCuts eventCuts(
"muEventCuts",
"muEventCuts");
692 eventCuts.SetFilterMask(eventSelectionMask);
693 if (selectPhysics) eventCuts.SetPhysicsSelectionMask(AliVEvent::kAny);
696 if (selectTrigger) eventCuts.SetTrigClassPatterns(eventCuts.GetDefaultTrigClassPatterns());
697 muonResolution->SetMuonEventCuts(eventCuts);
700 UInt_t trackSelectionMask = 0;
701 if (matchTrig) trackSelectionMask |= AliMuonTrackCuts::kMuMatchLpt;
702 if (applyAccCut) trackSelectionMask |= AliMuonTrackCuts::kMuEta | AliMuonTrackCuts::kMuThetaAbs;
703 if (applyPDCACut) trackSelectionMask |= AliMuonTrackCuts::kMuPdca;
704 if (trackSelectionMask != 0) {
705 AliMuonTrackCuts trackCuts(
"muTrackCuts",
"muTrackCuts");
706 trackCuts.SetAllowDefaultParams();
707 if (isMC) trackCuts.SetIsMC();
708 trackCuts.SetFilterMask(trackSelectionMask);
709 muonResolution->SetMuonTrackCuts(trackCuts);
712 return muonResolution;
721 TFile* outFile = TFile::Open(Form(
"chamberResolution_step%d.root", iStep),
"READ");
723 if (!outFile || !outFile->IsOpen()) {
724 Error(
"GetChamberResolution",
"output file does not exist!");
729 TGraphErrors* gCombinedResidualXPerChSigma = (summary) ? static_cast<TGraphErrors*>(summary->FindObject(
"gCombinedResidualXPerChSigma")) : 0x0;
730 TGraphErrors* gCombinedResidualYPerChSigma = (summary) ? static_cast<TGraphErrors*>(summary->FindObject(
"gCombinedResidualYPerChSigma")) : 0x0;
732 if (!gCombinedResidualXPerChSigma || !gCombinedResidualYPerChSigma) {
733 Error(
"GetChamberResolution",
"resolution graphs do not exist!");
738 for (
Int_t i = 0; i < 10; i++) {
739 gCombinedResidualXPerChSigma->GetPoint(i, dummy, clusterResNB[i]);
740 gCombinedResidualYPerChSigma->GetPoint(i, dummy, clusterResB[i]);
741 clusterResNBErr[i] = gCombinedResidualXPerChSigma->GetErrorY(i);
742 clusterResBErr[i] = gCombinedResidualYPerChSigma->GetErrorY(i);
756 TFile* outFile = TFile::Open(Form(
"chamberResolution_step%d.root", iStep),
"READ");
758 if (!outFile || !outFile->IsOpen()) {
759 Error(
"AddHalfChShift",
"output file does not exist!");
764 TGraphErrors* gResidualXPerHalfChMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject(
"gResidualXPerHalfChMean_ClusterIn")) : 0x0;
765 TGraphErrors* gResidualYPerHalfChMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject(
"gResidualYPerHalfChMean_ClusterIn")) : 0x0;
767 if (!gResidualXPerHalfChMean || !gResidualYPerHalfChMean) {
768 Error(
"AddHalfChShift",
"half-chamber shift graphs do not exist!");
773 for (
Int_t i = 0; i < 20; i++) {
774 gResidualXPerHalfChMean->GetPoint(i, dummy, dx);
775 halfChShiftNB[i] += dx;
776 halfChShiftNBErr[i] = gResidualXPerHalfChMean->GetErrorY(i);
777 gResidualYPerHalfChMean->GetPoint(i, dummy, dy);
778 halfChShiftB[i] += dy;
779 halfChShiftBErr[i] = gResidualYPerHalfChMean->GetErrorY(i);
793 TFile* outFile = TFile::Open(Form(
"chamberResolution_step%d.root", iStep),
"READ");
795 if (!outFile || !outFile->IsOpen()) {
796 Error(
"AddDEShift",
"output file does not exist!");
801 TGraphErrors* gResidualXPerDEMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject(
"gResidualXPerDEMean_ClusterIn")) : 0x0;
802 TGraphErrors* gResidualYPerDEMean = (summary) ? static_cast<TGraphErrors*>(summary->FindObject(
"gResidualYPerDEMean_ClusterIn")) : 0x0;
804 if (!gResidualXPerDEMean || !gResidualYPerDEMean) {
805 Error(
"AddDEShift",
"DE shift graphs do not exist!");
810 nDE = gResidualXPerDEMean->GetN();
812 gResidualXPerDEMean->GetPoint(i, dummy, dx);
814 gResidualYPerDEMean->GetPoint(i, dummy, dy);
829 if ( ! AliMpDDLStore::Instance(
false) )
831 Warning(
"AddMCHViews",
"mapping was not loaded. Loading it from OCDB");
832 if (smode ==
"saf3") AliCDBManager::Instance()->SetDefaultStorage(
"raw://");
833 else AliCDBManager::Instance()->SetDefaultStorage(
"local://$ALIROOT_OCDB_ROOT/OCDB");
834 AliCDBManager::Instance()->SetRun(999999999);
841 Error(
"AddMCHViews",
"resolution graphs do not exist!");
846 g =
static_cast<TGraphErrors*
>(summary->FindObject(
"gCombinedResidualXPerDESigma"));
854 g =
static_cast<TGraphErrors*
>(summary->FindObject(
"gCombinedResidualYPerDESigma"));
862 g =
static_cast<TGraphErrors*
>(summary->FindObject(
"gResidualXPerDEMean_ClusterOut"));
870 g =
static_cast<TGraphErrors*
>(summary->FindObject(
"gResidualYPerDEMean_ClusterOut"));
884 AliMUON2DMap deValues(kFALSE);
886 for (
Int_t i = 0 ; i < g.GetN(); ++i )
888 double y = g.GetY()[i];
889 double ey = g.GetEY()[i];
891 sscanf(g.GetXaxis()->GetBinLabel(i+1),
"%d",&detElemId);
893 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
895 AliMUONVCalibParam* param =
new AliMUONCalibParamND(5, 1, detElemId, 0);
899 Double_t sumw2 = (sumn-1)*ey*ey+sumw*sumw/sumn;
901 param->SetValueAsDouble(0,0,sumw);
902 param->SetValueAsDouble(0,1,sumw2);
903 param->SetValueAsDouble(0,2,sumn);
904 param->SetValueAsDouble(0,3,de->NofChannels());
905 param->SetValueAsDouble(0,4,1);
910 AliMUONTrackerData* data =
new AliMUONTrackerData(name,name,deValues,1);
911 data->SetDimensionName(0,name);
919 if (smode ==
"local") {
922 else if ( input.EndsWith(
".root") )
return kLocal;
923 }
else if (smode ==
"caf" || smode ==
"saf" || smode ==
"saf3")
return kProof;
924 else if ((smode ==
"test" || smode ==
"offline" || smode ==
"submit" || smode ==
"full" ||
925 smode ==
"merge" || smode ==
"terminate") && input.EndsWith(
".txt"))
return kGrid;
926 else if (smode ==
"terminateonly")
return kTerminate;
934 if (!TGrid::Connect(
"alien://"))
return NULL;
936 TGridCollection* coll = TAlienCollection::Open(xmlfile);
938 Error(
"CreateChainFromCollection",
"Cannot create the AliEn collection");
942 TGridResult* tagResult = coll->GetGridResult(
"",kFALSE,kFALSE);
943 AliTagAnalysis *tagAna =
new AliTagAnalysis(
"ESD");
944 tagAna->ChainGridTags(tagResult);
946 AliRunTagCuts *runCuts =
new AliRunTagCuts();
947 AliLHCTagCuts *lhcCuts =
new AliLHCTagCuts();
948 AliDetectorTagCuts *detCuts =
new AliDetectorTagCuts();
949 AliEventTagCuts *evCuts =
new AliEventTagCuts();
952 if (!
gSystem->AccessPathName(
"ConfigureCuts.C"))
953 gROOT->ProcessLine(Form(
".x ConfigureCuts.C((AliRunTagCuts*)%p, (AliLHCTagCuts*)%p, (AliDetectorTagCuts*)%p," 954 " (AliEventTagCuts*)%p)", runCuts, lhcCuts, detCuts, evCuts));
956 TChain *chain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evCuts);
957 if (!chain || !chain->GetNtrees())
return NULL;
967 chain->Add(rootfile);
968 if (!chain->GetNtrees())
return NULL;
978 ifstream inFile(esdList);
980 if (inFile.is_open()) {
981 while (! inFile.eof() ) {
982 inFileName.ReadLine(inFile,kFALSE);
983 if(!inFileName.EndsWith(
".root"))
continue;
984 chain->Add(inFileName.Data());
988 if (!chain->GetNtrees())
return NULL;
996 printf(
"*******************************\n");
997 printf(
"*** Getting the Chain ***\n");
998 printf(
"*******************************\n");
Bool_t AddDEShift(Int_t iStep, Double_t deShiftNB[200], Double_t deShiftB[200])
void CreateAlienHandler(TString runMode, TString &aliphysicsVersion, TString &runListName, TString &dataDir, TString &dataPattern, TString &outDir, Int_t iStep, TString runFormat, Int_t maxFilesPerJob, Int_t maxMergeFiles, Int_t maxMergeStages)
Int_t GetMode(TString smode, TString input)
TChain * CreateChain(Int_t mode, TString input)
void LoadAlirootOnProof(TString &aaf, TString rootVersion, TString aliphysicsVersion, Int_t iStep)
void MuonResolution(TString smode, TString inputFileName, Int_t nSteps, TString rootVersion, TString aliphysicsVersion, TString dataDir, TString dataPattern, TString runFormat, TString outDir, Int_t maxFilesPerJob, Int_t maxMergeFiles, Int_t maxMergeStages, Bool_t selectPhysics, Bool_t selectTrigger, Bool_t matchTrig, Bool_t applyAccCut, Bool_t applyPDCACut, Double_t minMomentum, Double_t minPt, Bool_t isMC, Bool_t correctForSystematics, Int_t extrapMode, Bool_t shiftHalfCh, Bool_t shiftDE, Int_t nevents)
TChain * CreateChainFromESDList(const char *esdList)
TObjArray * GetCanvases()
return the list of summary canvases
Bool_t GetChamberResolution(Int_t iStep, Double_t clusterResNB[10], Double_t clusterResB[10], Double_t clusterResNBErr[10], Double_t clusterResBErr[10])
TChain * CreateChainFromCollection(const char *xmlfile)
AliAnalysisTaskMuonResolution * AddTaskMuonResolution(Double_t minMomentum=0., Double_t minPt=0., Bool_t correctForSystematics=kTRUE, Int_t extrapMode=1)
void GetHalfChShift(Double_t valNB[20], Double_t valB[20]) const
void AddMCHViews(TString smode, TFile *file)
void GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const
TChain * CreateChainFromFile(const char *rootfile)
Muon spectrometer resolution.
TFile * file
TList with histograms for a given trigger.
Bool_t AddHalfChShift(Int_t iStep, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], Double_t halfChShiftNBErr[20], Double_t halfChShiftBErr[20])
Bool_t Resume(Int_t mode, Int_t &firstStep, Double_t clusterResNB[10], Double_t clusterResB[10], Double_t clusterResNBErr[10], Double_t clusterResBErr[10], Bool_t shiftHalfCh, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], Double_t halfChShiftNBErr[20], Double_t halfChShiftBErr[20], Bool_t shiftDE, Double_t deShiftNB[200], Double_t deShiftB[200], TGraphErrors *clusterResXVsStep[10], TGraphErrors *clusterResYVsStep[10], TGraphErrors *halfChShiftXVsStep[20], TGraphErrors *halfChShiftYVsStep[20])
void GetDEShift(Double_t valNB[200], Double_t valB[200]) const
AliAnalysisTaskMuonResolution * CreateAnalysisTrain(Int_t mode, Int_t iStep, Bool_t selectPhysics, Bool_t selectTrigger, Bool_t matchTrig, Bool_t applyAccCut, Bool_t applyPDCACut, Double_t minMomentum, Double_t minPt, Bool_t isMC, Bool_t correctForSystematics, Int_t extrapMode, Double_t clusterResNB[10], Double_t clusterResB[10], Bool_t shiftHalfCh, Double_t halfChShiftNB[20], Double_t halfChShiftB[20], Bool_t shiftDE, Double_t deShiftNB[200], Double_t deShiftB[200])
AliMUONTrackerData * ConvertGraph(TGraphErrors &g, const char *name)