]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSVertexer.cxx
Using AliLog (F.Carminati)
[u/mrichter/AliRoot.git] / ITS / AliITSVertexer.cxx
1 #include <AliESDVertex.h>
2 #include <AliITSVertexer.h>
3 #include <AliRunLoader.h>
4 #include <AliITSLoader.h>
5 #include <AliITSRecPoint.h>
6 #include <AliITSclusterV2.h>
7
8 ClassImp(AliITSVertexer)
9
10 //////////////////////////////////////////////////////////////////////
11 // Base class for primary vertex reconstruction                     //
12 // AliESDVertexer is a class for full 3D primary vertex finding     //
13 // derived classes: AliITSVertexerIons AliITSvertexerPPZ            //
14 //                  AliITSVertexerTracks                            //
15 //////////////////////////////////////////////////////////////////////
16
17 //______________________________________________________________________
18 AliITSVertexer::AliITSVertexer():AliVertexer() {
19   // Default Constructor
20   SetUseV2Clusters(kTRUE);
21 }
22
23 AliITSVertexer::AliITSVertexer(TString filename) {
24   // Standard constructor
25   AliRunLoader *rl = AliRunLoader::GetRunLoader();
26   if(!rl){
27     Fatal("AliITSVertexer","Run Loader not found");
28   }
29   if(rl->LoadgAlice()){
30     Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
31   }
32   fCurrentVertex  = 0;   
33   SetDebug();
34   SetFirstEvent(0);
35   SetLastEvent(0);
36   rl->LoadHeader();
37   AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
38   if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
39   if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
40   itsLoader->LoadRecPoints();
41   Int_t lst;
42   if(rl->TreeE()){
43     lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
44     SetLastEvent(lst-1);
45   }
46   SetUseV2Clusters(kTRUE);
47 }
48
49 //______________________________________________________________________
50 AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr) {
51   // Copy constructor
52   // Copies are not allowed. The method is protected to avoid misuse.
53   Error("AliITSVertexer","Copy constructor not allowed\n");
54 }
55
56 //______________________________________________________________________
57 AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
58   // Assignment operator
59   // Assignment is not allowed. The method is protected to avoid misuse.
60   Error("= operator","Assignment operator not allowed\n");
61   return *this;
62 }
63
64
65 //______________________________________________________________________
66 void AliITSVertexer::WriteCurrentVertex(){
67   // Write the current AliVertex object to file fOutFile
68   AliRunLoader *rl = AliRunLoader::GetRunLoader();
69   AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
70   fCurrentVertex->SetName("Vertex");
71   //  const char * name = fCurrentVertex->GetName();
72   //  itsLoader->SetVerticesContName(name);
73   Int_t rc = itsLoader->PostVertex(fCurrentVertex);
74   rc = itsLoader->WriteVertices();
75 }
76
77 //______________________________________________________________________
78 void AliITSVertexer::Clusters2RecPoints
79 (const TClonesArray *clusters, Int_t idx, TClonesArray *points) {
80   //------------------------------------------------------------
81   // Conversion AliITSclusterV2 -> AliITSRecPoints for the ITS
82   // module "idx" (entry in the tree with the clusters).
83   // Simplified version, supposed to work with the pixels only !
84   //------------------------------------------------------------
85   const Int_t lastSPD1=79; //let's hope the number of the SPDs will not change
86   const Int_t lastSPD2=239;//let's hope the number of the SPDs will not change
87
88   Float_t yshift = 0; //see AliITSclustererV2.cxx about these shifts
89   Float_t zshift[4] = {-10.708000, -3.536000, 3.536000, 10.708000}; //let's hope the positioning of the SPDs will not change
90
91   if (idx<=lastSPD1) {
92     yshift=0.248499;  //let's hope the positioning of the SPDs will not change
93   } else if (idx<=lastSPD2) {
94     yshift=3.096207;  //let's hope the positioning of the SPDs will not change
95   } else {
96     Fatal("Clusters2RecPoints","This is not an SPD module ! %d",idx);
97   }
98
99   TClonesArray &pn=*points;
100   Int_t ncl=clusters->GetEntriesFast();
101   for (Int_t i=0; i<ncl; i++) {
102     AliITSRecPoint p;
103     AliITSclusterV2 *c = (AliITSclusterV2 *)clusters->UncheckedAt(i);
104
105     Float_t x=c->GetY();  if (idx<=lastSPD1) x=-x;
106     x+=yshift;
107
108     Float_t z=c->GetZ();
109     z=-z; z+=zshift[idx%4];
110
111     p.SetX(x);
112     p.SetZ(z);
113     p.SetQ(c->GetQ());
114     p.SetSigmaX2(c->GetSigmaY2());
115     p.SetSigmaZ2(c->GetSigmaZ2());
116     p.SetLabel(0,c->GetLabel(0));
117     p.SetLabel(1,c->GetLabel(1));
118     p.SetLabel(2,c->GetLabel(2));
119
120     new (pn[i]) AliITSRecPoint(p);
121   }
122
123 }