Digits and RecPoint with NewIO
[u/mrichter/AliRoot.git] / START / AliSTARTvertex.cxx
CommitLineData
6740ab97 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 **************************************************************************/
4c475d27 15
88cb7938 16/* $Id$ */
ef0750c2 17
88cb7938 18#include <Riostream.h>
19#include <stdlib.h>
94de3818 20
88cb7938 21#include <TDirectory.h>
22#include <TVirtualMC.h>
ef51244a 23
88cb7938 24#include "AliRun.h"
25#include "AliSTART.h"
6740ab97 26#include "AliSTARTdigit.h"
27#include "AliSTARThit.h"
88cb7938 28#include "AliSTARTvertex.h"
f3ed336b 29
6740ab97 30ClassImp(AliSTARTvertex)
31
32AliSTARTvertex::AliSTARTvertex( Int_t * Zposit)
33{
34 //
6740ab97 35 // The creator for the AliSTARTvertex class. This routine fills the
36 // AliSTARTvertex data members from the array vertex.
37 // The order of the elements in the vertex array are
f3ed336b 38 // fZposition = vertex[0],
6740ab97 39 //
40
41 Zposit = &fZposition ;
42}
43
7a68e0ef 44void AliSTARTvertex::Reconstruct()
6740ab97 45{
f3ed336b 46 /***************************************************
47 Resonstruct digits to vertex position
48 ****************************************************/
49
6740ab97 50 Int_t timediff;
51 Float_t timePs;
52 char nameTD[8],nameTR[8];
7a68e0ef 53 char filename[100];
54 sprintf(filename,"galice.root");
55 AliRunLoader* rl = AliRunLoader::Open("galice.root",AliConfig::fgkDefaultEventFolderName,"read");
56 if (rl == 0x0)
57 {
58 cerr<<"Can not open session for file galice.root\n";
59 return;
60 }
61
62 rl->LoadgAlice();
63 gAlice = rl->GetAliRun();
64
65 AliSTART* START = (AliSTART *)gAlice->GetDetector("START");
66
67 rl->LoadHeader();
68 rl->LoadKinematics("READ");
69 Int_t retval;
70 AliLoader* lstart = rl->GetLoader("STARTLoader");
71 lstart->LoadDigits("READ");
72
6740ab97 73 AliSTARTdigit *digits;
7115262b 74 AliSTARTvertex *fvertex;
6740ab97 75
6740ab97 76 digits = new AliSTARTdigit();
7115262b 77 fvertex = new AliSTARTvertex();
6740ab97 78
79 // Event ------------------------- LOOP
80
e73d68f2 81 // gAlice->GetEvent(evNumber);
7a68e0ef 82 Int_t iNevents=rl->GetNumberOfEvents();
83 cout<<" nevents "<<iNevents<<endl;
7115262b 84
7a68e0ef 85 for (Int_t evNumber=0; evNumber<iNevents; evNumber++){
86 rl->GetEvent(evNumber);
87 lstart->LoadDigits("READ");
88 gDirectory->ls();
89
90 sprintf(nameTD,"START_D_%d",evNumber);
91 TObject *td = (TObject*)gDirectory->Get(nameTD);
92 printf("%s\n",nameTD);
93 // td->Dump();
94 if (!td) {
95 cerr<<"something wrong with input...."<<endl;
96 exit(111);
97 }
98 td->Read(nameTD);
99 digits->Read(nameTD);
100 if(digits->GetTimeDiff()<TMath::Abs(1000))
101 {
102 timediff=digits->GetTimeDiff(); //time in number of channels
103 timePs=(512-timediff)*2.5; // time in Ps channel_width =10ps
104 cout<<"timediff "<< timediff<<" timePs "<<timePs<<endl;
105 // Float_t c = 299792458/1.e9; //speed of light cm/ps
106 Float_t c = 0.3; //speed of light mm/ps
107 Float_t Zposit=timePs*c;// for 0 vertex
108 cout<<" Zposit "<<Zposit<<endl;
109 fvertex->Set((Int_t) Zposit);
6740ab97 110 }
7a68e0ef 111 lstart->LoadRecPoints("UPDATE");
112 sprintf(nameTR,"START_R_%d",evNumber);
113 printf("%s\n",nameTR);
114 fvertex->Write(nameTR);
115
116
117 }
6740ab97 118}
119
120
121
122
7115262b 123
124