1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include <TClonesArray.h>
19 #include <TParticle.h>
21 #include "AliMUONSDigitizerV2.h"
24 #include "AliMUONChamber.h"
25 #include "AliMUONVDigit.h"
26 #include "AliMUONHit.h"
27 #include "AliMUONVDigitStore.h"
28 #include "AliMUONVHitStore.h"
29 #include "AliMUONCalibrationData.h"
30 #include "AliMUONResponseTrigger.h"
31 #include "AliMUONConstants.h"
34 #include "AliMpDEManager.h"
37 #include "AliCDBManager.h"
38 #include "AliLoader.h"
40 #include "AliRunLoader.h"
42 #include "AliHeader.h"
43 #include "AliGenCocktailEventHeader.h"
45 //-----------------------------------------------------------------------------
46 /// The sdigitizer performs the transformation from hits (energy deposits by
47 /// the transport code) to sdigits (equivalent of charges on pad).
49 /// It does so by converting the energy deposit into a charge and then spreading
50 /// this charge over several pads, according to the response function (a
51 /// Mathieson distribution, basically).
53 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
54 /// method), while this sdigitizer is just "steering" the process.
56 /// Please note that we do *not* merge sdigits after creation, which means
57 /// that after sdigitization, a given pad can have several sdigits. This
58 /// merging is taken care of later on by the digitizer(V3).
59 //-----------------------------------------------------------------------------
61 ClassImp(AliMUONSDigitizerV2)
63 Float_t AliMUONSDigitizerV2::fgkMaxIntTime = 10.0;
64 Float_t AliMUONSDigitizerV2::fgkMaxPosTimeDif = 1.22E-6;
65 Float_t AliMUONSDigitizerV2::fgkMaxNegTimeDif = -3.5E-6;
66 Float_t AliMUONSDigitizerV2::fgkMinTimeDif = 25E-9;
68 //_____________________________________________________________________________
69 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
70 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
77 if ( ! AliMpCDB::LoadMpSegmentation() ) {
78 AliFatal("Could not access mapping from OCDB !");
82 //_____________________________________________________________________________
83 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
90 //_____________________________________________________________________________
92 AliMUONSDigitizerV2::Exec(Option_t*)
95 /// Go from hits to sdigits.
97 /// In the code below, apart from the loop itself (which look complicated
98 /// but is really only a loop on each hit in the input file) the main
99 /// work is done in AliMUONResponse::DisIntegrate method, which converts
100 /// a single hit in (possibly) several sdigits.
105 AliRunLoader* runLoader = AliRunLoader::Instance();
106 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
108 loader->LoadHits("READ");
110 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
112 AliMUONCalibrationData *calibrationData = 0x0;
114 if(muon->GetTriggerEffCells()){
115 Int_t runnumber = AliCDBManager::Instance()->GetRun();
116 calibrationData = new AliMUONCalibrationData(runnumber);
117 for (Int_t chamber = 10; chamber < 14; chamber++) {
118 ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency
122 Int_t nofEvents(runLoader->GetNumberOfEvents());
124 TString classname = muon->DigitStoreClassName();
126 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
130 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
133 AliDebug(1,Form("Will use digitStore of type %s",sDigitStore->ClassName()));
135 // average arrival time to chambers, for pileup studies
137 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
141 tdlist.SetOwner(kTRUE);
143 AliDebug(1,Form("iEvent=%d",iEvent));
144 runLoader->GetEvent(iEvent);
146 // for pile up studies
147 float T0=fgkMaxIntTime; int AA=0;
148 AliHeader* header = runLoader->GetHeader();
149 AliGenCocktailEventHeader* cocktailHeader =
150 dynamic_cast<AliGenCocktailEventHeader*>(header->GenEventHeader());
151 if (cocktailHeader) {
152 AliGenCocktailEventHeader* genEventHeader = (AliGenCocktailEventHeader*) (header->GenEventHeader());
153 TList* headers = genEventHeader->GetHeaders();
154 TIter nextH(headers);
155 AliGenEventHeader *entry;
156 while((entry = (AliGenEventHeader*)nextH())) {
157 float t = entry->InteractionTime();
158 if (TMath::Abs(t)<TMath::Abs(T0)) T0 = t;
162 AliGenEventHeader* evtHeader =
163 (AliGenEventHeader*)(header->GenEventHeader());
164 float t = evtHeader->InteractionTime();
165 if (TMath::Abs(t)<TMath::Abs(T0)) T0 = t;
169 loader->MakeSDigitsContainer();
171 TTree* treeS = loader->TreeS();
178 sDigitStore->Connect(*treeS);
180 TTree* treeH = loader->TreeH();
182 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
183 hitStore->Connect(*treeH);
185 Long64_t nofTracks = treeH->GetEntries();
187 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
189 // Loop over the tracks of this event.
190 treeH->GetEvent(iTrack);
193 TIter next(hitStore->CreateIterator());
196 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
198 Int_t chamberId = hit->Chamber()-1;
199 Float_t age = hit->Age()-T0;
201 AliMUONChamber& chamber = muon->Chamber(chamberId);
202 AliMUONResponse* response = chamber.ResponseModel();
204 // This is the heart of this method : the dis-integration
206 if (AA>1){ // if there are pileup events
207 Float_t chamberTime = AliMUONConstants::AverageChamberT(chamberId);
208 Float_t timeDif=age-chamberTime;
209 if (timeDif>fgkMaxPosTimeDif || timeDif<fgkMaxNegTimeDif) {
212 if(TMath::Abs(timeDif)>fgkMinTimeDif){
213 response->DisIntegrate(*hit,digits,timeDif);
216 response->DisIntegrate(*hit,digits,0.);
220 response->DisIntegrate(*hit,digits,0.);
223 TIter nextd(&digits);
225 while ( ( d = (AliMUONVDigit*)nextd() ) )
227 // Update some sdigit information that could not be known
228 // by the DisIntegrate method
231 d->AddTrack(hit->GetTrack(),d->Charge());
237 } // end of loop on tracks within an event
242 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
244 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
245 // method, but to compare with old sdigitizer, it has to be there.
247 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
250 AliError("Could not add digit to digitStore");
257 loader->WriteSDigits("OVERWRITE");
259 sDigitStore->Clear();
261 loader->UnloadSDigits();
267 loader->UnloadHits();
271 if(calibrationData) delete calibrationData;