]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSVertexer.cxx
Add/remove classes according to changes in MUON.
[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 <AliMultiplicity.h>
6 #include <AliITSMultReconstructor.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 //                  AliITSVertexer3D                                //
15 //////////////////////////////////////////////////////////////////////
16
17 //______________________________________________________________________
18 AliITSVertexer::AliITSVertexer():AliVertexer() {
19   // Default Constructor
20 }
21
22 AliITSVertexer::AliITSVertexer(TString filename) {
23   // Standard constructor
24   AliRunLoader *rl = AliRunLoader::GetRunLoader();
25   if(!rl){
26     Fatal("AliITSVertexer","Run Loader not found");
27   }
28   if(rl->LoadgAlice()){
29     Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
30   }
31   fCurrentVertex  = 0;   
32   fDebug = 0;
33   SetFirstEvent(0);
34   SetLastEvent(0);
35   rl->LoadHeader();
36   AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
37   if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
38   if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
39   itsLoader->LoadRecPoints();
40   Int_t lst;
41   if(rl->TreeE()){
42     lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
43     SetLastEvent(lst-1);
44   }
45 }
46
47 //______________________________________________________________________
48 AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr) {
49   // Copy constructor
50   // Copies are not allowed. The method is protected to avoid misuse.
51   Error("AliITSVertexer","Copy constructor not allowed\n");
52 }
53
54 //______________________________________________________________________
55 AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
56   // Assignment operator
57   // Assignment is not allowed. The method is protected to avoid misuse.
58   Error("= operator","Assignment operator not allowed\n");
59   return *this;
60 }
61
62 //______________________________________________________________________
63 void AliITSVertexer::FindMultiplicity(Int_t evnumber){
64   // Invokes AliITSMultReconstructor to determine the
65   // charged multiplicity in the pixel layers
66   if(fMult){delete fMult; fMult = 0;}
67   Bool_t success=kTRUE;
68   if(!fCurrentVertex)success=kFALSE;
69   if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
70   if(!success){
71     AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
72     return;
73   }
74   AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
75   AliRunLoader *rl =AliRunLoader::GetRunLoader();
76   AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
77   multReco->SetGeometry(itsLoader->GetITSgeom());
78   itsLoader->LoadRecPoints();
79   rl->GetEvent(evnumber);
80   TTree* itsClusterTree = itsLoader->TreeR();
81   if (!itsClusterTree) {
82     AliError(" Can't get the ITS cluster tree !\n");
83     return;
84   }
85   Double_t vtx[3];
86   fCurrentVertex->GetXYZ(vtx);
87   Float_t vtxf[3];
88   for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
89   multReco->SetHistOn(kFALSE);
90   multReco->Reconstruct(itsClusterTree,vtxf,vtxf);
91   cout<<"======================================================="<<endl;
92   cout<<"Event number "<<evnumber<<"; tracklets= "<<multReco->GetNTracklets()<<endl;
93   Int_t notracks=multReco->GetNTracklets();
94   Float_t *trk = new Float_t [notracks];
95   Float_t *phi = new Float_t [notracks];
96   Float_t *dphi = new Float_t [notracks];
97   for(Int_t i=0;i<multReco->GetNTracklets();i++){
98     trk[i] = multReco->GetTracklet(i)[0];
99     phi[i] =  multReco->GetTracklet(i)[1];
100     dphi[i] = multReco->GetTracklet(i)[2];
101   }
102   fMult = new AliMultiplicity(notracks,trk,phi, dphi);
103   delete [] trk;
104   delete [] phi;
105   delete [] dphi;
106   itsLoader->UnloadRecPoints();
107   delete multReco;
108   return;
109 }
110
111 //______________________________________________________________________
112 void AliITSVertexer::WriteCurrentVertex(){
113   // Write the current AliVertex object to file fOutFile
114   AliRunLoader *rl = AliRunLoader::GetRunLoader();
115   AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
116   fCurrentVertex->SetName("Vertex");
117   //  const char * name = fCurrentVertex->GetName();
118   //  itsLoader->SetVerticesContName(name);
119   Int_t rc = itsLoader->PostVertex(fCurrentVertex);
120   rc = itsLoader->WriteVertices();
121 }