ROOT logo
using namespace std;
#include "hshowertaskset.h"
#include "htask.h"
#include "htaskset.h"
#include "hdebug.h"
#include "TROOT.h"
#include "TClass.h"
#include "haddef.h"
#include "hades.h"
#include "hshowercalibrater.h"
#include "hshowerhitfinder.h"
#include "hshowercopy.h"
#include "hshowerhitdigitizer.h"
#include "hshowerpaddigitizer.h"
#include "hshowerhittrackmatcher.h"
#include "TBrowser.h"
#include "TString.h"
#include "TObjString.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>

//*-- Author : Dan Magestro
//*-- Modified: 05/04/2003  by J.Otwinowski
//	    simulation flag set for hshowertofinocorrealtor
//*-- Modified: 19/11/2001  by D. Magestro
//*-- Modified: 14/02/2002  by J.Otwinowski
//*-- Modified: 02/06/2006  by J.Otwinowski
//   	 lowshowerefficiency flag added
//_HADES_CLASS_DESCRIPTION
///////////////////////////////////////////////////////////////////////////////
// HShowerTaskSet
//
// This HTaskSet contains the tasks for the Shower - Tofino detector
//
// BEGIN_HTML<b><font color="maroon">For more information, see <a target="_top" href="http://webdb.gsi.de:8010/pls/hades_webdbs/hanal.hal_posting_query.show_posting_text?p_id=436">this analysis logbook entry<a>.</font></b> END_HTML
//
///////////////////////////////////////////////////////////////////////////////

Int_t HShowerTaskSet::ianalysisSimOrReal=0;
Int_t HShowerTaskSet::ianalysisLevel=0;
Int_t HShowerTaskSet::imagnet=0;
Int_t HShowerTaskSet::analysisSimOrReal=0;
Int_t HShowerTaskSet::analysisLevel=3;
Bool_t HShowerTaskSet::isCoilOff=kFALSE;
Bool_t HShowerTaskSet::isSimulation=kFALSE;
Bool_t HShowerTaskSet::isLowShowerEfficiency=kTRUE;

HShowerTaskSet::HShowerTaskSet(const Text_t name[],const Text_t title[]) : HTaskSet(name,title) {
    // Constructor
}


HShowerTaskSet::HShowerTaskSet(void) : HTaskSet() {
    // Default constructor
}


HShowerTaskSet::~HShowerTaskSet(void) {
    // Destructor.
}


HTask* HShowerTaskSet::make(const Char_t *select,const Option_t *option) {
    // Returns a pointer to the Shower task or taskset specified by 'select'


    HTaskSet *tasks = new HTaskSet("Shower","List of Shower tasks");

    TString sel = select;
    sel.ToLower() ;
    passArguments(sel);

    TString opt = option;

    passArguments(opt);

    if(isSimulation&&gHades->getEmbeddingMode()>0)
    {
	Error("HShowerTaskSet::make()","Embedding is not implemented in Simulation! Use Real for embedding!");
	exit(1);
    }


    //if( isLowShowerEfficiency == kFALSE) pShTofCorr->setLowShowerEfficiencyFlag(kFALSE);
    //else pShTofCorr->setLowShowerEfficiencyFlag(kTRUE);


    if(!isSimulation)
    {
	// real or embedding
	if(analysisLevel >= 1 )
	{
	    tasks->add( new HShowerCalibrater("sho.cal","sho.cal") );

	    if(gHades->getEmbeddingMode()>0)
	    {   // embedding
		tasks->add( new HShowerHitDigitizer("shohit.digi","shohit.digi") );
		tasks->add( new HShowerPadDigitizer("shopad.digi","shopad.digi") );
		tasks->add( new HShowerCopy("sho.copy","sho.copy"));
	    }
	}
	if(analysisLevel >= 2)
	{
	    tasks->add( new HShowerHitFinder("sho.hitf","sho.hitf") );
	    if(gHades->getEmbeddingMode()>0)
	    {   // embedding
		tasks->add( new HShowerHitTrackMatcher("sho.htmatch","sho.htmatch") );
	    }
	}
    }
    else
    {
	// simulation
	if(analysisLevel >=1 )
	{
	    tasks->add( new HShowerHitDigitizer("shohit.digi","shohit.digi") );
	    tasks->add( new HShowerPadDigitizer("shopad.digi","shopad.digi") );
	    tasks->add( new HShowerCopy("sho.copy","sho.copy"));
	}
	if(analysisLevel >=2)
	{
	    tasks->add( new HShowerHitFinder("sho.hitf","sho.hitf") );
	    tasks->add( new HShowerHitTrackMatcher("sho.htmatch","sho.htmatch") );
	}
    }
    return tasks;
}

void HShowerTaskSet::setAnalysisSimOrReal(Option_t* optrealorsim="") {
    TString optRealOrSim=optrealorsim;

    optRealOrSim.ToLower();
    if(optRealOrSim.CompareTo("real")==0)
    {
	isSimulation=kFALSE;
    }
    else if(optRealOrSim.CompareTo("simulation")==0)
    {
	isSimulation=kTRUE;
    }
    else
    {
	cerr<<"HShowerTaskSet:setRealOrSim() unknown argument :use real or simulation" << endl;
	exit(1);
    }
}

void HShowerTaskSet::setAnalysisLevel(Option_t* optanalysislevel="") {
    // Sets maximum analysis levels leprecognition
    TString optanalLavel = optanalysislevel;

    optanalLavel.ToLower();
    if(optanalLavel.CompareTo("leprecognition")==0)
    {
	analysisLevel=1;
    }
    else
    {
	cerr<<"HShowerTaskSet::setAnalysisLevel(Option_t*): unknown argument use leprecognition" << endl;
	exit(1);
    }
}

void HShowerTaskSet::passArguments(TString s1) {
    // pass arguments to the make tasks function

    TString ssimulation = "simulation" ;
    TString sreal = "real" ;
    TString smagneton = "magneton" ;
    TString smagnetoff = "magnetoff" ;
    TString sraw = "raw" ;
    TString scal = "cal" ;
    TString shit = "hit" ;
    TString slowshowerefficiency = "nolowshowerefficiency" ;

    TString s2 = s1;

    s1.ToLower();
    s1.ReplaceAll(" ","");

    Ssiz_t len=s1.Length();

    if(len!=0) {

	TObjArray* myarguments = s1.Tokenize(",");
	TObjString *stemp;
	TString argument;

	ianalysisSimOrReal=0;
	ianalysisLevel=0;
	imagnet=0;

	TIterator* myiter=myarguments->MakeIterator();
	// go over list of arguments and compare the known keys

	while ((stemp=(TObjString*)myiter->Next())!= 0)
	{
	    argument=stemp->GetString();

	    Info("parseArguments()","option: %s", argument.Data() );

	    if( argument.CompareTo(slowshowerefficiency) == 0) isLowShowerEfficiency = kFALSE;

	    if(argument.CompareTo(sraw) == 0)
	    {
		ianalysisLevel++;
		if(ianalysisLevel>1)
		{
		    cerr<<"HShowerTaskSet: overlap with other argument for analysis level:RAW!" << endl;

		    cout << "input option string: " << s2  << endl;
		    exit(1);
		}

		analysisLevel=0;
	    }

	    else if(argument.CompareTo(scal) == 0)
	    {
		ianalysisLevel++;
		if(ianalysisLevel>1)
		{
		    cerr<<"HShowerTaskSet: overlap with other argument for analysis level:CAL!" << endl;

		    cout << "input option string: " << s2  << endl;
		    exit(1);
		}

		analysisLevel=1;
	    }

	    else if(argument.CompareTo(shit) == 0)
	    {
		ianalysisLevel++;
		if(ianalysisLevel>1)
		{
		    cerr<<"HShowerTaskSet: overlap with other argument for analysis level:HIT!" << endl;

		    cout << "input option string: " << s2  << endl;
		    exit(1);
		}

		analysisLevel=2;
	    }

	    else if(argument.CompareTo(ssimulation) == 0) {

		ianalysisSimOrReal++;
		if(ianalysisSimOrReal>1)
		{
		    cerr<<"HShowerTaskSet: ovrlap with other argument for analysis level:SIMULATION!"<< endl;
		    cout << "input option string: " << s2  << endl;
		    exit(1);
		}
		isSimulation=kTRUE;
	    }

	    else if(argument.CompareTo(sreal)==0)
	    {
		ianalysisSimOrReal++;
		if(ianalysisSimOrReal>1)
		{
		    cerr<<"HShowerTaskSet: overlap with other argument for analysis level:REAL!" << endl;
		    cout << "input option string: " << s2  << endl;
		    exit(1);
		}
		isSimulation=kFALSE;
	    }

	    else if(argument.CompareTo(smagnetoff)==0)
	    {
		imagnet++;
		if(imagnet>1)
		{
		    cerr<< "HShowerTaskSet: overlap with other argument for magnet status:MagnetOff!" << endl;
		    cout<<"INPUT OPTIONSTRING: "<<s2<<endl;
		    printOptions();
		    exit(1);
		}
		isCoilOff=kTRUE;
	    }

	    else if(argument.CompareTo(smagneton)==0)
	    {
		imagnet++;
		cout<<"INPUT OPTIONSTRING: "<<s2<<endl;
		if(imagnet>1)
		{
		    cerr<<"HShowerTaskSet: overlap with other argument for magnet status:MagnetOn!" << endl;
		    cout<<"INPUT OPTIONSTRING: "<<s2<<endl;
		    printOptions();
		    exit(1);
		}
		isCoilOff=kFALSE;
	    }
	}
	delete myiter;

	myarguments->Delete();
	delete myarguments ;
    }
}

void HShowerTaskSet::printOptions(void) {

    printf("*********************************************************** \n\n");

    printf("THESE ARE POSSIBLE ANALYSIS OPTIONS FOR SHOWER - TOFINO DETECTOR \n\n");
    printf("real - REAL DATA ANALYSIS / DEFAULT \n");
    printf("simulation - SIMULATION DATA ANALYSIS \n");
    printf("magnetoff - MAGNETIC FIELD SWITCH OFF \n");
    printf("magneton - MAGNETIC FIELD SWITCH ON / DEFAULT \n");
    printf("raw - ANALYSIS UP TO THE RAW LEVEL");
    printf("cal - ANALYSIS UP TO THE CAL LEVEL  \n");
    printf("hit - ANALYSIS UP TO THE HIT LEVEL  \n");

    printf("*********************************************************** \n");
}

ClassImp(HShowerTaskSet)

 hshowertaskset.cc:1
 hshowertaskset.cc:2
 hshowertaskset.cc:3
 hshowertaskset.cc:4
 hshowertaskset.cc:5
 hshowertaskset.cc:6
 hshowertaskset.cc:7
 hshowertaskset.cc:8
 hshowertaskset.cc:9
 hshowertaskset.cc:10
 hshowertaskset.cc:11
 hshowertaskset.cc:12
 hshowertaskset.cc:13
 hshowertaskset.cc:14
 hshowertaskset.cc:15
 hshowertaskset.cc:16
 hshowertaskset.cc:17
 hshowertaskset.cc:18
 hshowertaskset.cc:19
 hshowertaskset.cc:20
 hshowertaskset.cc:21
 hshowertaskset.cc:22
 hshowertaskset.cc:23
 hshowertaskset.cc:24
 hshowertaskset.cc:25
 hshowertaskset.cc:26
 hshowertaskset.cc:27
 hshowertaskset.cc:28
 hshowertaskset.cc:29
 hshowertaskset.cc:30
 hshowertaskset.cc:31
 hshowertaskset.cc:32
 hshowertaskset.cc:33
 hshowertaskset.cc:34
 hshowertaskset.cc:35
 hshowertaskset.cc:36
 hshowertaskset.cc:37
 hshowertaskset.cc:38
 hshowertaskset.cc:39
 hshowertaskset.cc:40
 hshowertaskset.cc:41
 hshowertaskset.cc:42
 hshowertaskset.cc:43
 hshowertaskset.cc:44
 hshowertaskset.cc:45
 hshowertaskset.cc:46
 hshowertaskset.cc:47
 hshowertaskset.cc:48
 hshowertaskset.cc:49
 hshowertaskset.cc:50
 hshowertaskset.cc:51
 hshowertaskset.cc:52
 hshowertaskset.cc:53
 hshowertaskset.cc:54
 hshowertaskset.cc:55
 hshowertaskset.cc:56
 hshowertaskset.cc:57
 hshowertaskset.cc:58
 hshowertaskset.cc:59
 hshowertaskset.cc:60
 hshowertaskset.cc:61
 hshowertaskset.cc:62
 hshowertaskset.cc:63
 hshowertaskset.cc:64
 hshowertaskset.cc:65
 hshowertaskset.cc:66
 hshowertaskset.cc:67
 hshowertaskset.cc:68
 hshowertaskset.cc:69
 hshowertaskset.cc:70
 hshowertaskset.cc:71
 hshowertaskset.cc:72
 hshowertaskset.cc:73
 hshowertaskset.cc:74
 hshowertaskset.cc:75
 hshowertaskset.cc:76
 hshowertaskset.cc:77
 hshowertaskset.cc:78
 hshowertaskset.cc:79
 hshowertaskset.cc:80
 hshowertaskset.cc:81
 hshowertaskset.cc:82
 hshowertaskset.cc:83
 hshowertaskset.cc:84
 hshowertaskset.cc:85
 hshowertaskset.cc:86
 hshowertaskset.cc:87
 hshowertaskset.cc:88
 hshowertaskset.cc:89
 hshowertaskset.cc:90
 hshowertaskset.cc:91
 hshowertaskset.cc:92
 hshowertaskset.cc:93
 hshowertaskset.cc:94
 hshowertaskset.cc:95
 hshowertaskset.cc:96
 hshowertaskset.cc:97
 hshowertaskset.cc:98
 hshowertaskset.cc:99
 hshowertaskset.cc:100
 hshowertaskset.cc:101
 hshowertaskset.cc:102
 hshowertaskset.cc:103
 hshowertaskset.cc:104
 hshowertaskset.cc:105
 hshowertaskset.cc:106
 hshowertaskset.cc:107
 hshowertaskset.cc:108
 hshowertaskset.cc:109
 hshowertaskset.cc:110
 hshowertaskset.cc:111
 hshowertaskset.cc:112
 hshowertaskset.cc:113
 hshowertaskset.cc:114
 hshowertaskset.cc:115
 hshowertaskset.cc:116
 hshowertaskset.cc:117
 hshowertaskset.cc:118
 hshowertaskset.cc:119
 hshowertaskset.cc:120
 hshowertaskset.cc:121
 hshowertaskset.cc:122
 hshowertaskset.cc:123
 hshowertaskset.cc:124
 hshowertaskset.cc:125
 hshowertaskset.cc:126
 hshowertaskset.cc:127
 hshowertaskset.cc:128
 hshowertaskset.cc:129
 hshowertaskset.cc:130
 hshowertaskset.cc:131
 hshowertaskset.cc:132
 hshowertaskset.cc:133
 hshowertaskset.cc:134
 hshowertaskset.cc:135
 hshowertaskset.cc:136
 hshowertaskset.cc:137
 hshowertaskset.cc:138
 hshowertaskset.cc:139
 hshowertaskset.cc:140
 hshowertaskset.cc:141
 hshowertaskset.cc:142
 hshowertaskset.cc:143
 hshowertaskset.cc:144
 hshowertaskset.cc:145
 hshowertaskset.cc:146
 hshowertaskset.cc:147
 hshowertaskset.cc:148
 hshowertaskset.cc:149
 hshowertaskset.cc:150
 hshowertaskset.cc:151
 hshowertaskset.cc:152
 hshowertaskset.cc:153
 hshowertaskset.cc:154
 hshowertaskset.cc:155
 hshowertaskset.cc:156
 hshowertaskset.cc:157
 hshowertaskset.cc:158
 hshowertaskset.cc:159
 hshowertaskset.cc:160
 hshowertaskset.cc:161
 hshowertaskset.cc:162
 hshowertaskset.cc:163
 hshowertaskset.cc:164
 hshowertaskset.cc:165
 hshowertaskset.cc:166
 hshowertaskset.cc:167
 hshowertaskset.cc:168
 hshowertaskset.cc:169
 hshowertaskset.cc:170
 hshowertaskset.cc:171
 hshowertaskset.cc:172
 hshowertaskset.cc:173
 hshowertaskset.cc:174
 hshowertaskset.cc:175
 hshowertaskset.cc:176
 hshowertaskset.cc:177
 hshowertaskset.cc:178
 hshowertaskset.cc:179
 hshowertaskset.cc:180
 hshowertaskset.cc:181
 hshowertaskset.cc:182
 hshowertaskset.cc:183
 hshowertaskset.cc:184
 hshowertaskset.cc:185
 hshowertaskset.cc:186
 hshowertaskset.cc:187
 hshowertaskset.cc:188
 hshowertaskset.cc:189
 hshowertaskset.cc:190
 hshowertaskset.cc:191
 hshowertaskset.cc:192
 hshowertaskset.cc:193
 hshowertaskset.cc:194
 hshowertaskset.cc:195
 hshowertaskset.cc:196
 hshowertaskset.cc:197
 hshowertaskset.cc:198
 hshowertaskset.cc:199
 hshowertaskset.cc:200
 hshowertaskset.cc:201
 hshowertaskset.cc:202
 hshowertaskset.cc:203
 hshowertaskset.cc:204
 hshowertaskset.cc:205
 hshowertaskset.cc:206
 hshowertaskset.cc:207
 hshowertaskset.cc:208
 hshowertaskset.cc:209
 hshowertaskset.cc:210
 hshowertaskset.cc:211
 hshowertaskset.cc:212
 hshowertaskset.cc:213
 hshowertaskset.cc:214
 hshowertaskset.cc:215
 hshowertaskset.cc:216
 hshowertaskset.cc:217
 hshowertaskset.cc:218
 hshowertaskset.cc:219
 hshowertaskset.cc:220
 hshowertaskset.cc:221
 hshowertaskset.cc:222
 hshowertaskset.cc:223
 hshowertaskset.cc:224
 hshowertaskset.cc:225
 hshowertaskset.cc:226
 hshowertaskset.cc:227
 hshowertaskset.cc:228
 hshowertaskset.cc:229
 hshowertaskset.cc:230
 hshowertaskset.cc:231
 hshowertaskset.cc:232
 hshowertaskset.cc:233
 hshowertaskset.cc:234
 hshowertaskset.cc:235
 hshowertaskset.cc:236
 hshowertaskset.cc:237
 hshowertaskset.cc:238
 hshowertaskset.cc:239
 hshowertaskset.cc:240
 hshowertaskset.cc:241
 hshowertaskset.cc:242
 hshowertaskset.cc:243
 hshowertaskset.cc:244
 hshowertaskset.cc:245
 hshowertaskset.cc:246
 hshowertaskset.cc:247
 hshowertaskset.cc:248
 hshowertaskset.cc:249
 hshowertaskset.cc:250
 hshowertaskset.cc:251
 hshowertaskset.cc:252
 hshowertaskset.cc:253
 hshowertaskset.cc:254
 hshowertaskset.cc:255
 hshowertaskset.cc:256
 hshowertaskset.cc:257
 hshowertaskset.cc:258
 hshowertaskset.cc:259
 hshowertaskset.cc:260
 hshowertaskset.cc:261
 hshowertaskset.cc:262
 hshowertaskset.cc:263
 hshowertaskset.cc:264
 hshowertaskset.cc:265
 hshowertaskset.cc:266
 hshowertaskset.cc:267
 hshowertaskset.cc:268
 hshowertaskset.cc:269
 hshowertaskset.cc:270
 hshowertaskset.cc:271
 hshowertaskset.cc:272
 hshowertaskset.cc:273
 hshowertaskset.cc:274
 hshowertaskset.cc:275
 hshowertaskset.cc:276
 hshowertaskset.cc:277
 hshowertaskset.cc:278
 hshowertaskset.cc:279
 hshowertaskset.cc:280
 hshowertaskset.cc:281
 hshowertaskset.cc:282
 hshowertaskset.cc:283
 hshowertaskset.cc:284
 hshowertaskset.cc:285
 hshowertaskset.cc:286
 hshowertaskset.cc:287
 hshowertaskset.cc:288
 hshowertaskset.cc:289
 hshowertaskset.cc:290
 hshowertaskset.cc:291
 hshowertaskset.cc:292
 hshowertaskset.cc:293
 hshowertaskset.cc:294
 hshowertaskset.cc:295
 hshowertaskset.cc:296
 hshowertaskset.cc:297
 hshowertaskset.cc:298
 hshowertaskset.cc:299
 hshowertaskset.cc:300
 hshowertaskset.cc:301
 hshowertaskset.cc:302
 hshowertaskset.cc:303
 hshowertaskset.cc:304
 hshowertaskset.cc:305
 hshowertaskset.cc:306
 hshowertaskset.cc:307
 hshowertaskset.cc:308
 hshowertaskset.cc:309
 hshowertaskset.cc:310
 hshowertaskset.cc:311
 hshowertaskset.cc:312
 hshowertaskset.cc:313
 hshowertaskset.cc:314
 hshowertaskset.cc:315
 hshowertaskset.cc:316
 hshowertaskset.cc:317
 hshowertaskset.cc:318
 hshowertaskset.cc:319
 hshowertaskset.cc:320
 hshowertaskset.cc:321
 hshowertaskset.cc:322