示例#1
0
文件: lsh_dfe.cpp 项目: Terranlee/LSH
 void LSH_DFE::generate_input_data(size_t features_num, size_t elements_num){
     srand(unsigned(time(NULL)));
     in_d = InputData(elements_num, features_num);
     for(size_t i=0; i<elements_num; i++)
         for(size_t j=0; j<features_num; j++)
             in_d(i, j) = float(rand()) / float(RAND_MAX) * formalize_max;
 }
示例#2
0
/***********************************************************************
		module		:	[WIFI]
		function		:	[设置连接服务器SSID]
  		return		:	[无]
		comment	:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date			:	[11/08/24]
 		author		:	[chen-zhengkai]
************************************************************************/
void setServerSSID()
{
	char pUserName[20] = {0};
	char retStr[20] = {0};
	char ret = -2;	//设置失败
	//strcpy(dspBuf, "端口设置成功");

	if (eeprom_read(pUserName, 16, EEPROM_OFFSET_SERVERSSID)) {
		ret = -1;
	}
	if (ret != -1) {
		 InputData((char*)"SSID", pUserName, 1);
		if (pUserName[0] != 0) {	//判断字符串不为空
			if (eeprom_write(pUserName, 16, EEPROM_OFFSET_SERVERSSID)) {
				ret = -2;	//设置失败
			}
			else {
				ret = 0;	//设置成功
			}
		}
	}
	 if (!ret) {
		strcpy(retStr, "设置成功");
	}
	else if (ret == -1) {
		strcpy(retStr, "EEPROM访问失败");
	}
	else if (ret == -2) {
		strcpy(retStr, "设置失败");
	}
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 );
}
示例#3
0
/***********************************************************************
		module		:	[WIFI]
		function		:	[设置连接服务器密码]
  		return		:	[无]
		comment	:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date			:	[11/08/24]
 		author		:	[chen-zhengkai]
************************************************************************/
void setPassword()
{
	char password[20] = {0};
	char retStr[20] = {0};
	char ret = -2;	//设置失败
	
	if (eeprom_read(password, 16, EEPROM_OFFSET_SEVPASSWORD)) {
		ret = -1;
	}
	if (ret != -1) {
		 InputData((char*)"密码", password, 1);
		if (password[0] != 0) {	//判断字符串不为空
			if (eeprom_write(password, 16, EEPROM_OFFSET_SEVPASSWORD)) {
				ret = -2;	//设置失败
			}
			else {
				ret = 0;	//设置成功
			}
		}
	}
	 if (!ret) {
		strcpy(retStr, "设置成功");
	}
	else if (ret == -1) {
		strcpy(retStr, "EEPROM访问失败");
	}
	else if (ret == -2) {
		strcpy(retStr, "设置失败");
	}
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 );
}
Boolean CH264StreamDecodeSink::DecodeData()
{
	//char kkkk[ 4096 ] = {0};
	//memcpy( kkkk, m_pBuffer, m_nDataLen );
	//memset( kkkk, 0, m_nDataLen );

// 	static CFile file;
// 	file.Open( _T( "" ), CFile::modeCreate | CFile::modeReadWrite );
// 	file.Write( m_pData, m_nDataLen );

	if ( m_pDecoder )
	{
		CBaseCodec::TStreamPacket tPkt;
		tPkt.data = m_pBuffer;
		tPkt.datalen = m_nDataLen;
		tPkt.timeStamp = m_timeStamp;
		m_pDecoder->InputStreamSync( tPkt );
	}

#ifdef USE_FFMPEG
	if( InvalidDecoder == m_decoderId )
	{
		return FALSE;
	}

	InputData( m_decoderId, m_pBuffer, m_nDataLen );
#endif

	memset( m_pData, 0, m_nDataLen );



	return true;
}
示例#5
0
/***********************************************************************
		module		:	[WIFI]
		function		:	[设置连接服务器端口]
  		return		:	[无]
		comment	:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date			:	[11/08/24]
 		author		:	[chen-zhengkai]
************************************************************************/
void setServerPort()
{
	char serverPort[10] = {0};
	char retStr[20] = {0};
	char ret = -2;	//设置失败
	//strcpy(dspBuf, "端口设置成功");

	if (eeprom_read(serverPort, 8, EEPROM_OFFSET_SERVERPORT)) {
		ret = -1;
	}
	if (ret != -1) {
		 InputData((char*)"服务器端口", serverPort, 0);
		if (serverPort[0] != 0) {	//判断字符串不为空
			if (eeprom_write(serverPort, 8, EEPROM_OFFSET_SERVERPORT)) {
				ret = -2;	//设置失败
			}
			else {
				ret = 0;	//设置成功
			}
		}
	}
	 if (!ret) {
		strcpy(retStr, "设置成功");
	}
	else if (ret == -1) {
		strcpy(retStr, "EEPROM访问失败");
	}
	else if (ret == -2) {
		strcpy(retStr, "设置失败");
	}
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 );
}
示例#6
0
/*
* In a script we don't really want the user to see a prompt, so we
* (ab)use the SetInput() function to allow the caller to supply the
* answer before the question is asked.
*/
void
ClientUserLua::Prompt( const StrPtr &msg, StrBuf &rsp, int noEcho, Error *e )
{
	if ( P4LUADEBUG_CALLS )
		fprintf( stderr, "[P4] Prompt(): %s\n", msg.Text() );

	InputData( &rsp, e );
}
示例#7
0
Simulation::Simulation(util::Checksum ck)
: simPeriodEnd(0), totalSimDuration(0), phase(STARTING_PHASE), _population(NULL), workUnitIdentifier(0), cksum(ck)
{
    Global::simulationTime = 0;
    Global::timeStep = numeric_limits<int>::min();
    
    // Initialize input variables and allocate memory.
    // We try to make initialization hierarchical (i.e. most classes initialise
    // through Population::init).
    util::random::seed (InputData().getModel().getParameters().getIseed());
    util::ModelOptions::init ();
    Surveys.init();
    Population::init();
    _population = new Population();
    
    workUnitIdentifier = InputData().getWuID();
}
示例#8
0
int main()
 {
	int data[MaxN];
	int scale;
	InputData(data,&scale);
	QSort(data,0,scale-1);
	OutputData(data,scale);
	return 0;
}
示例#9
0
文件: UnfoldMe.C 项目: ktf/AliPhysics
TH1 *
UnfoldMe_TAG(Char_t *datatag, Char_t *mctag, Char_t *anatag, Int_t bin, Bool_t useMBcorr = kTRUE, Bool_t usecorrfit = kFALSE, Bool_t ismc = kFALSE, Float_t smooth = 0.001, Int_t iter = 50, Int_t regul = AliUnfolding::kPowerLaw, Float_t weight = 100., Bool_t bayesian = kTRUE, Int_t nloop = 1)
{

  if (ismc)
    return UnfoldMe(InputMC(datatag), InputMC(mctag), anatag, bin, useMBcorr, usecorrfit, ismc, smooth, iter, regul, weight, bayesian, nloop);
  else
    return UnfoldMe(InputData(datatag), InputMC(mctag), anatag, bin, useMBcorr, usecorrfit, ismc, smooth, iter, regul, weight, bayesian, nloop);
      
}
示例#10
0
/*
* Add Student Information on the tail
* @param LinkList *L
* @return Status
*/
Status AddStudent(LinkList L) {
	LinkList p;
	p = L;
	while(p->next != NULL) 
		p = p->next;

	p->next = InputData();
	p->next->next = NULL;
	return OK;
}
	StringSubsequenceKernel::StringSubsequenceKernel(
        const std::wstring &s,
        const std::wstring &t,
        double lambda)
	{
        std::vector<SubsequenceKernel::value_type> viS(s.begin(), s.end());
        std::vector<SubsequenceKernel::value_type> viT(t.begin(), t.end());

		InputData(viS, viT, lambda);
	}
示例#12
0
void CreatList_DuL(DuLinkList &L,int n,void (* InputData)(ElemType &)){
	//创建链表 向链表头之前插入
	L=NULL;//将数值初始化为空
	if(n<1)return;//当元素个数小于1时直接退出函数
	
	L=(DuLinkList)malloc(sizeof(DuLNode));
	L->prior=L;
	L->next=L;
	InputData(L->data);//输入初始数据

	DuLinkList p;
	for(int i=n-1;i>0;--i){
		p=(DuLinkList)malloc(sizeof(DuLNode));
		InputData(p->data);
		L->prior->next=p;
		p->prior=L->prior;
		p->next=L;
		L=p;
	}//for
}//CreatList
 /**
   * @brief      Main function
   * @return	 0
   */
int _tmain(int argc, _TCHAR* argv[])
{
	long *plInputVector;
	UC ucItemConut = 0;
	
	ucItemConut = InputData(plInputVector);

	PrintResults(plInputVector, ucItemConut);

	_getch();
	return 0;
}
int main(int argc, char **argv)
{
     char buff[256];
	 int sock, newsock, port;
	 pid_t  pid;
     socklen_t clen;
     struct sockaddr_in serv_addr, cli_addr;
    
	if (argc != 2) 
	 {                                                  /* Need 2 arguments: file name and port no.. */
         printf("Please provide a port number: \n");
         exit(1);
     }
     sock = socket(AF_INET, SOCK_STREAM, 0);             /*creates a new socket*/
     
	 if (sock < 0)
     {
      error("Could not open the socket..");
     }
	 
	 bzero((char *) &serv_addr, sizeof(serv_addr));
     port = atoi(argv[1]);                               /* Converts the port no. from character to integer */
     serv_addr.sin_family = AF_INET;
     serv_addr.sin_addr.s_addr = INADDR_ANY;
     serv_addr.sin_port = htons(port);
     
	 if (bind(sock, (struct sockaddr *) &serv_addr,           /*it binds the socket to an address*/
        sizeof(serv_addr)) < 0)
        error("Binding error");
     listen(sock,5);                                           /*can listen to a maximum of 5 connections*/
     clen = sizeof(cli_addr);
     newsock = accept(sock,(struct sockaddr *) &cli_addr, &clen);            
     
	 if (newsock < 0)
	 {
		error("Accepting error"); 
	 } 
     bzero(buff,256);
     do
	 {
		fl =1;
	    if (InputData(newsock)) break;                         /*The request from the client is sent here. It breaks if file not found*/
	 }
	 while((!strcmp(CS,"0")));                     /*0 represents connection status as keep alive. So it executes a persistent execution if its 0 */
	
	 close(newsock);
     close(sock);
     return 0;
}
示例#15
0
文件: C5.cpp 项目: vova98/Isengreem
int _tmain(int argc, _TCHAR* argv[])
{
	int count = 0;
	scanf_s("%d", &count);
	StudAndMark* arrayOfStud = InputData(count);
	for (int i = 0; i < count; i++)
	{
		for (int j = 0; j < arrayOfStud[i].surnlength; j++)
			printf("%c", arrayOfStud[i].surname[j]);
		printf(" %d", arrayOfStud[i].mark);
	}


	return 0;
}
示例#16
0
/***********************************************************************
		module		:	[WIFI]
		function	:	[设置IP]
  		return		:	[无]
		comment		:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date		:	[11/07/26]
 		author		:	[chen-zhengkai]
************************************************************************/
void setIP()
{
	char plIPAddr[16];
	char retStr[16] = {0};
	memset(plIPAddr,0x00,16);
	CWiFi_GetLocalAddress(plIPAddr);	
	InputData((char*)"本机IP",plIPAddr, 0);
	if (NaNo_OK == CWiFi_SetLocalAddress(plIPAddr)) {
		strcpy(retStr, "设置成功");
	}
	else {
		strcpy(retStr, "设置失败");
	}
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 ); 
}
示例#17
0
/***********************************************************************
		module		:	[WIFI]
		function	:	[设置子网掩码]
  		return		:	[无]
		comment		:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date		:	[11/07/26]
 		author		:	[chen-zhengkai]
************************************************************************/
void setNetMask()
{
	char netMask[16];
	char retStr[16] = {0};
	memset(netMask,0x00,16);
	CWiFi_GetLocalNetMask(netMask);	
	InputData((char*)"子网掩码",netMask, 0);
	if (NaNo_OK == CWiFi_SetLocalNetMask(netMask)) {
		strcpy(retStr, "设置成功");
	}
	else {
		strcpy(retStr, "设置失败");
	}
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 ); 
}
示例#18
0
/***********************************************************************
		module		:	[WIFI]
		function	:	[设置网关]
  		return		:	[无]
		comment		:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date		:	[11/07/26]
 		author		:	[chen-zhengkai]
************************************************************************/
void setGateway()
{
	char geteWay[16];
	char retStr[16] = {0};
	memset(geteWay,0x00,16);
	CWiFi_GetGatewayAddress(geteWay);	
	InputData((char*)"网关",geteWay, 0);
	if (NaNo_OK == CWiFi_SetGatewayAddress(geteWay)) {
		strcpy(retStr, "设置成功");
	}
	else {
		strcpy(retStr, "设置失败");
	}
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 ); 
}
示例#19
0
pDICT MakeDictionary()
{
	pDICT root =NULL;
	DATA temp1,temp2;
	char *str = "\0";
	temp1 = InputData();
	root = CreateWord(temp1);
	while (1)
	{
		InputString("New Word:",&temp2.word);
		if(strcmp(temp2.word, str)==0)
			break;
		InputString("Mean's:", &temp2.mean);
		AddWordTree(root,temp2);
	}
	return root;
}
示例#20
0
/*
* createlist to store student information
* @param LinkList *L
* @return Status
*/
Status CreateList(LinkList *L) {
	LinkList S,q;

	(*L) = (LinkList) malloc(sizeof(struct LNode));
	q = *L;
	
	while(1) {
		S = InputData();
		if(S == NULL) 
			return ERROR;
		q->next = S;
		q = S;
	}

	q->next = NULL;

	return OK;
}
示例#21
0
livre::Pipeline createPipeline( const uint32_t inputValue,
                                size_t nConvertFilter = 1 )
{
    livre::Pipeline pipeline;
    livre::PipeFilter pipeInput = pipeline.add< TestFilter >( "Producer" );
    livre::PipeFilter pipeOutput = pipeline.add< TestFilter >( "Consumer" );

    for( size_t i = 0; i < nConvertFilter; ++i )
    {
        std::stringstream name;
        name << "Converter" << i;
        livre::PipeFilter convertPipeFilter =
                pipeline.add< ConvertFilter >( name.str( ));
        pipeInput.connect( "TestOutputData", convertPipeFilter, "ConvertInputData" );
        convertPipeFilter.connect( "ConvertOutputData", pipeOutput, "TestInputData" );
    }

    pipeInput.getPromise( "TestInputData" ).set( InputData( inputValue ));
    return pipeline;
}
 /**
   * @brief      Main function
   * @return	 0
   */
int _tmain(int argc, _TCHAR* argv[])
{
	char *pcInputBuffer; //text
	UC *ucChar;			 //letter

	if(!InputData(pcInputBuffer, ucChar) )
	{
		printf("\nError has been occurred");
		_getch();
		return 0;
	}
	printf("text: \n%s\nHide words with letter: %c\n",
			pcInputBuffer, ucChar[0]);

	HideWords(pcInputBuffer, strlen(pcInputBuffer), ucChar[0]);
	printf("--------------result--------------------\n%s", pcInputBuffer);

	delete[] pcInputBuffer;
	delete[] ucChar;
	_getch();
	return 0;
}
示例#23
0
/***********************************************************************
		module		:	[WIFI]
		function	:	[设置连接服务器IP]
  		return		:	[无]
		comment		:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date		:	[11/07/26]
 		author		:	[chen-zhengkai]
************************************************************************/
void setServerIP()
{
	char retStr[20] = {0};
	char ret = -2;	//设置失败
	unsigned char serverIPAdd[25] = {0};	//服务器IP

	memset(serverIPAdd,0x00,16);

	if (eeprom_read(serverIPAdd, 16, EEPROM_OFFSET_SERVERIPADD)) {
		ret = -1;	//读取失败
	}
	if (ret != -1) {
		InputData((char*)"服务器IP",serverIPAdd, 0);
		if (serverIPAdd[0] != 0) {	//判断字符串不为空
			if (eeprom_write(serverIPAdd, strlen(serverIPAdd)+1, EEPROM_OFFSET_SERVERIPADD)) {
				ret = -2;	//设置失败
			}
			else {
				ret = 0;	//设置成功
			}
		}
	}

	if (!ret) {
		strcpy(retStr, "设置成功");
	}
	else if (ret == -1) {
		strcpy(retStr, "EEPROM访问失败");
	}
	else if (ret == -2) {
		strcpy(retStr, "设置失败");
	}	
	DispStr_CE(0,6,retStr,DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,8,"按任意键继续",DISP_CENTER);
	delay_and_wait_key( 3, EXIT_KEY_ALL, 0 );
}
int main(int argc, char **argv)
{
   int sock, newsock, length, n;
   struct sockaddr_in server;
   struct sockaddr_in from;
   char buf[1024];
    
	if (argc != 2) 
	 {                                                  /* Need 2 arguments: file name and port no.. */
         printf("Please provide a port number: \n");
         exit(1);
     }
     
	 
   sock=socket(AF_INET, SOCK_DGRAM, 0);
   if (sock < 0) error("Opening socket");
   length = sizeof(server);
   bzero(&server,length);
   server.sin_family=AF_INET;
   server.sin_addr.s_addr=INADDR_ANY;
   server.sin_port=htons(atoi(argv[1]));
	 
	 if (bind(sock,(struct sockaddr *)&server,length)<0) 
       error("binding");
   fromlen = sizeof(struct sockaddr_in);
   while (1) {
       
	   newsock = recvfrom(sock,buf,1024,0,(struct sockaddr *)&from,&fromlen);
       if (n < 0) error("recvfrom");
	   
	   InputData(newsock);
	    
   }
   return 0;
   
 }
示例#25
0
文件: e07.cpp 项目: cqiyi/kaoshi
void main( ) {
	int a[MAX],len=0;
	InputData(a,&len);
	BubbleSort( a,len );
}
示例#26
0
int main(int argc, icChar* argv[])
{
	int minargs = 4; // minimum number of arguments
  if(argc<minargs) {
		Usage();
    return -1;
  }

  int nNumProfiles, temp;
  temp = argc - minargs;

  if(temp%2 != 0) {
    printf("\nMissing arguments!\n");
		Usage();
    return -1;
  }

  nNumProfiles = temp/2;

  std::ifstream InputData(argv[1]);

  if(!InputData) {
    printf("\nFile [%s] cannot be opened.\n", argv[1]);
    return false;
  }

  icChar ColorSig[7], tempBuf[5000];
  InputData.getline(tempBuf, sizeof(tempBuf));

  int i;
  for (i = 0; (i<4 || tempBuf[i+1]!='\'') && i < 6; i++) {
    ColorSig[i] = tempBuf[i+1];
  }
  for (;i<7; i++)
    ColorSig[i] = '\0';


  icColorSpaceSignature SrcspaceSig = (icColorSpaceSignature)icGetSigVal(ColorSig);
  int nSamples = icGetSpaceSamples(SrcspaceSig);

  if(SrcspaceSig != icSigNamedData) {
    if(!nSamples) {
      printf("Source color space signature not recognized.\n");
      return -1;
    }
  }

  InputData.getline(tempBuf, sizeof(tempBuf));
  sscanf(tempBuf, "%s", tempBuf);

  icFloatColorEncoding srcEncoding, destEncoding;

  srcEncoding = CIccCmm::GetFloatColorEncoding(tempBuf);

  if(srcEncoding == icEncodeUnknown) {
    printf("Source color data encoding not recognized.\n");
    return false;
  }

  destEncoding = (icFloatColorEncoding)atoi(argv[2]);
	icXformInterp nInterp = (icXformInterp)atoi(argv[3]);

  int nIntent, nType;
  CIccNamedColorCmm namedCmm(SrcspaceSig, icSigUnknownData, !IsSpacePCS(SrcspaceSig));
  IccProfilePtrList pccList;

  int nCount;
  bool bUseMPE;
  icCmmEnvSigMap sigMap;

  for(i = 0, nCount=minargs; i<nNumProfiles; i++, nCount+=2) {
    if (!strnicmp(argv[nCount], "-ENV:", 5)) {  //check for -ENV: to allow for Cmm Environment variables to be defined for next transform
      icSignature sig = icGetSigVal(argv[nCount]+5);
      icFloatNumber val = (icFloatNumber)atof(argv[nCount+1]);
      
      sigMap[sig]=val;
    }
    else if (stricmp(argv[nCount], "-PCC")) {      //check for -PCC arg to allow for profile connection conditions to be defined
      bUseMPE = true;
      nIntent = atoi(argv[nCount+1]);
      nType = abs(nIntent) / 10;
      nIntent = nIntent % 10;
      CIccProfile *pPccProfile = NULL;

      CIccCreateXformHintManager Hint;

      switch(nType) {
        case 1:
          nType = 0;
          bUseMPE = false;
          break;
        case 4:
          nType = 0;
          Hint.AddHint(new CIccApplyBPCHint());
          break;
      }

      if (i+1<nNumProfiles && !stricmp(argv[nCount+2], "-PCC")) {
        pPccProfile = OpenIccProfile(argv[nCount+3]);
        if (!pPccProfile) {
          printf("Unable to open Profile Connections Conditions from '%s'\n", argv[nCount+3]);
          return -1;
        }
        //Keep track of pPccProfile for until after cmm.Begin is called
        pccList.push_back(pPccProfile);
      }

      if (sigMap.size()>0) {
        Hint.AddHint(new CIccCmmEnvVarHint(sigMap));
      }

      if (namedCmm.AddXform(argv[nCount], nIntent<0 ? icUnknownIntent : (icRenderingIntent)nIntent, nInterp, pPccProfile, (icXformLutType)nType, bUseMPE, &Hint)) {
        printf("Invalid Profile:  %s\n", argv[nCount]);
        return -1;
      }
      sigMap.clear();
    }
  }

  icStatusCMM stat;
  if((stat=namedCmm.Begin())) {
    printf("Error %d - Unable to begin profile application - Possibly invalid or incompatible profiles\n", stat);
    return -1;
  }

  //Now we can release the pccProfile nodes.
  IccProfilePtrList::iterator pcc;

  for (pcc=pccList.begin(); pcc!=pccList.end(); pcc++) {
    CIccProfile *pPccProfile = *pcc;
    delete pPccProfile;
  }
  pccList.clear();

  SrcspaceSig = namedCmm.GetSourceSpace();
  int nSrcSamples = icGetSpaceSamples(SrcspaceSig);

  icColorSpaceSignature DestspaceSig = namedCmm.GetDestSpace();
  int nDestSamples = icGetSpaceSamples(DestspaceSig);
  
  std::string OutPutData;
  char SrcNameBuf[256], DestNameBuf[256];
  CIccPixelBuf SrcPixel(nSrcSamples+16), DestPixel(nDestSamples+16), Pixel(icIntMax(nSrcSamples, nDestSamples)+16);

  sprintf(tempBuf,"%s\t; ", icGetColorSig(tempBuf, DestspaceSig, false));
  OutPutData += tempBuf;
  OutPutData += "Data Format\n";

  if(DestspaceSig==icSigNamedData)
    destEncoding = icEncodeValue;
  sprintf(tempBuf, "%s\t; ", CIccCmm::GetFloatColorEncoding(destEncoding));
  OutPutData += tempBuf;
  OutPutData += "Encoding\n\n";

  OutPutData += ";Source Data Format: ";
  sprintf(tempBuf,"%s\n", icGetColorSig(tempBuf, SrcspaceSig, false));
  OutPutData += tempBuf;

  if(SrcspaceSig==icSigNamedData)
    srcEncoding = icEncodeValue;
  OutPutData += ";Source Data Encoding: ";
  sprintf(tempBuf, "%s\n", CIccCmm::GetFloatColorEncoding(srcEncoding));
  OutPutData += tempBuf;

  OutPutData += ";Source data is after semicolon\n";
  
  OutPutData += "\n;Profiles applied\n";
  for(i = 0, nCount=minargs; i<nNumProfiles; i++, nCount+=2) {
    OutPutData += "; ";
    if (stricmp(argv[nCount], "-PCC") && strnicmp(argv[nCount], "-ENV:", 5)) {
      if (i+1<nNumProfiles && !stricmp(argv[nCount+2], "-PCC")) {
        sprintf(tempBuf, "%s -PCC %s\n", argv[nCount], argv[nCount+3]);
        OutPutData += tempBuf;
        nCount += 2;
        nNumProfiles--;
      }
      else {
        sprintf(tempBuf, "%s\n", argv[nCount]);
        OutPutData += tempBuf;
      }
    }
  }
  OutPutData += "\n";
  
  fwrite(OutPutData.c_str(), 1, OutPutData.length(), stdout);

  while(!InputData.eof()) {

    if(SrcspaceSig==icSigNamedData) {
      InputData.getline(tempBuf, sizeof(tempBuf));
      if(!ParseName(SrcNameBuf, tempBuf))
        continue;

      icChar *numptr = strstr(tempBuf, "\" }");
      if (numptr)
        numptr+=3;

      icFloatNumber tint;
      if (!ParseNextNumber(tint, &numptr))
        tint = 1.0;

      OutPutData.erase();

      switch(namedCmm.GetInterface()) {
        case icApplyNamed2Pixel:
          {

            if(namedCmm.Apply(DestPixel, SrcNameBuf, tint)) {
              printf("Profile application failed.\n");
              return -1;
            }

            if(CIccCmm::FromInternalEncoding(DestspaceSig, destEncoding, DestPixel, DestPixel, destEncoding!=icEncodeFloat)) {
              printf("Invalid final data encoding\n");
              return -1;
            }

            for(i = 0; i<nDestSamples; i++) {
              sprintf(tempBuf, "%9.4lf ", DestPixel[i]);
              OutPutData += tempBuf;
            }
            OutPutData += "\t; ";
            
            break;
          }
        case icApplyNamed2Named:
          {
            if(namedCmm.Apply(DestNameBuf, SrcNameBuf, tint)) {
              printf("Profile application failed.\n");
              return -1;
            }
            
            sprintf(tempBuf, "{ \"%s\" }\t; ", DestNameBuf);
            OutPutData += tempBuf;

            break;
          }
        case icApplyPixel2Pixel:
        case icApplyPixel2Named:
        default:
          printf("Incorrect interface.\n");
          return -1;
      }      

      if (tint==1.0)
        sprintf(tempBuf, "{ \"%s\" }\n", SrcNameBuf);
      else
        sprintf(tempBuf, "{ \"%s\" } %.4f\n", SrcNameBuf, tint);

      OutPutData += tempBuf;
    }
    else {
      InputData.getline(tempBuf, sizeof(tempBuf));
      if(!ParseNumbers(Pixel, tempBuf, nSamples))
        continue;

      OutPutData.erase();
      if(CIccCmm::ToInternalEncoding(SrcspaceSig, srcEncoding, SrcPixel, Pixel)) {
        printf("Invalid source data encoding\n");
        return -1;
      }

      switch(namedCmm.GetInterface()) {
        case icApplyPixel2Pixel:
          {
            if(namedCmm.Apply(DestPixel, SrcPixel)) {
              printf("Profile application failed.\n");
              return -1;
            }
            if(CIccCmm::FromInternalEncoding(DestspaceSig, destEncoding, DestPixel, DestPixel)) {
              printf("Invalid final data encoding\n");
              return -1;
            }

            for(i = 0; i<nDestSamples; i++) {
              sprintf(tempBuf, "%9.4lf ", DestPixel[i]);
              OutPutData += tempBuf;
            }
            OutPutData += "\t; ";
            break;
          }
        case icApplyPixel2Named:
          {
            if(namedCmm.Apply(DestNameBuf, SrcPixel)) {
              printf("Profile application failed.\n");
              return -1;
            }
            sprintf(tempBuf, "{ \"%s\" }\t; ", DestNameBuf);
            OutPutData += tempBuf;
            break;
          }
        case icApplyNamed2Pixel:
        case icApplyNamed2Named:
        default:
          printf("Incorrect interface.\n");
          return -1;
      }      


      for(i = 0; i<nSamples; i++) {
        sprintf(tempBuf, "%9.4lf ", Pixel[i]);
        OutPutData += tempBuf;
      }

      OutPutData += "\n";
    }

    fwrite(OutPutData.c_str(), 1, OutPutData.length(), stdout);
  }


  return 0;
}
示例#27
0
    /// Create a list of input workspace names
    std::vector<PlotPeakByLogValue::InputData> PlotPeakByLogValue::makeNames()const
    {
      std::vector<InputData> nameList;
      std::string inputList = getPropertyValue("Input");
      int default_wi = getProperty("WorkspaceIndex");
      int default_spec = getProperty("Spectrum");
      double start = 0;
      double end = 0;

      typedef Poco::StringTokenizer tokenizer;
      tokenizer names(inputList, ";", tokenizer::TOK_IGNORE_EMPTY | tokenizer::TOK_TRIM);
      for (tokenizer::Iterator it = names.begin(); it != names.end(); ++it)
      {
        tokenizer params(*it, ",", tokenizer::TOK_TRIM);
        std::string name = params[0];
        int wi = default_wi;
        int spec = default_spec;
        if (params.count() > 1)
        {
          std::string index = params[1]; // spectrum or workspace index with a prefix
          if (index.size() > 2 && index.substr(0,2) == "sp")
          {// spectrum number
            spec = boost::lexical_cast<int>(index.substr(2));
            wi = -1; // undefined yet
          }
          else if (index.size() > 1 && index[0] == 'i')
          {// workspace index
            wi = boost::lexical_cast<int>(index.substr(1));
            spec = -1; // undefined yet
          }
          else if (index.size() > 0 && index[0] == 'v')
          {
            if (index.size() > 1)
            {// there is some text after 'v'
              tokenizer range(index.substr(1), ":", tokenizer::TOK_IGNORE_EMPTY | tokenizer::TOK_TRIM);
              if (range.count() < 1)
              {
                wi = -2; // means use the whole range
              }
              else if (range.count() == 1)
              {
                start = boost::lexical_cast<double>(range[0]);
                end = start;
                wi = -1;
                spec = -1;
              }
              else if (range.count() > 1)
              {
                start = boost::lexical_cast<double>(range[0]);
                end = boost::lexical_cast<double>(range[1]);
                if (start > end) std::swap(start,end);
                wi = -1;
                spec = -1;
              }
            }
            else
            {
              wi = -2;
            }
          }
          else
          {// error
            //throw std::invalid_argument("Malformed spectrum identifier ("+index+"). "
            //  "It must be either \"sp\" followed by a number for a spectrum number or"
            //  "\"i\" followed by a number for a workspace index.");
            wi = default_wi;
          }
          
        }
        int period = (params.count() > 2)? boost::lexical_cast<int>(params[2]) : 1;
        if (API::AnalysisDataService::Instance().doesExist(name))
        {
          API::Workspace_sptr ws = API::AnalysisDataService::Instance().retrieve(name);
          API::WorkspaceGroup_sptr wsg = boost::dynamic_pointer_cast<API::WorkspaceGroup>(ws);
          if (wsg)
          {
            std::vector<std::string> wsNames = wsg->getNames();
            for(std::vector<std::string>::iterator i=wsNames.begin();i!=wsNames.end();++i)
            {
             nameList.push_back(InputData(*i,wi,-1,period,start,end));
            }
            continue;
          }
        }
        nameList.push_back(InputData(name,wi,spec,period,start,end));
      }
      return nameList;
    }
示例#28
0
//     const char*   cDataType      = "AOD",       // set the analysis type, AOD or ESD
//##################################################
AliAnalysisManager* EmcalJetCDF (
    const char*   cRunPeriod     = "LHC11d",    // set the run period
    const char*   cLocalFiles    = "data.txt",  // set the local list file
    const Int_t   arg_sel_chg    = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   arg_sel_full   = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   mgr_mode       = 0,         // local = 0, proof = 1, grid = 2, mixing = 3
    const Int_t   alien_mode     = 0,         // test = 0, offline = 1, submit = 2, merge = 3, full = 4
    const char*   cTaskName      = "CDFJets",   // sets name of task manager
    unsigned int  iNumFiles      = 100,         // numger of files to process from list file
    unsigned int  iNumEvents     = 999999999,   // number of events to be analyzed
    bool          bDoChargedJets = true,        // enable charge jets
    bool          bDoFullJets    = false        // enable full jets
) {
//Load needed libs
TString     ListLibs      = ""; // string list of loaded libs
TString     ListLibsExtra = ""; // string list of loaded extra libs
LoadLibs( ListLibs, ListLibsExtra );

AnalysisType  ManagerMode = static_cast<AnalysisType>(mgr_mode);
PluginType    PluginMode  = static_cast<PluginType>(alien_mode);

namespace CDF = PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetCDF_NS; // shortcut to task namespace
unsigned int       kGridFilesPerJob         = iNumFiles;      // Maximum number of files per job (gives size of AOD)
unsigned int       kTTL                     = 64800 ;         // Time To Live; 18h = 64800; 12h = 43200

bool bDoBackgroundSubtraction = true;
bool bDoEmbedding = false;

// Embeded Configuration options
// Embedding files list
const TString embeddedFilesList = "aodFilesEmbed.txt";
// If true, events that are not selected in the PbPb will not be used for embedding.
// This ensures that good embedded events are not wasted on bad PbPb events.
const bool internalEventSelection = true;
// Do jet matching
const bool useJetTagger = true;


TString sGridMode ("test");
if ( PluginMode == PluginType::offline ) { sGridMode = "offline"; }
if ( PluginMode == PluginType::submit )  { sGridMode = "submit"; }
if ( PluginMode == PluginType::merge )   { sGridMode = "merge"; }
if ( PluginMode == PluginType::full )    { sGridMode = "full"; }
const char* cGridMode = sGridMode.Data();

TString sAnalysisType ("local");
if ( ManagerMode == AnalysisType::proof )  { sAnalysisType = "proof"; }
if ( ManagerMode == AnalysisType::grid )   { sAnalysisType = "grid"; }
if ( ManagerMode == AnalysisType::mixing ) { sAnalysisType = "mix"; }
const char* cAnalysisType = sAnalysisType.Data();

cout << std::endl << ">>>>>>>> ManagerMode : " << ManagerMode << " ; String value : " << cAnalysisType << std::endl << ">>>>>>>> PluginMode : " << PluginMode << " ; String value : " << cGridMode << std::endl << std::endl;

//---------------------------------------------------------------------------------------------
TRegexp false_regex ("[f,F][a,A][l,L][s,S][e,E]");
TRegexp true_regex ("[t,T][r,R][u,U][e,E]");
TRegexp enable_regex ("[e,E][n,N][a,A][b,B][l,L][e,E]");
TRegexp disable_regex ("[d,D][i,I][s,S][a,A][b,B][l,L][e,E]");

bool  bDoSample = false;
TString ENV_doSAMPLE = gSystem->Getenv("CDF_doSAMPLE");
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("0") || ENV_doSAMPLE.Contains(false_regex) ) ) { bDoSample = kFALSE; }
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("1") || ENV_doSAMPLE.Contains(true_regex)  ) ) { bDoSample = kTRUE; }

bool  bDoCDF    = true;
TString ENV_doCDF = gSystem->Getenv("CDF_doCDF");
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("0") || ENV_doCDF.Contains(false_regex) ) ) { bDoCDF = kFALSE; }
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("1") || ENV_doCDF.Contains(true_regex)  ) ) { bDoCDF = kTRUE; }

// ######   DEBUG    ######
Int_t           debug              =  0 ; // kFatal = 0, kError, kWarning, kInfo, kDebug, kMaxType
UInt_t          mgr_debug          =  0 ; // AliAnalysisManager debug level
UInt_t          kUseSysInfo        =  0 ; // activate debugging

TString ENV_DEBUG = gSystem->Getenv("CDF_DEBUG");
if (!ENV_DEBUG.IsNull() && ENV_DEBUG.IsDigit() ) { debug = ENV_DEBUG.Atoi(); }

TString ENV_DEBUG_MGR = gSystem->Getenv("CDF_DEBUG_MGR");
if (!ENV_DEBUG_MGR.IsNull() && ENV_DEBUG_MGR.IsDigit() ) { mgr_debug = ENV_DEBUG_MGR.Atoi(); }

TString ENV_NSYSINFO = gSystem->Getenv("CDF_NSYSINFO");
if (!ENV_NSYSINFO.IsNull() && ENV_NSYSINFO.IsDigit() ) { kUseSysInfo = ENV_NSYSINFO.Atoi(); }

if ( debug == 0 ) { AliLog::SetGlobalLogLevel ( AliLog::kFatal   ); }
if ( debug == 1 ) { AliLog::SetGlobalLogLevel ( AliLog::kError   ); }
if ( debug == 2 ) { AliLog::SetGlobalLogLevel ( AliLog::kWarning ); }
if ( debug == 3 ) { AliLog::SetGlobalLogLevel ( AliLog::kInfo    ); }
if ( debug >= 4 ) { AliLog::SetGlobalLogLevel ( AliLog::kDebug   ); }

// Progress bar
Bool_t bUseProgBar = kFALSE; // N.B. !! if true will set fDebug to 0
TString ENV_USEPROGBAR = gSystem->Getenv("PROGRESSBAR");
if (!ENV_USEPROGBAR.IsNull() && ( ENV_USEPROGBAR.EqualTo("1") || ENV_USEPROGBAR.Contains(true_regex) ) )  { bUseProgBar = kTRUE; }

//##################################################
//        AliEN plugin variables
//##################################################
const char* curdir = gSystem->BaseName(gSystem->pwd());
TString     kJobTag (curdir);

TString execArgs (" -l -b -q -x");
TString exec =
//               "aliroot";
              "root.exe";

TString     kPluginExecutableCommand = exec + execArgs;

TString     kAliPhysicsVersion       = "vAN-20190304-1";

// == grid plugin files rules
TString     kGridExtraFiles          = ""; // extra files that will be added to the input list in the JDL
TString     kGridMergeExclude        = "AliAOD.root AliAOD.Jets.root"; // Files that should not be merged
TString     kGridOutputStorages      = "disk=2"; // Make replicas on the storages

// FILES USED IN MACRO
TString     kCommonOutputFileName    = "AnalysisResults.root";

//--------------------
//   PROOF SETTINGS
//--------------------
TString kAAF        = "";
Int_t   kProofReset = 0; (void)kProofReset;
Int_t   kWorkers    = 20; (void)kWorkers;
Int_t   kCores      = 8  ; (void)kCores;
// AliRoot mode among the list supported by the proof cluster.
// TString     kAlirootMode             = "ALIROOT";     // STEERBase,ESD,AOD,ANALYSIS,ANALYSISalice (default aliroot mode)

//############################################################
// const AliAnalysisTaskEmcal::EDataType_t kAod = AliAnalysisTaskEmcal::kAOD;
// const AliAnalysisTaskEmcal::EDataType_t kEsd = AliAnalysisTaskEmcal::kESD;

const AliJetContainer::EJetType_t    fulljet = AliJetContainer::kFullJet;
const AliJetContainer::EJetType_t     chgjet = AliJetContainer::kChargedJet;
const AliJetContainer::EJetAlgo_t     antikt = AliJetContainer::antikt_algorithm;
const AliJetContainer::EJetAlgo_t         kt = AliJetContainer::kt_algorithm;
const AliJetContainer::ERecoScheme_t  recomb = AliJetContainer::pt_scheme;

// kTPC, kTPCfid, kEMCAL, kEMCALfid, kDCAL, kDCALfid, kDCALonly, kDCALonlyfid, kPHOS, kPHOSfid, kUser
const AliEmcalJet::JetAcceptanceType acc_chgjets  = AliEmcalJet::kTPCfid;
const AliEmcalJet::JetAcceptanceType acc_fulljets = AliEmcalJet::kEMCALfid;
//############################################################

// data source name
TString kDataSource (cLocalFiles);

// label of dataset from InputData.C
TString kGridDataSet ("");
if ( ManagerMode == AnalysisType::grid ) { kGridDataSet = kDataSource;}

//############################################################
// SETUP OF TRIGGERS
const AliEmcalPhysicsSelection::EOfflineEmcalTypes mykEMCAL  = AliEmcalPhysicsSelection::kEmcalOk;
const AliVEvent::EOfflineTriggerTypes  mykEMC             = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE | AliVEvent::kEMCEGA);
const AliVEvent::EOfflineTriggerTypes  mykEMC_noGA        = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE);

const AliVEvent::EOfflineTriggerTypes  mykMB              = AliVEvent::kAnyINT;
const AliVEvent::EOfflineTriggerTypes  mykMB_central      = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_semicentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kSemiCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_mostcentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral | AliVEvent::kSemiCentral);

AliVEvent::EOfflineTriggerTypes kPhysSel   = mykMB; //AliVEvent::kAnyINT; // physics selection
// AliVEvent::EOfflineTriggerTypes kSel_tasks = mykMB;

AliVEvent::EOfflineTriggerTypes kSel_chg   = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_chg);
AliVEvent::EOfflineTriggerTypes kSel_full  = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_full);

//############################################################
// Analysis manager
  AliAnalysisManager* pMgr = new AliAnalysisManager(cTaskName);
  pMgr->SetDebugLevel(mgr_debug);
  if ( kUseSysInfo > 0 ) { pMgr->SetNSysInfo ( kUseSysInfo ); }

  // actual runName in the form of LHCXXX....
  TString sRunName;
  Bool_t kIsAOD = kTRUE;
  AliAnalysisTaskEmcal::EDataType_t iDataType = AliAnalysisTaskEmcal::kAOD; // assuming default is to process AOD
  TString file;
  AliAnalysisAlien* plugin = NULL;
  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL, const char* outdir, const char subworkdir, const char* extradirlvl);
    plugin = CreateAlienHandler(cGridMode, kJobTag.Data(), kGridFilesPerJob, kTTL);
    if ( !plugin ) { ::Error ( "runEMCalJetSampleTask.C - StartGridAnalysis", "plugin invalid" ); return NULL; }
    pMgr->SetGridHandler(plugin);

    // use this command to run the macro
    plugin->SetExecutableCommand(kPluginExecutableCommand.Data());

    // AliPhysics version.
    plugin->SetAliPhysicsVersion ( kAliPhysicsVersion.Data() ); // Here you can set the (Ali)PHYSICS version you want to use

    gROOT->LoadMacro("InputData.C");
    InputData(kGridDataSet);
    sRunName = CDF::GetPeriod( plugin->GetGridDataDir() );

    file = CDF::GetFileFromPath(plugin->GetDataPattern());
    if (file.Contains("AliESD")) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }

    plugin->SetMergeExcludes(kGridMergeExclude.Data());
    }

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    if ( kDataSource.IsNull() ) { Printf("You need to provide the list of local files!"); return NULL; }
    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }
    Printf("Setting local analysis for %d files from list %s, max events = %d", iNumFiles, kDataSource.Data(), iNumEvents);

    // get the path of first file
    file = pChain->GetFile()->GetEndpointUrl()->GetUrl();
    sRunName = CDF::GetPeriod(file.Data()); // get the run name : first token beggining with lhc
    if ( CDF::GetFileFromPath(file).Contains("AliESD") ) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }
    }

  TString sDataType ("AOD");
  if (!kIsAOD) { sDataType = "ESD"; }
  std::cout << ">>> Analysis data type : " << sDataType.Data() << std::endl;

  // name of de period (for MC is the name of "achored to" production)
  TString sRunPeriod (cRunPeriod);
  sRunPeriod.ToLower();

  bool isMC = false;
  isMC = CDF::PeriodIsMC(sRunName.Data());

  // EMCAL corrections task configuration file
  TString EMCALcfg ("CDF_CorrectionsConf.yaml");
  if (isMC) {EMCALcfg = "CDF_MC_CorrectionsConf.yaml";}

  if ( !kGridExtraFiles.IsNull() ) {kGridExtraFiles += " ";}
  kGridExtraFiles += EMCALcfg;

  AliAnalysisTaskEmcal::BeamType iBeamType = AliAnalysisTaskEmcal::kpp;
  Bool_t bIsRun2 = kFALSE;

  if (sRunPeriod.Length() == 6 && (sRunPeriod.BeginsWith("lhc15") || sRunPeriod.BeginsWith("lhc16") || sRunPeriod.BeginsWith("lhc17") || sRunPeriod.BeginsWith("lhc18") ) ) { bIsRun2 = kTRUE; }

  if (sRunPeriod == "lhc10h" || sRunPeriod == "lhc11h" || sRunPeriod == "lhc15o" || sRunPeriod == "lhc17n" )                            { iBeamType = AliAnalysisTaskEmcal::kAA; }
  if (sRunPeriod == "lhc12g" || sRunPeriod == "lhc13b" || sRunPeriod == "lhc13c" || sRunPeriod == "lhc13d" || sRunPeriod == "lhc13e" ||
      sRunPeriod == "lhc13f" || sRunPeriod == "lhc16q" || sRunPeriod == "lhc16r" || sRunPeriod == "lhc16s" || sRunPeriod == "lhc16t" )  { iBeamType = AliAnalysisTaskEmcal::kpA; }

  Double_t kGhostArea = 0.01;
  if (iBeamType != AliAnalysisTaskEmcal::kpp) { kGhostArea = 0.005; }

  AliTrackContainer::SetDefTrackCutsPeriod(sRunPeriod);
  Printf("Default track cut period set to: %s", AliTrackContainer::GetDefTrackCutsPeriod().Data());

  Bool_t bDoEmcalCorrections  = kFALSE;
  if (bDoFullJets) { bDoEmcalCorrections  = kTRUE; }

// ###   Containers and string definitions
  TString name_tracks   = "usedefault";
  TString name_clusters = "usedefault";
  TString name_cells    = "usedefault";
  // Set centrality estimator for centrality task
  TString cent_est_chg  = "V0M" ;
  TString cent_est_full = "V0M" ;

  TString mc_container ("");
  if (isMC) { mc_container = "mcparticles"; }

/*
  // General input object names
  TString tracksName             = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kTrack);
  TString clustersName           = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCluster);
  TString emcalCellsName         = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCaloCells);
  // Combined (PbPb + embedded det level)
  TString emcalCellsCombined = emcalCellsName + "Combined";
  TString clustersCombined = clustersName + "Combined";
*/

//##########################
//   TASKS DEFINITIONS   ###
//##########################
  AliAODInputHandler* pAODHandler = NULL;
  AliESDInputHandler* pESDHandler = NULL;
  if (kIsAOD)
    { pAODHandler = AliAnalysisTaskEmcal::AddAODHandler(); }
  else
    { pESDHandler = AliAnalysisTaskEmcal::AddESDHandler(); }

  // CDBconnect task
  AliTaskCDBconnect* taskCDB = AliTaskCDBconnect::AddTaskCDBconnect();
  taskCDB->SetFallBackToRaw(kTRUE); // Needed for the moment as not all grid sites do support cvmfs OCDB for the moment
  if (!taskCDB) { std::cout << "--------->>>>  taskCDB :: could not connect!!!! CHECK CVMFS" << std::endl; return NULL;}

  // Physics selection task
  AliPhysicsSelectionTask* pPhysSelTask = NULL;
  if (!kIsAOD) {
    // signature : (Bool_t mCAnalysisFlag = kFALSE, Bool_t applyPileupCuts = kFALSE, UInt_t deprecatedFlag2 = 0, Bool_t useSpecialOutput=kFALSE)
    pPhysSelTask = AliPhysicsSelectionTask::AddTaskPhysicsSelection();
    }

  // Centrality task
  // The Run 2 condition is too restrictive, but until the switch to MultSelection is complete, it is the best we can do
  AliCentralitySelectionTask* pCentralityTask = NULL;
  if ( !kIsAOD && (iBeamType != AliAnalysisTaskEmcal::kpp && bIsRun2) ) {
    //signature : (Bool_t fillHistos=kTRUE, Bool_t aod=kFALSE)
    pCentralityTask = AliCentralitySelectionTask::AddTaskCentrality(kFALSE, kIsAOD);
    pCentralityTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // AliMultSelection
  AliMultSelectionTask* pMultSelTask = NULL;
  if (bIsRun2) {
    // signature : ( Bool_t lCalibration = kFALSE, TString lExtraOptions = "", Int_t lNDebugEstimators = 1, const TString lMasterJobSessionFlag = "")
    pMultSelTask = AliMultSelectionTask::AddTaskMultSelection();
    pMultSelTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // Embedding task
  if (bDoEmbedding) {
    // Debug options
    //AliLog::SetClassDebugLevel("AliAnalysisTaskEmcalEmbeddingHelper", AliLog::kDebug+0);

    // Setup embedding task
    AliAnalysisTaskEmcalEmbeddingHelper * embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::AddTaskEmcalEmbeddingHelper();
    embeddingHelper->SelectCollisionCandidates(kPhysSel);
    // The pt hard bin should be set via the filenames in this file
    // If using a file pattern, it could be configured via embeddingHelper->SetPtHardBin(ptHardBin);
    embeddingHelper->SetFileListFilename(embeddedFilesList.Data());

    // Some example settings for LHC12a15e_fix (anchored to LHC11h)
    embeddingHelper->SetNPtHardBins(11);
    embeddingHelper->SetMCRejectOutliers();

    // Setup internal event selection and additional configuration options
    embeddingHelper->SetConfigurationPath("EmbeddingConfigurationExample.yaml");

    // Initialize the task to complete the setup.
    embeddingHelper->Initialize();
    }

  // EMCal corrections
  AliEmcalCorrectionTask* correctionTask = NULL;
  if (bDoEmcalCorrections) {
    // Configuration of the Correction Task is handled via a YAML file, which is setup below
    // signature : (TString suffix)
    correctionTask = AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask();
//  correctionTask = AliEmcalCorrectionTask::ConfigureEmcalCorrectionTaskOnLEGOTrain(suffix);
    correctionTask->SelectCollisionCandidates(kPhysSel);
    correctionTask->SetUseNewCentralityEstimation(bIsRun2);
    correctionTask->SetForceBeamType(static_cast<AliEmcalCorrectionTask::BeamType>(iBeamType));

    // Configure and initialize
    correctionTask->SetUserConfigurationFilename( EMCALcfg.Data() );
    //correctionTask->SetUserConfigurationFilename("alien:///alice/cern.ch/user/m/mfasel/EMCALCorrectionConfig/ConfigDataPWGJEhighClusterThresholds.yaml");
    correctionTask->Initialize(true);

    }

//     TObjArray correctionTasks;
//
//     // Create the Correction Tasks
//     // "data" corresponds to the PbPb level
//     // "embed" corresponds to the embedded detector level
//     // "combined" corresponds to the hybrid (PbPb + embedded detector) level
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("data"));
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("embed"));
//     // It is important that combined is last!
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("combined"));
//
//     // Loop over all of the correction tasks to configure them
//     AliEmcalCorrectionTask * tempCorrectionTask = 0;
//     TIter next(&correctionTasks);
//     while (( tempCorrectionTask = static_cast<AliEmcalCorrectionTask *>(next()))) {
//       tempCorrectionTask->SelectCollisionCandidates(kPhysSel);
//       // Configure centrality
//       tempCorrectionTask->SetNCentBins(5);
//       tempCorrectionTask->SetUseNewCentralityEstimation(bIsRun2);
//       tempCorrectionTask->SetUserConfigurationFilename("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/EMCalCorrectionTaskEmbeddingExample.yaml");
//
//       tempCorrectionTask->Initialize(true);
//       }

  // Background
  TString sRhoChName;
  TString sRhoFuName;
  AliAnalysisTaskRho* pRhoTask = NULL;
  if ( bDoBackgroundSubtraction && iBeamType != AliAnalysisTaskEmcal::kpp ) {
    sRhoChName = "Rho";
    sRhoFuName = "Rho_Scaled";

    AliEmcalJetTask* pKtChJetTask = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", kt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 0., kFALSE, kFALSE);
    pKtChJetTask->SelectCollisionCandidates(kPhysSel);

    //signature :
    // const char* nTracks = "usedefault", const char* nClusters = "usedefault", const char* nRho = "Rho", Double_t jetradius = 0.2, UInt_t acceptance = AliEmcalJet::kTPCfid,
    // AliJetContainer::EJetType_t jetType = AliJetContainer::kChargedJet, const Bool_t histo = kFALSE, AliJetContainer::ERecoScheme_t rscheme = AliJetContainer::pt_scheme, const char* suffix = ""
    pRhoTask = AliAnalysisTaskRho::AddTaskRhoNew(name_tracks.Data(), name_clusters.Data(), sRhoChName, 0.4);
    pRhoTask->SetExcludeLeadJets(2);
    pRhoTask->SelectCollisionCandidates(kPhysSel);
    pRhoTask->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);

    if (bDoFullJets) {
      TString sFuncPath = "alien:///alice/cern.ch/user/s/saiola/LHC11h_ScaleFactorFunctions.root";
      TString sFuncName = "LHC11h_HadCorr20_ClustersV2";
      pRhoTask->LoadRhoFunction(sFuncPath, sFuncName);
      }
    }

  // Find Charged jets
  AliEmcalJetTask* pChJet02Task = NULL;
  AliEmcalJetTask* pChJet04Task = NULL;
  AliEmcalJetTask* pChJet02Task_MC = NULL;
  AliEmcalJetTask* pChJet04Task_MC = NULL;
  if (bDoChargedJets) {
    pChJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet02Task->SelectCollisionCandidates(kSel_chg);

    pChJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet04Task->SelectCollisionCandidates(kSel_chg);

    if (isMC) {
      pChJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pChJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pChJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pChJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoChargedJets

  // Find Full jets
  AliEmcalJetTask* pFuJet02Task = NULL;
  AliEmcalJetTask* pFuJet04Task = NULL;
  AliEmcalJetTask* pFuJet02Task_MC = NULL;
  AliEmcalJetTask* pFuJet04Task_MC = NULL;
  if (bDoFullJets) {
    pFuJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet02Task->SelectCollisionCandidates(kSel_full);
    pFuJet02Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    pFuJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet04Task->SelectCollisionCandidates(kSel_full);
    pFuJet04Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (isMC) {
      pFuJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pFuJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pFuJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pFuJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
      if (bDoEmbedding) {
        pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pFuJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoFullJets

////////////////////////
//   ANALYSIS TASKS   //
////////////////////////

  // Sample task - charge jets
  AliAnalysisTaskEmcalJetSample* sampleTaskchg = NULL;
  if (bDoSample && bDoChargedJets) {
    sampleTaskchg = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), "", "", "SMPCHG");
    sampleTaskchg->SetHistoBins(600, 0, 300);
    sampleTaskchg->SelectCollisionCandidates(kSel_chg);
    sampleTaskchg->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskchg_partCont = sampleTaskchg->GetParticleContainer(0);
    sampleTaskchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { sampleTaskchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      sampleTaskchg->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskchg->SetNCentBins(5);
      }
    }

  // Sample task - full jets
  AliAnalysisTaskEmcalJetSample* sampleTaskfull = NULL;
  if (bDoSample && bDoFullJets) {
    sampleTaskfull = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), name_clusters.Data(), name_cells.Data(), "SMPFULL");
    sampleTaskfull->SetHistoBins(600, 0, 300);
    sampleTaskfull->SelectCollisionCandidates(kSel_full);
    sampleTaskfull->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskfull_partCont = sampleTaskfull->GetParticleContainer(0);
    sampleTaskfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* sampleTaskfull_clusCont = sampleTaskfull->GetClusterContainer(0);
    sampleTaskfull_clusCont->SetClusECut(0.);
    sampleTaskfull_clusCont->SetClusPtCut(0.);
    sampleTaskfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    sampleTaskfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    sampleTaskfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      sampleTaskfull_partCont->SetIsEmbedding(kTRUE);
      sampleTaskfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      sampleTaskfull->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskfull->SetNCentBins(5);
      }
    }


  //###   CDF task - charged jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg = NULL;
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg_MC = NULL;
  if (bDoCDF && bDoChargedJets) {
    anaTaskCDFchg = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), "", "", "", "CDFchg" );
    anaTaskCDFchg->SetHistoBins(600, 0, 300);
    anaTaskCDFchg->SelectCollisionCandidates(kSel_chg);
    anaTaskCDFchg->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFchg_partCont = anaTaskCDFchg->GetParticleContainer(0);
    anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { anaTaskCDFchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      anaTaskCDFchg->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFchg->SetNCentBins(5);
      anaTaskCDFchg->SetCentralityEstimator(cent_est_chg.Data());
      }

    //#################################################
    if (isMC){
      anaTaskCDFchg_MC = CDF::AddTaskEmcalJetCDF ( mc_container.Data(), "", "", "", "CDFchgMC" );
      anaTaskCDFchg_MC->SetHistoBins(600, 0, 300);
      anaTaskCDFchg_MC->SelectCollisionCandidates(kSel_chg);
      anaTaskCDFchg_MC->SetDebugLevel(debug);

      AliParticleContainer* anaTaskCDFchg_partCont_MC = anaTaskCDFchg_MC->GetMCParticleContainer(0);
      anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

      if (bDoEmbedding) { anaTaskCDFchg_partCont_MC->SetIsEmbedding(kTRUE); }

      if ( pMultSelTask ) {
        anaTaskCDFchg_MC->SetUseNewCentralityEstimation(bIsRun2);
        anaTaskCDFchg_MC->SetNCentBins(5);
        anaTaskCDFchg_MC->SetCentralityEstimator(cent_est_chg.Data());
        }
      }
    }

  //###   CDF task - full jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFfull = NULL;
  if (bDoCDF && bDoFullJets) {
    anaTaskCDFfull = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), name_clusters.Data(), name_cells.Data(), mc_container.Data(), "CDFfull" );
    anaTaskCDFfull->SetHistoBins(600, 0, 300);
    anaTaskCDFfull->SelectCollisionCandidates(kSel_full);
    anaTaskCDFfull->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFfull_partCont = anaTaskCDFfull->GetParticleContainer(0);
    anaTaskCDFfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* anaTaskCDFfull_clusCont = anaTaskCDFfull->GetClusterContainer(0);
    anaTaskCDFfull_clusCont->SetClusECut(0.);
    anaTaskCDFfull_clusCont->SetClusPtCut(0.);
    anaTaskCDFfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    anaTaskCDFfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    anaTaskCDFfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      anaTaskCDFfull_partCont->SetIsEmbedding(kTRUE);
      anaTaskCDFfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      anaTaskCDFfull->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFfull->SetNCentBins(5);
      anaTaskCDFfull->SetCentralityEstimator(cent_est_full.Data());
      }
    }

//########################
//   ANALYSIS TASKS - CONTAINERS SETUP
//########################

//   AliEmcalJetTask* pChJet02Task_MC = NULL;
//   AliEmcalJetTask* pChJet04Task_MC = NULL;

// add jet containers to CDF task for charged jets
  if (bDoChargedJets && bDoCDF) {
    AliJetContainer* jetcont_chg = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // CHG JETS 0.2
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      // CHG JETS 0.4
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

    if (isMC) {
      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
      }

    jetcont_chg = NULL;
    }

  // add jet containers to CDF task for full jets
  if (bDoFullJets && bDoCDF) {
    AliJetContainer* jetcont_full = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // FULL JETS 0.2
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      // FULL JETS 0.4
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    if (isMC) {
      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);

      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);
      }
    jetcont_full = NULL;
    }

  // add jet containers to sample task for charged jets
  if (bDoChargedJets && bDoSample) {
    AliJetContainer* jetCont02chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    AliJetContainer* jetCont04chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02chg_sample->SetRhoName(sRhoChName);
      jetCont02chg_sample->SetPercAreaCut(0.6);

      jetCont04chg_sample->SetRhoName(sRhoChName);
      jetCont04chg_sample->SetPercAreaCut(0.6);
      }
    }

  // add jet containers to sample task for full jets
  if (bDoFullJets && bDoSample) {
    AliJetContainer* jetCont02full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    AliJetContainer* jetCont04full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02full_sample->SetRhoName(sRhoFuName);
      jetCont02full_sample->SetPercAreaCut(0.6);

      jetCont04full_sample->SetRhoName(sRhoFuName);
      jetCont04full_sample->SetPercAreaCut(0.6);
      }
    }


  TObjArray* tasks_list = pMgr->GetTasks(); TIter task_iter (tasks_list); AliAnalysisTaskSE* task = NULL;
  while (( task = dynamic_cast<AliAnalysisTaskSE*>(task_iter.Next()) )) {
    if (task->InheritsFrom("AliAnalysisTaskEmcal")) {
      Printf("Setting beam type %d for task %s", iBeamType, static_cast<AliAnalysisTaskEmcal*>(task)->GetName());
      static_cast<AliAnalysisTaskEmcal*>(task)->SetForceBeamType(iBeamType);
      }
    }

  //   Let's start #########################################################################################################
  if ( !pMgr->InitAnalysis() ) { std::cout << ">>>>>>>>>>>>>> AliAnalysisManager Initialising FAILED!!! " << std::endl; return NULL; }
  std::cout << "##-->> Initialising Analysis :: Status :" << std::endl;
  pMgr->PrintStatus();
  pMgr->SetUseProgressBar(bUseProgBar, 100);

  // task profiling
  if ( kUseSysInfo > 0 ) {
    for ( int i = 0; i < pMgr->GetTopTasks()->GetEntries(); i++ ) { pMgr->ProfileTask (i); }
    }

  CDF::SaveManager("train.root");

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    // enable class level debugging for these classes
    if ( debug > 2 ) {
    //   pMgr->AddClassDebug("AliJetContainer", 100);
    //   pMgr->AddClassDebug("AliEmcalJetTask", 100);
      if (bDoCDF)    { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetCDF", 100); }
      if (bDoSample) { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetSample", 100); }
      }

    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }

    // start analysis
    Printf("Starting LOCAL Analysis...");
    pMgr->StartAnalysis( cAnalysisType, pChain, iNumEvents );
    }

  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // start analysis
    Printf("Starting GRID Analysis...");

    ListLibs += kGridExtraFiles;
    if ( ListLibs.Length() )       { plugin->SetAdditionalLibs     ( ListLibs.Data() ); }
    if ( ListLibsExtra.Length() )  { plugin->SetAdditionalRootLibs ( ListLibsExtra.Data() ); }

    if ( PluginMode == PluginType::test )
      { plugin->StartAnalysis(iNumEvents); }
    else {
      pMgr->SetDebugLevel(0);
      plugin->StartAnalysis();
      }
    }

cout << "END of EmcalJetCDF.C" << std::endl;
return pMgr;
}
void CPDF_StreamContentParser::EndImageDict()
{
    if (m_StringBuf.GetSize() != m_LastImageDict.GetSize() ||
            FXSYS_memcmp32(m_StringBuf.GetBuffer(), m_LastImageDict.GetBuffer(), m_StringBuf.GetSize())) {
        m_WordState = 0;
        StartDict();
        InputData(m_StringBuf.GetBuffer(), m_StringBuf.GetSize());
        Finish();
        m_bSameLastDict = FALSE;
        if (m_pLastImageDict && m_bReleaseLastDict) {
            m_pLastImageDict->Release();
            m_pLastImageDict = NULL;
        }
        if (!m_ObjectSize) {
            m_InlineImageState = 0;
            return;
        }
        m_pLastImageDict = (CPDF_Dictionary*)m_pObjectStack[--m_ObjectSize];
        m_bReleaseLastDict = !m_pObjectState[m_ObjectSize];
        m_pObjectState[m_ObjectSize] = FALSE;
        _PDF_ReplaceAbbr(m_pLastImageDict);
        m_LastImageDict.TakeOver(m_StringBuf);
        if (m_pLastImageDict->KeyExist(FX_BSTRC("ColorSpace"))) {
            CPDF_Object* pCSObj = m_pLastImageDict->GetElementValue(FX_BSTRC("ColorSpace"));
            if (pCSObj->GetType() == PDFOBJ_NAME) {
                CFX_ByteString name = pCSObj->GetString();
                if (name != FX_BSTRC("DeviceRGB") && name != FX_BSTRC("DeviceGray") && name != FX_BSTRC("DeviceCMYK")) {
                    pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name);
                    if (pCSObj) {
                        if (!pCSObj->GetObjNum()) {
                            pCSObj = pCSObj->Clone();
                        }
                        m_pLastImageDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj, m_pDocument);
                    }
                }
            }
        }
    } else {
        m_bSameLastDict = TRUE;
    }
    m_ImageSrcBuf.Clear();
    if (m_pLastCloneImageDict) {
        m_pLastCloneImageDict->Release();
    }
    m_pLastCloneImageDict = (CPDF_Dictionary*)m_pLastImageDict->Clone();
    if (m_pLastCloneImageDict->KeyExist(FX_BSTRC("Filter"))) {
        m_WordState = 10;
        m_InlineImageState = 0;
    } else {
        int width = m_pLastCloneImageDict->GetInteger(FX_BSTRC("Width"));
        int height = m_pLastCloneImageDict->GetInteger(FX_BSTRC("Height"));
        int OrigSize = 0;
        CPDF_Object* pCSObj = m_pLastCloneImageDict->GetElementValue(FX_BSTRC("ColorSpace"));
        if (pCSObj != NULL) {
            int bpc = m_pLastCloneImageDict->GetInteger(FX_BSTRC("BitsPerComponent"));
            int nComponents = 1;
            CPDF_ColorSpace* pCS = m_pDocument->LoadColorSpace(pCSObj);
            if (pCS == NULL) {
                nComponents = 3;
            } else {
                nComponents = pCS->CountComponents();
                m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
            }
            int pitch = (width * bpc * nComponents + 7) / 8;
            OrigSize = pitch * height;
        } else {
            OrigSize = ((width + 7) / 8) * height;
        }
        m_ImageSrcBuf.AppendBlock(NULL, OrigSize);
        m_WordState = 11;
        m_InlineImageState = 0;
    }
}