// ------------------------------------------------------------------------- // ----- CHIUnpack source file ----- // ----- Created 12/04/12 by P. Russotto ----- // ------------------------------------------------------------------------- #include "CHIUnpack.h" #include "FairLogger.h" #include "TClonesArray.h" #include #define UMA 931.5 #define ycm 0.448 using std::cout; using std::endl; CHIUnpack::CHIUnpack() :FairTask() { //init calibration } // ------------------------------------------------------------------------- CHIUnpack::CHIUnpack(const char* name, Int_t iVerbose) : FairTask(name, iVerbose), fChimera_evt(0), fIdr(new TCHIResult()), fCalib(0), fRootCHIEvent(0), fRootCHIEventCopy(0), fRootCHIGlobal(0), fRootCHIGlobalCopy(0), fCHITSCopy(0), fCHITS(0), ffEvtBufferClone(0) { } // ------------------------------------------------------------------------- CHIUnpack::~CHIUnpack() { } // ------------------------------------------------------------------------- InitStatus CHIUnpack::Init() { fLogger->Info(MESSAGE_ORIGIN," CHIUnpack::Init()------------------Start "); string dir = getenv("VMCWORKDIR"); string caldir = dir + "/calfiles/CHIMERA/"; string chipar = caldir + "gsieos.par"; string chiped = caldir + "asyeos.ped"; string chioffset = caldir + "r1428_v16112011.offset"; string chiecalib = caldir + "ecalib141111.txt"; string chiecalibrec = caldir + "dee.txt"; string chigrid = caldir + "grid_16032012.dat"; fChimera_evt = new TCHIEvent(chipar,2); fChimera_evt->ProcessParFile(); fChimera_evt->Get_Pedestal_Data(chiped.c_str()); fChimera_evt->Get_Offset_Data(chioffset.c_str()); fCalib= new TCHICsIGSIEnergy(chiecalib,chiecalibrec,caldir); //define fCalibration object fCalib->Init(); //init calibration fCsigrid = new TCHIGridCsI(chigrid); fCsigrid->ReadAsciiFile(); fCsigrid->Initialize(); fLogger->Info(MESSAGE_ORIGIN," CHIUnpack::Init()------------------now did fCsigrid->Initialize() "); fRootCHIEvent= new TRootCHIEvent(); fRootCHIGlobal=new TRootCHIGlobal(); fCHITS= new TRootTS(); FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) Fatal("Init", "No FairRootManager"); ioman->Register("CHIEVENT", "CHIMERA EVENT TREE", fRootCHIEvent, kFALSE); ioman->Register("CHIGLOBAL", "CHIMERA GLOABL TREE", fRootCHIGlobal, kFALSE); ioman->Register("CHITS", "CHIMERA TIMESTAMP", fCHITS, kFALSE); fRootCHIEventCopy = new TClonesArray("TRootCHIEvent"); fRootCHIGlobalCopy = new TClonesArray("TRootCHIGlobal"); fCHITSCopy = new TClonesArray("TRootTS"); fRootCHIEventCopy=(TClonesArray*)fRootCHIEvent; fRootCHIGlobalCopy=(TClonesArray*)fRootCHIGlobal; fCHITSCopy=(TClonesArray*)fCHITS; ioman->Register("CHITSCLONE", "CHIMERA TIMESTAMP CLONE", fCHITSCopy, kFALSE); ioman->Register("CHIEVENTCLONE", "CHIMERA EVENT TREE CLONE", fRootCHIEventCopy, kFALSE); ioman->Register("CHIGLOBALCLONE", "CHIMERA GLOBAL TREE CLONE", fRootCHIGlobalCopy, kFALSE); ffEvtBufferClone = (TClonesArray*) ioman->GetObject("EVTBUFFERCLONE"); ffEvtBuffer = (TEvtBuffer*)ffEvtBufferClone; if(!ffEvtBufferClone)cout << "CHIMERA EVT BUFFER NOT FOUND"<Info(MESSAGE_ORIGIN," CHIUnpack::Init()------------------End "); cout << " ...return to continue..."<< endl; getchar(); } // ------------------------------------------------------------------------- void CHIUnpack::SetParTask() { } // ------------------------------------------------------------------------- void CHIUnpack::Finish() { // fLogger->Info(MESSAGE_ORIGIN," Finish all events in file"); } // ------------------------------------------------------------------------- void CHIUnpack::Reset() { } // ------------------------------------------------------------------------- void CHIUnpack::Exec(Option_t* opt) { /* fLogger->Info(MESSAGE_ORIGIN," CHIUnpack::Exec(Option_t* opt) "); cout <<"CHIUnpack::Exec*****************BEGIN***************"<CHInrlw << endl; cout << ffEvtBuffer->CHInrlw << endl; cout << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"<CHInrlw) <Clear_fired_param(0); fCHITS->ClearTS(); int CHITSh,CHITSm,CHITSs; vector pchim; Int_t time, de, fastpg, fastgg, slowpg, slowgg, timecsi; Float_t x,y; int idcode; /* if(verbose)cout << "[CHIUnpack::Exec ] BUFFER 0 "<<(ffEvtBuffer->CHIBuffer[0] & 0x0000ffff)<< endl; if(verbose)cout << "[CHIUnpack::Exec ] BUFFER 1 "<<(ffEvtBuffer->CHIBuffer[1] & 0x0000ffff)<< endl; if(verbose)cout << "[CHIUnpack::Exec ] BUFFER 2 "<<(ffEvtBuffer->CHIBuffer[2] & 0x0000ffff)<< endl; if(verbose)cout << "[CHIUnpack::Exec ] BUFFER 3 "<<(ffEvtBuffer->CHIBuffer[3] & 0x0000ffff)<< endl; if(verbose)cout << "[CHIUnpack::Exec ] BUFFER 4 "<<(ffEvtBuffer->CHIBuffer[4] & 0x0000ffff)<< endl;*/ Int_t ftotfired=fChimera_evt->ProcessCurrentEventMBS(ffEvtBuffer->CHIBuffer); fChimera_evt->GetTiMeStamp(&CHITSs,&CHITSm,&CHITSh); fCHITS->TSS=CHITSs; fCHITS->TSM=CHITSm; fCHITS->TSH=CHITSh; /* cout << "CHIMERA TIMESTAMPS"<TSS << " " << fCHITS->TSM << " " << fCHITS->TSH << endl;*/ Int_t multTOF = fChimera_evt->GetTofMultiplicity(); fChimera_evt->GetFired(pchim); int ntel = pchim.size(); int num = 0; // cout << "[CHIUnpack::Exec ] num= "<tavecsi=-100; int ntcsi=0; for(int k=0; kGet_Data_Telescope(numtel, TOFSi,SI, LG,LG, &time, &de); fChimera_evt->Get_Data_Telescope(numtel, SLOW, FAST,LG,LG, &slowpg, &fastpg); fChimera_evt->Get_Data_Telescope(numtel, SLOW, FAST,HG,HG, &slowgg, &fastgg); fChimera_evt->Get_Data_Telescope(numtel, TOF30,NONE,LG,LG, &timecsi,&none); if(numtel>=144 && numtel<=495) { fCsigrid->Identify(numtel, slowpg, fastpg, fIdr); idcode=fIdr->Getcod(); if(idcode<10){ fRootCHIEvent->IdA[num] = fIdr->GetA(); fRootCHIEvent->Idcode[num] = fIdr->Getcod(); fRootCHIEvent->IdPID[num] = fIdr->GetPID(); fCalib->EvalEnergy(numtel,fastpg, slowpg,fIdr); fRootCHIEvent->IdE[num]= fCalib->GetDE(); fRootCHIEvent->IdA[num] = fIdr->GetA(); fRootCHIEvent->IdZ[num] = fIdr->GetZ(); fRootCHIEvent->Idcode[num] = fIdr->Getcod(); fRootCHIEvent->Idnumtel[num]= numtel; fRootCHIEvent->Idstopped[num]=fIdr->GetIfStopped(); fRootCHIEvent->fastpg[num]= fastpg; fRootCHIEvent->slowpg[num]=slowpg; num++; } } // fRootCHIEvent->Idmulti = num; if(timecsi && numtel >= 144 && numtel <= 495){ if(numtel==144)timecsi=0;if(numtel==154)timecsi=0;if(numtel==164)timecsi=0;if(numtel==174)timecsi=0; if(numtel==184)timecsi=0;if(numtel==194)timecsi=0;if(numtel==204)timecsi=0;if(numtel==214)timecsi=0; if(numtel==224)timecsi=0;if(numtel==234)timecsi=0;if(numtel==244)timecsi=0;if(numtel==254)timecsi=0; if(numtel==264)timecsi=0;if(numtel==274)timecsi=0;if(numtel==284)timecsi=0;if(numtel==294)timecsi=0; if(numtel==412)timecsi=0;if(numtel==460)timecsi=0;tsumcsi=tsumcsi+timecsi; if(timecsi!=0)ntcsi++; } } fRootCHIEvent->Idmulti = num; // cout << "[CHIUnpack::Exec ] num= "<tavecsi= tsumcsi/ntcsi; //19112012-> const double thetaring[9]={7.75,9.25,10.75,12.25,13.75,15.25,17.,19.,21.00}; const double thetamin[9]= {7.00,8.50,10.00,11.50,13.00,14.50,16.,18.,20.00}; const int telmin[9]= {144,184,224,264,304,352,400,448,496}; int multR[8],ZR[8]; double Qx,Qy,Q1x,Q1y,Q2x,Q2y; double phirp,dphi,phirp1,phirp2; for(int iring=0;iring<8;iring++){ multR[iring]=0; ZR[iring]=0; } Qx=-999;Qy=-999; Q1x=-999;Q1y=-999; Q2x=-999;Q2y=-999; phirp=-1000.; dphi=-1000.; int ww;double ycutforw,ycutback; double r; int Z,A,code,numtel,stopped; double energy,esua,gamma,beta,betaz,betat,yrap,betagamma; double betazrandom,betatrandom,yraprandom,thetarandom; double phidetg=-1000.,phidet=-1000.; double theta; int Ztot=-10; int Zforw=-10; int Zforw1=-10; double mulforw=-10; double mulforw1=-10; int Atot=-10; int mult=-10; int multH=-10; int multHe=-10; int multIMF=-10; int Zbound=-10; double Etrans12=-1000; double Etrans=-1000; double ET=-1000, EL=-1000; double ZT=-1000, ZL=-1000; double ZTcm=-1000, ZLcm=-1000; double Zgbeta2Lcm=-1000.,Zgbeta2Tcm=-1000.; double ThetaT=-1000, ThetaL=-1000; int jj=0; if(fRootCHIEvent->tavecsi>1900 || fRootCHIEvent->tavecsi==-100){ Ztot=0;Atot=0; mult=0;multH=0;multHe=0;Zbound=0;Etrans12=0;Etrans=0;multIMF=0;ET=0;EL=0; ZT=0;ZL=0; ZTcm=0;ZLcm=0; Zgbeta2Lcm=0.;Zgbeta2Tcm=0.; ThetaT=0;ThetaL=0; Zforw=0;Zforw1=0;mulforw=0;mulforw1=0; Qx=0;Qy=0; Q1x=0;Q1y=0; Q2x=0;Q2y=0; for(int j=0;j Idmulti;j++){ Z=fRootCHIEvent->IdZ[j]; A=fRootCHIEvent->IdA[j]; code=fRootCHIEvent->Idcode[j]; energy=fRootCHIEvent->IdE[j]; stopped=fRootCHIEvent->Idstopped[j]; numtel=fRootCHIEvent->Idnumtel[j]; if(A)esua=energy/A; if(!A)esua=-1; // if(Z>0.5 && esua>25 && esua<600 && code<=7){//attenzione <800 prima era <600 10052013 if(Z>0.5 && esua>25 && code<=7){//10052013 Ztot=Ztot+Z; Atot=Atot+A; mult++; if(Z==1)multH++; if(Z==2)multHe++; if(Z>2.5)multIMF++; if(Z>1.5)Zbound=Zbound+Z; gamma=energy/(A*UMA)+1; beta=sqrt((gamma*gamma-1)/(gamma*gamma)); betagamma=beta*gamma; for(int iring=0;iring<=7;iring++){ if((numtel >= telmin[iring]) && (numtel < telmin[iring+1])){ multR[iring]=multR[iring]+1; ZR[iring]=ZR[iring]+Z; //original phi=(numtel-telmin[iring])*6.283185307/(telmin[iring+1]-telmin[iring]); phidetg=((numtel-telmin[iring])*360./(telmin[iring+1]-telmin[iring]))+90.; phidet=phidetg*3.14159/180.; // printf ("nt=%d phidetg=%lf\n",numtel,phidetg); // getchar(); betaz=beta*cos(thetaring[iring]*3.14159/180); betat=beta*sin(thetaring[iring]*3.14159/180); theta=thetaring[iring]*3.14159/180; r = rr->Uniform(); thetarandom=thetamin[iring]+r*(thetamin[iring+1]-thetamin[iring]); betazrandom=beta*cos(thetarandom*3.14159/180); betatrandom=beta*sin(thetarandom*3.14159/180); } } yrap=0.5*log((1+betaz)/(1-betaz)); if(yrap>0.448){ Zforw =Zforw +Z; mulforw++; } if(yrap>0.548){ Zforw1=Zforw1+Z; mulforw1++; } if(Z<=2)Etrans12=Etrans12+energy*sin(theta)*sin(theta); Etrans=Etrans+energy*sin(theta)*sin(theta); ET=ET+energy*sin(theta)*sin(theta); EL=EL+energy*cos(theta)*cos(theta); ZT=ZT+Z*sin(theta)*sin(theta); ZL=ZL+Z*cos(theta)*cos(theta); ThetaT=ThetaT+sin(theta)*sin(theta); ThetaL=ThetaL+cos(theta)*cos(theta); ww=0; ycutforw=0.1;//ok ycutback=0.2;//ok if(yrap>(ycm+ycutforw) && yrap<1.048)ww= 1;//originale if(yrap<(ycm-ycutback) && yrap>0.248){ ww=-1;//commentata originalmente }// Qx=Qx+ww*Z*cos(phidet)*beta; Qy=Qy+ww*Z*sin(phidet)*beta; r = rr->Uniform(); if(jj%2){ // if(r>0.5){ Q1x=Q1x+ww*Z*cos(phidet)*beta; Q1y=Q1y+ww*Z*sin(phidet)*beta; }else{ Q2x=Q2x+ww*Z*cos(phidet)*beta; Q2y=Q2y+ww*Z*sin(phidet)*beta; } if(ww)jj++; }// endif is a good particle }// end of cycle over multiplicity // cout << jj <<" "<< mulforw1 << endl; if (jj>=4){ if(Qx)phirp=atan2(Qy,Qx)*180/3.14159; if(Q1x)phirp1=atan2(Q1y,Q1x)*180/3.14159; if(Q2x)phirp2=atan2(Q2y,Q2x)*180/3.14159; dphi=phirp1-phirp2; if(dphi>180)dphi=360-dphi; if(dphi<-180)dphi=360+dphi; if (dphi<0)dphi=-dphi; } // end at least 4 particles in rp } //endif tavecsi fRootCHIGlobal->multi=mult; for (int iring=0;iring<3;iring++){ fRootCHIGlobal->multR[iring]=multR[iring*2]+multR[iring*2+1]; fRootCHIGlobal->ZR[iring]=ZR[iring*2]+ZR[iring*2+1]; } fRootCHIGlobal->Qx=Qx; fRootCHIGlobal->Qy=Qy; fRootCHIGlobal->Q1x=Q1x; fRootCHIGlobal->Q1y=Q1y; fRootCHIGlobal->Q2x=Q2x; fRootCHIGlobal->Q2y=Q2y; fRootCHIGlobal->phirp=phirp; fRootCHIGlobal->dphi=dphi; fRootCHIGlobal->Ztot=Ztot; fRootCHIGlobal->Zforw=Zforw; fRootCHIGlobal->Zforw1=Zforw1; fRootCHIGlobal->mulforw=mulforw; fRootCHIGlobal->mulforw1=mulforw1; fRootCHIGlobal->Atot=Atot; fRootCHIGlobal->multH=multH; fRootCHIGlobal->multHe=multHe; fRootCHIGlobal->multIMF=multIMF; fRootCHIGlobal->Zbound=Zbound; fRootCHIGlobal->Etrans12=Etrans12; fRootCHIGlobal->Etrans=Etrans; fRootCHIGlobal->ET=ET; fRootCHIGlobal->EL=EL; fRootCHIGlobal->ZT=ZT; fRootCHIGlobal->ZL=ZL; fRootCHIGlobal->ThetaT=ThetaT; fRootCHIGlobal->ThetaL=ThetaL; fRootCHIGlobal->tavecsi=fRootCHIEvent->tavecsi; //19112012-< // fChimera_evt->Clear_fired_param(0); // cout <<"CHIUnpack::Exec*****************END***************"<