]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/TenderSupplies/AliVtxTenderSupply.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliVtxTenderSupply.cxx
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
17 ///////////////////////////////////////////////////////////////////////////////
18 //                                                                           //
19 // Redo primary vertex on the fly, using the diamond constraint              //
20 //                                                                           //
21 ///////////////////////////////////////////////////////////////////////////////
22
23
24 #include <AliESDEvent.h>
25 #include <AliESDInputHandler.h>
26 #include <AliVertexerTracks.h>
27 #include <AliTender.h>
28 #include <AliCDBId.h>
29 #include <AliCDBManager.h>
30 #include <AliCDBEntry.h>
31 #include <AliESDUtils.h>
32
33 #include "AliVtxTenderSupply.h"
34
35 ClassImp(AliVtxTenderSupply)
36
37 AliVtxTenderSupply::AliVtxTenderSupply() :
38   AliTenderSupply(),
39   fDiamond(0x0),
40   fRefitAlgo(-1)
41 {
42   //
43   // default ctor
44   //
45 }
46
47 //_____________________________________________________
48 AliVtxTenderSupply::AliVtxTenderSupply(const char *name, const AliTender *tender) :
49   AliTenderSupply(name,tender),
50   fDiamond(0x0),
51   fRefitAlgo(-1)
52 {
53   //
54   // named ctor
55   //
56 }
57
58 //_____________________________________________________
59 void AliVtxTenderSupply::ProcessEvent()
60 {
61   //
62   // Recalculate the Vertex with constraint
63   //
64
65   AliESDEvent *event=fTender->GetEvent();
66   if (!event) return;
67
68   //
69   if (fRefitAlgo >=0 ) { // refit with user supplied algo and using the diamond stored in ESD
70     AliESDUtils::RefitESDVertexTracks(event, fRefitAlgo);
71     return;
72   }
73   //
74
75   if (fTender->RunChanged()){
76     fDiamond=0x0;
77     AliCDBEntry *meanVertex=fTender->GetCDBManager()->Get("GRP/Calib/MeanVertex",fTender->GetRun());
78     if (!meanVertex) {
79       AliError("No new MeanVertex entry found");
80       return;
81     } else {
82       fDiamond=(AliESDVertex*)meanVertex->GetObject();
83     }
84     //printf("\nRun %d, sigmaX %f, sigmaY %f\n",fTender->GetRun(),fDiamond->GetXRes(),fDiamond->GetYRes());
85   }
86
87   if (!fDiamond) return;
88
89   // Redo the primary with the constraint ONLY if the updated mean vertex was found in the OCDB
90   if ( (fDiamond->GetXRes())<2){ 
91     AliVertexerTracks vertexer(event->GetMagneticField());
92     vertexer.SetITSMode();
93     vertexer.SetMinClusters(3);
94     vertexer.SetVtxStart(fDiamond);
95     AliESDVertex *pvertex = vertexer.FindPrimaryVertex(event);
96     event->SetPrimaryVertexTracks(pvertex);
97     // write the diamond parameters
98     event->SetDiamond(fDiamond);
99     delete pvertex;
100   }  
101 }