From: alla Date: Wed, 4 Apr 2007 10:16:09 +0000 (+0000) Subject: reading Zposition from DB, the same RawReader for sim. and test data, reading detecto... X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=5325480c2c283cfe4be70248f7eb1086364ea7e1 reading Zposition from DB, the same RawReader for sim. and test data, reading detector configuration from loookup table --- diff --git a/T0/AliT0CalibData.cxx b/T0/AliT0CalibData.cxx index 5f299392673..815f417999e 100644 --- a/T0/AliT0CalibData.cxx +++ b/T0/AliT0CalibData.cxx @@ -96,8 +96,8 @@ void AliT0CalibData::Print(Option_t*) const { printf("\n ---- PM Arrays ----\n\n"); - printf(" Time delay CFD \n"); - for (Int_t i=0; i<24; i++) printf(" %f",fTimeDelayCFD[i]); + printf(" Time delay CFD & LED\n"); + for (Int_t i=0; i<24; i++) printf(" CFD %f LED %f ",fTimeDelayCFD[i], fTimeDelayLED[i]); } //________________________________________________________________ @@ -106,11 +106,13 @@ void AliT0CalibData::PrintLookup(Option_t*, Int_t iTRM, Int_t iTDC, Int_t iChan AliT0LookUpKey* lookkey= new AliT0LookUpKey(); AliT0LookUpValue* lookvalue= new AliT0LookUpValue(); - + + cout<<" Number Of TRMs in setup "<SetTRM(iTRM); lookvalue->SetTDC(iTDC); lookvalue->SetChain(0); lookvalue->SetChannel(iChannel); + printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i \n",iTRM, iTDC, iChannel); lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue); @@ -153,7 +155,7 @@ void AliT0CalibData::SetWalk(Int_t ipmt) ifstream inFile(filename); if(!inFile) AliError(Form("Cannot open file %s !",filename)); - Int_t i=0, i1=0, i2=0; + Int_t i=0; while(getline(inFile,buffer)){ inFile >> ps >> mv; @@ -161,11 +163,12 @@ void AliT0CalibData::SetWalk(Int_t ipmt) i++; } inFile.close(); + cout<<" number of data "<ExpandPathName("$ALICE_ROOT/T0/data/re.root"); + const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-LED.root"); ifstream inFile(filename); if(!inFile) {AliError(Form("Cannot open file %s !",filename));} @@ -251,6 +254,7 @@ void AliT0CalibData::SetSlewingRec(Int_t ipmt) } +//________________________________________________________________ void AliT0CalibData::ReadAsciiLookup(const Char_t *filename) { @@ -268,46 +272,53 @@ void AliT0CalibData::ReadAsciiLookup(const Char_t *filename) { // AliLog(Form("Cannot open file %s ! Getting hardcoded value",filename)); - trm=0; tdc=0; chain=0; channel=0; key=0; - for (Int_t ik=0; ik<108; ik++) - { - AliT0LookUpKey * lookkey= new AliT0LookUpKey(); - AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); - - lookvalue->SetTRM(trm); - lookvalue->SetTDC(tdc); - lookvalue->SetChain(chain); - lookvalue->SetChannel(channel); - lookkey->SetKey(ik); - if(ik>53) { trm=1; tdc=0; channel=0;} - if (channel<7) channel +=2; - else {channel = 0; tdc++;} - } + // fNumberOfTRMs = 2; + SetNumberOfTRMs(2); + trm=0; tdc=0; chain=0; channel=0; key=0; + for (Int_t ik=0; ik<108; ik++) + { + AliT0LookUpKey * lookkey= new AliT0LookUpKey(); + AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); + + lookvalue->SetTRM(trm); + lookvalue->SetTDC(tdc); + lookvalue->SetChain(chain); + lookvalue->SetChannel(channel); + lookkey->SetKey(ik); + if(ik>53) { trm=1; tdc=0; channel=0;} + if (channel<7) channel +=2; + else {channel = 0; tdc++;} + } } Char_t varname[11]; - // while(lookup.eof()) - - for (Int_t i=0; i<108; i++) + Int_t ntrms; + if(lookup) { - AliT0LookUpKey * lookkey= new AliT0LookUpKey(); - AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); - - lookup>>varname>>key>>trm>>chain>>tdc>>channel; - lookvalue->SetTRM(trm); - lookvalue->SetTDC(tdc); - lookvalue->SetChain(chain); - lookvalue->SetChannel(channel); - lookkey->SetKey(key); - + lookup>>ntrms; + cout<<" !!!!!!! ntrms "<>varname>>key>>trm>>chain>>tdc>>channel; + lookvalue->SetTRM(trm); + lookvalue->SetTDC(tdc); + lookvalue->SetChain(chain); + lookvalue->SetChannel(channel); + lookkey->SetKey(key); + cout<<"lookup "<GetTimeDelayTVD(); for (Int_t i=0; i<24; i++){ timeDelayCFD[i] = param->GetTimeDelayCFD(i); - timeDelayLED[i] = param->GetTimeDelayLED(i); + timeDelayLED[i] = param->GetTimeDelayLED(i); TGraph* gr = param ->GetSlew(i); slewingLED.AddAtAndExpand(gr,i); @@ -165,13 +165,14 @@ void AliT0Digitizer::Exec(Option_t* /*option*/) TGraph* grEff = param ->GetPMTeff(i); fEffPMT.AddAtAndExpand(grEff,i); } - - zdetC = param->GetZposition(0); - zdetA = param->GetZposition(1); - - AliT0hit *startHit; - TBranch *brHits=0; - + + + zdetC = TMath::Abs(param->GetZPosition("T0/C/PMT1")); + zdetA = TMath::Abs(param->GetZPosition("T0/A/PMT15")); + + AliT0hit *startHit; + TBranch *brHits=0; + Int_t nFiles=fManager->GetNinputs(); for (Int_t inputFile=0; inputFileGetMaximum(50); trCFD=trCFD-Int_t((maxValue-slew)/channelWidth); ftimeCFD->AddAt(Int_t (trCFD),i); - cout<<" slew "< #include #include +#include +#include AliT0CalibData* AliT0Parameters::fgCalibData = 0; AliT0CalibData* AliT0Parameters::fgLookUp = 0; @@ -57,7 +59,14 @@ AliT0Parameters::Instance() //____________________________________________________________________ AliT0Parameters::AliT0Parameters() - :fIsInit(kFALSE),fPh2Mip(0),fmV2Mip(0),fChannelWidth(0),fmV2Channel(0),fQTmin(0),fQTmax(0),fSlewingLED(),fSlewingRec(),fPMTeff(),fTimeDelayLED(0),fTimeDelayCFD(0),fTimeDelayTVD(0),fCalibentry(), fLookUpentry(),fSlewCorr() + :fIsInit(kFALSE), + fPh2Mip(0),fmV2Mip(0), + fChannelWidth(0),fmV2Channel(0), + fQTmin(0),fQTmax(0), + fSlewingLED(),fSlewingRec(), + fPMTeff(), + fTimeDelayLED(0),fTimeDelayCFD(0),fTimeDelayTVD(0), + fCalibentry(), fLookUpentry(),fSlewCorr() { // Default constructor @@ -77,6 +86,7 @@ AliT0Parameters::AliT0Parameters() } SetTimeDelayTVD(); SetZposition(); + SetNumberOfTRMs(2); } @@ -92,15 +102,14 @@ AliT0Parameters::Init() AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT"); //time equalizing AliCDBEntry* fCalibentry = stor->Get("T0/Calib/TimeDelay",0); - if (fCalibentry){ + if (fCalibentry) fgCalibData = (AliT0CalibData*)fCalibentry->GetObject(); - } - else - { AliError(" ALARM !!!! No time delays in CDB "); } + else + AliError(" ALARM !!!! No time delays in CDB "); //slewing correction AliCDBEntry* fSlewCorr = stor->Get("T0/Calib/Slewing_Walk",0); - if (fSlewCorr){ - fgSlewCorr = (AliT0CalibData*)fSlewCorr->GetObject(); + if (fSlewCorr){ + fgSlewCorr = (AliT0CalibData*)fSlewCorr->GetObject(); } fLookUpentry = stor->Get("T0/Calib/LookUp_Table",0); if (fLookUpentry){ @@ -300,7 +309,6 @@ Float_t AliT0Parameters::GetWalkVal(Int_t ipmt, Float_t mv) const return fgCalibData -> GetWalkVal(ipmt, mv) ; } -//__________________________________________________________________ //__________________________________________________________________ void @@ -343,3 +351,42 @@ AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) } +//__________________________________________________________________ +Int_t +AliT0Parameters::GetNumberOfTRMs() +{ + // return number of trms + // + if (!fgLookUp) { + fNumberOfTRMs = 2; + return fNumberOfTRMs; + } + return fgLookUp ->GetNumberOfTRMs(); +} +//________________________________________________________________________________ +Double_t AliT0Parameters::GetZPosition(const char* symname){ +// Get the global z coordinate of the given T0 alignable volume +// + Double_t *tr; + + cout<GetAlignableEntry(symname); + if (!pne) return 0; + + + TGeoPhysicalNode *pnode = pne->GetPhysicalNode(); + if(pnode){ + TGeoHMatrix* hm = pnode->GetMatrix(); + tr = hm->GetTranslation(); + }else{ + const char* path = pne->GetTitle(); + if(!gGeoManager->cd(path)){ + AliErrorClass(Form("Volume path %s not valid!",path)); + return 0; + } + tr = gGeoManager->GetCurrentMatrix()->GetTranslation(); + } + return tr[2]; + +} + diff --git a/T0/AliT0Parameters.h b/T0/AliT0Parameters.h index ced59b45353..6c94bc8dc21 100644 --- a/T0/AliT0Parameters.h +++ b/T0/AliT0Parameters.h @@ -54,8 +54,9 @@ public: Int_t GetmV2channel() const { return fmV2Channel; } Int_t GetQTmin() const {return fQTmin;} Int_t GetQTmax() const {return fQTmax;} - Float_t GetZposition(Int_t i) const {return fT0zPosition[i];} - TGraph * GetPMTeff(Int_t ipmt) const + Double_t GetZposition(Int_t i) const {return fT0zPosition[i];} + Double_t GetZPosition(const char* symname) ; + TGraph * GetPMTeff(Int_t ipmt) const {return (TGraph*)fPMTeff.At(ipmt);} Float_t GetpmtEFF(Int_t ipmt, Float_t lambda) const {return((TGraph*)fPMTeff.At(ipmt))->Eval(lambda);} @@ -80,6 +81,8 @@ public: // TMap *LookupTable; Int_t GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel); + Int_t GetNumberOfTRMs(); + void SetNumberOfTRMs(Int_t ntrms=2) {fNumberOfTRMs = ntrms;} protected: AliT0Parameters(); @@ -105,7 +108,8 @@ protected: Float_t fTimeDelayTVD; //time delay for TVD (vertex trigger channel) TMap fLookUp; //lookup table - + Int_t fNumberOfTRMs; // number of TRMs in setup + static AliT0CalibData * fgCalibData; // singleton for Calibration data static AliT0CalibData * fgLookUp; // singleton for Calibration data static AliT0CalibData * fgSlewCorr; // singleton for Calibration data diff --git a/T0/AliT0RawData.cxx b/T0/AliT0RawData.cxx index 51cb2ef7667..fb1604b0d7a 100644 --- a/T0/AliT0RawData.cxx +++ b/T0/AliT0RawData.cxx @@ -171,7 +171,7 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits) allData->AddAt(fTimeCFD->At(i-1),i+24); allData->AddAt(fADC0->At(i-1),i+54); allData->AddAt(fADC1->At(i-1),i+78); - // cout<At(i-1)<<" cfd "<At(i-1)<<" qt0 "<At(i-1)<<" qt1 "<At(i-1)<AddAt(meantime,49); allData->AddAt(timediff,50); @@ -185,82 +185,88 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits) allData->AddAt(mult1,54); allData->AddAt(mult1,107); //trigger semi-central - // cout<<" new Event "<At(ia)<At(det); - - if (time >0) { + if (time >0) FillTime(channel, iTDC, time); - trm1words++; - } if (channel < 6) channel +=2; else { channel = 0; iTDC++; if (iTDC>15) { chain++; iTDC=0;} } - // cout<At(det); - - if (time >0) { + + if (time >0) FillTime(channel, iTDC, time); - trm2words++;} + if (channel < 6) channel +=2; else { channel = 0; iTDC++; if (iTDC>15) { chain++; iTDC=0;} } - // cout<Reset(); fRawReader->Select("T0"); - cout<<" AliT0RawReader::AliT0RawReaderfRawReader->Select "<Branch("T0","AliT0digit",&fDigits,405,1); UInt_t word; - Int_t time=0, itdc=0, ichannel=0; + Int_t time=0, itdc=0, ichannel=0, uu; Int_t numberOfWordsInTRM=0, iTRM=0; - Int_t tdcTime, koef,hit, meanTime, timeDiff ; - Int_t numTRM=2; // number of TRMs in game For test =1 !!!!! - + Int_t tdcTime, koef,hit=0; + Int_t koefhits[110]; - - AliT0Parameters* param = AliT0Parameters::Instance(); //-->Zhenya + Int_t fDRM_GLOBAL_HEADER = 0x40000001; + Int_t fDRM_GLOBAL_TRAILER = 0x50000001; + + Int_t TRM_GLOBAL_HEADER = 0x40000000; + Int_t TRM_CHAIN_0_HEADER = 0x00000000; + Int_t TRM_CHAIN_1_HEADER = 0x20000000; + Int_t TRM_CHAIN_0_TRAILER = 0x10000000; + Int_t TRM_CHAIN_1_TRAILER = 0x30000000; + Int_t TRM_GLOBAL_TRAILER = 0x5000000f; + + AliT0Parameters* param = AliT0Parameters::Instance(); param->Init(); + Int_t fNTRM = param->GetNumberOfTRMs(); for ( Int_t k=0; k<110; k++) { - for ( Int_t jj=0; jj<5; jj++) { - fAllData[k][jj]=0; - } + koefhits[k]=0; + for ( Int_t jj=0; jj<5; jj++) { + fAllData[k][jj]=0; + } } do { if (!fRawReader->ReadNextData(fData)) return kFALSE; @@ -96,24 +101,43 @@ Bool_t AliT0RawReader::Next() // fPosition = GetPosition(); fPosition = 0; + // cout.setf( ios_base::hex, ios_base::basefield ); //DRM header - for (Int_t i=0; i<4; i++) { - word = GetNextWord(); - } - - for (Int_t ntrm=0; ntrm< numTRM; ntrm++) - { + for (Int_t i=0; i<6; i++) { + word = GetNextWord(); + uu = word&fDRM_GLOBAL_HEADER; + if(uu != fDRM_GLOBAL_HEADER ) + { + AliError(Form(" !!!! wrong DRM header %x!!!!", word)); + break; + } + } + + for (Int_t ntrm=0; ntrm< fNTRM; ntrm++) + { //TRMheader word = GetNextWord(); + uu = word&TRM_GLOBAL_HEADER; + if(uu != TRM_GLOBAL_HEADER ) + { + AliError(Form(" !!!! wrong TRM header %x!!!!", word)); + break; + } numberOfWordsInTRM=AliBitPacking::UnpackWord(word,4,16); iTRM=AliBitPacking::UnpackWord(word,0,3); //chain header - Int_t ichain=0; word = GetNextWord(); + uu = word & TRM_CHAIN_0_HEADER; + if(uu != TRM_CHAIN_0_HEADER) + { + AliError(Form(" !!!! wrong CHAIN 0 header %x!!!!", word)); + break; + } + Int_t ichain=AliBitPacking::UnpackWord(word,0,3); - for (Int_t i=0; iGetChannel(iTRM,itdc,ichain,ichannel); - // cout<<" RawReader::Next ::"<GetSlewRec(i); slewingLEDrec.AddAtAndExpand(gr,i) ; } - zdetC = param->GetZposition(0); - zdetA = param->GetZposition(1); + zdetC = param->GetZPosition("C"); + zdetA = param->GetZPosition("A"); + AliDebug(1,Form("Start DIGITS reconstruction ")); @@ -211,7 +212,8 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con //Q->T-> coefficients !!!! should be asked!!! Float_t timeDelayLED[24]; Float_t zdetA,zdetC; - TObjArray slewingLEDrec; + Int_t allData[110][5]; + TObjArray slewingLEDrec; TObjArray walk; TArrayI * timeCFD = new TArrayI(24); @@ -219,10 +221,13 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con TArrayI * chargeQT0 = new TArrayI(24); TArrayI * chargeQT1 = new TArrayI(24); + for (Int_t i=0; i<110; i++) { + allData[i][0]=0; + } + AliT0RawReader myrawreader(rawReader); if (!myrawreader.Next()) AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next())); - Int_t allData[110][5]; for (Int_t i=0; i<110; i++) { allData[i][0]=myrawreader.GetData(i,0); } @@ -240,12 +245,10 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con slewingLEDrec.AddAtAndExpand(gr,i) ; } - zdetC = param->GetZposition(0); - zdetA = param->GetZposition(1); - // zdetC=GetZdet("C"); - // zdetA=GetZdet("A"); - cout<<" !!!!! zdetC "<GetZPosition("T0/C/PMT1"); + zdetA = param->GetZPosition("T0/A/PMT15"); + + for (Int_t in=0; in<24; in++) { timeLED->AddAt(allData[in+1][0],in); timeCFD->AddAt(allData[in+25][0],in); @@ -272,7 +275,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con Int_t qt0= chargeQT0->At(ipmt); Int_t qt1= chargeQT1->At(ipmt); if((qt1-qt0)>0) adc[ipmt] = TMath::Exp( Double_t (channelWidth*(qt1-qt0)/1000)); - time[ipmt] = channelWidth * (calib-> WalkCorrection( ipmt,qt1 , timeCFD->At(ipmt) ) ) ; + time[ipmt] = channelWidth * (calib-> WalkCorrection( ipmt,qt1 , timeCFD->At(ipmt) ) ) ; Double_t sl = (timeLED->At(ipmt) - timeCFD->At(ipmt)- (1000.*timeDelayLED[ipmt]/channelWidth))*channelWidth; Double_t qt=((TGraph*)slewingLEDrec.At(ipmt))->Eval(sl/1000.); frecpoints->SetTime(ipmt,time[ipmt]); @@ -376,7 +379,8 @@ void AliT0Reconstructor::FillESD(AliRunLoader* runLoader, AliESD *pESD) const pESD->SetT0(timeStart); // interaction time pESD->SetT0time(time); // best TOF on each PMT pESD->SetT0amplitude(amp); // number of particles(MIPs) on each PMT - cout<<" ESD >> "<UnloadRecPoints(); diff --git a/T0/AliT0SetCDB.C b/T0/AliT0SetCDB.C index 855c77c4354..adc4bb81e6e 100644 --- a/T0/AliT0SetCDB.C +++ b/T0/AliT0SetCDB.C @@ -31,13 +31,13 @@ void AliT0SetCDB() "Set time dalay"); menu->AddButton("Set walk","SetWalk()", "Set slewing coorection"); - menu->AddButton("Set Align","SetAC()", + menu->AddButton("Set Align","SetAC()", "Set alignment coefficients"); menu->AddButton("Set LookUpTable","SetLookUp()", "Set LookUp table"); menu->AddButton("Read time delay","GetTimeDelay()", "Read time delay"); - menu->AddButton("Read walk","GetWalk()", + menu->AddButton("Read walk","GetWalk()", "Read amplitude-time correction"); menu->AddButton("Read alignment CC","GetAC()", "Read face detector position "); @@ -159,9 +159,12 @@ void SetWalk() TRandom rn; for(Int_t ipmt=0; ipmt<24; ipmt++) { - calibda->SetWalk(ipmt,"data/CFD-Amp.txt"); - calibda->SetSlewingLED(ipmt,"data/CFD-LED.txt"); - calibda->SetSlewingRec(ipmt,"data/CFD-LED.txt"); + // calibda->SetWalk(ipmt,"data/CFD-Amp.txt"); + // calibda->SetSlewingLED(ipmt,"data/CFD-LED.txt"); + // calibda->SetSlewingRec(ipmt,"data/CFD-LED.txt"); + calibda->SetWalk(ipmt); + calibda->SetSlewingLED(ipmt); + calibda->SetSlewingRec(ipmt); } //Store calibration data into database AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); @@ -259,7 +262,7 @@ void SetLookUp() AliT0CalibData *calibda=new AliT0CalibData("T0"); calibda->ReadAsciiLookup("lookUpTable.txt"); -//calibda->SetA(5); + //Store calibration data into database AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); diff --git a/T0/lookUpTable.txt b/T0/lookUpTable.txt index 30804ef8892..6600b03b88e 100644 --- a/T0/lookUpTable.txt +++ b/T0/lookUpTable.txt @@ -1,3 +1,4 @@ + 2 RefPoint 0 0 0 0 0 T0_A_1_A 1 0 0 0 2 T0_A_2_A 2 0 0 0 4