EmcGetGEA.cc

Go to the documentation of this file.
00001 #include "EmcPISAHit.h"
00002 #include "EmcPISAPara.h"
00003 //INCLUDECHECKER: Removed this line: #include "dEmcGeaHit.h"
00004 #include "dEmcGeaHitWrapper.h"
00005 #include "emcparWrapper.h"
00006 //INCLUDECHECKER: Removed this line: #include "EmcGetGEA.h"
00007 #include "root_ptrk.h"
00008 
00009 //INCLUDECHECKER: Removed this line: #include "phool.h"
00010 #include "PHIODataNode.h"
00011 //INCLUDECHECKER: Removed this line: #include "PHCompositeNode.h"
00012 //INCLUDECHECKER: Removed this line: #include "PHNodeIterator.h"
00013 
00014 #include <iostream>
00015 using namespace std;
00016 
00017 typedef PHIODataNode<PHTable> TableNode_t;
00018 
00019 long
00020 EmcGetGEA(PHCompositeNode* topNode)
00021 {
00022 
00023   int true_track;
00024   int nfile;
00025   int error;
00026   float ptot;
00027   float ptheta;
00028   float pphi;
00029   float r_vertex;
00030   float z_vertex;
00031   float theta_vertex;
00032   float phi_vertex;
00033   int itparent;
00034   int idparent;
00035   int idpart;
00036 
00037 
00038   static Int_t iEMC = 0;
00039   PHNodeIterator iter(topNode), *j;
00040   PHNodeIterator *jpar;
00041   PHCompositeNode* geaNode;
00042   PHCompositeNode* parNode;
00043   PHNode *n2;                   // EmcGetDCM also defined n1 pointer
00044   TableNode_t *d;
00045 
00046   // Find the GEA "directory" if it exists; otherwise exit on error
00047   n2 = iter.findFirst("PHCompositeNode", "GEA");
00048   if (!n2) {
00049     cerr << "\n EmcGetGEA <E> unable to find GEA node; program exiting " << endl;
00050     exit(1);
00051   }
00052   else {
00053     geaNode = static_cast<PHCompositeNode*>(n2);
00054   }
00055   
00056   if(iEMC == 0) {
00057     iEMC = 1;
00058 
00059     PHNode *n3;
00060     // Find the PAR "directory" if it exists; otherwise exit on error.
00061     n3 = iter.findFirst("PHCompositeNode", "PAR");
00062     if (!n3) {
00063       cerr << "\n EmcGetGEA <E> unable to find PAR node; program exiting " << endl;
00064       exit(1);
00065     }
00066     else {
00067       parNode = static_cast<PHCompositeNode*>(n3);
00068     }
00069     
00070     EmcPISAPara *parevent = EmcPISAPara::GetEmcParaEvt();
00071     Int_t emcParaRows = EmcPISAPara::GetEmcParaCount();    // should be 8 walls
00072 
00073     // Instantiate the PAR table for this subsystem, and attach it to
00074     // the PAR "directory" node.
00075     emcparWrapper* wpar;
00076     jpar = new PHNodeIterator(parNode);
00077 
00078     d = static_cast<TableNode_t*>(jpar->findFirst("PHIODataNode","emcpar"));
00079     if (!d) {
00080       cerr << "\n EmcGetGEA<E>: unable to find emcpar STAF Table; " ;
00081       cerr << " program is exiting at this point " << endl;
00082       exit(1);
00083     }
00084     else {
00085       wpar = static_cast<emcparWrapper*>(d->getData());
00086       if (!wpar) {
00087         cerr << "\n EmcGetGEA<E>: unable to find emcparWrapper pointer; " ;
00088         cerr << " program is exiting at this point " << endl;
00089         exit(1);
00090       }
00091       wpar->SetMaxRowCount(emcParaRows);
00092     }
00093 
00094     EMCPAR_ST* emcpar = wpar->TableData();
00095     Float_t upar[80];
00096     for(int i=0; i<emcParaRows; i++) {
00097 
00098       parevent[i].GetEmcPar(upar);
00099 
00100       emcpar[i].emc_walls        = upar[0]; /* number of walls from PHNX.PAR */
00101       emcpar[i].emc_opt          = upar[1]; /* EMCal option from PHNX.PAR */
00102       emcpar[i].iwall            = upar[2]; /* wall number (1-4) */
00103       emcpar[i].itype            = upar[3]; /* detector type (Sh-K,PbGl */
00104       emcpar[i].angle            = upar[4]; /* phi angle of wall center */
00105       emcpar[i].rpos             = upar[5]; /* radial position of wall center */
00106       emcpar[i].zc_start         = upar[6]; /* center of first cell, z coor. */
00107       emcpar[i].yc_start         = upar[7]; /* center of first cell, y coor. */
00108       emcpar[i].lsiz             = upar[8]; /* long. size of a cell */
00109       emcpar[i].tsiz             = upar[9]; /* transverse size of a cell */
00110       emcpar[i].no_modz          = upar[10]; /* No. of cells in z in a supermod. */
00111       emcpar[i].no_mody          = upar[11]; /* No. of cells in y in a supermod. */
00112       emcpar[i].no_smodz         = upar[12]; /* No. of supermods. in z / wall */
00113       emcpar[i].no_smody         = upar[13]; /* No. of supermods. in y / wall */
00114                                
00115       emcpar[i].scint_emc_med    = upar[17]; /* Shish-Kebab scint. medium */
00116                                
00117       emcpar[i].emc_debug        = upar[21]; /* */
00118       emcpar[i].gcuts[0]         = upar[22]; /* */
00119       emcpar[i].gcuts[1]         = upar[23]; /* */
00120       emcpar[i].gcuts[2]         = upar[24]; /* */
00121       emcpar[i].gcuts[3]         = upar[25]; /* */
00122       emcpar[i].gcuts[4]         = upar[26]; /* */
00123                                
00124       emcpar[i].emc_r_min_sc     = upar[29]; /* bitp lower limit, PbSc */
00125       emcpar[i].emc_r_max_sc     = upar[30]; /* bitp upper limit, PbSc */
00126       emcpar[i].emc_r_step       = upar[31]; /* bitp stepsize, PbSc */
00127       emcpar[i].emc_z_min        = upar[32]; /* bitp lower limit */
00128       emcpar[i].emc_z_max        = upar[33]; /* bitp upper limit */
00129       emcpar[i].emc_z_step       = upar[34]; /* bitp stepsize */
00130       emcpar[i].emc_x_min_sc     = upar[35]; /* bitp lower limit, PbSc */
00131       emcpar[i].emc_x_max_sc     = upar[36]; /* bitp upper limit, PbSc */
00132       emcpar[i].emc_x_step       = upar[37]; /* bitp stepsize, PbSc */
00133 
00134       emcpar[i].emc_dele_max_sc  = upar[39]; /* bitp dE upper limit, PbSc */
00135       emcpar[i].emc_dele_step_sc = upar[40]; /* bitp dE upper limit, PbSc */
00136       emcpar[i].emc_tof_min      = upar[41]; /* bitp lower limit */
00137       emcpar[i].emc_tof_max      = upar[42]; /* bitp upper limit */
00138       emcpar[i].emc_tof_step     = upar[43]; /* bitp stepsize */
00139 
00140       emcpar[i].emc_ind1_max_sc  = upar[49]; /* bitp tower ind. */
00141       emcpar[i].emc_ind2_max_sc  = upar[50]; /* bitp tower ind. */
00142       emcpar[i].emc_iwall_max    = upar[51]; /* */
00143       emcpar[i].emc_itype_max    = upar[52]; /* */
00144       emcpar[i].emc_i1_max       = upar[53]; /* */
00145 
00146       emcpar[i].emc_itrack_max   = upar[59]; /* */
00147       emcpar[i].emc_spart_max    = upar[60]; /* */
00148       emcpar[i].emc_ncycle_max   = upar[61]; /* */
00149 
00150       emcpar[i].emc_cutgam       = upar[64]; /* */
00151       emcpar[i].emc_cutele       = upar[65]; /* */
00152       emcpar[i].emc_cutneu       = upar[66]; /* */
00153       emcpar[i].emc_cuthad       = upar[67]; /* */
00154       emcpar[i].emc_cutmuo       = upar[68]; /* */
00155 
00156       emcpar[i].array[0]         = upar[14];
00157       emcpar[i].array[1]         = upar[15];
00158       emcpar[i].array[2]         = upar[16];
00159 
00160       emcpar[i].array[3]         = upar[18];
00161       emcpar[i].array[4]         = upar[19];
00162       emcpar[i].array[5]         = upar[20];
00163 
00164       emcpar[i].array[6]         = upar[27];
00165       emcpar[i].array[7]         = upar[28];
00166 
00167       emcpar[i].array[8]         = upar[38];
00168 
00169       emcpar[i].array[9]         = upar[44];
00170       emcpar[i].array[10]        = upar[45];
00171       emcpar[i].array[11]        = upar[46];
00172       emcpar[i].array[12]        = upar[47];
00173 
00174       emcpar[i].array[13]        = upar[48];
00175 
00176       emcpar[i].array[14]        = upar[54];
00177       emcpar[i].array[15]        = upar[55];
00178       emcpar[i].array[16]        = upar[56];
00179       emcpar[i].array[17]        = upar[57];
00180       emcpar[i].array[18]        = upar[58];
00181 
00182       emcpar[i].array[19]        = upar[62];
00183       emcpar[i].array[20]        = upar[63];
00184 
00185       emcpar[i].array[21]        = upar[69];
00186       emcpar[i].array[22]        = upar[70];
00187       emcpar[i].array[23]        = upar[71];
00188       emcpar[i].array[24]        = upar[72];
00189       emcpar[i].array[25]        = upar[73];
00190       emcpar[i].array[26]        = upar[74];
00191       emcpar[i].array[27]        = upar[75];
00192       emcpar[i].array[28]        = upar[76];
00193       emcpar[i].array[29]        = upar[77];
00194       emcpar[i].array[30]        = upar[78];
00195       emcpar[i].array[31]        = upar[79];
00196 
00197     }
00198     wpar->SetRowCount(emcParaRows);
00199 
00200     delete jpar;
00201   }
00202 
00203   EmcPISAHit *event = EmcPISAHit::GetEmcHitEvt();
00204   Int_t emcRows = EmcPISAHit::GetEmcCount();    // variable number of rows
00205 
00206   // Instantiate the GEA table for this subsystem, and attach it to
00207   // the GEA "directory" node.
00208   dEmcGeaHitWrapper* w;
00209   j = new PHNodeIterator(geaNode);
00210   d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcGeaHit"));
00211   if (!d) {
00212     cerr << "\n EmcGetGEA<E>: unable to find dEmcGeaHit STAF Table; " ;
00213     cerr << " program is exiting at this point " << endl;
00214     exit(1);
00215   }
00216   else {
00217     w = static_cast<dEmcGeaHitWrapper*>(d->getData());
00218     if (!w) {
00219       cerr << "\n EmcGetGEA<E>: unable to find dEmcGeaHitWrapper pointer; " ;
00220       cerr << " program is exiting at this point " << endl;
00221       exit(1);
00222     }
00223     w->SetMaxRowCount(emcRows);
00224   }
00225   delete j;
00226 
00227   DEMCGEAHIT_ST* dEmcGeaHit = w->TableData();
00228 
00229   Int_t nPbGl = 0;
00230 
00231   for(int i=0; i<emcRows; i++) {
00232     dEmcGeaHit[i].id         = i;                      // serial ID number
00233     dEmcGeaHit[i].type       = event[i].GetItype();   
00234     dEmcGeaHit[i].sector     = event[i].GetWall() ; 
00235     if(dEmcGeaHit[i].type != 1 && dEmcGeaHit[i].type != 2) {
00236        cerr <<"\n Bad type " << dEmcGeaHit[i].type << " i = " << i <<"\n";
00237        exit(1);
00238     }
00239     if(dEmcGeaHit[i].sector < 7) {
00240       dEmcGeaHit[i].smodind    = event[i].GetIndex1();
00241       dEmcGeaHit[i].towerind   = event[i].GetIndex2();
00242     }
00243     if(dEmcGeaHit[i].sector > 6) {
00244       nPbGl++;
00245       dEmcGeaHit[i].smodind    = event[i].GetIndex1();
00246       dEmcGeaHit[i].towerind   = event[i].GetIndex2();
00247     }
00248     dEmcGeaHit[i].deltae     = event[i].GetDele();  
00249     dEmcGeaHit[i].xyz[0]     = event[i].GetPosx();
00250     dEmcGeaHit[i].xyz[1]     = event[i].GetPosy();
00251     dEmcGeaHit[i].xyz[2]     = event[i].GetPosz();
00252     dEmcGeaHit[i].tof        = event[i].GetTof();
00253     dEmcGeaHit[i].numed      = event[i].GetNumed();
00254     dEmcGeaHit[i].itrack     = event[i].GetNtrack();
00255     dEmcGeaHit[i].isubevt    = event[i].GetIsubevent();   
00256     dEmcGeaHit[i].nfile      = event[i].GetNfile();
00257 
00258     Int_t mctrack = event[i].GetMctrack();
00259     true_track = mctrack;
00260     dio_ptrkstack(&true_track, &nfile, &error, &ptot, &ptheta, &pphi,
00261                   &r_vertex, &z_vertex, &theta_vertex, &phi_vertex, 
00262                   &itparent, &idparent, &idpart);
00263     dEmcGeaHit[i].partid     = idpart;
00264     dEmcGeaHit[i].true_track = true_track;
00265   
00266 
00267   }  // loop over emcRows
00268 
00269   w->SetRowCount(emcRows);
00270 
00271  // cout << "\n Exiting EmcGetGEA: emcRows = " << emcRows << ", nPbGl = " << nPbGl << endl;
00272 
00273  return 0;
00274 }
00275