2 // $Id: AliHLTMCGeneratorComponent.cxx $
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTMCGeneratorComponent.cxx
20 @author Jochen Thaeder
22 @brief Component for generating MC events
23 @note The class is used in Offline (AliRoot) context
26 #include "AliHLTMCGeneratorComponent.h"
28 #if !defined(__CINT__) || defined(__MAKECINT__)
29 #include <Riostream.h>
31 #include <TStopwatch.h>
34 #include <TDatabasePDG.h>
35 #include <TParticle.h>
38 #include "AliGenerator.h"
40 #include "AliRunLoader.h"
43 #include "AliHeader.h"
44 #include "AliGenPythia.h"
45 #include "AliPythia.h"
48 #include "TPythia6Calls.h"
51 /** ROOT macro for the implementation of ROOT specific class methods */
52 ClassImp(AliHLTMCGeneratorComponent)
55 * ---------------------------------------------------------------------------------
56 * Constructor / Destructor
57 * ---------------------------------------------------------------------------------
60 // #################################################################################
61 AliHLTMCGeneratorComponent::AliHLTMCGeneratorComponent() :
73 fRunType(kPythia6Jets104_125),
84 fApplyParticleCuts(kFALSE) {
85 // see header file for class documentation
87 // refer to README to build package
89 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
92 // #################################################################################
93 AliHLTMCGeneratorComponent::~AliHLTMCGeneratorComponent() {
94 // see header file for class documentation
96 // file list and file name list are owner of their objects and
97 // delete all the objects
101 * ---------------------------------------------------------------------------------
102 * Initialize static const
103 * ---------------------------------------------------------------------------------
106 //##################################################################################
107 const Char_t *AliHLTMCGeneratorComponent::fgkPprRunName[] = {
108 "kPythia6Jets20_24", "kPythia6Jets24_29", "kPythia6Jets29_35",
109 "kPythia6Jets35_42", "kPythia6Jets42_50", "kPythia6Jets50_60",
110 "kPythia6Jets60_72", "kPythia6Jets72_86", "kPythia6Jets86_104",
111 "kPythia6Jets104_125", "kPythia6Jets125_150", "kPythia6Jets150_180",
112 "kPyJetJet", "kPyGammaJetPHOS"
116 * ---------------------------------------------------------------------------------
117 * Public functions to implement AliHLTComponent's interface.
118 * These functions are required for the registration process
119 * ---------------------------------------------------------------------------------
122 // #################################################################################
123 const Char_t* AliHLTMCGeneratorComponent::GetComponentID() {
124 // see header file for class documentation
125 return "MCGenerator";
128 // #################################################################################
129 AliHLTComponentDataType AliHLTMCGeneratorComponent::GetOutputDataType() {
130 // see header file for class documentation
132 return kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT;
135 // #################################################################################
136 void AliHLTMCGeneratorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
137 // see header file for class documentation
140 inputMultiplier = 1.0;
143 // #################################################################################
144 AliHLTComponent* AliHLTMCGeneratorComponent::Spawn() {
145 // see header file for class documentation
146 return new AliHLTMCGeneratorComponent;
150 * ---------------------------------------------------------------------------------
151 * Protected functions to implement AliHLTComponent's interface.
152 * These functions provide initialization as well as the actual processing
153 * capabilities of the component.
154 * ---------------------------------------------------------------------------------
157 // #################################################################################
158 Int_t AliHLTMCGeneratorComponent::DoInit(int argc, const char** argv) {
159 // see header file for class documentation
162 Int_t bMissingParam=0;
166 // -- Loop over all arguments
167 for ( Int_t iter = 0; iter<argc && iResult>=0; iter++) {
169 if (argument.IsNull()) continue;
172 if ( !argument.CompareTo("-seed") ) {
173 if ((bMissingParam=(++iter>=argc))) break;
175 TString parameter(argv[iter]);
176 parameter.Remove(TString::kLeading, ' ');
178 if ( parameter.IsDigit() ) {
179 fSeed = parameter.Atoi();
183 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
189 else if ( !argument.CompareTo("-runtype") ) {
190 if ((bMissingParam=(++iter>=argc))) break;
192 TString parameter(argv[iter]);
193 parameter.Remove(TString::kLeading, ' ');
195 Bool_t found = kFALSE;
197 if ( parameter.IsDigit() ) {
198 Int_t idx = parameter.Atoi();
199 if ( idx < kRunMax ) {
200 fRunType = (PprRun_t) idx;
205 for ( Int_t iRun = 0; iRun < kRunMax && !found; iRun++ ) {
206 if ( ! parameter.CompareTo(fgkPprRunName[iRun]) ) {
207 fRunType = (PprRun_t) iRun;
213 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
219 else if ( !argument.CompareTo("-nevents") ) {
220 if ((bMissingParam=(++iter>=argc))) break;
222 TString parameter(argv[iter]);
223 parameter.Remove(TString::kLeading, ' ');
225 if ( parameter.IsDigit() ) {
226 fNEvents = parameter.Atoi();
230 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
236 else if ( !argument.CompareTo("-coneRadius") ) {
237 if ((bMissingParam=(++iter>=argc))) break;
239 TString parameter(argv[iter]);
240 parameter.Remove(TString::kLeading, ' ');
242 if ( parameter.IsFloat() ) {
243 fJetConeRadius = parameter.Atof();
246 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
252 else if ( !argument.CompareTo("-jetCutMinEt") ) {
253 if ((bMissingParam=(++iter>=argc))) break;
255 TString parameter(argv[iter]);
256 parameter.Remove(TString::kLeading, ' ');
258 if ( parameter.IsFloat() ) {
259 fJetEtMin = parameter.Atof();
262 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
267 // -- applyParticleCuts
268 else if ( !argument.CompareTo("-applyParticleCuts") ) {
269 fApplyParticleCuts = kTRUE;
272 // -- Argument not known
274 HLTError("Unknown argument %s.", argument.Data());
278 } // for ( Int iter = 0; iter<argc && iResult>=0; iter++) {
280 // -- Check if parameter is missing
281 if ( bMissingParam ) {
282 HLTError("Missing parameter for argument %s.", argument.Data());
286 // -- Check if seed and nevents has been specified
287 if ( !fSeed || !fNEvents ) {
288 HLTError("-seed and -nevents need to be specified.");
292 // -- Set Random Number seed
293 gRandom->SetSeed( fSeed );
297 AliPDG::AddParticlesToPdgDataBase();
299 fRunLoader = AliRunLoader::Open("galice.root","FASTRUN","recreate");
300 if (fRunLoader == NULL ) {
301 // gAlice->Fatal("AliHLTMCGeneratorComponent","Can not instatiate the Run Loader");
302 HLTFatal("Can not instatiate the Run Loader");
306 fRunLoader->SetCompressionLevel(2);
307 fRunLoader->SetNumberOfEventsPerFile(fNEvents);
308 fRunLoader->LoadKinematics("RECREATE");
309 fRunLoader->MakeTree("E");
310 gAlice->SetRunLoader(fRunLoader);
313 fRunLoader->MakeStack();
315 // -- Create and Initialize Generator
316 fGenerator = GeneratorFactory();
317 fGenerator->SetStack(fRunLoader->Stack());
320 HLTInfo("MC Generator setup with : %s", fComment.Data() );
325 // #################################################################################
326 Int_t AliHLTMCGeneratorComponent::DoDeinit() {
327 // see header file for class documentation
340 // #################################################################################
341 Int_t AliHLTMCGeneratorComponent::GetEvent( const AliHLTComponentEventData& /*evtData*/,
342 AliHLTComponentTriggerData& /*trigData*/,
343 AliHLTUInt8_t* /*outputPtr*/,
344 AliHLTUInt32_t& size,
345 vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
346 // see header file for class documentation
348 if ( !IsDataEvent() )
354 AliStack* stack = fRunLoader->Stack();
355 AliHeader* header = fRunLoader->GetHeader();
357 // -- Initialize event
358 header->Reset(0,fCurrentEvent);
364 fGenerator->Generate();
367 header->SetNprimary(stack->GetNprimary());
368 header->SetNtrack(stack->GetNtrack());
371 stack->FinishEvent();
372 header->SetStack(stack);
374 // -- Create HLT MC Event
377 fpHLTMC = new AliHLTMCEvent( fApplyParticleCuts);
379 // -- Fill HLT MC event
380 iResult = fpHLTMC->FillMCEvent( stack, header );
382 // -- Send HLT MC event
383 if ( fpHLTMC && !iResult )
384 PushBack( fpHLTMC, kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT, 0 );
391 // #################################################################################
392 AliGenerator* AliHLTMCGeneratorComponent::GeneratorFactory() {
394 // -- Configuration for hard QCD processes generation with PYTHIA
395 // ----------------------------------------------------------------
396 AliGenPythia * gener = new AliGenPythia(-1);
398 gener->SetEnergyCMS(fEcms); // Centre of mass energy
399 gener->SetGluonRadiation(1,1);
400 gener->SetForceDecay(kAll); // Decay type
402 // -- Final state kinematic cuts
403 gener->SetJetEtaRange(fJetEtaMin, fJetEtaMax);
404 gener->SetJetPhiRange(0., 360.);
405 gener->SetJetEtRange(fJetEtMin, fJetEtMax);
406 // gener->SetMomentumRange(0,99999999);
408 // -- Structure function
409 gener->SetStrucFunc(kCTEQ4L);
411 /************************************************************************
412 * void AliGenPythia::SetPycellParameters()
413 * Float_t etamax -- fPycellEtaMax -- PARU(51) -- +/- eta max of detector
414 * Int_t neta -- fPycellNEta -- MSTU(51) -- N cells in eta
415 * Int_t nphi -- fPycellNPhi -- MSTU(52) -- N cells in phi
416 * Float_t thresh -- fPycellThreshold -- PARU(58) -- cells with Et below treshold are discared
417 * Float_t etseed -- fPycellEtSeed -- PARU(52) -- Et threshold for seed cells
418 * Float_t minet -- fPycellMinEtJet -- PARU(53) -- Min Et for jets
419 * Float_t r -- fPycellMaxRadius -- PARU(54) -- cone radius
420 ************************************************************************/
421 gener->SetPycellParameters(fJetEtaMax, 274, 432, 0., 4., fJetEtMin, fJetConeRadius);
423 // gener->SetPtKick(5.); // set the intrinsic kt to 5 GeV/c
426 gener->SetQuench(fQuenching);
427 if( fQuenching == 1){
428 Float_t k = 6e5*(fQhat/1.7) ; // qhat=1.7, k = 6e5, default value
429 AliPythia::Instance()->InitQuenching(0.,0.1,k,0,0.95,6);
433 case kPythia6Jets20_24:
435 fComment = fComment.Append(":Pythia jets 20-24 GeV @ 14 TeV");
436 gener->SetProcess(kPyJets);// Process type
437 gener->SetPtHard(20., 24.);// Pt transfer of the hard scattering
441 case kPythia6Jets24_29:
443 fComment = fComment.Append(":Pythia jets 24-29 GeV @ 14 TeV");
444 gener->SetProcess(kPyJets);// Process type
445 gener->SetPtHard(24., 29.);// Pt transfer of the hard scattering
449 case kPythia6Jets29_35:
451 fComment = fComment.Append(":Pythia jets 29-35 GeV @ 14 TeV");
452 gener->SetProcess(kPyJets);// Process type
453 gener->SetPtHard(29., 35.);// Pt transfer of the hard scattering
457 case kPythia6Jets35_42:
459 fComment = fComment.Append(":Pythia jets 35-42 GeV @ 14 TeV");
460 gener->SetProcess(kPyJets);// Process type
461 gener->SetPtHard(35., 42.);// Pt transfer of the hard scattering
465 case kPythia6Jets42_50:
467 fComment = fComment.Append(":Pythia jets 42-50 GeV @ 14 TeV");
468 gener->SetProcess(kPyJets);// Process type
469 gener->SetPtHard(42., 50.);// Pt transfer of the hard scattering
473 case kPythia6Jets50_60:
475 fComment = fComment.Append(":Pythia jets 50-60 GeV @ 14 TeV");
476 gener->SetProcess(kPyJets);// Process type
477 gener->SetPtHard(50., 60.);// Pt transfer of the hard scattering
481 case kPythia6Jets60_72:
483 fComment = fComment.Append(":Pythia jets 60-72 GeV @ 14 TeV");
484 gener->SetProcess(kPyJets);// Process type
485 gener->SetPtHard(60., 72.);// Pt transfer of the hard scattering
489 case kPythia6Jets72_86:
491 fComment = fComment.Append(":Pythia jets 72-86 GeV @ 14 TeV");
492 gener->SetProcess(kPyJets);// Process type
493 gener->SetPtHard(72., 86.);// Pt transfer of the hard scattering
497 case kPythia6Jets86_104:
499 fComment = fComment.Append(":Pythia jets 86-104 GeV @ 14 TeV");
500 gener->SetProcess(kPyJets);// Process type
501 gener->SetPtHard(86., 104.);// Pt transfer of the hard scattering
505 case kPythia6Jets104_125:
507 fComment = fComment.Append(":Pythia jets 104-125 GeV @ 14 TeV");
508 gener->SetProcess(kPyJets);// Process type
509 gener->SetPtHard(104., 125.);// Pt transfer of the hard scattering
513 case kPythia6Jets125_150:
515 fComment = fComment.Append(":Pythia jets 125-150 GeV @ 14 TeV");
516 gener->SetProcess(kPyJets);// Process type
517 gener->SetPtHard(125., 150.);// Pt transfer of the hard scattering
521 case kPythia6Jets150_180:
523 fComment = fComment.Append(":Pythia jets 150-180 GeV @ 14 TeV");
524 gener->SetProcess(kPyJets);// Process type
525 gener->SetPtHard(150., 180.);// Pt transfer of the hard scattering
531 fComment = fComment.Append(" Jet-jet @ 14 TeV");
532 gener->SetProcess(kPyJets);
533 gener->SetPtHard(fPtHardMin,fPtHardMax);
534 gener->SetEventListRange(0,1); // XXXX
537 case kPyGammaJetPHOS:
539 fComment = fComment.Append(" pp->jet + Gamma over PHOS @ 14 TeV");
540 gener->SetProcess(kPyDirectGamma);
541 gener->SetPtHard(fPtHardMin,fPtHardMax);
542 //gener->SetYHard(-1.0,1.0);
543 gener->SetGammaEtaRange(-0.13,0.13);
544 gener->SetGammaPhiRange(218.,322.); //Over 5 modules +-2 deg
545 gener->SetEventListRange(0,1); // XXXX