--- calo/flight/CaloFranzini/src/CaloFranzini.cpp 2007/12/04 12:05:29 1.1 +++ calo/flight/CaloFranzini/src/CaloFranzini.cpp 2007/12/04 12:42:54 1.2 @@ -29,6 +29,7 @@ debug = false; dolong = true; dofull = false; + sntr = 0; // Clear(); // @@ -39,8 +40,9 @@ OBT = 0; PKT = 0; atime = 0; - longtzeta = 0.; - fulltzeta = 0.; + longtzeta = -100.; + fulltzeta = -100.; + degfre = 0; memset(estrip, 0, 2*22*96*sizeof(Float_t)); memset(qplane, 0, 2*22*sizeof(Float_t)); // @@ -60,14 +62,122 @@ } void CaloFranzini::Delete(){ + // if ( file ) file->Close(); + // Clear(); + // +} + + +void CaloFranzini::Process(){ + this->Process(0); +} + +void CaloFranzini::Process(Int_t itr){ + // + if ( !L2 ){ + printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); + printf(" ERROR: CaloFranzini variables _NOT_ filled \n"); + return; + }; + // + if ( !nbin || !file || !brig ){ + printf(" ERROR: it seems covariance matrix file has not been opened (CaloFranzini::Open()) \n"); + printf(" ERROR: CaloFranzini variables _NOT_ filled \n"); + return; + }; + // + Bool_t newentry = false; + // + if ( L2->IsORB() ){ + if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || itr != sntr ){ + newentry = true; + OBT = L2->GetOrbitalInfo()->OBT; + PKT = L2->GetOrbitalInfo()->pkt_num; + atime = L2->GetOrbitalInfo()->absTime; + sntr = itr; + }; + } else { + newentry = true; + }; + // + if ( !newentry ) return; + // + // Some variables + // + if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); + // + this->Clear(); + // + Float_t rig = L2->GetTrack(itr)->GetTrkTrack()->GetRigidity(); + // + // Fill the estrip matrix + // + Int_t nplane = 0; + Int_t view = 0; + Int_t plane = 0; + Int_t strip = 0; + Float_t mip = 0.; + for ( Int_t i=0; iGetCaloLevel1()->istrip; i++ ){ + // + mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); + // + estrip[view][plane][strip] = mip; + nplane = 1 - view + 2 * plane; + qplane[nplane] += mip; + // + }; + // + // + // + if ( dolong ){ + // + degfre = 44; + // + for (Int_t i=0; i < 22; i++){ + if ( L2->GetTrack(itr)->GetCaloTrack()->tibar[i][1] < 0 ){ + degfre = 2 * i; + break; + }; + if ( L2->GetTrack(itr)->GetCaloTrack()->tibar[i][0] < 0 ){ + degfre = 1 + 2 * i; + break; + }; + }; + // + if ( degfre > 0 ){ + TArrayF *qplmean = this->LoadLongAverage(rig); + TMatrixD *lmatrix = this->LoadCovarianceMatrix(rig); + for (Int_t i = 0; i < degfre; i++){ + for (Int_t j = 0; j < degfre; j++){ + longtzeta += (qplane[i]-qplmean->At(i)) * (*lmatrix)[i][j] * (qplane[j]-qplmean->At(j)); + }; + }; + }; + }; + if ( dofull ){ + printf(" ERROR: NOT IMPLEMENTED YET\n"); printf(" ERROR: CaloFranzini variables _NOT_ filled \n"); }; // if ( debug ) this->Print(); if ( debug ) printf(" exit \n"); - // +} + + +Float_t CaloFranzini::GetNormLongTZeta(){ + Process(); + Float_t normz = 0.; + if ( degfre > 0 ) normz = longtzeta/(Float_t)degfre; + return normz; +} + +Float_t CaloFranzini::GetNormFullTZeta(){ + Process(); + Float_t normz = 0.; + if ( degfre > 0 ) normz = fulltzeta/(Float_t)degfre; + return normz; } Bool_t CaloFranzini::CreateMatrixFile(TString matrixfile){