#include <math.h>
#include <TFile.h>
#include "AliITSOnlineSPDphys.h"
#include "AliITSOnlineSPDphysInfo.h"
#include "AliITSOnlineSPDHitArray.h"
AliITSOnlineSPDphys::AliITSOnlineSPDphys(const Char_t *fileName, Bool_t readFromGridFile) :
fFile(NULL),
fWrite(kFALSE),
fModified(kFALSE),
fInfoModified(kFALSE),
fPhysInfo(NULL),
fFileName(fileName)
{
for(Int_t ihs =0; ihs<6; ihs++) fHitArray[ihs]=0x0;
Bool_t bRead = readFromGridFile;
if (!bRead) {
FILE* fp0 = fopen(fFileName.Data(), "r");
if (fp0 != NULL) {
bRead=kTRUE;
fclose(fp0);
}
}
if (bRead) {
fFile = TFile::Open(fFileName.Data(), "READ");
if (fFile==NULL) {
printf("ERROR: AliITSOnlineSPDphys: File %s not found! Creating 'test999.root' file instead\n",fFileName.Data());
fFileName = "test999.root";
fPhysInfo = new AliITSOnlineSPDphysInfo();
fInfoModified=kTRUE;
fFile = new TFile(fFileName.Data(), "RECREATE");
fWrite=kTRUE;
InitHitmap();
}
else {
fWrite=kFALSE;
fFile->GetObject("AliITSOnlineSPDphysInfo", fPhysInfo);
ReadHitmap();
}
}
else {
fPhysInfo = new AliITSOnlineSPDphysInfo();
fInfoModified=kTRUE;
fFile = new TFile(fFileName.Data(), "RECREATE");
fWrite=kTRUE;
InitHitmap();
}
}
AliITSOnlineSPDphys::AliITSOnlineSPDphys(const AliITSOnlineSPDphys& ) :
fFile(NULL),
fWrite(kFALSE),
fModified(kFALSE),
fInfoModified(kFALSE),
fPhysInfo(NULL),
fFileName(".")
{
for(Int_t i=0; i<6; i++) fHitArray[i]=0x0;
printf("This object should not be copied!");
}
AliITSOnlineSPDphys::~AliITSOnlineSPDphys() {
if (fModified) {
SaveHitmap();
}
for (UInt_t hs=0; hs<6; hs++) {
if (fHitArray[hs]!=NULL) {
delete fHitArray[hs];
fHitArray[hs]=NULL;
}
}
if (fInfoModified) {
if (!fWrite) {
fFile->Close();
delete fFile;
fFile = new TFile(fFileName.Data(), "UPDATE");
fWrite=kTRUE;
}
fFile->Delete("AliITSOnlineSPDphysInfo;*");
fFile->WriteTObject(fPhysInfo, "AliITSOnlineSPDphysInfo");
}
if (fFile!=NULL) {
delete fFile;
}
}
AliITSOnlineSPDphys& AliITSOnlineSPDphys::operator=(const AliITSOnlineSPDphys& phys) {
printf("This object should not be copied!");
if (this!=&phys) {
}
return *this;
}
void AliITSOnlineSPDphys::ClearThis() {
for (UInt_t hs=0; hs<6; hs++) {
if (fHitArray[hs]!=NULL) {
delete fHitArray[hs];
}
fHitArray[hs] = NULL;
}
InitHitmap();
fPhysInfo->ClearThis();
fFile->Close();
delete fFile;
fFile = new TFile(fFileName.Data(), "RECREATE");
fWrite=kTRUE;
fFile->WriteTObject(fPhysInfo, "AliITSOnlineSPDphysInfo");
fInfoModified=kTRUE;
}
void AliITSOnlineSPDphys::InitHitmap() {
for (UInt_t hs=0; hs<6; hs++) {
fHitArray[hs] = new AliITSOnlineSPDHitArray();
}
fModified=kTRUE;
}
void AliITSOnlineSPDphys::AddPhys(AliITSOnlineSPDphys* phys2) {
if (phys2==NULL) return;
if (GetEqNr()!=phys2->GetEqNr() && GetEqNr()!=999) {
printf("AliITSOnlineSPDphys::AddPhys eqNr mismatch!\n");
return;
}
if (GetEqNr()==999) {
SetEqNr(phys2->GetEqNr());
}
UInt_t nrRuns = phys2->GetNrRuns();
for (UInt_t i=0; i<nrRuns; i++) {
AddRunNr(phys2->GetRunNr(i));
}
SetNrEvents(GetNrEvents() + phys2->GetNrEvents());
for (UInt_t hs=0; hs<6; hs++) {
for (UInt_t chip=0; chip<10; chip++) {
for (UInt_t col=0; col<32; col++) {
for (UInt_t row=0; row<256; row++) {
SetHits(hs,chip,col,row,GetHits(hs,chip,col,row)+phys2->GetHits(hs,chip,col,row));
}
}
}
}
}
void AliITSOnlineSPDphys::ReadHitmap() {
for (UInt_t hs=0; hs<6; hs++) {
TString hName = Form("HitArray_HS%d",hs);
fFile->GetObject(hName.Data(), fHitArray[hs]);
}
}
void AliITSOnlineSPDphys::SaveHitmap() {
if (!fWrite) {
fFile->Close();
delete fFile;
fFile = new TFile(fFileName.Data(), "UPDATE");
fWrite=kTRUE;
}
for (UInt_t hs=0; hs<6; hs++) {
TString hName = Form("HitArray_HS%d",hs);
TString hDelete = Form("%s;*",hName.Data());
fFile->Delete(hDelete.Data());
fFile->WriteTObject(fHitArray[hs], hName.Data());
}
fModified=kFALSE;
}
void AliITSOnlineSPDphys::SetHits(UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi, UInt_t val) {
fHitArray[hs]->SetHits(chipi,coli,rowi,val);
fModified=kTRUE;
}
void AliITSOnlineSPDphys::AddHits(UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi, Int_t val) {
Int_t summedVal = fHitArray[hs]->GetHits(chipi,coli,rowi)+val;
if (summedVal>0) {
fHitArray[hs]->SetHits(chipi,coli,rowi,(UInt_t)summedVal);
}
else {
fHitArray[hs]->SetHits(chipi,coli,rowi,0);
}
fModified=kTRUE;
}
void AliITSOnlineSPDphys::IncrementHits(UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi) {
fHitArray[hs]->IncrementHits(chipi,coli,rowi);
fModified=kTRUE;
}
UInt_t AliITSOnlineSPDphys::GetHits(UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi) {
return fHitArray[hs]->GetHits(chipi,coli,rowi);
}
Float_t AliITSOnlineSPDphys::GetHitsEfficiency(UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi) {
UInt_t ntr = GetNrEvents();
if (ntr>0) {
return ((Float_t)GetHits(hs,chipi,coli,rowi))/ntr;
}
else {
return 0;
}
}
Float_t AliITSOnlineSPDphys::GetHitsEfficiencyError(UInt_t hs, UInt_t chipi, UInt_t coli, UInt_t rowi) {
Float_t hits = GetHits(hs,chipi,coli,rowi);
UInt_t ntr = GetNrEvents();
return sqrt(hits*(ntr-hits)/ntr)/ntr;
}
Float_t AliITSOnlineSPDphys::GetAverageMultiplicity(UInt_t hs, UInt_t chipi) {
Float_t nrhits = 0;
for (UInt_t chip=0;chip<10;chip++) {
if (chipi==10 || chip==chipi) {
for (Int_t col=0; col<32; col++) {
for (Int_t row=0; row<256; row++) {
nrhits+=GetHits(hs,chip,col,row);
}
}
}
}
UInt_t ntr = GetNrEvents();
if (ntr>0) {
return nrhits/ntr;
}
else {
return 0;
}
}
Float_t AliITSOnlineSPDphys::GetAverageMultiplicityTot(UInt_t hs) {
return GetAverageMultiplicity(hs,10);
}
void AliITSOnlineSPDphys::AddRunNr(UInt_t val) {
fPhysInfo->AddRunNr(val);
fInfoModified=kTRUE;
}
void AliITSOnlineSPDphys::SetEqNr(UInt_t val) {
fPhysInfo->SetEqNr(val);
fInfoModified=kTRUE;
}
void AliITSOnlineSPDphys::SetNrEvents(UInt_t val) {
fPhysInfo->SetNrEvents(val);
fInfoModified=kTRUE;
}
void AliITSOnlineSPDphys::AddNrEvents(Int_t val) {
fPhysInfo->AddNrEvents(val);
fInfoModified=kTRUE;
}
void AliITSOnlineSPDphys::IncrementNrEvents() {
fPhysInfo->IncrementNrEvents();
fInfoModified=kTRUE;
}
UInt_t AliITSOnlineSPDphys::GetNrRuns() const {
return fPhysInfo->GetNrRuns();
}
UInt_t AliITSOnlineSPDphys::GetRunNr(UInt_t posi) const {
return fPhysInfo->GetRunNr(posi);
}
UInt_t AliITSOnlineSPDphys::GetEqNr() const {
return fPhysInfo->GetEqNr();
}
UInt_t AliITSOnlineSPDphys::GetNrEvents() const {
return fPhysInfo->GetNrEvents();
}
AliITSOnlineSPDphys.cxx:1 AliITSOnlineSPDphys.cxx:2 AliITSOnlineSPDphys.cxx:3 AliITSOnlineSPDphys.cxx:4 AliITSOnlineSPDphys.cxx:5 AliITSOnlineSPDphys.cxx:6 AliITSOnlineSPDphys.cxx:7 AliITSOnlineSPDphys.cxx:8 AliITSOnlineSPDphys.cxx:9 AliITSOnlineSPDphys.cxx:10 AliITSOnlineSPDphys.cxx:11 AliITSOnlineSPDphys.cxx:12 AliITSOnlineSPDphys.cxx:13 AliITSOnlineSPDphys.cxx:14 AliITSOnlineSPDphys.cxx:15 AliITSOnlineSPDphys.cxx:16 AliITSOnlineSPDphys.cxx:17 AliITSOnlineSPDphys.cxx:18 AliITSOnlineSPDphys.cxx:19 AliITSOnlineSPDphys.cxx:20 AliITSOnlineSPDphys.cxx:21 AliITSOnlineSPDphys.cxx:22 AliITSOnlineSPDphys.cxx:23 AliITSOnlineSPDphys.cxx:24 AliITSOnlineSPDphys.cxx:25 AliITSOnlineSPDphys.cxx:26 AliITSOnlineSPDphys.cxx:27 AliITSOnlineSPDphys.cxx:28 AliITSOnlineSPDphys.cxx:29 AliITSOnlineSPDphys.cxx:30 AliITSOnlineSPDphys.cxx:31 AliITSOnlineSPDphys.cxx:32 AliITSOnlineSPDphys.cxx:33 AliITSOnlineSPDphys.cxx:34 AliITSOnlineSPDphys.cxx:35 AliITSOnlineSPDphys.cxx:36 AliITSOnlineSPDphys.cxx:37 AliITSOnlineSPDphys.cxx:38 AliITSOnlineSPDphys.cxx:39 AliITSOnlineSPDphys.cxx:40 AliITSOnlineSPDphys.cxx:41 AliITSOnlineSPDphys.cxx:42 AliITSOnlineSPDphys.cxx:43 AliITSOnlineSPDphys.cxx:44 AliITSOnlineSPDphys.cxx:45 AliITSOnlineSPDphys.cxx:46 AliITSOnlineSPDphys.cxx:47 AliITSOnlineSPDphys.cxx:48 AliITSOnlineSPDphys.cxx:49 AliITSOnlineSPDphys.cxx:50 AliITSOnlineSPDphys.cxx:51 AliITSOnlineSPDphys.cxx:52 AliITSOnlineSPDphys.cxx:53 AliITSOnlineSPDphys.cxx:54 AliITSOnlineSPDphys.cxx:55 AliITSOnlineSPDphys.cxx:56 AliITSOnlineSPDphys.cxx:57 AliITSOnlineSPDphys.cxx:58 AliITSOnlineSPDphys.cxx:59 AliITSOnlineSPDphys.cxx:60 AliITSOnlineSPDphys.cxx:61 AliITSOnlineSPDphys.cxx:62 AliITSOnlineSPDphys.cxx:63 AliITSOnlineSPDphys.cxx:64 AliITSOnlineSPDphys.cxx:65 AliITSOnlineSPDphys.cxx:66 AliITSOnlineSPDphys.cxx:67 AliITSOnlineSPDphys.cxx:68 AliITSOnlineSPDphys.cxx:69 AliITSOnlineSPDphys.cxx:70 AliITSOnlineSPDphys.cxx:71 AliITSOnlineSPDphys.cxx:72 AliITSOnlineSPDphys.cxx:73 AliITSOnlineSPDphys.cxx:74 AliITSOnlineSPDphys.cxx:75 AliITSOnlineSPDphys.cxx:76 AliITSOnlineSPDphys.cxx:77 AliITSOnlineSPDphys.cxx:78 AliITSOnlineSPDphys.cxx:79 AliITSOnlineSPDphys.cxx:80 AliITSOnlineSPDphys.cxx:81 AliITSOnlineSPDphys.cxx:82 AliITSOnlineSPDphys.cxx:83 AliITSOnlineSPDphys.cxx:84 AliITSOnlineSPDphys.cxx:85 AliITSOnlineSPDphys.cxx:86 AliITSOnlineSPDphys.cxx:87 AliITSOnlineSPDphys.cxx:88 AliITSOnlineSPDphys.cxx:89 AliITSOnlineSPDphys.cxx:90 AliITSOnlineSPDphys.cxx:91 AliITSOnlineSPDphys.cxx:92 AliITSOnlineSPDphys.cxx:93 AliITSOnlineSPDphys.cxx:94 AliITSOnlineSPDphys.cxx:95 AliITSOnlineSPDphys.cxx:96 AliITSOnlineSPDphys.cxx:97 AliITSOnlineSPDphys.cxx:98 AliITSOnlineSPDphys.cxx:99 AliITSOnlineSPDphys.cxx:100 AliITSOnlineSPDphys.cxx:101 AliITSOnlineSPDphys.cxx:102 AliITSOnlineSPDphys.cxx:103 AliITSOnlineSPDphys.cxx:104 AliITSOnlineSPDphys.cxx:105 AliITSOnlineSPDphys.cxx:106 AliITSOnlineSPDphys.cxx:107 AliITSOnlineSPDphys.cxx:108 AliITSOnlineSPDphys.cxx:109 AliITSOnlineSPDphys.cxx:110 AliITSOnlineSPDphys.cxx:111 AliITSOnlineSPDphys.cxx:112 AliITSOnlineSPDphys.cxx:113 AliITSOnlineSPDphys.cxx:114 AliITSOnlineSPDphys.cxx:115 AliITSOnlineSPDphys.cxx:116 AliITSOnlineSPDphys.cxx:117 AliITSOnlineSPDphys.cxx:118 AliITSOnlineSPDphys.cxx:119 AliITSOnlineSPDphys.cxx:120 AliITSOnlineSPDphys.cxx:121 AliITSOnlineSPDphys.cxx:122 AliITSOnlineSPDphys.cxx:123 AliITSOnlineSPDphys.cxx:124 AliITSOnlineSPDphys.cxx:125 AliITSOnlineSPDphys.cxx:126 AliITSOnlineSPDphys.cxx:127 AliITSOnlineSPDphys.cxx:128 AliITSOnlineSPDphys.cxx:129 AliITSOnlineSPDphys.cxx:130 AliITSOnlineSPDphys.cxx:131 AliITSOnlineSPDphys.cxx:132 AliITSOnlineSPDphys.cxx:133 AliITSOnlineSPDphys.cxx:134 AliITSOnlineSPDphys.cxx:135 AliITSOnlineSPDphys.cxx:136 AliITSOnlineSPDphys.cxx:137 AliITSOnlineSPDphys.cxx:138 AliITSOnlineSPDphys.cxx:139 AliITSOnlineSPDphys.cxx:140 AliITSOnlineSPDphys.cxx:141 AliITSOnlineSPDphys.cxx:142 AliITSOnlineSPDphys.cxx:143 AliITSOnlineSPDphys.cxx:144 AliITSOnlineSPDphys.cxx:145 AliITSOnlineSPDphys.cxx:146 AliITSOnlineSPDphys.cxx:147 AliITSOnlineSPDphys.cxx:148 AliITSOnlineSPDphys.cxx:149 AliITSOnlineSPDphys.cxx:150 AliITSOnlineSPDphys.cxx:151 AliITSOnlineSPDphys.cxx:152 AliITSOnlineSPDphys.cxx:153 AliITSOnlineSPDphys.cxx:154 AliITSOnlineSPDphys.cxx:155 AliITSOnlineSPDphys.cxx:156 AliITSOnlineSPDphys.cxx:157 AliITSOnlineSPDphys.cxx:158 AliITSOnlineSPDphys.cxx:159 AliITSOnlineSPDphys.cxx:160 AliITSOnlineSPDphys.cxx:161 AliITSOnlineSPDphys.cxx:162 AliITSOnlineSPDphys.cxx:163 AliITSOnlineSPDphys.cxx:164 AliITSOnlineSPDphys.cxx:165 AliITSOnlineSPDphys.cxx:166 AliITSOnlineSPDphys.cxx:167 AliITSOnlineSPDphys.cxx:168 AliITSOnlineSPDphys.cxx:169 AliITSOnlineSPDphys.cxx:170 AliITSOnlineSPDphys.cxx:171 AliITSOnlineSPDphys.cxx:172 AliITSOnlineSPDphys.cxx:173 AliITSOnlineSPDphys.cxx:174 AliITSOnlineSPDphys.cxx:175 AliITSOnlineSPDphys.cxx:176 AliITSOnlineSPDphys.cxx:177 AliITSOnlineSPDphys.cxx:178 AliITSOnlineSPDphys.cxx:179 AliITSOnlineSPDphys.cxx:180 AliITSOnlineSPDphys.cxx:181 AliITSOnlineSPDphys.cxx:182 AliITSOnlineSPDphys.cxx:183 AliITSOnlineSPDphys.cxx:184 AliITSOnlineSPDphys.cxx:185 AliITSOnlineSPDphys.cxx:186 AliITSOnlineSPDphys.cxx:187 AliITSOnlineSPDphys.cxx:188 AliITSOnlineSPDphys.cxx:189 AliITSOnlineSPDphys.cxx:190 AliITSOnlineSPDphys.cxx:191 AliITSOnlineSPDphys.cxx:192 AliITSOnlineSPDphys.cxx:193 AliITSOnlineSPDphys.cxx:194 AliITSOnlineSPDphys.cxx:195 AliITSOnlineSPDphys.cxx:196 AliITSOnlineSPDphys.cxx:197 AliITSOnlineSPDphys.cxx:198 AliITSOnlineSPDphys.cxx:199 AliITSOnlineSPDphys.cxx:200 AliITSOnlineSPDphys.cxx:201 AliITSOnlineSPDphys.cxx:202 AliITSOnlineSPDphys.cxx:203 AliITSOnlineSPDphys.cxx:204 AliITSOnlineSPDphys.cxx:205 AliITSOnlineSPDphys.cxx:206 AliITSOnlineSPDphys.cxx:207 AliITSOnlineSPDphys.cxx:208 AliITSOnlineSPDphys.cxx:209 AliITSOnlineSPDphys.cxx:210 AliITSOnlineSPDphys.cxx:211 AliITSOnlineSPDphys.cxx:212 AliITSOnlineSPDphys.cxx:213 AliITSOnlineSPDphys.cxx:214 AliITSOnlineSPDphys.cxx:215 AliITSOnlineSPDphys.cxx:216 AliITSOnlineSPDphys.cxx:217 AliITSOnlineSPDphys.cxx:218 AliITSOnlineSPDphys.cxx:219 AliITSOnlineSPDphys.cxx:220 AliITSOnlineSPDphys.cxx:221 AliITSOnlineSPDphys.cxx:222 AliITSOnlineSPDphys.cxx:223 AliITSOnlineSPDphys.cxx:224 AliITSOnlineSPDphys.cxx:225 AliITSOnlineSPDphys.cxx:226 AliITSOnlineSPDphys.cxx:227 AliITSOnlineSPDphys.cxx:228 AliITSOnlineSPDphys.cxx:229 AliITSOnlineSPDphys.cxx:230 AliITSOnlineSPDphys.cxx:231 AliITSOnlineSPDphys.cxx:232 AliITSOnlineSPDphys.cxx:233 AliITSOnlineSPDphys.cxx:234 AliITSOnlineSPDphys.cxx:235 AliITSOnlineSPDphys.cxx:236 AliITSOnlineSPDphys.cxx:237 AliITSOnlineSPDphys.cxx:238 AliITSOnlineSPDphys.cxx:239 AliITSOnlineSPDphys.cxx:240 AliITSOnlineSPDphys.cxx:241 AliITSOnlineSPDphys.cxx:242 AliITSOnlineSPDphys.cxx:243 AliITSOnlineSPDphys.cxx:244 AliITSOnlineSPDphys.cxx:245 AliITSOnlineSPDphys.cxx:246 AliITSOnlineSPDphys.cxx:247 AliITSOnlineSPDphys.cxx:248 AliITSOnlineSPDphys.cxx:249 AliITSOnlineSPDphys.cxx:250 AliITSOnlineSPDphys.cxx:251 AliITSOnlineSPDphys.cxx:252 AliITSOnlineSPDphys.cxx:253 AliITSOnlineSPDphys.cxx:254 AliITSOnlineSPDphys.cxx:255 AliITSOnlineSPDphys.cxx:256 AliITSOnlineSPDphys.cxx:257 AliITSOnlineSPDphys.cxx:258 AliITSOnlineSPDphys.cxx:259 AliITSOnlineSPDphys.cxx:260 AliITSOnlineSPDphys.cxx:261 AliITSOnlineSPDphys.cxx:262 AliITSOnlineSPDphys.cxx:263 AliITSOnlineSPDphys.cxx:264 AliITSOnlineSPDphys.cxx:265 AliITSOnlineSPDphys.cxx:266 AliITSOnlineSPDphys.cxx:267 AliITSOnlineSPDphys.cxx:268 AliITSOnlineSPDphys.cxx:269 AliITSOnlineSPDphys.cxx:270 AliITSOnlineSPDphys.cxx:271 AliITSOnlineSPDphys.cxx:272 AliITSOnlineSPDphys.cxx:273 AliITSOnlineSPDphys.cxx:274 AliITSOnlineSPDphys.cxx:275 AliITSOnlineSPDphys.cxx:276 AliITSOnlineSPDphys.cxx:277 AliITSOnlineSPDphys.cxx:278 AliITSOnlineSPDphys.cxx:279 AliITSOnlineSPDphys.cxx:280 AliITSOnlineSPDphys.cxx:281 AliITSOnlineSPDphys.cxx:282 AliITSOnlineSPDphys.cxx:283 AliITSOnlineSPDphys.cxx:284 AliITSOnlineSPDphys.cxx:285 AliITSOnlineSPDphys.cxx:286 AliITSOnlineSPDphys.cxx:287 AliITSOnlineSPDphys.cxx:288 AliITSOnlineSPDphys.cxx:289 AliITSOnlineSPDphys.cxx:290 AliITSOnlineSPDphys.cxx:291 AliITSOnlineSPDphys.cxx:292 AliITSOnlineSPDphys.cxx:293 AliITSOnlineSPDphys.cxx:294 AliITSOnlineSPDphys.cxx:295 AliITSOnlineSPDphys.cxx:296 AliITSOnlineSPDphys.cxx:297 AliITSOnlineSPDphys.cxx:298 AliITSOnlineSPDphys.cxx:299 AliITSOnlineSPDphys.cxx:300