//Author: Uli Frankenfeld //Last Modified: 17.12.2000 #include #include #include #include #include #include #include "AliL3Transform.h" #include "AliL3Logging.h" #include "AliL3MemHandler.h" #include "AliL3FileHandler.h" #include "AliTPCClustersArray.h" #include "AliTPCcluster.h" #include "AliTPCClustersRow.h" #include "AliTPCParam.h" #include "AliSimDigits.h" #include "AliL3DigitData.h" #include "AliL3TrackSegmentData.h" #include "AliL3SpacePointData.h" #include "AliL3TrackArray.h" //_____________________________________________________________ // // The L3 Binary File handler // ClassImp(AliL3FileHandler) AliL3FileHandler::AliL3FileHandler(){ //Default constructor fInAli = 0; fParam = 0; fTransformer = 0; fMC =0; } AliL3FileHandler::~AliL3FileHandler(){ //Destructor if(fTransformer) delete fTransformer; if(fMC) CloseMCOutput(); } Bool_t AliL3FileHandler::SetMCOutput(char *name){ fMC = fopen(name,"w"); if(!fMC){ LOG(AliL3Log::kWarning,"AliL3FileHandler::SetMCOutput","File Open") <<"Pointer to File = 0x0 "<IsOpen()){ LOG(AliL3Log::kError,"AliL3FileHandler::SetAliInput","File Open") <<"Ali File "<GetName()<<" does not exist"<Get("75x40_100x60"); if(!fParam){ LOG(AliL3Log::kError,"AliL3FileHandler::SetAliInput","File Open") <<"No AliTPCParam 75x40_100x60 in File "<GetName()<IsOpen()) fInAli->Close(); delete fInAli; fInAli = 0; } Bool_t AliL3FileHandler::IsDigit(){ if(!fInAli){ LOG(AliL3Log::kWarning,"AliL3FileHandler::IsDigit","File") <<"Pointer to TFile = 0x0 "<Get("TreeD_75x40_100x60"); if(t){ LOG(AliL3Log::kInformational,"AliL3FileHandler::IsDigit","File Type") <<"Found Digit Tree -> Use Fast Cluster Finder"< Use Cluster Tree"<IsOpen()){ LOG(AliL3Log::kWarning,"AliL3FileHandler::AliDigits2Memory","File") <<"No Input avalible: TFile not opend"<cd(); TTree *t=(TTree*)fInAli->Get("TreeD_75x40_100x60"); if(!t){ LOG(AliL3Log::kWarning,"AliL3FileHandler::AliDigits2Binary","AliRoot") <<"No Digit Tree inside!"<GetBranch("Segment")->SetAddress(&dummy); UShort_t dig; Int_t time,pad,sector,row; Int_t nrows=0; Int_t ndigitcount=0; Int_t entries = (Int_t)t->GetEntries(); Int_t ndigits[entries]; Int_t lslice,lrow; for(Int_t n=0; nGetEntries(); n++) { t->GetEvent(n); fParam->AdjustSectorRow(digarr.GetID(),sector,row); fTransformer->Sector2Slice(lslice,lrow,sector,row); if(fSlice != lslice || lrowfRowMax) continue; // if(fSlice != lslice) continue; Float_t xyz[3]; ndigits[lrow] = 0; digarr.First(); do { time=digarr.CurrentRow(); pad=digarr.CurrentColumn(); dig = digarr.GetDigit(time,pad); if(dig<=fParam->GetZeroSup()) continue; if(time < fParam->GetMaxTBin()-1 && time > 0) if(digarr.GetDigit(time+1,pad) <= fParam->GetZeroSup() && digarr.GetDigit(time-1,pad) <= fParam->GetZeroSup()) continue; fTransformer->Raw2Local(xyz,sector,row,pad,time); if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) continue; ndigits[lrow]++; //for this row only ndigitcount++; //total number of digits to be published } while (digarr.Next()); nrows++; } Int_t size = sizeof(AliL3DigitData)*ndigitcount + nrows*sizeof(AliL3DigitRowData); LOG(AliL3Log::kDebug,"AliL3FileHandler::AliDigits2Memory","Digits") <GetEntries(); n++) { t->GetEvent(n); Float_t xyz[3]; fParam->AdjustSectorRow(digarr.GetID(),sector,row); fTransformer->Sector2Slice(lslice,lrow,sector,row); // if(fSlice != lslice) continue; if(fSlice != lslice || lrowfRowMax) continue; tempPt->fRow = lrow; tempPt->fNDigit = ndigits[lrow]; Int_t localcount=0; digarr.First(); do { dig=digarr.CurrentDigit(); if (dig<=fParam->GetZeroSup()) continue; time=digarr.CurrentRow(); pad=digarr.CurrentColumn(); if(time < fParam->GetMaxTBin()-1 && time > 0) if(digarr.GetDigit(time-1,pad) <= fParam->GetZeroSup() && digarr.GetDigit(time+1,pad) <= fParam->GetZeroSup()) continue; //Exclude data outside cone: fTransformer->Raw2Local(xyz,sector,row,pad,time); if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) continue; if(localcount >= ndigits[lrow]) LOG(AliL3Log::kFatal,"AliL3FileHandler::AliDigits2Binary","Memory") <fDigitData[localcount].fCharge=dig; tempPt->fDigitData[localcount].fPad=pad; tempPt->fDigitData[localcount].fTime=time; localcount++; } while (digarr.Next()); Byte_t *tmp = (Byte_t*)tempPt; Int_t size = sizeof(AliL3DigitRowData) + ndigits[lrow]*sizeof(AliL3DigitData); tmp += size; tempPt = (AliL3DigitRowData*)tmp; } savedir->cd(); return data; } ///////////////////////////////////////// Point IO Bool_t AliL3FileHandler::AliPoints2Binary(){ Bool_t out = kTRUE; UInt_t npoint; AliL3SpacePointData *data = AliPoints2Memory(npoint); out = Memory2Binary(npoint,data); Free(); return out; } AliL3SpacePointData * AliL3FileHandler::AliPoints2Memory(UInt_t & npoint){ AliL3SpacePointData *data = 0; npoint=0; if(!fInAli){ LOG(AliL3Log::kWarning,"AliL3FileHandler::AliPoints2Memory","File") <<"No Input avalible: no object TFile"<IsOpen()){ LOG(AliL3Log::kWarning,"AliL3FileHandler::AliPoints2Memory","File") <<"No Input avalible: TFile not opend"<cd(); AliTPCClustersArray carray; carray.Setup(fParam); carray.SetClusterType("AliTPCcluster"); Bool_t clusterok = carray.ConnectTree("Segment Tree"); if(!clusterok) return 0; AliTPCClustersRow ** clusterrow = new AliTPCClustersRow*[ (int)carray.GetTree()->GetEntries()]; Int_t *rows = new int[ (int)carray.GetTree()->GetEntries()]; Int_t *sects = new int[ (int)carray.GetTree()->GetEntries()]; Int_t sum=0; Int_t lslice,lrow; for(Int_t i=0; iGetEntries(); i++){ AliSegmentID *s = carray.LoadEntry(i); Int_t sector,row; fParam->AdjustSectorRow(s->GetID(),sector,row); rows[i] = row; sects[i] = sector; clusterrow[i] = 0; fTransformer->Sector2Slice(lslice,lrow,sector,row); if(fSlice != lslice || lrowfRowMax) continue; clusterrow[i] = carray.GetRow(sector,row); if(clusterrow[i]) sum+=clusterrow[i]->GetArray()->GetEntriesFast(); } UInt_t size = sum*sizeof(AliL3SpacePointData); LOG(AliL3Log::kDebug,"AliL3FileHandler::AliPoints2Memory","File") <GetEntries(); i++){ if(!clusterrow[i]) continue; Int_t row = rows[i]; Int_t sector = sects[i]; fTransformer->Sector2Slice(lslice,lrow,sector,row); Int_t entries_in_row = clusterrow[i]->GetArray()->GetEntriesFast(); for(Int_t j = 0;jGetZ(); data[n].fY = c->GetY(); data[n].fX = fParam->GetPadRowRadii(sector,row); data[n].fID = n+((fSlice&0x7f)<<25)+((fPatch&0x7)<<22);//uli data[n].fPadRow = lrow; data[n].fXYErr = c->GetSigmaY2(); data[n].fZErr = c->GetSigmaZ2(); if(fMC) fprintf(fMC,"%d %d\n",data[n].fID,c->GetLabel(0)); n++; } } for(Int_t i=0;iGetEntries();i++){ Int_t row = rows[i]; Int_t sector = sects[i]; if(carray.GetRow(sector,row)) carray.ClearRow(sector,row); } delete [] clusterrow; delete [] rows; delete [] sects; savedir->cd(); return data; }