X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDrawData.cxx;h=6a7e474f59725041bb4fe5fda122a9e8dc53a4a1;hb=74b0bf8547e39fcb52b6ad978f5f02a48ef28f3f;hp=cccb6f94364681a38ac4cb1b0c626ceff1b2e1c9;hpb=ff792017d1ecb6d8c30416e7413ae814ded0a3a5;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDrawData.cxx b/TRD/AliTRDrawData.cxx index cccb6f94364..6a7e474f597 100644 --- a/TRD/AliTRDrawData.cxx +++ b/TRD/AliTRDrawData.cxx @@ -30,6 +30,7 @@ #include "AliRawReader.h" #include "AliLog.h" #include "AliFstream.h" +#include "AliLoader.h" #include "AliTreeLoader.h" #include "AliTRDrawData.h" @@ -37,7 +38,7 @@ #include "AliTRDgeometry.h" #include "AliTRDarrayDictionary.h" #include "AliTRDarrayADC.h" -#include "AliTRDrawStreamBase.h" +#include "AliTRDrawStream.h" #include "AliTRDcalibDB.h" #include "AliTRDSignalIndex.h" #include "AliTRDfeeParam.h" @@ -57,10 +58,13 @@ AliTRDrawData::AliTRDrawData() ,fFee(NULL) ,fNumberOfDDLs(0) ,fTrackletTree(NULL) - ,fTrackletContainer(NULL) + ,fTracklets(NULL) + ,fTracks(NULL) ,fSMindexPos(0) ,fStackindexPos(0) ,fEventCounter(0) + ,fTrgFlags() + ,fMcmSim(new AliTRDmcmSim) ,fDigitsParam(NULL) { // @@ -80,10 +84,13 @@ AliTRDrawData::AliTRDrawData(const AliTRDrawData &r) ,fFee(NULL) ,fNumberOfDDLs(0) ,fTrackletTree(NULL) - ,fTrackletContainer(NULL) + ,fTracklets(NULL) + ,fTracks(NULL) ,fSMindexPos(0) ,fStackindexPos(0) ,fEventCounter(0) + ,fTrgFlags() + ,fMcmSim(new AliTRDmcmSim) ,fDigitsParam(NULL) { // @@ -102,10 +109,7 @@ AliTRDrawData::~AliTRDrawData() // Destructor // - if (fTrackletContainer){ - delete fTrackletContainer; - fTrackletContainer = NULL; - } + delete fMcmSim; } @@ -188,7 +192,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager) for (Int_t sect = 0; sect < fGeo->Nsector(); sect++) { char name[1024]; - sprintf(name,"TRD_%d.ddl",sect + AliTRDrawStreamBase::kDDLOffset); + snprintf(name,1024,"TRD_%d.ddl",sect + AliTRDrawStream::kDDLOffset); AliFstream* of = new AliFstream(name); @@ -209,7 +213,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager) Bool_t bSMHasData = kFALSE; //iwbuffer[nheader++] = 0x0001a020; // SM index words - iwbuffer[nheader++] = 0x0044a020; // SM index words | additional SM header:48 = 1 SM header + 47 dummy words(for future use) + iwbuffer[nheader++] = 0x0044b020; // SM index words | additional SM header:48 = 1 SM header + 47 dummy words(for future use) iwbuffer[nheader++] = 0x10404071; // SM header for ( Int_t i=0; i<66; i++ ) iwbuffer[nheader++] = 0x00000000; // dummy words iwbuffer[nheader++] = 0x10000000; // end of dummy words @@ -238,7 +242,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager) if ( fgDataSuppressionLevel==0 || bSMHasData ){ iwbuffer[0] = iwbuffer[0] | bStackMask; // add stack masks to SM index word - if (fgDataSuppressionLevel==0) iwbuffer[0] = 0x0044a03f; // no suppression : all stacks are active + if (fgDataSuppressionLevel==0) iwbuffer[0] = 0x0044b03f; // no suppression : all stacks are active of->WriteBuffer((char *) iwbuffer, nheader*4); AliDebug(11, Form("SM %d index word: %08x", sect, iwbuffer[0])); AliDebug(11, Form("SM %d header: %08x", sect, iwbuffer[1])); @@ -291,6 +295,9 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager) of->Seekp(hpos); // Rewind to header position of->WriteBuffer((char *) (& header), sizeof(header)); delete of; + + delete [] iwbuffer; + } // loop over sector(SM) delete [] hcBuffer; @@ -333,7 +340,7 @@ void AliTRDrawData::ProduceSMIndexData(UInt_t *buf, Int_t& nw){ //buf[nw++] = 0x0001a03f; // SM index words fSMindexPos = nw; // memorize position of the SM index word for re-allocating stack mask - buf[nw++] = 0x0001a020; // SM index words + buf[nw++] = 0x0001b020; // SM index words buf[nw++] = 0x10404071; // SM header fStackindexPos = nw; // memorize position of the stack index word for future adding @@ -433,15 +440,13 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det AliDebug(1,Form("Producing raw data for sect=%d layer=%d stack=%d side=%d",sect,layer,stack,side)); - AliTRDmcmSim* mcm = new AliTRDmcmSim(); - UInt_t *tempBuffer = buf; // tempBuffer used to write ADC data // different in case of tracklet writing if (trackletOn) { tempBuffer = new UInt_t[maxSize]; - tempnw = new Int_t(0); - tempof = new Int_t(0); + tempnw = new Int_t(0); + tempof = new Int_t(0); } WriteIntermediateWords(tempBuffer,*tempnw,*tempof,maxSize,det,side); @@ -456,11 +461,11 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det for (Int_t iMcmRB = 0; iMcmRB < fGeo->MCMmax(); iMcmRB++ ) { Int_t iMcm = 16 - 4*(iMcmRB/4 + 1) + (iMcmRB%4); - mcm->Init(det, iRob, iMcm); - mcm->SetData(digits); // no filtering done here (already done in digitizer) + fMcmSim->Init(det, iRob, iMcm); + fMcmSim->SetData(digits); // no filtering done here (already done in digitizer) if (trackletOn) { - mcm->Tracklet(); - Int_t tempNw = mcm->ProduceTrackletStream(&buf[nw], maxSize - nw); + fMcmSim->Tracklet(); + Int_t tempNw = fMcmSim->ProduceTrackletStream(&buf[nw], maxSize - nw); if( tempNw < 0 ) { of += tempNw; nw += maxSize - nw; @@ -469,10 +474,10 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det nw += tempNw; } } - mcm->ZSMapping(); // Calculate zero suppression mapping + fMcmSim->ZSMapping(); // Calculate zero suppression mapping // at the moment it has to be rerun here // Write MCM data to temp. buffer - Int_t tempNw = mcm->ProduceRawStream( &tempBuffer[*tempnw], maxSize - *tempnw, fEventCounter ); + Int_t tempNw = fMcmSim->ProduceRawStream( &tempBuffer[*tempnw], maxSize - *tempnw, fEventCounter ); if ( tempNw < 0 ) { *tempof += tempNw; *tempnw += maxSize - nw; @@ -483,8 +488,6 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det } } - delete mcm; - // in case of tracklet writing copy temp data to final buffer if (trackletOn) { if (nw + *tempnw < maxSize) { @@ -494,12 +497,15 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det else { AliError("Buffer overflow detected"); } - delete [] tempBuffer; - delete tempof; - delete tempnw; } } + if (trackletOn) { + delete [] tempBuffer; + delete tempof; + delete tempnw; + } + // Write end of raw data marker if (nw+3 < maxSize) { buf[nw++] = fgkEndOfDataMarker; @@ -536,45 +542,38 @@ AliTRDdigitsManager *AliTRDrawData::Raw2Digits(AliRawReader *rawReader) AliTRDdigitsManager* digitsManager = new AliTRDdigitsManager(); digitsManager->CreateArrays(); - if (!fTrackletContainer) { - const Int_t kTrackletChmb=256; - fTrackletContainer = new UInt_t *[2]; - fTrackletContainer[0] = new UInt_t[kTrackletChmb]; - fTrackletContainer[1] = new UInt_t[kTrackletChmb]; - memset(fTrackletContainer[0], 0, kTrackletChmb*sizeof(UInt_t)); //jkl - memset(fTrackletContainer[1], 0, kTrackletChmb*sizeof(UInt_t)); //jkl - } - - AliTRDrawStreamBase *pinput = AliTRDrawStreamBase::GetRawStream(rawReader); - AliTRDrawStreamBase &input = *pinput; - input.SetRawVersion( fFee->GetRAWversion() ); //<= ADDED by MinJung - - AliInfo(Form("Stream version: %s", input.IsA()->GetName())); + AliTRDrawStream input(rawReader); // ----- preparing tracklet output ----- AliDataLoader *trklLoader = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets"); if (!trklLoader) { - //AliInfo("Could not get the tracklets data loader, adding it now!"); trklLoader = new AliDataLoader("TRD.Tracklets.root","tracklets", "tracklets"); AliRunLoader::Instance()->GetLoader("TRDLoader")->AddDataLoader(trklLoader); } + if (!trklLoader) { + return 0x0; + } AliTreeLoader *trklTreeLoader = dynamic_cast (trklLoader->GetBaseLoader("tracklets-raw")); if (!trklTreeLoader) { trklTreeLoader = new AliTreeLoader("tracklets-raw", trklLoader); trklLoader->AddBaseLoader(trklTreeLoader); } + if (!trklTreeLoader) { + return 0x0; + } if (!trklTreeLoader->Tree()) trklTreeLoader->MakeTree(); + input.SetTrackletArray(fTracklets); + input.SetTrackArray(fTracks); + // Loop through the digits Int_t det = 0; while (det >= 0) { - det = input.NextChamber(digitsManager,fTrackletContainer); - - if (*(fTrackletContainer[0]) > 0 || *(fTrackletContainer[1]) > 0) WriteTracklets(det); + det = input.NextChamber(digitsManager); if (det >= 0) { @@ -591,20 +590,12 @@ AliTRDdigitsManager *AliTRDrawData::Raw2Digits(AliRawReader *rawReader) } } - if (trklTreeLoader) - trklTreeLoader->WriteData("OVERWRITE"); - if (trklLoader) - trklLoader->UnloadAll(); - - if (fTrackletContainer){ - delete [] fTrackletContainer[0]; - delete [] fTrackletContainer[1]; - delete [] fTrackletContainer; - fTrackletContainer = NULL; + for (Int_t iSector = 0; iSector < fGeo->Nsector(); iSector++) { + fTrgFlags[iSector] = input.GetTriggerFlags(iSector); } - delete pinput; - pinput = NULL; + trklTreeLoader->WriteData("OVERWRITE"); + trklLoader->UnloadAll(); return digitsManager; } @@ -667,44 +658,3 @@ void AliTRDrawData::WriteIntermediateWords(UInt_t* buf, Int_t& nw, Int_t& of, co x = ((kNTBin)<<26) | (bcCtr<<10) | (ptCtr<<6) | (ptPhase<<2) | 1; if (nw < maxSize) buf[nw++] = x; else of++; } - -//_____________________________________________________________________________ -Bool_t AliTRDrawData::WriteTracklets(Int_t det) -{ - // - // Write the raw data tracklets into seperate file - // - - UInt_t **leaves = new UInt_t *[2]; - for (Int_t i=0; i<2 ;i++){ - leaves[i] = new UInt_t[258]; - leaves[i][0] = det; // det - leaves[i][1] = i; // side - memcpy(leaves[i]+2, fTrackletContainer[i], sizeof(UInt_t) * 256); - } - - if (!fTrackletTree){ - AliDataLoader *dl = fRunLoader->GetLoader("TRDLoader")->GetDataLoader("tracklets"); - dl->MakeTree(); - fTrackletTree = dl->Tree(); - } - - TBranch *trkbranch = fTrackletTree->GetBranch("trkbranch"); - if (!trkbranch) { - trkbranch = fTrackletTree->Branch("trkbranch",leaves[0],"det/i:side/i:tracklets[256]/i"); - } - - for (Int_t i=0; i<2; i++){ - if (leaves[i][2]>0) { - trkbranch->SetAddress(leaves[i]); - fTrackletTree->Fill(); - } - } - - // AliDataLoader *dl = fRunLoader->GetLoader("TRDLoader")->GetDataLoader("tracklets"); //jkl: wrong - // dl->WriteData("OVERWRITE"); //jkl: wrong - //dl->Unload(); - delete [] leaves; - - return kTRUE; -}