2 /// \file AddTaskMuonAlignment.C
3 /// \brief Macro to add an AliMUONAlignmentTask to an analysis train
5 /// \author Javier Castillo, CEA/Saclay - Irfu/SPhN
6 /// \author Hugo Pereira Da Costa, CEA/Saclay - Irfu/SPhN
9 AliMUONAlignmentTask calculates alignment correction for the muon spectrometer
10 based on reconstructed tracks, either with or without magnetic field. It uses AliMillePede2
11 internally for alignment, and AliMillePedeRecords for storing the derivatives.
13 The task has two ways of operation
16 This corresponds to flags: readRecords = kFALSE, doAlignment = kTRUE, writeRecords = kFALSE
17 - reads tracks from an ESD,
18 - calculates all derivatives needed to minimize both the tracks
19 and the alignment parameters
20 - fill and invert the (large) matrix corresponding to the global chisquare minimization
21 - write the resulting alignment parameters, on top of the initiali geometry, in a new CDB
23 Note that writeRecords can also be set to kTRUE. This will output all derivatives to a special
24 branch in an AOD for re-running the alignment with no need to process the tracks (see below)
27 The task must run twice.
28 First pass with flags: readRecords = kFALSE, writeRecords = kTRUE, doAlignment = kFALSE
30 - reads tracks from an ESD,
31 - calculates all derivatives needed to minimize both the tracks
32 and the alignment parameters
33 - stores them in a special branch of the output AOD, named "records",
34 and containing a TClonesArray of objects typed "AliMillePedeRecord"
36 Second pass with flags: readRecords = kTRUE, doAlignment = kTRUE
37 - reads the AliMillePedeRecords stored in the AOD (or a collection of AODs)
38 - fill and invert the (large) matrix corresponding to the global chisquare minimization
39 - write the resulting alignment parameters, on top of the initiali geometry, in a new CDB
41 The split mode is usefull for running on the grid:
42 - the first pass can be done with multiple jobs (one per ESD chunk) in parallel.
43 - the second pass must be done one on all created AODs, in a single shot, possibly locally
45 When performing the alignment (doAlignment=kTRUE), one can "fix", "group", or "constrain"
46 detector's alignment parameters in order to ease the inversion.
48 One can redo the second pass as many times as needed, changing these "fixed/group/constrained" parameters,
49 without re-processing the ESD tracks.
52 #include "AliAnalysisManager.h"
53 #include "AliMUONAlignmentTask.h"
54 #include "AliVEventHandler.h"
56 AliMUONAlignmentTask *AddTaskMuonAlignment(
57 TString oldAlignmentOCDB,
58 TString newAlignmentOCDB,
59 Bool_t doAlignment = kTRUE,
60 Bool_t writeRecords = kTRUE,
61 Bool_t readRecords = kFALSE
65 /// Creates a Muon Alignment task and adds it to the analysis manager.
67 // Get the pointer to the existing analysis manager via the static access method.
68 AliAnalysisManager *analysisManager = AliAnalysisManager::GetAnalysisManager();
69 if( !analysisManager )
71 ::Error("AddTaskMuonAlignment", "No analysis manager to connect to.");
75 // get input event handler and check type
76 TString type = analysisManager->GetInputEventHandler()->GetDataType();
80 // when reading records, AOD are required
81 if (!type.Contains( "AOD" ) )
83 Error("AddTaskMuonRefit", "AOD input handler needed!");
89 // ESDs are required otherwise
90 if( !type.Contains( "ESD" ) )
92 Error("AddTaskMuonRefit", "AOD input handler needed!");
98 // Create the task, add it to the manager and configure it.
99 AliMUONAlignmentTask *muonAlign = new AliMUONAlignmentTask( "AliMUONAlignmentTask" );
100 muonAlign->SetOldAlignStorage( oldAlignmentOCDB );
101 muonAlign->SetNewAlignStorage( newAlignmentOCDB );
102 muonAlign->SetLoadOCDBOnce( kTRUE );
103 muonAlign->SetReadRecords( readRecords );
104 muonAlign->SetDoAlignment( doAlignment );
105 muonAlign->SetWriteRecords( writeRecords );
106 muonAlign->SetMergeAlignmentCDBs( kTRUE );
108 analysisManager->AddTask(muonAlign);
111 analysisManager->ConnectInput(muonAlign, 0, analysisManager->GetCommonInputContainer());
113 // when writting records, also connect output
115 { analysisManager->ConnectOutput(muonAlign, 0, analysisManager->GetCommonOutputContainer()); }
117 // return created task