X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONSDigitizerV2.cxx;h=a4d596df9cdd90a7b478389b2f7ddff40eaeb65b;hb=2176e8cffb1bf74705a0b9654e040ab08dc57210;hp=b534ed7fcbc64532d638da9407cbf71b7b47ee95;hpb=2c6e3e3044a111b38fd90a780a08b790656da1e4;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONSDigitizerV2.cxx b/MUON/AliMUONSDigitizerV2.cxx index b534ed7fcbc..a4d596df9cd 100644 --- a/MUON/AliMUONSDigitizerV2.cxx +++ b/MUON/AliMUONSDigitizerV2.cxx @@ -15,63 +15,125 @@ // $Id$ +#include +#include + #include "AliMUONSDigitizerV2.h" -#include "AliLog.h" #include "AliMUON.h" #include "AliMUONChamber.h" -#include "AliMUONData.h" -#include "AliMUONDigit.h" +#include "AliMUONVDigit.h" #include "AliMUONHit.h" +#include "AliMUONVDigitStore.h" +#include "AliMUONVHitStore.h" +#include "AliMUONCalibrationData.h" +#include "AliMUONResponseTrigger.h" +#include "AliMUONConstants.h" + +#include "AliMpCDB.h" +#include "AliMpDEManager.h" + +#include "AliLog.h" +#include "AliCDBManager.h" #include "AliLoader.h" #include "AliRun.h" #include "AliRunLoader.h" -#include "TObjArray.h" + +#include "AliHeader.h" +#include "AliGenCocktailEventHeader.h" + +//----------------------------------------------------------------------------- +/// The sdigitizer performs the transformation from hits (energy deposits by +/// the transport code) to sdigits (equivalent of charges on pad). +/// +/// It does so by converting the energy deposit into a charge and then spreading +/// this charge over several pads, according to the response function (a +/// Mathieson distribution, basically). +/// +/// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate +/// method), while this sdigitizer is just "steering" the process. +/// +/// Please note that we do *not* merge sdigits after creation, which means +/// that after sdigitization, a given pad can have several sdigits. This +/// merging is taken care of later on by the digitizer(V3). +//----------------------------------------------------------------------------- ClassImp(AliMUONSDigitizerV2) +Float_t AliMUONSDigitizerV2::fgkMaxIntTime = 10.0; +Float_t AliMUONSDigitizerV2::fgkMaxPosTimeDif = 1.22E-6; +Float_t AliMUONSDigitizerV2::fgkMaxNegTimeDif = -3.5E-6; +Float_t AliMUONSDigitizerV2::fgkMinTimeDif = 25E-9; + //_____________________________________________________________________________ AliMUONSDigitizerV2::AliMUONSDigitizerV2() : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON") { - // - // ctor. - // + /// + /// ctor. + /// + + // Load mapping + if ( ! AliMpCDB::LoadMpSegmentation() ) { + AliFatal("Could not access mapping from OCDB !"); + } } //_____________________________________________________________________________ AliMUONSDigitizerV2::~AliMUONSDigitizerV2() { - // - // dtor. - // + /// + /// dtor. + /// } //_____________________________________________________________________________ void AliMUONSDigitizerV2::Exec(Option_t*) { - // - // Go from hits to sdigits. - // - // In the code below, apart from the loop itself (which look complicated - // but is really only a loop on each hit in the input file) the main - // work is done in AliMUONResponse::DisIntegrate method, which converts - // a single hit in (possibly) several sdigits. - // + /// + /// Go from hits to sdigits. + /// + /// In the code below, apart from the loop itself (which look complicated + /// but is really only a loop on each hit in the input file) the main + /// work is done in AliMUONResponse::DisIntegrate method, which converts + /// a single hit in (possibly) several sdigits. + /// AliDebug(1,""); - AliRunLoader* runLoader = AliRunLoader::GetRunLoader(); - AliLoader* fLoader = runLoader->GetLoader("MUONLoader"); + AliRunLoader* runLoader = AliRunLoader::Instance(); + AliLoader* loader = runLoader->GetDetectorLoader("MUON"); - fLoader->LoadHits("READ"); + loader->LoadHits("READ"); - AliMUONData muonData(fLoader,"MUON","MUON"); - AliMUON* muon = static_cast(gAlice->GetModule("MUON")); - - const Int_t nofEvents(runLoader->GetNumberOfEvents()); + + AliMUONCalibrationData *calibrationData = 0x0; + + if(muon->GetTriggerEffCells()){ + Int_t runnumber = AliCDBManager::Instance()->GetRun(); + calibrationData = new AliMUONCalibrationData(runnumber); + for (Int_t chamber = 10; chamber < 14; chamber++) { + ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency + } + } + + Int_t nofEvents(runLoader->GetNumberOfEvents()); + + TString classname = muon->DigitStoreClassName(); + + AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data()); + + if (!sDigitStore) + { + AliFatal(Form("Could not create digitstore of class %s",classname.Data())); + } + + AliDebug(1,Form("Will use digitStore of type %s",sDigitStore->ClassName())); + + // average arrival time to chambers, for pileup studies + for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent ) { // Loop over events. @@ -80,71 +142,131 @@ AliMUONSDigitizerV2::Exec(Option_t*) AliDebug(1,Form("iEvent=%d",iEvent)); runLoader->GetEvent(iEvent); - TTree* treeS = fLoader->TreeS(); - AliDebug(1,Form("TreeS=%p",treeS)); + + // for pile up studies + float t0=fgkMaxIntTime; int aa=0; + AliHeader* header = runLoader->GetHeader(); + AliGenCocktailEventHeader* cocktailHeader = + dynamic_cast(header->GenEventHeader()); + if (cocktailHeader) { + AliGenCocktailEventHeader* genEventHeader = (AliGenCocktailEventHeader*) (header->GenEventHeader()); + TList* headers = genEventHeader->GetHeaders(); + TIter nextH(headers); + AliGenEventHeader *entry; + while((entry = (AliGenEventHeader*)nextH())) { + float t = entry->InteractionTime(); + if (TMath::Abs(t)GenEventHeader()); + float t = evtHeader->InteractionTime(); + if (TMath::Abs(t)MakeSDigitsContainer(); + + TTree* treeS = loader->TreeS(); + if ( !treeS ) { - AliDebug(1,"MakeSDigitsContainer"); - fLoader->MakeSDigitsContainer(); - treeS = fLoader->TreeS(); + AliFatal(""); } - AliDebug(1,Form("TreeS=%p",treeS)); - muonData.MakeBranch("S"); - muonData.SetTreeAddress("S"); + + sDigitStore->Connect(*treeS); + + TTree* treeH = loader->TreeH(); + + AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH); + hitStore->Connect(*treeH); - muonData.SetTreeAddress("H"); - TTree* treeH = fLoader->TreeH(); - AliDebug(1,Form("TreeH=%p",treeH)); - Long64_t nofTracks = treeH->GetEntries(); + for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack ) { // Loop over the tracks of this event. treeH->GetEvent(iTrack); - TClonesArray* hits = muonData.Hits(); - Int_t nofHits = hits->GetEntriesFast(); - for ( Int_t ihit = 0; ihit < nofHits; ++ihit ) + + AliMUONHit* hit; + TIter next(hitStore->CreateIterator()); + Int_t ihit(0); + + while ( ( hit = static_cast(next()) ) ) { - // Loop over the hits of this track. - AliMUONHit* hit = static_cast(hits->At(ihit)); - Int_t chamberId = hit->Chamber()-1; + Int_t chamberId = hit->Chamber()-1; + Float_t age = hit->Age()-t0; + AliMUONChamber& chamber = muon->Chamber(chamberId); AliMUONResponse* response = chamber.ResponseModel(); // This is the heart of this method : the dis-integration TList digits; - response->DisIntegrate(*hit,digits); + if (aa>1){ // if there are pileup events + Float_t chamberTime = AliMUONConstants::AverageChamberT(chamberId); + Float_t timeDif=age-chamberTime; + if (timeDif>fgkMaxPosTimeDif || timeDiffgkMinTimeDif){ + response->DisIntegrate(*hit,digits,timeDif); + } + else{ + response->DisIntegrate(*hit,digits,0.); + } + } + else{ + response->DisIntegrate(*hit,digits,0.); + } - TIter next(&digits); - AliMUONDigit* d; - while ( ( d = (AliMUONDigit*)next() ) ) + TIter nextd(&digits); + AliMUONVDigit* d; + while ( ( d = (AliMUONVDigit*)nextd() ) ) { // Update some sdigit information that could not be known // by the DisIntegrate method d->SetHit(ihit); - d->AddTrack(iTrack,d->Signal()); + d->SetTime(age); + d->AddTrack(hit->GetTrack(),d->Charge()); tdlist.Add(d); } + ++ihit; } - muonData.ResetHits(); + hitStore->Clear(); } // end of loop on tracks within an event - for ( Int_t i = 0; i <= tdlist.GetLast(); ++i ) + TIter next(&tdlist); + AliMUONVDigit* d; + + while ( ( d = static_cast(next()) ) ) { - AliMUONDigit* d = (AliMUONDigit*)tdlist[i]; - StdoutToAliDebug(1,d->Print();); - if ( d->Signal() > 0 ) // that check would be better in the disintegrate + if ( d->Charge() > 0 ) // that check would be better in the disintegrate // method, but to compare with old sdigitizer, it has to be there. { - muonData.AddSDigit(d->DetElemId()/100-1,*d); + AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge); + if (!added) + { + AliError("Could not add digit to digitStore"); + } } } - muonData.Fill("S"); - fLoader->WriteSDigits("OVERWRITE"); + + treeS->Fill(); + + loader->WriteSDigits("OVERWRITE"); + + sDigitStore->Clear(); + + loader->UnloadSDigits(); + + delete hitStore; - muonData.ResetSDigits(); - fLoader->UnloadSDigits(); } // loop on events - fLoader->UnloadHits(); + loader->UnloadHits(); + + delete sDigitStore; + + if(calibrationData) delete calibrationData; }