Channels rejected :

/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/t/mod

/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/test

   Channels are populated in different ADC & energy thresholds : 
/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/StRoot/StFmsHitMaker/StFmsHitMaker.cxx
SET-1
            h0->Fill(((d-8)*1000)+c);
            hh0->Fill(((d-8)*1000)+c,adc);
SET-2
            if(adc>10){
            h10->Fill(((d-8)*1000)+c);
            hh10->Fill(((d-8)*1000)+c,adc);
            }
SET-3
            if(adc>50){
            h50->Fill(((d-8)*1000)+c);
            hh50->Fill(((d-8)*1000)+c,adc);
            }
SET-4
            if(adc>100){
            h100->Fill(((d-8)*1000)+c);
            hh100->Fill(((d-8)*1000)+c,adc);
            }
SET-5
           he0->Fill(((d-8)*1000)+c);
            hhe0->Fill(((d-8)*1000)+c,e);
SET-6
           if(e>1){
            he1->Fill(((d-8)*1000)+c);
            hhe1->Fill(((d-8)*1000)+c,e);
            }
SET-7
           if(e>10){
            he10->Fill(((d-8)*1000)+c);
            hhe10->Fill(((d-8)*1000)+c,e);
            }
SET-8
            if(e>20){
            he20->Fill(((d-8)*1000)+c);
            hhe20->Fill(((d-8)*1000)+c,e);
            }

//////////////////////////// 
For each SET 4 top bincontent towers are being selected. A tower is being marked to be masked if belong in the 4*8 set. There are several common.
Generally the number is ,ess than 20.

Writes hot channels run by run  in txt directory with gif files in gif  :
/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/test/run.C

///////////////////////////
Writing in database : in couple with time dependent : 

/star/data01/pwg/mriganka/fms2015/jetData2011/old/led/test1/AKIO/writeFMSAll.C
If there is any hot channel,  time dep. correction is made  0.

///////  generating time dependent files //////////////

Bsic concept to inset channels for which correction is significnat : 
https://drupal.star.bnl.gov/STAR/blog/mriganka/fms-led-time

in starver SL14i from PSU locally  generated TimeDepCorr.root we are listing the channels to be corrected for each time slot : 
/star/data01/pwg/mriganka/fms2015/jetData2011/old/led/test1

 //////////////////////////// GETTING all LED Correction /////////////////////////////

  nr=34;
  nc=17;

  Float_t val = -10;
  Float_t Lval = -10;
  Int_t channel;
 
  Int_t lastChannel = 0;
  Int_t contSkip = 0;
  Int_t sliceMod[500] = {0};
  Int_t sliceEvent[500] = {0};
Int_t slotLast = 0;

  Int_t Chro  =33;
  Int_t Chco  =1;

  ///////////////////////////////////////////////

  Chco++;
 

  for(int k = 0; k<4; k++ ){
        det = k;
    for(int ro=0;ro<nr;ro++){
      for(int co=0;co<nc;co++){

 slotLast = 0;
  contSkip = 0;

    for(int i = 0; i<500; i++ ){
      SegNM = i;
     
      for(int j = 0; j<10000; j++ ){
        EvNum=j;
           
    //        if(det==0&&ro==Chro &&co==Chco)
          {
        if(mRdep->Legal(2,det+1,ro,co)){
          ctm = mMgr->Rdep->Cdep(det+1,ro,co);
          Float_t mfac = ctm->FixFactor(SegNM,EvNum,2);
          Float_t ledfac = mMgr->ledFactor[det][ro][co];

          val = ledfac*mfac;

          if(Lval!=val){
            sliceMod[i] = 1;
            sliceEvent[i] = i*10000+j;
            contSkip = 0;
            slotLast  = i;
            cout<<"slice event :"<<i*10000+j<<endl;   
      }else{
            contSkip++;

          }
          if(contSkip>99000) i = 499;     
          Lval = val;

        }

          }
      }
    }   

  if( slotLast > 2 )goto stop;

      }}}
  slotLast++;

  cout<<slotLast<<endl;

 stop:

  cout<<" =================================================================  "<<slotLast<<endl;
  /*
    stop:
    Chco++;
    Int_t slotLast = 0;

    for(int i = 0; i<500; i++ ){
    cout<<"slot :    "<<i<<endl;
    SegNM = i;

    for(int j = 0; j<10000; j++ ){
    EvNum=j;

    for(int k = 0; k<4; k++ ){
    det = k;
    for(int ro=0;ro<nr;ro++){
    for(int co=0;co<nc;co++){
    //      if(det==0&&ro==33 &&co==1)
    {

    //      if(((*padc)(ro,co))>1)

    if(mRdep->Legal(2,det+1,ro,co))
    {
    // ct = mRdep->Cdep(det+1,ro,co);
    //cout<<ro<<" RC  "<<co<<endl;
    ctm = mMgr->Rdep->Cdep(det+1,ro,co);
    //    Float_t ffac = ct->FixFactor(SegNM,EvNum,2);
    Float_t mfac = ctm->FixFactor(SegNM,EvNum,2);
    Float_t ledfac = mMgr->ledFactor[det][ro][co];
           
    // (*pEmat)(ro,co) = ((*pEmat)(ro,co))*mfac*ledfac;
    // cout<<(*pEmat)(ro,co)<<endl;

    if(k==0||k==1)   channel = fmsdb->getChannelNumber(det+8,34-ro,co+1);
    if(k==2||k==3)   channel = fmsdb->getChannelNumber(det+8,24-ro,co+1);

    val = ledfac*mfac;

    if(det==0&&Chro==33 &&Chco==3)
    {
    if(Lval!=val){
    sliceMod[i] = 1;
    sliceEvent[i] = i*10000+j;
    cout<<"---- "<<i<<"  "<<det+8<<"  "<<ro<<" " <<co<<"  "<<channel<<"  "<<i*10000+j<<"  "<<val<<endl;
    contSkip = 0;
    slotLast  = i;
    }else{
    contSkip++;
    }
    if(contSkip>90000) i = 499;
     
    Lval = val;
    }
    valid_ch[i][k][channel] = 1;
    factor[i][k][channel] = val;
    event[i][k][channel] = i*10000+j;     
    }

    }
    }
    }   

    }}}
    slotLast++;

    if( slotLast ==1 )goto stop;
  */

  for(int i = 0; i<slotLast; i++ ){
    cout<<"slot :    "<<i<<endl;
    SegNM = i;
    if(sliceMod[i] == 0 ) continue;
    for(int j = 0; j<10000; j++ ){
      EvNum=j;

      for(int k = 0; k<4; k++ ){
    det = k;
    for(int ro=0;ro<nr;ro++){
      for(int co=0;co<nc;co++){
        //      if(det==0&&ro==33 &&co==1)
        {

          //      if(((*padc)(ro,co))>1)

          if(mRdep->Legal(2,det+1,ro,co))
        {
          // ct = mRdep->Cdep(det+1,ro,co);
          //cout<<ro<<" RC  "<<co<<endl;
          ctm = mMgr->Rdep->Cdep(det+1,ro,co);
          //    Float_t ffac = ct->FixFactor(SegNM,EvNum,2);
          Float_t mfac = ctm->FixFactor(SegNM,EvNum,2);
          Float_t ledfac = mMgr->ledFactor[det][ro][co];
           
          // (*pEmat)(ro,co) = ((*pEmat)(ro,co))*mfac*ledfac;
          // cout<<(*pEmat)(ro,co)<<endl;

          if(k==0||k==1)   channel = fmsdb->getChannelNumber(det+8,34-ro,co+1);
          if(k==2||k==3)   channel = fmsdb->getChannelNumber(det+8,24-ro,co+1);

          val = ledfac*mfac;
          /*
            if(det==0&&Chro==33 &&Chco==3)
            {
            if(Lval!=val){
            sliceMod[i] = 1;
            sliceEvent[i] = i*10000+j;
            cout<<"---- "<<i<<"  "<<det+8<<"  "<<ro<<" " <<co<<"  "<<channel<<"  "<<i*10000+j<<"  "<<val<<endl;
            contSkip = 0;
            slotLast  = i;
            }else{
            contSkip++;
            }
            if(contSkip>90000) i = 499;
     
            Lval = val;
            }
          */
          if( sliceMod[i] == 1){
            //            sliceEvent[i] = i*10000+j;

            valid_ch[i][k][channel] = 1;
            factor[i][k][channel] = val;
            event[i][k][channel] = i*10000+j;
       
          }     
        }

        }
      }
    }   

      }}}
  //slotLast++;

  cout<<" last SLICE :  "<<slotLast<<endl;
  Float_t diff;
  //////////////////////////////////////////////////////
  for(int i = 0; i<slotLast; i++ ){
    if(sliceMod[i] == 0) continue;

    for(int k = 0; k<4; k++ ){
      for(int j = 0; j<1000; j++ ){

    if(valid_ch[i][k][j] == 0) continue; 
    for(int ii = 0; ii<slotLast; ii++ ){
      if(i==ii)continue;
      if(sliceMod[ii] == 0) continue;
      if(valid_ch[ii][k][j] == 0) continue; 

      diff =-999;
      if( factor[i][k][j] > 0)      diff = (factor[ii][k][j] - factor[i][k][j] )/factor[i][k][j];
      if(k==2||k==3)   hD[0]->Fill(diff);
      if(k==0||k==1)   hD[1]->Fill(diff);
    }
      }}}

  ////////////////    //////////////    ///////////
  Int_t entriesS[500] = {0};

  for(int i = 0; i<slotLast; i++ ){

    if(sliceMod[i] == 0) continue;
    cout<<"SLICE : "<<i<<endl;

    for(int k = 0; k<4; k++ ){

      for(int j = 0; j<1000; j++ ){

    if(valid_ch[i][k][j] == 0) continue; 
    cout<<i<<"  "<<j<<"  "<<k<<"  "<<factor[i][k][j]<<endl;

    int stat = 0;
    for(int ii = 0; ii<slotLast; ii++ ){
      if(sliceMod[ii] == 0) continue;
      if(valid_ch[ii][k][j] == 0) continue; 
      if(i==ii)continue;
      diff =-999;
      if( factor[i][k][j] > 0)      diff = (factor[ii][k][j] - factor[i][k][j] )/factor[i][k][j];
      if((k==2||k==3) && hD[0]->GetRMS()< TMath::Abs(diff)) stat=1;
      if((k==0||k==1) && hD[1]->GetRMS()<TMath::Abs(diff)) stat=1;    
    }

    if((k==2||k==3) )  hD[2]->Fill(factor[i][k][j]);
    if((k==0||k==1) )  hD[3]->Fill(factor[i][k][j]);
    if(stat==1){
     

     
     
      entriesS[i]++;
      if((k==2||k==3) )  hD[4]->Fill(factor[i][k][j]);
      if((k==0||k==1) )  hD[5]->Fill(factor[i][k][j]);

      if(i==0&&k==0&&j==1) continue; // writing all slot0 and all slots for det =0  ch =1
      if(i==0) continue;
      //if(i>0)

  valid_ch[i][k][j]=10;  // writing all first slot &&
    }
       
      }}}

  ///////////////////////////////////////////////////////////
  char fname[100];
  sprintf(fname,"f_%d.txt", mCurrentRunNumber);
  FILE *f = fopen(fname,"w");

  char fnamef[100];
  sprintf(fnamef,"ff_%d.txt", mCurrentRunNumber);
  FILE *ff = fopen(fnamef,"w");

  char fnameR[100];
  sprintf(fnameR,"f_%d.gif", mCurrentRunNumber);

  int indexn =0;
  int indexn1 =0;
  //  sliceEvent[slotLast] = 999000000;
  Int_t sliceEvent1[1000] = {0};
  Int_t timeSlot = 0;
    Int_t last =  999000001;
  for(int i = slotLast-1; i>-1; i-- ){   // making last evnet of the nest slot as event tag in the slot
    if(sliceMod[i] == 0) continue;
    sliceEvent1[i] = last;
    last = sliceEvent[i];
    timeSlot++;
  }

  Int_t nEnt = 0;

  //Int_t lineforSlot[500] = 0;
  //Int_t start = 0;
 

    //   start = 0;
  for(int k = 0; k<4; k++ ){
    for(int j = 0; j<1000; j++ ){
      valid_ch_ent[k][j] =  0;// valid_ch_ent[k][j]+1;
      for(int i = 0; i<slotLast; i++ ){

    if(sliceMod[i] == 0) continue;
   
    if(valid_ch[i][k][j] == 0) continue; 
    
    if(i==0) {
      nEnt++;
      valid_ch_ent[k][j] =  i;// valid_ch_ent[k][j]+1;  /// making last slot  999000
    }else{   
      if(valid_ch[i][k][j] != 10) continue;     
      if(valid_ch[i][k][j] != 10) continue;       
      nEnt++;
          valid_ch_ent[k][j] =  i;// valid_ch_ent[k][j]+1;  /// making last slot  999000
    }

      }}}

  fprintf(f,"%10d %6d  %6d\n", mCurrentRunNumber, nEnt, timeSlot);   

  for(int k = 0; k<4; k++ ){
    for(int j = 0; j<1000; j++ ){
      if(valid_ch_ent[k][j] != 0)  cout<<"  "<<valid_ch_ent[k][j]<<endl;
    }}

 unsigned short detectorId;   /* DetectorId */
    unsigned short ch;           /* ch */
    unsigned long  endEvent;     /* last event# for which this correction applys*/
    float corr;   

  //  if(slotLast == 1) sliceEvent1[0] = 999000000;
  for(int k = 0; k<4; k++ ){
    for(int j = 0; j<1000; j++ ){
      //      for(int i = 0; i<slotLast; i++ ){
      for(int i = 0; i<1; i++ ){
    if(sliceMod[i] == 0) continue;
    if(valid_ch[i][k][j] == 0) continue; 

    //valid_ch_ent[k][j] == 0

    if(factor[i][k][j]>-1 && factor[i][k][j]<10){ }else{factor[i][k][j] = 10.;}  // fixing higher limit
   

    detectorId = k;
    ch = j;
    endEvent = sliceEvent1[i];
    corr = factor[i][k][j];
    if(valid_ch_ent[k][j] == i) endEvent = 999000000;

    if(i==0) {
      //    fprintf(f," %hu %hu %lu  %f \n", detectorId, ch, endEvent, corr);
      fprintf(f," %hu %hu %lu  %f \n", detectorId, ch, 999000000, 1);
    //      fprintf(f," %4d %8d %8d  %f \n", k, j, sliceEvent1[i], factor[i][k][j]);
      cout<<indexn<<"  "<<k<<"  "<<j<<"  "<<i<<"  "<<sliceEvent1[i]<< "  "<<valid_ch_ent[k][j]<<"  "<<factor[i][k][j]<<endl;   

    }else{   
     
      if(valid_ch[i][k][j] != 10) continue;   
    fprintf(f," %hu %hu %lu  %f \n", detectorId, ch, endEvent, corr);   
      //cout<<indexn<<"  "<<k<<"  "<<j<<"  "<<i<<"  "<<sliceEvent1[i]<< "  "<<factor[i][k][j]<<endl;   
      cout<<indexn<<"  "<<k<<"  "<<j<<"  "<<i<<"  "<<sliceEvent1[i]<< "  "<<valid_ch_ent[k][j]<<"  "<<factor[i][k][j]<<endl;   
      //      fprintf(f," %4d %8d %8d  %f \n", k, j, sliceEvent1[i], factor[i][k][j]);
     
    }
   
    indexn++;         
      }}}

  fprintf(f," %4d %8d %8d  %f \n",  0, 0, 0, 0.0);   

  fclose(f);