AliRoot Core  edcc906 (edcc906)
AliMUONChamberCalibrationTask.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 
16 // $Id$
17 
18 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
23 
24 #include <Riostream.h>
25 
26 #include <TBranch.h>
27 #include <TChain.h>
28 #include <TObjArray.h>
29 #include <TFile.h>
30 #include <TMath.h>
31 #include <TRandom.h>
32 #include <TROOT.h>
33 #include <TString.h>
34 #include <TTree.h>
35 
37 
38 // STEER includes
39 #include "AliCDBManager.h"
40 #include "AliGRPManager.h"
41 #include "AliESDEvent.h"
42 #include "AliESDInputHandler.h"
43 #include "AliESDtrack.h"
44 #include "AliESDMuonTrack.h"
45 #include "AliLog.h"
46 #include "AliRecoParam.h"
47 #include "AliTracker.h"
48 
49 // ANALYSIS includes
50 #include "AliAnalysisDataSlot.h"
51 #include "AliAnalysisManager.h"
52 
53 // MUON includes
54 #include "AliMpConstants.h"
55 #include "AliMpCDB.h"
56 #include "AliMpPad.h"
57 #include "AliMpSegmentation.h"
58 #include "AliMpVSegmentation.h"
59 #include "AliMUONCalibrationData.h"
60 #include "AliMUONClusterInfo.h"
61 #include "AliMUONESDInterface.h"
62 #include "AliMUONPadInfo.h"
63 #include "AliMUONRecoParam.h"
64 #include "AliMUONTrack.h"
65 #include "AliMUONTrackParam.h"
66 #include "AliMUONVCalibParam.h"
67 #include "AliMUONVCluster.h"
68 //#include "AliMUONVClusterStore.h"
69 #include "AliMUONVDigit.h"
70 #include "AliMUONVDigitStore.h"
71 
75 
76 //______________________________________________________________
78  AliAnalysisTaskSE( "AliMUONChamberCalibrationTask" ),
79  fOCDBPath( "local://$ALICE_ROOT/OCDB" ),
80  fClusterInfoTree(0x0),
81  fMuonRecoParam(0x0),
82  fClusterInfo(0x0),
83  fCalibData(0x0),
84  fESDInterface(0x0),
85  fDigitStore(0x0),
86  fESDInputHandler(0x0),
87  fESDInputEvent(0x0)
88 {
89  //
91  //
92 
93 }
94 
95 //______________________________________________________________
97  char* ocdbpath,
98  const Int_t my_calib_option ):
99  AliAnalysisTaskSE( name ),
100  fOCDBPath( "local://$ALICE_ROOT/OCDB" ),
101  fClusterInfoTree(0x0),
102  fMuonRecoParam(0x0),
103  fClusterInfo(0x0),
104  fCalibData(0x0),
105  fESDInterface(0x0),
106  fDigitStore(0x0),
107  fESDInputHandler(0x0),
108  fESDInputEvent(0x0)
109 {
110  //
112  //
113 
114  fOCDBPath = ocdbpath;
115 }
116 
117 //______________________________________________________________
119 {
120  //
122  //
123 
124  delete fMuonRecoParam;
125  delete fClusterInfo;
126  delete fESDInterface;
127 
128 }
129 //______________________________________________________________
131 {
132  //
134  //
135 
136  AliDebug( 1, "" );
137 
138  TFile* clusterInfoFile = OpenFile( 0, "RECREATE" );
139  if( clusterInfoFile ) clusterInfoFile->SetCompressionLevel(1);
140  else AliError( "no output file created !!!" );
141 
142  if ( !fClusterInfoTree ) fClusterInfoTree = new TTree( "clusterInfoTree", "clusterInfoTree" );
143  fClusterInfoTree->Branch( "clusterInfo" , &fClusterInfo, 32000, 99);
144 }
145 
146 //______________________________________________________________
148 {
149  //
153  //
154 
155  AliDebug( 1, "" );
156 
157  // initialize the cluster info and the ESD interface
158 
161 
162  gRandom->SetSeed(0);
163 
164  // set mag field
165 
166  if ( !TGeoGlobalMagField::Instance()->GetField() ) {
167  AliInfo( "Loading field map..." );
168  AliGRPManager *grpMan = new AliGRPManager();
169  grpMan->ReadGRPEntry();
170  grpMan->SetMagField();
171  delete grpMan;
172  }
173 
174  // Load mapping
175 
178  man->SetSpecificStorage( "MUON/Calib/MappingData", fOCDBPath );
179  man->SetSpecificStorage( "MUON/Calib/MappingRunData", fOCDBPath ); // for the manu serial numbers
180  man->SetRun(0);
181  man->Print();
182  if ( ! AliMpCDB::LoadDDLStore() ) {
183  AliFatal( "Could not access mapping from OCDB !" );
184  exit(-1);
185  }
186 
187  // Set the reconstruction parameters for track refitting
188  // (needed when applying any of the with-gain options)
189 
191 
192  for (Int_t iCh=0; iCh<10; iCh++) {
193  fMuonRecoParam->SetDefaultNonBendingReso( iCh, 0.152 ); // input ESD was aligned (default cosmic settings)
194  fMuonRecoParam->SetDefaultBendingReso( iCh, 0.027 );
195  }
196  fMuonRecoParam->SetMaxNonBendingDistanceToTrack(5.); // was at 1. in default cosmic settings
198 
199  fMuonRecoParam->RequestStation(1, kTRUE); // only St 4 and 5 enabled in default cosmic settings
200  fMuonRecoParam->ImproveTracks(kTRUE, 7.); // was 6. in default cosmic settings
201 
202  AliInfo( "reconstruction parameters initialized as follows :" );
203  fMuonRecoParam->Print("FULL");
204 
206 }
207 
208 //______________________________________________________________
210 {
211  //
214  //
215 
216  AliDebug( 1, "" );
217 
218  fESDInputHandler = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
219  TTree* tree = NULL;
220 
221  if ( fESDInputHandler ) {
222 
223  // The properly initialized ESD input handler reads ESD tree
224  // and connect it to ESD event, so we only need to retrieve the later
226  if ( !fESDInputEvent ) {
227 
228  AliFatal( "Could not get input ESD event !!! ");
229 
230  }
231  } else {
232 
233  AliError( "Could not get input ESD handler !!!" );
234  // If no input event handler we need to get the tree once
235  // from input slot 0 for the chain
236  tree = dynamic_cast<TTree*> (GetInputData(0));
237  if ( tree ) tree->GetReadEntry();
238  else AliFatal( "Could not read tree from input slot 0 !!!" );
239  }
240 }
241 
242 //______________________________________________________________
243 void AliMUONChamberCalibrationTask::Exec( Option_t* /*option*/ )
244 {
245  //
248  //
249 
250  static Bool_t first = kTRUE;
251 
252  if ( first ) {
253  AliDebug( 1, "" );
254  first = kFALSE;
255  }
256 
257  if ( !fESDInputEvent ) {
258  AliError( "Input ESD event not available !!! " );
259  return;
260  }
261 
262  // load the current ESD event
264 
265  // get digit store
267 
268  // prepare access to calibration data
270 
271  // --------------------------------------------------------------------
272  // fill cluster info from clusters attached to each track of this event
273  // --------------------------------------------------------------------
274 
275  Int_t nTracks = (Int_t)fESDInputEvent->GetNumberOfMuonTracks();
276  if ( nTracks < 1 ) return;
277 
278  TIter nextTrack( fESDInterface->CreateTrackIterator() );
280 
281  while ( (track = static_cast<AliMUONTrack*>(nextTrack())) ) { // loop over tracks
282 
283  UInt_t muonClusterMap = BuildClusterMap( *track );
284 
285  AliMUONTrackParam* trackParam =
286  static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
287 
288  while ( trackParam ) { // loop over clusters
289 
290  fClusterInfo->Clear("C");
291 
292  // fill cluster info
293  AliMUONVCluster* cluster = trackParam->GetClusterPtr();
296  fClusterInfo->SetZ( cluster->GetZ() );
297  fClusterInfo->SetClusterId( cluster->GetUniqueID() );
298  fClusterInfo->SetClusterXY( cluster->GetX(), cluster->GetY() );
299  fClusterInfo->SetClusterXYErr( cluster->GetErrX(), cluster->GetErrY() );
300  fClusterInfo->SetClusterChi2( cluster->GetChi2() );
301  fClusterInfo->SetClusterCharge( cluster->GetCharge() );
302 
303  // fill track info
304  fClusterInfo->SetTrackId( track->GetUniqueID() );
305  fClusterInfo->SetTrackXY( trackParam->GetNonBendingCoor(), trackParam->GetBendingCoor() );
306  fClusterInfo->SetTrackThetaXY( TMath::ATan( trackParam->GetNonBendingSlope() ),
307  TMath::ATan( trackParam->GetBendingSlope() ) );
308  fClusterInfo->SetTrackP( trackParam->P() );
309  const TMatrixD paramCov = trackParam->GetCovariances();
310  fClusterInfo->SetTrackXYErr( TMath::Sqrt( paramCov(0,0) ),
311  TMath::Sqrt( paramCov(2,2) ) );
312  fClusterInfo->SetTrackChi2( track->GetNormalizedChi2() );
313  fClusterInfo->SetTrackCharge( (Short_t)trackParam->GetCharge() );
314  fClusterInfo->SetTrackNHits( track->GetNClusters() );
315  fClusterInfo->SetTrackChamberHitMap( muonClusterMap );
316 
317  // fill pad info if available
318  for ( Int_t i=0; i<cluster->GetNDigits(); i++ ) {
319 
320  AliMUONVDigit* digit = fDigitStore->FindObject( cluster->GetDigitId(i) );
321  if ( !digit ) continue;
322 
323  // pad location
325  GetMpSegmentation( digit->DetElemId(), AliMp::GetCathodType( digit->Cathode() ) );
326  AliMpPad pad = seg->PadByIndices( digit->PadX(), digit->PadY() );
327 
328  // calibration parameters
329  AliMUONVCalibParam* ped = fCalibData->Pedestals( digit->DetElemId(), digit->ManuId() );
330  Int_t manuChannel = digit->ManuChannel();
331  Int_t planeType = 0;
333  planeType = 1;
334  }
335 
336  // fill pad info
337  AliMUONPadInfo padInfo;
338  padInfo.SetPadId( digit->GetUniqueID() );
339  padInfo.SetPadPlaneType( planeType );
340  padInfo.SetPadXY( pad.GetPositionX(), pad.GetPositionY() );
341  padInfo.SetPadDimXY( pad.GetDimensionX(), pad.GetDimensionY() );
342  padInfo.SetPadCharge( (Double_t)digit->Charge() );
343  padInfo.SetPadADC( digit->ADC() );
344  padInfo.SetSaturated( digit->IsSaturated() );
345  padInfo.SetCalibrated( digit->IsCalibrated() );
346  padInfo.SetPedestal( ped->ValueAsFloatFast(manuChannel,0), // mean
347  ped->ValueAsFloatFast(manuChannel,1) ); // sigma
348 
349  fClusterInfo->AddPad( padInfo );
350  }
351 
352  // fill cluster info tree
353  fClusterInfoTree->Fill();
354 
355  trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
356  }
357 
358  }
359  // Added protection in case the derived task is not an AOD producer.
360  AliAnalysisDataSlot *out0 = GetOutputSlot(0);
361  if (out0 && out0->IsConnected()) PostData( 0, fClusterInfoTree );
362 
363 }
364 
365 
366 //______________________________________________________________
368 {
369  //
371  //
372 
373  UInt_t muonClusterMap = 0;
374 
375  AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->First());
376  while ( trackParam ) {
377 
378  muonClusterMap |= BIT(trackParam->GetClusterPtr()->GetChamberId());
379 
380  trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->After(trackParam));
381  }
382 
383  return muonClusterMap;
384 }
385 
386 //______________________________________________________________
387 void AliMUONChamberCalibrationTask::Terminate( Option_t* /*option*/ )
388 {
389  //
391  //
392 
393  AliDebug( 1, "" );
394 }
virtual Int_t ManuChannel() const =0
The channel within ManuId() this digit belongs to (manuChannel for tracker, localBoardChannel for tri...
void SetCalibrated(Bool_t calibrated=kTRUE)
Set the pad as being calibrated or not.
TString fOCDBPath
! default path to the condition database
void SetTrackNHits(UInt_t NHits)
Set the total number of hits associated to the track leaving this cluster.
void SetPedestal(Float_t mean, Float_t sigma)
Set pedestal parameters.
void ImproveTracks(Bool_t flag)
switch on/off the track improvement and keep the default cut in sigma to apply on cluster (local chi2...
virtual Int_t PadY() const =0
The y-index of this digit (>=0)
void SetClusterXY(Double_t x, Double_t y)
Set cluster coordinates (cm)
AliMUONCalibrationData * fCalibData
! needed to access to the calibration data for each pad within each cluster
static AliMpSegmentation * Instance(Bool_t warn=true)
virtual Double_t GetZ() const =0
Return coordinate Z (cm)
void SetPadDimXY(Double_t dX, Double_t dY)
Set pad dimension (cm)
void SetPadCharge(Double_t charge)
Set the calibrated charge.
Double_t GetBendingCoor() const
return bending coordinate (cm)
virtual Float_t ValueAsFloatFast(Int_t i, Int_t j=0) const =0
Same as above but without bound checking.
void LoadEvent(AliESDEvent &esdEvent, Bool_t refit=kTRUE)
AliMUONESDInterface * fESDInterface
! interface to easily access to the ESD content
static void ResetTracker(const AliMUONRecoParam *recoParam=0x0, Bool_t info=kTRUE)
virtual Int_t ADC() const =0
Raw ADC value of this digit.
void SetDefaultNonBendingReso(Int_t iCh, Double_t val)
Set the default non bending resolution of chamber iCh.
Bool_t ReadGRPEntry()
void SetClusterCharge(Double_t charge)
Set the total cluster charge.
void SetClusterChi2(Double_t clusterChi2)
set cluster Chi2
virtual Double_t GetErrX() const =0
Return resolution (cm) on coordinate X.
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
TIterator * CreateTrackIterator() const
void SetPadPlaneType(Int_t planeType)
Set the plane type 0=Bending 1=NonBending.
Track parameters in ALICE dimuon spectrometer.
void SetPadADC(Int_t adc)
Set the raw charge.
void SetTrackChi2(Double_t trackChi2)
set track Chi2
virtual void Terminate(Option_t *option="")
AliTPCfastTrack * track
void SetZ(Double_t z)
Set cluster/track Z-position (cm)
virtual Float_t Charge() const =0
The charge of this digit, calibrated or not depending on IsCalibrated()
virtual Bool_t IsCalibrated() const =0
Whether this digit has been calibrated or not (see note 1 in AliMUONVDigit.cxx)
TTree * tree
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
AliMUONRecoParam * fMuonRecoParam
! reconstruction parameters for track refitting
virtual UInt_t GetDigitId(Int_t i) const =0
Return Id of digits i.
Container of calibration values for a given number of channels.
Double_t GetBendingSlope() const
return bending slope (cm ** -1)
abstract base class for clusters
Double_t GetCharge() const
return the charge (assumed forward motion)
void SetSpecificStorage(const char *calibType, const char *dbString, Int_t version=-1, Int_t subVersion=-1)
Int_t GetNumberOfMuonTracks() const
Definition: AliESDEvent.h:543
void SetMaxNonBendingDistanceToTrack(Double_t val)
set the maximum distance to the track to search for compatible cluster(s) in non bending direction ...
void SetClusterXYErr(Double_t xErr, Double_t yErr)
Set cluster resolution (cm)
#define AliInfo(message)
Definition: AliLog.h:484
virtual void Clear(Option_t *opt="")
Int_t GetRunNumber() const
Definition: AliESDEvent.h:141
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
void SetTrackThetaXY(Double_t thetaX, Double_t thetaY)
Set track angles (radian)
static AliMUONRecoParam * GetCosmicParam()
Converter between MUON track/cluster/digit and ESDMuon track/cluster/pad.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
virtual Double_t GetErrY() const =0
Return resolution (cm) on coordinate Y.
non-bending plane
void SetSaturated(Bool_t saturated=kTRUE)
Set the pad as being saturated or not.
Definition of the task to extract cluster information from MCH tracks after applying the calibration ...
void SetTrackP(Double_t p)
Set track momentum (MeV/c)
virtual Int_t GetNDigits() const =0
Return number of associated digits.
void SetEventId(Int_t eventId)
set event number
virtual Double_t GetChi2() const =0
Return chi2 of cluster.
Double_t P() const
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
Bool_t SetMagField()
virtual Int_t PadX() const =0
The x-index of this digit (>=0)
void SetRun(Int_t run)
AliMUONVStore * Pedestals() const
Get the pedestal store.
void SetTrackId(UInt_t trackId)
set track ID
#define AliFatal(message)
Definition: AliLog.h:640
void SetTrackXY(Double_t x, Double_t y)
Set track coordinates (cm)
void SetDefaultStorage(const char *dbString)
void Print(Option_t *option="") const
static Int_t GetChamberId(UInt_t uniqueID)
Return chamber id (0..), part of the uniqueID.
virtual Double_t GetY() const =0
Return coordinate Y (cm)
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
void SetDefaultBendingReso(Int_t iCh, Double_t val)
Set the default bending resolution of chamber iCh.
Single entry point to access MUON calibration data.
void SetTrackXYErr(Double_t xErr, Double_t yErr)
Set track resolution (cm)
void SetRunId(Int_t runId)
set run number
AliMUONClusterInfo * fClusterInfo
! cluster info used to fill the output TTree
The abstract base class for the segmentation.
AliVEvent * GetEvent() const
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
void SetPadId(UInt_t padId)
Set pad ID.
Int_t GetRunNumber() const
Definition: AliESDRun.h:35
void RequestStation(Int_t iSt, Bool_t flag)
request or not at least one cluster in the station to validate the track
Double_t GetNonBendingCoor() const
return non bending coordinate (cm)
virtual Int_t ManuId() const =0
The electronic card id this digit belongs to (manuId for tracker, localboardId for trigger) ...
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
AliMUONVDigitStore * fDigitStore
! pointer to the digit stored for the current input ESD event
AliMUONVCluster * GetClusterPtr() const
get pointeur to associated cluster
virtual void Exec(Option_t *option="")
const AliESDRun * GetESDRun() const
Definition: AliESDEvent.h:135
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
virtual Bool_t IsSaturated() const =0
Whether the ADC has saturated.
virtual Double_t GetX() const =0
Return coordinate X (cm)
void SetTrackChamberHitMap(UInt_t trackChamberHitMap)
Set the map of hit chambers.
void SetMaxBendingDistanceToTrack(Double_t val)
set the maximum distance to the track to search for compatible cluster(s) in bending direction ...
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
Int_t GetEventNumberInFile() const
Definition: AliESDEvent.h:224
AliMUONVDigitStore * GetDigits() const
Return internal track store.
Reconstructed track in ALICE dimuon spectrometer.
Definition: AliMUONTrack.h:24
#define AliError(message)
Definition: AliLog.h:591
virtual AliMUONVDigit * FindObject(const TObject *object) const
Find an object (default is to forward to FindObject(object->GetUniqueID())
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
AliESDInputHandler * fESDInputHandler
! ESD input handler
Class to summarize ESD data at cluster.
TTree * fClusterInfoTree
! TTree filled with the cluster information
virtual Double_t GetCharge() const =0
Set the cluster charge.
virtual void ConnectInputData(Option_t *option="")
Class to summarize ESD data at pad.
AliESDEvent * fESDInputEvent
! pointer to the current input ESD event
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
void AddPad(const AliMUONPadInfo &pad)
attach a pad to the cluster
const TMatrixD & GetCovariances() const
void SetTrackCharge(Short_t charge)
Set the muon charge.
class TMatrixT< Double_t > TMatrixD
void SetClusterId(UInt_t clusterId)
set cluster ID
static Int_t ManuMask(AliMp::PlaneType planeType)
TObjArray * GetTrackParamAtCluster() const
void SetPadXY(Double_t x, Double_t y)
Set pad coordinates (cm)
virtual void Print(Option_t *option="") const
Double_t GetNonBendingSlope() const
return non bending slope (cm ** -1)