/[PAMELA software]/DarthVader/AnticounterLevel2/src/AcLevel2.cpp
ViewVC logotype

Diff of /DarthVader/AnticounterLevel2/src/AcLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Fri May 19 13:16:00 2006 UTC revision 1.6 by mocchiut, Mon Feb 12 08:17:21 2007 UTC
# Line 1  Line 1 
1  #include <TObject.h>  #include <TObject.h>
2  #include <AcLevel2.h>  #include <AcLevel2.h>
3    
4  ClassImp(AcLevel2);  ClassImp(AcLevel2);
5    
6  AcLevel2::AcLevel2() {  AcLevel2::AcLevel2() {
7      this->Clear();
8    }
9    
10    void AcLevel2::Clear(){
11    status[0]=0;    status[0]=0;
12    hitmap[0]=0;    hitmap[0]=0;
13    hitstatus[0]=0;    hitstatus[0]=0;
14    trigger[0]=0;    trigger[0]=0;
   //OBT=0ULL;  
   //pro_num=0;  
   //pkt_num=0ULL;  
15    status[1]=0;    status[1]=0;
16    hitmap[1]=0;    hitmap[1]=0;
17    hitstatus[1]=0;    hitstatus[1]=0;
18    trigger[1]=0;    trigger[1]=0;
19  }    unpackError=0;
20    }
21    
22    bool AcLevel2::IsHit(TString what){
23    
24        char* cabl[] = {"CARD4","CAT2","CAS1","ND","CARD2","CAT4","CAS4","ND",
25                        "CARD3","CAT3","CAS3","ND","CARD1","CAT1","CAS2","ND"};
26    
27        bool answer = false;
28        for(Int_t ibit=0; ibit<16; ibit++){
29            if( what.Contains( cabl[ibit], TString::kIgnoreCase ) ){
30                if( what.Contains( "M" , TString::kIgnoreCase ) )
31                    answer = (Bool_t)((hitmap[0]>>ibit)&1) & (Bool_t)((hitstatus[0]>>ibit)&1);
32                else if( what.Contains( "E" , TString::kIgnoreCase ) )
33                    answer = (Bool_t)((hitmap[1]>>ibit)&1) & (Bool_t)((hitstatus[1]>>ibit)&1);
34                return answer;
35            };
36        };
37        return answer;
38    
39    }
40    
41    bool AcLevel2::CAShit(TString card)
42    {
43      if(card.Contains("main") || card.CompareTo("")==0 )
44        {
45          if( this->IsHit("CAS1-M") )return true;
46          if( this->IsHit("CAS2-M") )return true;
47          if( this->IsHit("CAS3-M") )return true;
48          if( this->IsHit("CAS4-M") )return true;
49        }
50      if(card.Contains("extra") || card.CompareTo("")==0)
51        {
52          if( this->IsHit("CAS1-E") ) return true;
53          if( this->IsHit("CAS2-E") ) return true;
54          if( this->IsHit("CAS3-E") ) return true;
55          if( this->IsHit("CAS4-E") ) return true;
56        }
57      
58      return false;
59    }
60    
61    bool AcLevel2::CAThit(TString card)
62    {
63      if(card.Contains("main") || card.CompareTo("")==0 )
64        {
65          if( this->IsHit("CAT1-M") )return true;
66          if( this->IsHit("CAT2-M") )return true;
67          if( this->IsHit("CAT3-M") )return true;
68          if( this->IsHit("CAT4-M") )return true;
69        }
70      if(card.Contains("extra") || card.CompareTo("")==0)
71        {
72          if( this->IsHit("CAT1-E") ) return true;
73          if( this->IsHit("CAT2-E") ) return true;
74          if( this->IsHit("CAT3-E") ) return true;
75          if( this->IsHit("CAT4-E") ) return true;
76        }
77      
78      return false;
79    }
80    
81    bool AcLevel2::CARDhit(TString card)
82    {
83      if(card.Contains("main") || card.CompareTo("")==0 )
84        {
85          if( this->IsHit("CARD1-M") )return true;
86          if( this->IsHit("CARD2-M") )return true;
87          if( this->IsHit("CARD3-M") )return true;
88          if( this->IsHit("CARD4-M") )return true;
89        }
90      if(card.Contains("extra") || card.CompareTo("")==0)
91        {
92          if( this->IsHit("CARD1-E") ) return true;
93          if( this->IsHit("CARD2-E") ) return true;
94          if( this->IsHit("CARD3-E") ) return true;
95          if( this->IsHit("CARD4-E") ) return true;
96        }
97      
98      return false;
99    }
100    
101    bool AcLevel2::AChit(TString card)
102    {
103      if(this->CAThit(card) || this->CARDhit(card) || this->CAShit(card)) return true;
104    
105      return false;
106    }
107    
108    
109    /**
110     * Fills a struct cAcLevel2 with values from a AcLevel2 object (to put data into a F77 common).
111     */
112    void AcLevel2::GetLevel2Struct(cAcLevel2 *l2) const{
113      for(int i=0;i<2;i++){
114        l2->status[i]    = status[i];
115        l2->hitmap[i]    = hitmap[i];
116        l2->hitstatus[i] = hitstatus[i];
117        l2->trigger[i]   = trigger[i];
118      }
119    }
120    
121    void AcLevel2::SetFromLevel2Struct(cAcLevel2 *l2){
122      for(int i=0;i<2;i++){
123        status[i]    = l2->status[i];
124        hitmap[i]    = l2->hitmap[i];
125        hitstatus[i] = l2->hitstatus[i];
126        trigger[i]   = l2->trigger[i];
127      }
128    }
129    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23