/************************************************************************** * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ //. /* $Id$ */ #include #include #include "AliDigitizationInput.h" #include #include #include "AliITSupgradeDigitizer.h" #include "AliITSDigitUpgrade.h" #include "AliITSupgrade.h" #include "AliITSsegmentationUpgrade.h" #include #include #include extern TRandom *gRandom; ClassImp(AliITSupgradeDigitizer) void AliITSupgradeDigitizer::SetConfiguration(TArrayD xcell, TArrayD zcell) { if(xcell.GetSize()!=zcell.GetSize()) AliError(" !! The # of X cells and Z cells differ !!"); fNlayers = xcell.GetSize(); if(fNlayers > 9) { AliError("* Only 9 layers can be be filled ...Exiting!!! *"); return; } fNxCells.Set(fNlayers); fNzCells.Set(fNlayers); for(Int_t i=0; iGetNinputs(),fDigInput->GetOutputEventNr())); AliITSsegmentationUpgrade *s = new AliITSsegmentationUpgrade(); SetConfiguration(s->GetFullCellSizeX(),s->GetFullCellSizeZ()); delete s; //First we read all sdigits from all inputs AliRunLoader *pInRunLoader=0;//in and out Run loaders AliLoader *pITSLoader=0;//in and out ITS loaders TClonesArray sdigits[10]; for(Int_t i=0; iGetNinputs();inFileN++){//files loop pInRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inFileN)); //get run loader from current input pITSLoader = pInRunLoader->GetLoader("ITSLoader"); if(pITSLoader==0) { continue; //no ITS in this input, check the next input AliDebug(1,"no ITS lodader, checking in the other input \n"); } if (!pInRunLoader->GetAliRun()) pInRunLoader->LoadgAlice(); AliITSupgrade* pITS=(AliITSupgrade*)pInRunLoader->GetAliRun()->GetDetector("ITS"); pITSLoader->LoadSDigits(); pITSLoader->TreeS()->GetEntry(0); //take list of ITS sdigits from current input for(Int_t is=0;isSDigitsList()->GetEntries();is++){ //collect sdigits from current input for(Int_t ientr =0; ientr < ((TClonesArray*)pITS->SDigitsList()->At(is))->GetEntries(); ientr++){ AliITSDigitUpgrade *pSDig=(AliITSDigitUpgrade*)((TClonesArray*)pITS->SDigitsList()->At(is))->At(ientr); pSDig->AddTidOffset(fDigInput->GetMask(inFileN)); // -> To be introduced for merging (apply TID shift since all inputs count tracks independently starting from 0) new((sdigits[is])[total[is]++]) AliITSDigitUpgrade(*pSDig); } } pITSLoader->UnloadSDigits(); pITS->SDigitsReset(); //close current input and reset }//files loop AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName()); //open output stream (only 1 possible) AliLoader *pOutITSLoader = pOutRunLoader->GetLoader("ITSLoader"); AliRun *pArun = pOutRunLoader->GetAliRun(); AliITSupgrade *pOutITS = (AliITSupgrade*)pArun->GetDetector("ITS"); pOutITSLoader->MakeTree("D"); pOutITS->MakeBranch("D"); //create TreeD in output stream pOutITS->SetTreeAddress(); Sdigits2Digits(sdigits,pOutITS->DigitsList()); pOutITSLoader->TreeD()->Fill(); //fill the output tree with the list of digits pOutITSLoader->WriteDigits("OVERWRITE"); //serialize them to file for(Int_t i=0; i< fNlayers; i++) sdigits[i].Clear(); //remove all tmp sdigits pOutITSLoader->UnloadDigits(); pOutITS->DigitsReset(); }//Exec() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliITSupgradeDigitizer::Sdigits2Digits(TClonesArray *pSDigitList,TObjArray *pDigitList) { TClonesArray *pLst[100]; Int_t iCnt[100]; for(Int_t i=0;iGetEntries()!=0) AliErrorClass("Some of digits lists is not empty"); //in principle those lists should be empty } Double_t eloss= 0.; Double_t nele = 0.; Int_t tids[maxLab]; // track with id# Float_t elossPart[maxLab]; // eloss produced by track with id# for(Int_t i=0; iGetModule(); ULong_t pixId = tmpdig->GetPixId(); Int_t trackId = tmpdig->GetTrackID(0); AliDebug(3,Form(" #tracks %d; #summed digits = %d, TrackIds (%d,%d,%d) ... ",iNtrackPart,iNdigPart,tids[0],tids[1],tids[2])); AliDebug(3,Form("\t adding lay:%d mod:%d pixId:%lu trackID:%d \n",tmpdig->GetLayer(),tmpdig->GetModule(),tmpdig->GetPixId(), tmpdig->GetTrackID(0))); if (trackId<0) AliError("Screw you! A track with label<0 produced a SDigit? Something is wrong with Geant?\n"); if(pixId==prevPixId && module==prevModule) { // This sdigit belongs to the same pixel as before // check if trackId is already in the list, if yes just add eloss ... Int_t iid =0; while (iidGetSignal(); // hardcoded limit for elossPart break; } iid++; } if (iid==labelsMC.GetSize()) { // the trackId is NEW!! if (iidGetTrackID(0); elossPart[iNtrackPart] = tmpdig->GetSignal(); } iNtrackPart++; // complete list of trackIDs labelsMC.Set(iNtrackPart); labelsMC.SetAt(trackId,iNtrackPart-1); } else { AliDebug(3," -> Track ID already in the list\n"); } if(iNtrackPart>maxLab) { AliWarning(Form(" Event %d: Number of summable digits for this pixel (lay=%d,mod=%d,pixId=%lu) is too large (%d<%d). Sum is ok but skipping track Id %d ... ", fDigInput->GetOutputEventNr(),ilay,module,pixId,maxLab,iNtrackPart,trackId)); } eloss+=tmpdig->GetSignal(); nele +=tmpdig->GetNelectrons(); iNdigPart++; } else { // new Pixel // write "previous" Digit if(isdigentr!=0) { AliITSDigitUpgrade digit(prevPixId,eloss); digit.SetNelectrons(nele); digit.SetLayer(ilay); digit.SetModule(prevModule); digit.SetTids(tids); digit.SetSignalID(elossPart); digit.SetNTracksIdMC(iNtrackPart); // for (Int_t i=0; i<12; i++) { if (i<12)printf("%d ",tids[i]); if (i==11) printf("| ");} // for (Int_t i=0; i Wrote NEW digit in layer %d (%d)\n",ilay,nDigits)); } // Prepare newly found Pixel eloss = tmpdig->GetSignal(); nele = tmpdig->GetNelectrons(); iNtrackPart=1; iNdigPart=1; labelsMC.Set(iNtrackPart); labelsMC.SetAt(tmpdig->GetTrackID(0),iNtrackPart-1); tids[0]=tmpdig->GetTrackID(0); elossPart[0]=tmpdig->GetSignal(); for(Int_t i=1; iGetPixId(); prevModule=tmpdig->GetModule(); } // write "last" Digit AliITSDigitUpgrade digit(prevPixId,eloss); digit.SetNelectrons(nele); digit.SetLayer(ilay); digit.SetModule(prevModule); digit.SetTids(tids); digit.SetSignalID(elossPart); digit.SetNTracksIdMC(iNtrackPart); // for (Int_t i=0; i<12; i++) { if (i<12)printf("%d ",tids[i]); if (i==11) printf("| ");} // for (Int_t i=0; i Wrote LAST digit in layer %d (%d)\n",ilay,nDigits)); AliDebug(3,Form(" -> layer %d: Number of created digits %d",ilay,nDigits)); AliDebug(1,"ending loop over sdigits to create digits"); } AliDebug(1,"ending loop over layers"); }