00001 #include "DefaultInteractiveActions.h"
00002
00003 extern ofstream fout;
00004
00005 void GeneralEventInfo::Run(vector<float>& options,AlphaBanks& EventInfo)
00006 {
00007 const float QQRADP=180./M_PI;
00008
00009 AlEvent myevent = EventInfo.Event();
00010 vector<float> output;
00011 output.push_back(1);
00012 output.push_back(myevent.number());
00013 SendMessage(Code(),output,"event");
00014 AlRun myrun = EventInfo.Run();
00015 output.clear();
00016 output.push_back(2);
00017 output.push_back(myrun.number());
00018 SendMessage(Code(),output,"run");
00019
00020 output.clear();
00021 output.push_back(3);
00022 output.push_back(myevent.Time().year);
00023 output.push_back(myevent.Time().month ? myevent.Time().month : 1);
00024 output.push_back(myevent.Time().day ? myevent.Time().day : 1);
00025 output.push_back(myevent.Time().hour);
00026 output.push_back(myevent.Time().min);
00027 output.push_back(myevent.Time().sec);
00028 SendMessage(Code(),output,"Time information");
00029
00030 output.clear();
00031 output.push_back(4);
00032 output.push_back(myevent.EdirClass());
00033 SendMessage(Code(),output,"EDIR class word");
00034
00035 AlephCollection<AlEflw *> alefp=EventInfo.EflwPV();
00036 QvecBase Psum = alefp.GetSum();
00037 output.clear();
00038 output.push_back(5);
00039 output.push_back(Psum.QM());
00040 output.push_back(Psum.QP());
00041 SendMessage(Code(),output,"summed quantities");
00042
00043 output.clear();
00044 output.push_back(6);
00045 if(alefp.size())
00046 {
00047 AlephCollection<AlJet> Jn = alefp.DurhamJet(-2,1,0);
00048 int jetr = Jn.size();
00049 float acopl = Jn.size() == 2 ? acos(min(max(cos(Jn[0].QPH()-Jn[1].QPH()),-1.),1.))*QQRADP : 180.;
00050 float acolin = Jn.size() == 2 ? acos(min(max(Jn[1].QCOSA(Jn[0]),(float)-1.),(float)1.))*QQRADP : 90. ;
00051 float thethrust = alefp.AThrust().getThrustValue();
00052 Hep3Vector thrustdir = alefp.AThrust().getThrustDirection();
00053 float sphericity = alefp.Sphericity();
00054 float planarity = alefp.Planarity();
00055 float aplanarity = alefp.Aplanarity();
00056 output.push_back(acopl);
00057 output.push_back(acolin);
00058 output.push_back(thethrust);
00059 output.push_back(thrustdir.x());
00060 output.push_back(thrustdir.y());
00061 output.push_back(thrustdir.z());
00062 output.push_back(aplanarity);
00063 output.push_back(planarity);
00064 output.push_back(sphericity);
00065 }
00066 else
00067 {
00068 output.push_back(0);
00069 output.push_back(0);
00070 output.push_back(0);
00071 output.push_back(0);
00072 output.push_back(0);
00073 output.push_back(0);
00074 output.push_back(0);
00075 output.push_back(0);
00076 output.push_back(0);
00077 }
00078 SendMessage(Code(),output,"topological quantities");
00079 }
00080
00081 void CollectTracks::Run(vector<float>& options,AlphaBanks& EventInfo)
00082 {
00083 AlephCollection<AlTrack *>::iterator Ich;
00084 AlephCollection<AlEflw *>::iterator Ief;
00085 vector<float> output;
00086 int request = int(options[0]);
00087 switch(request)
00088 {
00089 case 0:
00090 {
00091
00092 output.push_back(0);
00093 SendMessage(Code(),output,"empty list");
00094 break;
00095 }
00096 case 1:
00097 {
00098 AlephCollection<AlTrack *> altp = EventInfo.TrackPV();
00099
00100 if(options[3])
00101 {
00102 for (Ich=altp.begin(); Ich<altp.end(); Ich++)
00103 {
00104 int Ntpc = (*Ich)->NT();
00105 float costhch = (*Ich)->QCT();
00106 float d0 = (*Ich) -> QDB();
00107 float z0 = (*Ich) -> QZB();
00108 if ((Ntpc<4)||(costhch>0.95)||(d0>2.)||(z0>10.)||(costhch<-.95)||(d0<-2)||(z0<-10))
00109 altp.looperase(Ich);
00110 }
00111 }
00112
00113 int counter = 0;
00114 for (Ich=altp.begin(); Ich<altp.end(); Ich++)
00115 {
00116 if(((*Ich)->QE()<options[1])||(fabs((*Ich)->QCT())>options[2]))
00117 altp.looperase(Ich);
00118 else
00119 counter++;
00120 }
00121
00122 if (counter==0)
00123 {
00124 output.push_back(0);
00125 SendMessage(Code(),output,"empty list");
00126 }
00127 for (Ich=altp.begin(); Ich<altp.end(); Ich++)
00128 {
00129 output.clear();
00130 output.push_back(--counter);
00131 output.push_back((*Ich)->QE());
00132 output.push_back((*Ich)->QX());
00133 output.push_back((*Ich)->QY());
00134 output.push_back((*Ich)->QZ());
00135 output.push_back((*Ich)->QCH());
00136 SendMessage(Code(),output,"track");
00137 }
00138 break;
00139 }
00140 case 2:
00141 {
00142 AlephCollection<AlEflw *> alefp=EventInfo.EflwPV();
00143
00144 int counter = 0;
00145 for (Ief=alefp.begin(); Ief<alefp.end(); Ief++)
00146 {
00147 if(((*Ief)->QE()<options[1])||(fabs((*Ief)->QCT())>options[2]))
00148 alefp.looperase(Ief);
00149 else
00150 counter++;
00151 }
00152
00153 if (counter==0)
00154 {
00155 output.push_back(0);
00156 SendMessage(Code(),output,"empty list");
00157 }
00158 for (Ief=alefp.begin(); Ief<alefp.end(); Ief++)
00159 {
00160 output.clear();
00161 output.push_back(--counter);
00162 output.push_back((*Ief)->QE());
00163 output.push_back((*Ief)->QX());
00164 output.push_back((*Ief)->QY());
00165 output.push_back((*Ief)->QZ());
00166 output.push_back((*Ief)->QCH());
00167 SendMessage(Code(),output,"Energy Flow");
00168 }
00169 break;
00170 }
00171 default:
00172 {
00173
00174 }
00175 }
00176 }
00177
00178 void CollectLeptons::Run(vector<float>& options,AlphaBanks& EventInfo)
00179 {
00180 if(options[0]==0)
00181 {
00182 vector<float> output;
00183 output.push_back(0);
00184 SendMessage(Code(),output,"no lepton");
00185 return;
00186 }
00187 AlephCollection<AlMuon *> almup=EventInfo.MuonPV();
00188 AlephCollection<AlElec *> alelp=EventInfo.ElecPV();
00189 AlephCollection<AlEflw *> alefp=EventInfo.EflwPV();
00190 AlephCollection<AlTrack *> altp = EventInfo.TrackPV();
00191 AlephCollection<AlTrack *>::iterator Ich;
00192 AlephCollection<AlElec *>::iterator Iel;
00193 AlephCollection<AlMuon *>::iterator Imu;
00194 AlephCollection<AlTau *>::iterator Itau;
00195 AlephCardsReader *tcr = &(((AlephIoManager*)AlephIoManager::TheAlephIoManager())->theCardsReader());
00196 vector<float> output;
00197
00198 for (Ich=altp.begin(); Ich<altp.end(); Ich++)
00199 {
00200 int Ntpc = (*Ich)->NT();
00201 float costhch = (*Ich)->QCT();
00202 float d0 = (*Ich) -> QDB();
00203 float z0 = (*Ich) -> QZB();
00204 if ((Ntpc<4)||(costhch>0.95)||(d0>2.)||(z0>10.)||(costhch<-.95)||(d0<-2)||(z0<-10))
00205 (*Ich)->Lock();
00206 }
00207 int nl = 0;
00208 if((int(options[0]))&1)
00209 {
00210
00211 alelp.FilterEl(almup,tcr->ELIDcuts());
00212 nl+=alelp.size();
00213 }
00214 if((int(options[0]))&2)
00215 {
00216
00217 almup.FilterMu(tcr->MUIDcuts());
00218 nl+=almup.size();
00219 }
00220 AlephCollection<AlTau> JJ;
00221 AlephCollection<AlTau*> altaup;
00222 if((int(options[0]))&4)
00223 {
00224
00225 AlEvent myevent = EventInfo.Event();
00226 float QELEP = myevent.Energy();
00227 JJ = alefp.ATauJn(tcr->TAIDcuts(),QELEP);
00228 altaup = JJ.Pointers();
00229 altaup.FilterTau(tcr->TAIDcuts());
00230 nl+=altaup.size();
00231 }
00232 if(nl==0)
00233 {
00234 vector<float> output;
00235 output.push_back(0);
00236 SendMessage(Code(),output,"no lepton");
00237 return;
00238 }
00239 if((int(options[0]))&1)
00240 for (Iel = alelp.begin(); Iel<alelp.end(); Iel++)
00241 {
00242 output.clear();
00243 output.push_back(--nl);
00244 output.push_back((*Iel)->QE());
00245 output.push_back((*Iel)->QX());
00246 output.push_back((*Iel)->QY());
00247 output.push_back((*Iel)->QZ());
00248 output.push_back((*Iel)->QCH());
00249 output.push_back(1);
00250 SendMessage(Code(),output,"Electron");
00251 }
00252 if((int(options[0]))&2)
00253 for (Imu = almup.begin(); Imu<almup.end(); Imu++)
00254 {
00255 output.clear();
00256 output.push_back(--nl);
00257 output.push_back((*Imu)->QE());
00258 output.push_back((*Imu)->QX());
00259 output.push_back((*Imu)->QY());
00260 output.push_back((*Imu)->QZ());
00261 output.push_back((*Imu)->QCH());
00262 output.push_back(2);
00263 SendMessage(Code(),output,"Muon");
00264 }
00265 if((int(options[0]))&4)
00266 for (Itau = altaup.begin(); Itau<altaup.end(); Itau++)
00267 {
00268 output.clear();
00269 output.push_back(--nl);
00270 output.push_back((*Itau)->QE());
00271 output.push_back((*Itau)->QX());
00272 output.push_back((*Itau)->QY());
00273 output.push_back((*Itau)->QZ());
00274 output.push_back((*Itau)->QCH());
00275 output.push_back(3);
00276 SendMessage(Code(),output,"tau");
00277 }
00278 for (Ich=altp.begin(); Ich<altp.end(); Ich++)
00279 (*Ich)->unLock();
00280 }
00281
00282 void CollectJets::Run(vector<float>& options,AlphaBanks& EventInfo)
00283 {
00284
00285 AlephCollection<AlEflw *> alefp=EventInfo.EflwPV();
00286 float Ycut = options[2];
00287 int scheme = int(options[1]);
00288 AlEvent myevent = EventInfo.Event();
00289 float QELEP = myevent.Energy();
00290 float energy = options[3]==-1 ? QELEP : options[3];
00291 AlephCollection<AlJet> Jn = options[0] ? alefp.DurhamJet(Ycut, scheme, energy) : alefp.JadeJet(Ycut, scheme, energy);
00292
00293 vector<float> output;
00294 int counter = Jn.size();
00295 for( AlephCollection<AlJet>::iterator jet = Jn.begin();jet<Jn.end();jet++)
00296 {
00297 AlephCollection<AlObject*> constituants = jet->getObjects();
00298 float costhetamin=1;
00299 for(AlephCollection<AlObject*>::iterator element = constituants.begin(); element<constituants.end();element++)
00300 {
00301 float costheta = ((QvecBase*)(*element))->QCOSA(*jet);
00302 costhetamin = costheta<costhetamin ? costheta : costhetamin;
00303 }
00304 output.clear();
00305 output.push_back(--counter);
00306 output.push_back(costhetamin);
00307 output.push_back(jet->QX());
00308 output.push_back(jet->QY());
00309 output.push_back(jet->QZ());
00310 SendMessage(Code(),output,"jet");
00311 }
00312 }
00313