]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AddTaskMuonAlignment.C
Minor changes.
[u/mrichter/AliRoot.git] / MUON / AddTaskMuonAlignment.C
1 /// \ingroup macros
2 /// \file AddTaskMuonAlignment.C
3 /// \brief Macro to add an AliMUONAlignmentTask to an analysis train
4 ///
5 /// \author Javier Castillo, CEA/Saclay - Irfu/SPhN
6 /// \author Hugo Pereira Da Costa, CEA/Saclay - Irfu/SPhN
7
8 /**
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.
12
13 The task has two ways of operation
14
15 1/ Full mode:
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
22
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)
25
26 2/ Split mode:
27 The task must run twice.
28 First pass with flags: readRecords = kFALSE, writeRecords = kTRUE, doAlignment = kFALSE
29 This
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"
35
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
40
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
44
45 When performing the alignment (doAlignment=kTRUE), one can "fix", "group", or "constrain"
46 detector's alignment parameters in order to ease the inversion.
47
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.
50 */
51
52 #include "AliAnalysisManager.h"
53 #include "AliMUONAlignmentTask.h"
54 #include "AliVEventHandler.h"
55
56 AliMUONAlignmentTask *AddTaskMuonAlignment(
57   TString oldAlignmentOCDB,
58   TString newAlignmentOCDB,
59   Bool_t doAlignment = kTRUE,
60   Bool_t writeRecords = kTRUE,
61   Bool_t readRecords = kFALSE
62  )
63 {
64
65   /// Creates a Muon Alignment task and adds it to the analysis manager.
66
67   // Get the pointer to the existing analysis manager via the static access method.
68   AliAnalysisManager *analysisManager = AliAnalysisManager::GetAnalysisManager();
69   if( !analysisManager )
70   {
71     ::Error("AddTaskMuonAlignment", "No analysis manager to connect to.");
72     return NULL;
73   }
74
75   // get input event handler and check type
76   TString type = analysisManager->GetInputEventHandler()->GetDataType();
77   if( readRecords )
78   {
79
80     // when reading records, AOD are required
81     if (!type.Contains( "AOD" ) )
82     {
83       Error("AddTaskMuonRefit", "AOD input handler needed!");
84       return NULL;
85     }
86
87   } else {
88
89     // ESDs are required otherwise
90     if( !type.Contains( "ESD" ) )
91     {
92       Error("AddTaskMuonRefit", "AOD input handler needed!");
93       return NULL;
94     }
95
96   }
97
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 );
107
108   analysisManager->AddTask(muonAlign);
109
110   // connect input
111   analysisManager->ConnectInput(muonAlign,  0, analysisManager->GetCommonInputContainer());
112
113   // when writting records, also connect output
114   if( writeRecords )
115   { analysisManager->ConnectOutput(muonAlign,  0, analysisManager->GetCommonOutputContainer()); }
116
117   // return created task
118   return muonAlign;
119
120 }